Mercurial > hg > toybox
annotate toys.h @ 7:fc9c0503d5e2
Implement df. Add -Wall to build and fix up warnings. Add copyright notices.
Add error_msg() and itoa() to library. Remove argc from globals (since argv is
null terminated), add optflags to globals.
author | landley@driftwood |
---|---|
date | Mon, 30 Oct 2006 01:38:00 -0500 |
parents | 732b055e17f7 |
children | d87d8a056295 |
rev | line source |
---|---|
1
59d58fab67c6
Next snapshot. Tries to grab something out of lib in order to build, I have
landley@driftwood
parents:
diff
changeset
|
1 /* vi: set ts=4 :*/ |
59d58fab67c6
Next snapshot. Tries to grab something out of lib in order to build, I have
landley@driftwood
parents:
diff
changeset
|
2 /* Toybox infrastructure. |
59d58fab67c6
Next snapshot. Tries to grab something out of lib in order to build, I have
landley@driftwood
parents:
diff
changeset
|
3 * |
59d58fab67c6
Next snapshot. Tries to grab something out of lib in order to build, I have
landley@driftwood
parents:
diff
changeset
|
4 * Copyright 2006 Rob Landley <rob@landley.net> |
59d58fab67c6
Next snapshot. Tries to grab something out of lib in order to build, I have
landley@driftwood
parents:
diff
changeset
|
5 * |
59d58fab67c6
Next snapshot. Tries to grab something out of lib in order to build, I have
landley@driftwood
parents:
diff
changeset
|
6 * Licensed under GPL version 2, see file LICENSE in this tarball for details. |
59d58fab67c6
Next snapshot. Tries to grab something out of lib in order to build, I have
landley@driftwood
parents:
diff
changeset
|
7 */ |
59d58fab67c6
Next snapshot. Tries to grab something out of lib in order to build, I have
landley@driftwood
parents:
diff
changeset
|
8 |
7
fc9c0503d5e2
Implement df. Add -Wall to build and fix up warnings. Add copyright notices.
landley@driftwood
parents:
4
diff
changeset
|
9 #include <ctype.h> |
fc9c0503d5e2
Implement df. Add -Wall to build and fix up warnings. Add copyright notices.
landley@driftwood
parents:
4
diff
changeset
|
10 #include <errno.h> |
fc9c0503d5e2
Implement df. Add -Wall to build and fix up warnings. Add copyright notices.
landley@driftwood
parents:
4
diff
changeset
|
11 #include <fcntl.h> |
fc9c0503d5e2
Implement df. Add -Wall to build and fix up warnings. Add copyright notices.
landley@driftwood
parents:
4
diff
changeset
|
12 #include <inttypes.h> |
2
67b517913e56
Infrastructure, first drop of toy shell, and a bit of work on df.
landley@driftwood
parents:
1
diff
changeset
|
13 #include <limits.h> |
67b517913e56
Infrastructure, first drop of toy shell, and a bit of work on df.
landley@driftwood
parents:
1
diff
changeset
|
14 #include <stdarg.h> |
7
fc9c0503d5e2
Implement df. Add -Wall to build and fix up warnings. Add copyright notices.
landley@driftwood
parents:
4
diff
changeset
|
15 #include <stdint.h> |
1
59d58fab67c6
Next snapshot. Tries to grab something out of lib in order to build, I have
landley@driftwood
parents:
diff
changeset
|
16 #include <stdio.h> |
2
67b517913e56
Infrastructure, first drop of toy shell, and a bit of work on df.
landley@driftwood
parents:
1
diff
changeset
|
17 #include <stdlib.h> |
67b517913e56
Infrastructure, first drop of toy shell, and a bit of work on df.
landley@driftwood
parents:
1
diff
changeset
|
18 #include <string.h> |
1
59d58fab67c6
Next snapshot. Tries to grab something out of lib in order to build, I have
landley@driftwood
parents:
diff
changeset
|
19 #include <strings.h> |
4
732b055e17f7
Add xmsprintf(), xgetcwd(), xgetcwd(), find_in_path().
landley@driftwood
parents:
3
diff
changeset
|
20 #include <sys/stat.h> |
7
fc9c0503d5e2
Implement df. Add -Wall to build and fix up warnings. Add copyright notices.
landley@driftwood
parents:
4
diff
changeset
|
21 #include <sys/statvfs.h> |
fc9c0503d5e2
Implement df. Add -Wall to build and fix up warnings. Add copyright notices.
landley@driftwood
parents:
4
diff
changeset
|
22 #include <sys/types.h> |
fc9c0503d5e2
Implement df. Add -Wall to build and fix up warnings. Add copyright notices.
landley@driftwood
parents:
4
diff
changeset
|
23 #include <sys/wait.h> |
2
67b517913e56
Infrastructure, first drop of toy shell, and a bit of work on df.
landley@driftwood
parents:
1
diff
changeset
|
24 #include <unistd.h> |
1
59d58fab67c6
Next snapshot. Tries to grab something out of lib in order to build, I have
landley@driftwood
parents:
diff
changeset
|
25 |
2
67b517913e56
Infrastructure, first drop of toy shell, and a bit of work on df.
landley@driftwood
parents:
1
diff
changeset
|
26 #include "lib/lib.h" |
1
59d58fab67c6
Next snapshot. Tries to grab something out of lib in order to build, I have
landley@driftwood
parents:
diff
changeset
|
27 |
2
67b517913e56
Infrastructure, first drop of toy shell, and a bit of work on df.
landley@driftwood
parents:
1
diff
changeset
|
28 int cd_main(void); |
3
266a462ed18c
Next drop of toysh, plus more infratructure.
landley@driftwood
parents:
2
diff
changeset
|
29 int df_main(void); |
2
67b517913e56
Infrastructure, first drop of toy shell, and a bit of work on df.
landley@driftwood
parents:
1
diff
changeset
|
30 int exit_main(void); |
1
59d58fab67c6
Next snapshot. Tries to grab something out of lib in order to build, I have
landley@driftwood
parents:
diff
changeset
|
31 int toybox_main(void); |
59d58fab67c6
Next snapshot. Tries to grab something out of lib in order to build, I have
landley@driftwood
parents:
diff
changeset
|
32 int toysh_main(void); |
59d58fab67c6
Next snapshot. Tries to grab something out of lib in order to build, I have
landley@driftwood
parents:
diff
changeset
|
33 |
2
67b517913e56
Infrastructure, first drop of toy shell, and a bit of work on df.
landley@driftwood
parents:
1
diff
changeset
|
34 #define TOYFLAG_USR (1<<0) |
67b517913e56
Infrastructure, first drop of toy shell, and a bit of work on df.
landley@driftwood
parents:
1
diff
changeset
|
35 #define TOYFLAG_BIN (1<<1) |
67b517913e56
Infrastructure, first drop of toy shell, and a bit of work on df.
landley@driftwood
parents:
1
diff
changeset
|
36 #define TOYFLAG_SBIN (1<<2) |
67b517913e56
Infrastructure, first drop of toy shell, and a bit of work on df.
landley@driftwood
parents:
1
diff
changeset
|
37 #define TOYMASK_LOCATION ((1<<4)-1) |
67b517913e56
Infrastructure, first drop of toy shell, and a bit of work on df.
landley@driftwood
parents:
1
diff
changeset
|
38 |
67b517913e56
Infrastructure, first drop of toy shell, and a bit of work on df.
landley@driftwood
parents:
1
diff
changeset
|
39 #define TOYFLAG_NOFORK (1<<4) |
67b517913e56
Infrastructure, first drop of toy shell, and a bit of work on df.
landley@driftwood
parents:
1
diff
changeset
|
40 |
1
59d58fab67c6
Next snapshot. Tries to grab something out of lib in order to build, I have
landley@driftwood
parents:
diff
changeset
|
41 extern struct toy_list { |
59d58fab67c6
Next snapshot. Tries to grab something out of lib in order to build, I have
landley@driftwood
parents:
diff
changeset
|
42 char *name; |
59d58fab67c6
Next snapshot. Tries to grab something out of lib in order to build, I have
landley@driftwood
parents:
diff
changeset
|
43 int (*toy_main)(void); |
2
67b517913e56
Infrastructure, first drop of toy shell, and a bit of work on df.
landley@driftwood
parents:
1
diff
changeset
|
44 int flags; |
1
59d58fab67c6
Next snapshot. Tries to grab something out of lib in order to build, I have
landley@driftwood
parents:
diff
changeset
|
45 } toy_list[]; |
2
67b517913e56
Infrastructure, first drop of toy shell, and a bit of work on df.
landley@driftwood
parents:
1
diff
changeset
|
46 struct toy_list *toy_find(char *name); |
3
266a462ed18c
Next drop of toysh, plus more infratructure.
landley@driftwood
parents:
2
diff
changeset
|
47 void toy_init(struct toy_list *which, char *argv[]); |
266a462ed18c
Next drop of toysh, plus more infratructure.
landley@driftwood
parents:
2
diff
changeset
|
48 void toy_exec(char *argv[]); |
1
59d58fab67c6
Next snapshot. Tries to grab something out of lib in order to build, I have
landley@driftwood
parents:
diff
changeset
|
49 |
59d58fab67c6
Next snapshot. Tries to grab something out of lib in order to build, I have
landley@driftwood
parents:
diff
changeset
|
50 // Global context for this applet. |
59d58fab67c6
Next snapshot. Tries to grab something out of lib in order to build, I have
landley@driftwood
parents:
diff
changeset
|
51 |
59d58fab67c6
Next snapshot. Tries to grab something out of lib in order to build, I have
landley@driftwood
parents:
diff
changeset
|
52 extern struct toy_context { |
2
67b517913e56
Infrastructure, first drop of toy shell, and a bit of work on df.
landley@driftwood
parents:
1
diff
changeset
|
53 struct toy_list *which; // Which entry in toy_list is this one? |
67b517913e56
Infrastructure, first drop of toy shell, and a bit of work on df.
landley@driftwood
parents:
1
diff
changeset
|
54 int exitval; // Value error_exit feeds to exit() |
7
fc9c0503d5e2
Implement df. Add -Wall to build and fix up warnings. Add copyright notices.
landley@driftwood
parents:
4
diff
changeset
|
55 int optflags; // Command line option flags |
fc9c0503d5e2
Implement df. Add -Wall to build and fix up warnings. Add copyright notices.
landley@driftwood
parents:
4
diff
changeset
|
56 char **argv; // Command line arguments |
1
59d58fab67c6
Next snapshot. Tries to grab something out of lib in order to build, I have
landley@driftwood
parents:
diff
changeset
|
57 char buf[4096]; |
59d58fab67c6
Next snapshot. Tries to grab something out of lib in order to build, I have
landley@driftwood
parents:
diff
changeset
|
58 } toys; |
59d58fab67c6
Next snapshot. Tries to grab something out of lib in order to build, I have
landley@driftwood
parents:
diff
changeset
|
59 |
2
67b517913e56
Infrastructure, first drop of toy shell, and a bit of work on df.
landley@driftwood
parents:
1
diff
changeset
|
60 struct exit_data {;}; |
67b517913e56
Infrastructure, first drop of toy shell, and a bit of work on df.
landley@driftwood
parents:
1
diff
changeset
|
61 struct cd_data {;}; |
1
59d58fab67c6
Next snapshot. Tries to grab something out of lib in order to build, I have
landley@driftwood
parents:
diff
changeset
|
62 struct toybox_data {;}; |
59d58fab67c6
Next snapshot. Tries to grab something out of lib in order to build, I have
landley@driftwood
parents:
diff
changeset
|
63 struct toysh_data {;}; |
7
fc9c0503d5e2
Implement df. Add -Wall to build and fix up warnings. Add copyright notices.
landley@driftwood
parents:
4
diff
changeset
|
64 struct df_data { |
fc9c0503d5e2
Implement df. Add -Wall to build and fix up warnings. Add copyright notices.
landley@driftwood
parents:
4
diff
changeset
|
65 struct string_list *fstype; |
fc9c0503d5e2
Implement df. Add -Wall to build and fix up warnings. Add copyright notices.
landley@driftwood
parents:
4
diff
changeset
|
66 long units; |
fc9c0503d5e2
Implement df. Add -Wall to build and fix up warnings. Add copyright notices.
landley@driftwood
parents:
4
diff
changeset
|
67 }; |
1
59d58fab67c6
Next snapshot. Tries to grab something out of lib in order to build, I have
landley@driftwood
parents:
diff
changeset
|
68 |
59d58fab67c6
Next snapshot. Tries to grab something out of lib in order to build, I have
landley@driftwood
parents:
diff
changeset
|
69 union toy_union { |
2
67b517913e56
Infrastructure, first drop of toy shell, and a bit of work on df.
landley@driftwood
parents:
1
diff
changeset
|
70 struct exit_data exit; |
67b517913e56
Infrastructure, first drop of toy shell, and a bit of work on df.
landley@driftwood
parents:
1
diff
changeset
|
71 struct cd_data cd; |
1
59d58fab67c6
Next snapshot. Tries to grab something out of lib in order to build, I have
landley@driftwood
parents:
diff
changeset
|
72 struct toybox_data toybox; |
59d58fab67c6
Next snapshot. Tries to grab something out of lib in order to build, I have
landley@driftwood
parents:
diff
changeset
|
73 struct toysh_data toysh; |
59d58fab67c6
Next snapshot. Tries to grab something out of lib in order to build, I have
landley@driftwood
parents:
diff
changeset
|
74 struct df_data df; |
59d58fab67c6
Next snapshot. Tries to grab something out of lib in order to build, I have
landley@driftwood
parents:
diff
changeset
|
75 } toy; |
59d58fab67c6
Next snapshot. Tries to grab something out of lib in order to build, I have
landley@driftwood
parents:
diff
changeset
|
76 |
3
266a462ed18c
Next drop of toysh, plus more infratructure.
landley@driftwood
parents:
2
diff
changeset
|
77 // Pending the addition of menuconfig... |
266a462ed18c
Next drop of toysh, plus more infratructure.
landley@driftwood
parents:
2
diff
changeset
|
78 |
266a462ed18c
Next drop of toysh, plus more infratructure.
landley@driftwood
parents:
2
diff
changeset
|
79 #define CFG_TOYS_FREE 0 |
266a462ed18c
Next drop of toysh, plus more infratructure.
landley@driftwood
parents:
2
diff
changeset
|
80 |
266a462ed18c
Next drop of toysh, plus more infratructure.
landley@driftwood
parents:
2
diff
changeset
|
81 #define CFG_TOYSH_TTY 0 // Terminal control |
266a462ed18c
Next drop of toysh, plus more infratructure.
landley@driftwood
parents:
2
diff
changeset
|
82 #define CFG_TOYSH_JOBCTL 0 // &, fg, bg, jobs. ctrl-z with tty. |
266a462ed18c
Next drop of toysh, plus more infratructure.
landley@driftwood
parents:
2
diff
changeset
|
83 #define CFG_TOYSH_FLOWCTL 0 // if, while, for, functions { } |
266a462ed18c
Next drop of toysh, plus more infratructure.
landley@driftwood
parents:
2
diff
changeset
|
84 #define CFG_TOYSH_ENVVARS 0 // Environment variables |
266a462ed18c
Next drop of toysh, plus more infratructure.
landley@driftwood
parents:
2
diff
changeset
|
85 #define CFG_TOYSH_LOCVARS 0 // Local, synthetic, fancy prompts, set, $? |
266a462ed18c
Next drop of toysh, plus more infratructure.
landley@driftwood
parents:
2
diff
changeset
|
86 #define CFG_TOYSH_PIPES 0 // Pipes and redirects: | > < >> << && || & () ; |
7
fc9c0503d5e2
Implement df. Add -Wall to build and fix up warnings. Add copyright notices.
landley@driftwood
parents:
4
diff
changeset
|
87 |
fc9c0503d5e2
Implement df. Add -Wall to build and fix up warnings. Add copyright notices.
landley@driftwood
parents:
4
diff
changeset
|
88 #define CFG_DF_PEDANTIC 1 // Support -P and -k in df |