commit eb57a460f6cc9e79fcbe6b6af30858aac94cabe2
parent 39be4bf848af47c7680ed2243607df7db6922790
Author: Christoph Lohmann <20h@r-36.net>
Date: Fri, 6 Apr 2012 20:46:01 +0200
Adding the missing arg.h for ARG* macros.
Diffstat:
arg.h | | | 40 | ++++++++++++++++++++++++++++++++++++++++ |
1 file changed, 40 insertions(+), 0 deletions(-)
diff --git a/arg.h b/arg.h
@@ -0,0 +1,40 @@
+/*
+ * See LICENSE file for copyright and license details.
+ */
+
+#ifndef __CMD_H__
+#define __CMD_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
+