geomyidae

A small C-based gopherd. (gopher://bitreich.org/1/scm/geomyidae)
git clone git://r-36.net/geomyidae
Log | Files | Refs | README | LICENSE

arg.h (685B)


      1 #ifndef ARG_H
      2 #define ARG_H
      3 
      4 #define USED(x) ((void)(x))
      5 
      6 extern char *argv0;
      7 
      8 #define ARGBEGIN	for(argv0 = *argv, argv++, argc--;\
      9 					argv[0] && argv[0][0] == '-'\
     10 					&& argv[0][1];\
     11 					argc--, argv++) {\
     12 				char _argc;\
     13 				char **_argv;\
     14 				if(argv[0][1] == '-' && argv[0][2] == '\0') {\
     15 					argv++;\
     16 					argc--;\
     17 					break;\
     18 				}\
     19 				int i_;\
     20 				for(i_ = 1, _argv = argv; argv[0][i_];\
     21 						i_++) {\
     22 					if(_argv != argv)\
     23 						break;\
     24 					_argc = argv[0][i_];\
     25 					switch(_argc)
     26 
     27 #define ARGEND			}\
     28 				USED(_argc);\
     29 			}\
     30 			USED(argv);\
     31 			USED(argc);
     32 
     33 #define	EARGF(x)	((argv[1] == NULL)? ((x), abort(), (char *)0) :\
     34 			(argc--, argv++, argv[0]))
     35 
     36 #endif
     37