arg.h (726B)
1 /* 2 * Copy me if you can. 3 * by 20h 4 */ 5 6 #ifndef ARG_H 7 #define ARG_H 8 9 #define USED(x) ((void)(x)) 10 11 extern char *argv0; 12 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 if(argv[0][1] == '-' && argv[0][2] == '\0') {\ 20 argv++;\ 21 argc--;\ 22 break;\ 23 }\ 24 int i_;\ 25 for(i_ = 1, _argv = argv; argv[0][i_];\ 26 i_++) {\ 27 if(_argv != argv)\ 28 break;\ 29 _argc = argv[0][i_];\ 30 switch(_argc) 31 32 #define ARGEND }\ 33 USED(_argc);\ 34 }\ 35 USED(argv);\ 36 USED(argc); 37 38 #define EARGF(x) ((argv[1] == NULL)? ((x), abort(), (char *)0) :\ 39 (argc--, argv++, argv[0])) 40 41 #endif 42