diff options
author | zavok <an2qzavok@gmail.com> | 2015-11-23 17:08:20 +0300 |
---|---|---|
committer | zavok <an2qzavok@gmail.com> | 2015-11-23 17:08:20 +0300 |
commit | 51da5915b03d9b06936ac32f47287beb73d96973 (patch) | |
tree | ad7a5eca744666befa37adb779e4fb2daccc3627 /arg.h |
This is a "barely works" version of spine, I hope it works, at least barely.
Diffstat (limited to 'arg.h')
-rw-r--r-- | arg.h | 41 |
1 files changed, 41 insertions, 0 deletions
@@ -0,0 +1,41 @@ +/* + * Copy me if you can. + * by 20h + */ + +#ifndef __ARG_H__ +#define __ARG_H__ + +extern char *argv0; + +#define USED(x) ((void)(x)) + +#define ARGBEGIN for (argv0 = *argv, argv++, argc--;\ + argv[0] && argv[0][1]\ + && argv[0][0] == '-';\ + argc--, argv++) {\ + char _argc;\ + char **_argv;\ + if (argv[0][1] == '-' && argv[0][2] == '\0') {\ + argv++;\ + argc--;\ + break;\ + }\ + for (argv[0]++, _argv = argv; argv[0][0];\ + argv[0]++) {\ + if (_argv != argv)\ + break;\ + _argc = argv[0][0];\ + 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 + |