OSDN Git Service

New option parsing infrastructure (doesn't use getopt). Hook it up to
[android-x86/external-toybox.git] / toys / toylist.h
1 /* vi: set ts=4 :*/
2 /* Toybox infrastructure.
3  *
4  * Copyright 2006 Rob Landley <rob@landley.net>
5  */
6
7
8 // When #included from main.c, provide the guts for toy_list[]
9
10 #ifdef FROM_MAIN
11 #undef NEWTOY
12 #undef OLDTOY
13 #define NEWTOY(name, opts, flags) {#name, name##_main, opts, flags},
14 #define OLDTOY(name, oldname, opts, flags) {#name, oldname##_main, opts, flags},
15
16 // When #included from toys.h, provide function declarations and structs.
17 // The #else is because main.c #includes this file twice.
18
19 #else
20 #define NEWTOY(name, opts, flags) int name##_main(void);
21 #define OLDTOY(name, oldname, opts, flags)
22
23 struct df_data {
24         struct string_list *fstype;
25         long units;
26 };
27
28 union toy_union {
29         struct df_data df;
30 } toy;
31
32 #define TOYFLAG_USR      (1<<0)
33 #define TOYFLAG_BIN      (1<<1)
34 #define TOYFLAG_SBIN     (1<<2)
35 #define TOYMASK_LOCATION ((1<<4)-1)
36
37 #define TOYFLAG_NOFORK   (1<<4)
38
39 extern struct toy_list {
40         char *name;
41         int (*toy_main)(void);
42         char *options;
43         int flags;
44 } toy_list[];
45
46 #endif
47
48 // List of all the applets toybox can provide.
49
50 // This one is out of order on purpose.
51
52 NEWTOY(toybox, NULL, 0)
53
54 // The rest of these are alphabetical, for binary search.
55
56 USE_TOYSH(NEWTOY(cd, NULL, TOYFLAG_NOFORK))
57 USE_DF(NEWTOY(df, "Pkt:a", TOYFLAG_USR|TOYFLAG_SBIN))
58 USE_TOYSH(NEWTOY(exit, NULL, TOYFLAG_NOFORK))
59 USE_HELLO(NEWTOY(hello, NULL, TOYFLAG_NOFORK|TOYFLAG_USR))
60 USE_PWD(NEWTOY(pwd, NULL, TOYFLAG_BIN))
61 USE_TOYSH(OLDTOY(sh, toysh, "c:i", TOYFLAG_BIN))
62 USE_TOYSH(NEWTOY(toysh, "c:i", TOYFLAG_BIN))
63 USE_WHICH(NEWTOY(which, "a", TOYFLAG_USR|TOYFLAG_BIN))