diff options
author | KatolaZ <katolaz@freaknet.org> | 2019-07-27 06:57:12 +0100 |
---|---|---|
committer | KatolaZ <katolaz@freaknet.org> | 2019-07-27 06:57:12 +0100 |
commit | 8e3d23b921d9bbcb7c53017bacff8a3050a34b55 (patch) | |
tree | fc26ae9768e6c72827b03e973dbf0479b0a0431d /arg.h | |
parent | 3d53fcefe3ca3e6f25d1731c2caa0c1c0e676453 (diff) |
reorganise code
Diffstat (limited to 'arg.h')
-rw-r--r-- | arg.h | 37 |
1 files changed, 37 insertions, 0 deletions
@@ -0,0 +1,37 @@ +#ifndef ARG_H +#define ARG_H + +#define USED(x) ((void)(x)) + +extern char *argv0; + +#define ARGBEGIN for(argv0 = *argv, argv++, argc--;\ + argv[0] && argv[0][0] == '-'\ + && argv[0][1];\ + argc--, argv++) {\ + char _argc;\ + char **_argv;\ + if(argv[0][1] == '-' && argv[0][2] == '\0') {\ + argv++;\ + argc--;\ + break;\ + }\ + int i_;\ + for(i_ = 1, _argv = argv; argv[0][i_];\ + i_++) {\ + if(_argv != argv)\ + break;\ + _argc = argv[0][i_];\ + switch(_argc) + +#define ARGEND }\ + USED(_argc);\ + }\ + USED(argv);\ + USED(argc); + +#define EARGF(x) ((argv[1] == NULL)? ((x), abort(), (char *)0) :\ + (argc--, argv++, argv[0])) + +#endif + |