annotate toys/toylist.h @ 70:a1b464bbef08

Add "echo". Has -n and -e (but not \0123 yet).
author Rob Landley <rob@landley.net>
date Sat, 20 Jan 2007 18:04:20 -0500
parents d2c7f1cbd7d2
children dfe99495acbc
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
25
eb46bb5626cb New option parsing infrastructure (doesn't use getopt). Hook it up to
Rob Landley <rob@landley.net>
parents: 21
diff changeset
13 #define NEWTOY(name, opts, flags) {#name, name##_main, opts, flags},
eb46bb5626cb New option parsing infrastructure (doesn't use getopt). Hook it up to
Rob Landley <rob@landley.net>
parents: 21
diff changeset
14 #define OLDTOY(name, oldname, opts, flags) {#name, oldname##_main, opts, flags},
21
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
25
eb46bb5626cb New option parsing infrastructure (doesn't use getopt). Hook it up to
Rob Landley <rob@landley.net>
parents: 21
diff changeset
20 #define NEWTOY(name, opts, flags) int name##_main(void);
eb46bb5626cb New option parsing infrastructure (doesn't use getopt). Hook it up to
Rob Landley <rob@landley.net>
parents: 21
diff changeset
21 #define OLDTOY(name, oldname, opts, flags)
21
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 {
33
bc91b57308dc Fix a warning.
Rob Landley <rob@landley.net>
parents: 32
diff changeset
24 struct arg_list *fstype;
53
41d55b5d49fd Add start of mke2fs/gene2fs, and some other stuff I've been working on.
Rob Landley <rob@landley.net>
parents: 35
diff changeset
25
21
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
26 long units;
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
53
41d55b5d49fd Add start of mke2fs/gene2fs, and some other stuff I've been working on.
Rob Landley <rob@landley.net>
parents: 35
diff changeset
29 struct mke2fs_data {
41d55b5d49fd Add start of mke2fs/gene2fs, and some other stuff I've been working on.
Rob Landley <rob@landley.net>
parents: 35
diff changeset
30 long blocksize;
41d55b5d49fd Add start of mke2fs/gene2fs, and some other stuff I've been working on.
Rob Landley <rob@landley.net>
parents: 35
diff changeset
31 long bytes_per_inode;
41d55b5d49fd Add start of mke2fs/gene2fs, and some other stuff I've been working on.
Rob Landley <rob@landley.net>
parents: 35
diff changeset
32 long inodes;
41d55b5d49fd Add start of mke2fs/gene2fs, and some other stuff I've been working on.
Rob Landley <rob@landley.net>
parents: 35
diff changeset
33 long reserved_percent;
41d55b5d49fd Add start of mke2fs/gene2fs, and some other stuff I've been working on.
Rob Landley <rob@landley.net>
parents: 35
diff changeset
34
41d55b5d49fd Add start of mke2fs/gene2fs, and some other stuff I've been working on.
Rob Landley <rob@landley.net>
parents: 35
diff changeset
35 int fsfd, noseek;
41d55b5d49fd Add start of mke2fs/gene2fs, and some other stuff I've been working on.
Rob Landley <rob@landley.net>
parents: 35
diff changeset
36 };
41d55b5d49fd Add start of mke2fs/gene2fs, and some other stuff I've been working on.
Rob Landley <rob@landley.net>
parents: 35
diff changeset
37
41d55b5d49fd Add start of mke2fs/gene2fs, and some other stuff I've been working on.
Rob Landley <rob@landley.net>
parents: 35
diff changeset
38 // "E:jJ:L:m:O:"
41d55b5d49fd Add start of mke2fs/gene2fs, and some other stuff I've been working on.
Rob Landley <rob@landley.net>
parents: 35
diff changeset
39 #define MKE2FS_OPTSTRING "Fnqm:N:i:b:"
41d55b5d49fd Add start of mke2fs/gene2fs, and some other stuff I've been working on.
Rob Landley <rob@landley.net>
parents: 35
diff changeset
40
21
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
41 union toy_union {
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
42 struct df_data df;
53
41d55b5d49fd Add start of mke2fs/gene2fs, and some other stuff I've been working on.
Rob Landley <rob@landley.net>
parents: 35
diff changeset
43 struct mke2fs_data mke2fs;
21
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
44 } toy;
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
45
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
46 #define TOYFLAG_USR (1<<0)
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
47 #define TOYFLAG_BIN (1<<1)
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
48 #define TOYFLAG_SBIN (1<<2)
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
49 #define TOYMASK_LOCATION ((1<<4)-1)
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 #define TOYFLAG_NOFORK (1<<4)
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 extern struct toy_list {
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
54 char *name;
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
55 int (*toy_main)(void);
25
eb46bb5626cb New option parsing infrastructure (doesn't use getopt). Hook it up to
Rob Landley <rob@landley.net>
parents: 21
diff changeset
56 char *options;
21
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
57 int flags;
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
58 } toy_list[];
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
59
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
60 #endif
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
61
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
62 // 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
63
53
41d55b5d49fd Add start of mke2fs/gene2fs, and some other stuff I've been working on.
Rob Landley <rob@landley.net>
parents: 35
diff changeset
64 // This one is out of order on purpose: it's the first element in the array.
21
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
65
25
eb46bb5626cb New option parsing infrastructure (doesn't use getopt). Hook it up to
Rob Landley <rob@landley.net>
parents: 21
diff changeset
66 NEWTOY(toybox, NULL, 0)
21
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
67
6475d6c46066 Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff changeset
68 // 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
69
54
60a7fb8ddeb4 Add a quick and dirt bzcat (stdin to stdout only for the moment) to test
Rob Landley <rob@landley.net>
parents: 53
diff changeset
70 USE_BZCAT(NEWTOY(bzcat, "", TOYFLAG_USR|TOYFLAG_BIN))
66
d2c7f1cbd7d2 Add count command.
Rob Landley <rob@landley.net>
parents: 54
diff changeset
71 USE_CATV(NEWTOY(catv, "vte", TOYFLAG_USR|TOYFLAG_BIN))
d2c7f1cbd7d2 Add count command.
Rob Landley <rob@landley.net>
parents: 54
diff changeset
72 USE_COUNT(NEWTOY(count, "", TOYFLAG_USR|TOYFLAG_BIN))
25
eb46bb5626cb New option parsing infrastructure (doesn't use getopt). Hook it up to
Rob Landley <rob@landley.net>
parents: 21
diff changeset
73 USE_TOYSH(NEWTOY(cd, NULL, TOYFLAG_NOFORK))
32
993eab821bd5 More work on option parsing. "df -t tmpfs" actually seems to work now.
Rob Landley <rob@landley.net>
parents: 25
diff changeset
74 USE_DF(NEWTOY(df, "Pkt*a", TOYFLAG_USR|TOYFLAG_SBIN))
70
a1b464bbef08 Add "echo". Has -n and -e (but not \0123 yet).
Rob Landley <rob@landley.net>
parents: 66
diff changeset
75 USE_ECHO(NEWTOY(echo, "en", TOYFLAG_BIN))
25
eb46bb5626cb New option parsing infrastructure (doesn't use getopt). Hook it up to
Rob Landley <rob@landley.net>
parents: 21
diff changeset
76 USE_TOYSH(NEWTOY(exit, NULL, TOYFLAG_NOFORK))
66
d2c7f1cbd7d2 Add count command.
Rob Landley <rob@landley.net>
parents: 54
diff changeset
77 USE_HELLO(NEWTOY(hello, NULL, TOYFLAG_USR))
53
41d55b5d49fd Add start of mke2fs/gene2fs, and some other stuff I've been working on.
Rob Landley <rob@landley.net>
parents: 35
diff changeset
78 USE_MKE2FS(NEWTOY(mke2fs, MKE2FS_OPTSTRING, TOYFLAG_SBIN))
34
c1f4f9101af7 Add oneit.
Rob Landley <rob@landley.net>
parents: 33
diff changeset
79 USE_ONEIT(NEWTOY(oneit, "+p<1", TOYFLAG_SBIN))
25
eb46bb5626cb New option parsing infrastructure (doesn't use getopt). Hook it up to
Rob Landley <rob@landley.net>
parents: 21
diff changeset
80 USE_PWD(NEWTOY(pwd, NULL, TOYFLAG_BIN))
eb46bb5626cb New option parsing infrastructure (doesn't use getopt). Hook it up to
Rob Landley <rob@landley.net>
parents: 21
diff changeset
81 USE_TOYSH(OLDTOY(sh, toysh, "c:i", TOYFLAG_BIN))
eb46bb5626cb New option parsing infrastructure (doesn't use getopt). Hook it up to
Rob Landley <rob@landley.net>
parents: 21
diff changeset
82 USE_TOYSH(NEWTOY(toysh, "c:i", TOYFLAG_BIN))
eb46bb5626cb New option parsing infrastructure (doesn't use getopt). Hook it up to
Rob Landley <rob@landley.net>
parents: 21
diff changeset
83 USE_WHICH(NEWTOY(which, "a", TOYFLAG_USR|TOYFLAG_BIN))