Mercurial > hg > toybox
annotate toys/toylist.h @ 92:154070b2b28d
Toybox option parsing must stop at the first non-option argument.
author | Rob Landley <rob@landley.net> |
---|---|
date | Thu, 01 Feb 2007 17:39:14 -0500 |
parents | 021fe1a818c3 |
children | cc0a6789f92a |
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 |
88
021fe1a818c3
Small cleanup to prepare for cross-compile friendly make install.
Rob Landley <rob@landley.net>
parents:
82
diff
changeset
|
8 // Provide function declarations and structs. Note that main.c #includes this |
021fe1a818c3
Small cleanup to prepare for cross-compile friendly make install.
Rob Landley <rob@landley.net>
parents:
82
diff
changeset
|
9 // file twice (with different macros) to populate toy_list[]. |
21
6475d6c46066
Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
10 |
88
021fe1a818c3
Small cleanup to prepare for cross-compile friendly make install.
Rob Landley <rob@landley.net>
parents:
82
diff
changeset
|
11 #ifndef NEWTOY |
25
eb46bb5626cb
New option parsing infrastructure (doesn't use getopt). Hook it up to
Rob Landley <rob@landley.net>
parents:
21
diff
changeset
|
12 #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
|
13 #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
|
14 |
6475d6c46066
Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
15 struct df_data { |
33 | 16 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
|
17 |
21
6475d6c46066
Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
18 long units; |
6475d6c46066
Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
19 }; |
6475d6c46066
Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
20 |
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
|
21 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
|
22 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
|
23 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
|
24 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
|
25 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
|
26 |
76 | 27 unsigned blocks, groups; |
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
|
28 int fsfd, noseek; |
82 | 29 struct ext2_superblock sb; |
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
|
30 }; |
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 |
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 // "E:jJ:L:m:O:" |
78
cd1f36a96185
Update args.c to implement numeric arguments.
Rob Landley <rob@landley.net>
parents:
76
diff
changeset
|
33 #define MKE2FS_OPTSTRING "<1>2Fnqm#N#i#b#" |
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
|
34 |
21
6475d6c46066
Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
35 union toy_union { |
6475d6c46066
Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
36 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
|
37 struct mke2fs_data mke2fs; |
21
6475d6c46066
Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
38 } toy; |
6475d6c46066
Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
39 |
6475d6c46066
Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
40 #define TOYFLAG_USR (1<<0) |
6475d6c46066
Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
41 #define TOYFLAG_BIN (1<<1) |
6475d6c46066
Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
42 #define TOYFLAG_SBIN (1<<2) |
6475d6c46066
Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
43 #define TOYMASK_LOCATION ((1<<4)-1) |
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 #define TOYFLAG_NOFORK (1<<4) |
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 extern struct toy_list { |
6475d6c46066
Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
48 char *name; |
6475d6c46066
Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
49 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
|
50 char *options; |
21
6475d6c46066
Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
51 int flags; |
6475d6c46066
Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
52 } toy_list[]; |
6475d6c46066
Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
53 |
6475d6c46066
Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
54 #endif |
6475d6c46066
Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
55 |
6475d6c46066
Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
56 // 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
|
57 |
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
|
58 // 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
|
59 |
25
eb46bb5626cb
New option parsing infrastructure (doesn't use getopt). Hook it up to
Rob Landley <rob@landley.net>
parents:
21
diff
changeset
|
60 NEWTOY(toybox, NULL, 0) |
21
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 // 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
|
63 |
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
|
64 USE_BZCAT(NEWTOY(bzcat, "", TOYFLAG_USR|TOYFLAG_BIN)) |
66 | 65 USE_CATV(NEWTOY(catv, "vte", TOYFLAG_USR|TOYFLAG_BIN)) |
66 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
|
67 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
|
68 USE_DF(NEWTOY(df, "Pkt*a", TOYFLAG_USR|TOYFLAG_SBIN)) |
92
154070b2b28d
Toybox option parsing must stop at the first non-option argument.
Rob Landley <rob@landley.net>
parents:
88
diff
changeset
|
69 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
|
70 USE_TOYSH(NEWTOY(exit, NULL, TOYFLAG_NOFORK)) |
66 | 71 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
|
72 USE_MKE2FS(NEWTOY(mke2fs, MKE2FS_OPTSTRING, TOYFLAG_SBIN)) |
34 | 73 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
|
74 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
|
75 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
|
76 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
|
77 USE_WHICH(NEWTOY(which, "a", TOYFLAG_USR|TOYFLAG_BIN)) |
74 | 78 USE_YES(NEWTOY(yes, "", TOYFLAG_USR|TOYFLAG_BIN)) |