stacinhtml

Static C in HTML - simple static site generator
git clone git://git.kocotian.pl/stacinhtml.git
Log | Files | Refs | README | LICENSE

arg.h (1076B)


      1 /* See licenses/LIBSL file for copyright and license details. */
      2 /*
      3  * Copy me if you can.
      4  * by 20h
      5  */
      6 
      7 #ifndef ARG_H__
      8 #define ARG_H__
      9 
     10 extern char *argv0;
     11 
     12 /* use main(int argc, char *argv[]) */
     13 #define ARGBEGIN	for (argv0 = *argv, argv++, argc--;\
     14 					argv[0] && argv[0][0] == '-'\
     15 					&& argv[0][1];\
     16 					argc--, argv++) {\
     17 				char argc_;\
     18 				char **argv_;\
     19 				int brk_;\
     20 				if (argv[0][1] == '-' && argv[0][2] == '\0') {\
     21 					argv++;\
     22 					argc--;\
     23 					break;\
     24 				}\
     25 				for (brk_ = 0, argv[0]++, argv_ = argv;\
     26 						argv[0][0] && !brk_;\
     27 						argv[0]++) {\
     28 					if (argv_ != argv)\
     29 						break;\
     30 					argc_ = argv[0][0];\
     31 					switch (argc_)
     32 
     33 #define ARGEND			}\
     34 			}
     35 
     36 #define ARGC()		argc_
     37 
     38 #define EARGF(x)	((argv[0][1] == '\0' && argv[1] == NULL)?\
     39 				((x), abort(), (char *)0) :\
     40 				(brk_ = 1, (argv[0][1] != '\0')?\
     41 					(&argv[0][1]) :\
     42 					(argc--, argv++, argv[0])))
     43 
     44 #define ARGF()		((argv[0][1] == '\0' && argv[1] == NULL)?\
     45 				(char *)0 :\
     46 				(brk_ = 1, (argv[0][1] != '\0')?\
     47 					(&argv[0][1]) :\
     48 					(argc--, argv++, argv[0])))
     49 
     50 #endif