diff options
author | KatolaZ <katolaz@freaknet.org> | 2019-07-27 06:57:29 +0100 |
---|---|---|
committer | KatolaZ <katolaz@freaknet.org> | 2019-07-27 06:57:29 +0100 |
commit | f678684b470f02d9fed4818eb92c2a925380c428 (patch) | |
tree | fc26ae9768e6c72827b03e973dbf0479b0a0431d /arg.h | |
parent | 8b67bd6c5f4e175721b44d4733d1a5a6fc1a2561 (diff) | |
parent | 8e3d23b921d9bbcb7c53017bacff8a3050a34b55 (diff) |
Merge branch 'devel' into master
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 + |