Mercurial > hg > toybox
comparison toys/toylist.h @ 25:eb46bb5626cb
New option parsing infrastructure (doesn't use getopt). Hook it up to
existing applets. Still a bit buggy, but bits of it work.
author | Rob Landley <rob@landley.net> |
---|---|
date | Sun, 19 Nov 2006 02:49:22 -0500 |
parents | 6475d6c46066 |
children | 993eab821bd5 |
comparison
equal
deleted
inserted
replaced
24:c8d0f1876c40 | 25:eb46bb5626cb |
---|---|
8 // When #included from main.c, provide the guts for toy_list[] | 8 // When #included from main.c, provide the guts for toy_list[] |
9 | 9 |
10 #ifdef FROM_MAIN | 10 #ifdef FROM_MAIN |
11 #undef NEWTOY | 11 #undef NEWTOY |
12 #undef OLDTOY | 12 #undef OLDTOY |
13 #define NEWTOY(name, flags) {#name, name##_main, flags}, | 13 #define NEWTOY(name, opts, flags) {#name, name##_main, opts, flags}, |
14 #define OLDTOY(name, oldname, flags) {#name, oldname##_main, flags}, | 14 #define OLDTOY(name, oldname, opts, flags) {#name, oldname##_main, opts, flags}, |
15 | 15 |
16 // When #included from toys.h, provide function declarations and structs. | 16 // When #included from toys.h, provide function declarations and structs. |
17 // The #else is because main.c #includes this file twice. | 17 // The #else is because main.c #includes this file twice. |
18 | 18 |
19 #else | 19 #else |
20 #define NEWTOY(name, flags) int name##_main(void); | 20 #define NEWTOY(name, opts, flags) int name##_main(void); |
21 #define OLDTOY(name, oldname, flags) | 21 #define OLDTOY(name, oldname, opts, flags) |
22 | 22 |
23 struct df_data { | 23 struct df_data { |
24 struct string_list *fstype; | 24 struct string_list *fstype; |
25 long units; | 25 long units; |
26 }; | 26 }; |
37 #define TOYFLAG_NOFORK (1<<4) | 37 #define TOYFLAG_NOFORK (1<<4) |
38 | 38 |
39 extern struct toy_list { | 39 extern struct toy_list { |
40 char *name; | 40 char *name; |
41 int (*toy_main)(void); | 41 int (*toy_main)(void); |
42 char *options; | |
42 int flags; | 43 int flags; |
43 } toy_list[]; | 44 } toy_list[]; |
44 | 45 |
45 #endif | 46 #endif |
46 | 47 |
47 // List of all the applets toybox can provide. | 48 // List of all the applets toybox can provide. |
48 | 49 |
49 // This one is out of order on purpose. | 50 // This one is out of order on purpose. |
50 | 51 |
51 NEWTOY(toybox, 0) | 52 NEWTOY(toybox, NULL, 0) |
52 | 53 |
53 // The rest of these are alphabetical, for binary search. | 54 // The rest of these are alphabetical, for binary search. |
54 | 55 |
55 USE_TOYSH(NEWTOY(cd, TOYFLAG_NOFORK)) | 56 USE_TOYSH(NEWTOY(cd, NULL, TOYFLAG_NOFORK)) |
56 USE_DF(NEWTOY(df, TOYFLAG_USR|TOYFLAG_SBIN)) | 57 USE_DF(NEWTOY(df, "Pkt:a", TOYFLAG_USR|TOYFLAG_SBIN)) |
57 USE_TOYSH(NEWTOY(exit, TOYFLAG_NOFORK)) | 58 USE_TOYSH(NEWTOY(exit, NULL, TOYFLAG_NOFORK)) |
58 USE_HELLO(NEWTOY(hello, TOYFLAG_NOFORK|TOYFLAG_USR)) | 59 USE_HELLO(NEWTOY(hello, NULL, TOYFLAG_NOFORK|TOYFLAG_USR)) |
59 USE_PWD(NEWTOY(pwd, TOYFLAG_BIN)) | 60 USE_PWD(NEWTOY(pwd, NULL, TOYFLAG_BIN)) |
60 USE_TOYSH(OLDTOY(sh, toysh, TOYFLAG_BIN)) | 61 USE_TOYSH(OLDTOY(sh, toysh, "c:i", TOYFLAG_BIN)) |
61 USE_TOYSH(NEWTOY(toysh, TOYFLAG_BIN)) | 62 USE_TOYSH(NEWTOY(toysh, "c:i", TOYFLAG_BIN)) |
62 USE_WHICH(NEWTOY(which, TOYFLAG_USR|TOYFLAG_BIN)) | 63 USE_WHICH(NEWTOY(which, "a", TOYFLAG_USR|TOYFLAG_BIN)) |