annotate toys/toylist.h @ 21:6475d6c46066

Add pwd. Consolidate toy list information under toylist.h.
author Rob Landley <rob@landley.net>
date Sat, 04 Nov 2006 17:45:18 -0500
parents
children eb46bb5626cb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
21
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
1 /* vi: set ts=4 :*/
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
2 /* Toybox infrastructure.
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
3 *
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
4 * Copyright 2006 Rob Landley <rob@landley.net>
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
5 */
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
6
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
7
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
8 // When #included from main.c, provide the guts for toy_list[]
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
9
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
10 #ifdef FROM_MAIN
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
11 #undef NEWTOY
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
12 #undef OLDTOY
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
13 #define NEWTOY(name, flags) {#name, name##_main, flags},
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
14 #define OLDTOY(name, oldname, flags) {#name, oldname##_main, flags},
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
15
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
16 // When #included from toys.h, provide function declarations and structs.
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
17 // The #else is because main.c #includes this file twice.
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
18
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
19 #else
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
20 #define NEWTOY(name, flags) int name##_main(void);
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
21 #define OLDTOY(name, oldname, flags)
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
22
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
23 struct df_data {
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
24 struct string_list *fstype;
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
25 long units;
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
26 };
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
27
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
28 union toy_union {
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
29 struct df_data df;
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
30 } toy;
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
31
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
32 #define TOYFLAG_USR (1<<0)
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
33 #define TOYFLAG_BIN (1<<1)
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
34 #define TOYFLAG_SBIN (1<<2)
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
35 #define TOYMASK_LOCATION ((1<<4)-1)
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
36
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
37 #define TOYFLAG_NOFORK (1<<4)
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
38
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
39 extern struct toy_list {
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
40 char *name;
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
41 int (*toy_main)(void);
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
42 int flags;
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
43 } toy_list[];
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
44
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
45 #endif
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
46
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
47 // List of all the applets toybox can provide.
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
48
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
49 // This one is out of order on purpose.
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
50
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
51 NEWTOY(toybox, 0)
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
52
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
53 // The rest of these are alphabetical, for binary search.
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
54
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
55 USE_TOYSH(NEWTOY(cd, TOYFLAG_NOFORK))
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
56 USE_DF(NEWTOY(df, TOYFLAG_USR|TOYFLAG_SBIN))
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
57 USE_TOYSH(NEWTOY(exit, TOYFLAG_NOFORK))
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
58 USE_HELLO(NEWTOY(hello, TOYFLAG_NOFORK|TOYFLAG_USR))
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
59 USE_PWD(NEWTOY(pwd, TOYFLAG_BIN))
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
60 USE_TOYSH(OLDTOY(sh, toysh, TOYFLAG_BIN))
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
61 USE_TOYSH(NEWTOY(toysh, TOYFLAG_BIN))
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
62 USE_WHICH(NEWTOY(which, TOYFLAG_USR|TOYFLAG_BIN))