💾 Archived View for gemini.rmf-dev.com › repo › Vaati › Menkar › files › a22e019e36f180cec5e5bb003a9… captured on 2023-12-28 at 15:38:09. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2023-09-08)
-=-=-=-=-=-=-
0 /*
1 * Copy me if you can.
2 * by 20h
3 */
4
5 #ifndef ARG_H__
6 #define ARG_H__
7
8 extern char *argv0;
9
10 /* use main(int argc, char *argv[]) */
11 #define ARGBEGIN for (argv0 = *argv, argv++, argc--;\
12 argv[0] && argv[0][0] == '-'\
13 && argv[0][1];\
14 argc--, argv++) {\
15 char argc_;\
16 char **argv_;\
17 int brk_;\
18 if (argv[0][1] == '-' && argv[0][2] == '\0') {\
19 argv++;\
20 argc--;\
21 break;\
22 }\
23 int i_;\
24 for (i_ = 1, brk_ = 0, argv_ = argv;\
25 argv[0][i_] && !brk_;\
26 i_++) {\
27 if (argv_ != argv)\
28 break;\
29 argc_ = argv[0][i_];\
30 switch (argc_)
31
32 #define ARGEND }\
33 }
34
35 #define ARGC() argc_
36
37 #define EARGF(x) ((argv[0][i_+1] == '\0' && argv[1] == NULL)?\
38 ((x), abort(), (char *)0) :\
39 (brk_ = 1, (argv[0][i_+1] != '\0')?\
40 (&argv[0][i_+1]) :\
41 (argc--, argv++, argv[0])))
42
43 #define ARGF() ((argv[0][i_+1] == '\0' && argv[1] == NULL)?\
44 (char *)0 :\
45 (brk_ = 1, (argv[0][i_+1] != '\0')?\
46 (&argv[0][i_+1]) :\
47 (argc--, argv++, argv[0])))
48
49 #endif
50