bmf-milter

bmf filter milter daemon
git clone git://r-36.net/bmf-milter
Log | Files | Refs | README | LICENSE

arg.h (996B)


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