1
2
3
4
5
6
7
8#include "generated/config.h"
9#include "lib/portability.h"
10
11
12#include <ctype.h>
13#include <dirent.h>
14#include <errno.h>
15#include <fcntl.h>
16#include <fnmatch.h>
17#include <grp.h>
18#include <inttypes.h>
19#include <limits.h>
20#include <math.h>
21#include <paths.h>
22#include <pwd.h>
23#include <regex.h>
24#include <sched.h>
25#include <setjmp.h>
26#include <signal.h>
27#include <stdarg.h>
28#include <stddef.h>
29#include <stdint.h>
30#include <stdio.h>
31#include <stdlib.h>
32#include <string.h>
33#include <strings.h>
34#include <sys/mman.h>
35#include <sys/resource.h>
36#include <sys/stat.h>
37#include <sys/statvfs.h>
38#include <sys/time.h>
39#include <sys/times.h>
40#include <sys/utsname.h>
41#include <sys/wait.h>
42#include <syslog.h>
43#include <termios.h>
44#include <time.h>
45#include <unistd.h>
46#include <utime.h>
47
48
49
50#include <arpa/inet.h>
51#include <netdb.h>
52#include <net/if.h>
53#include <netinet/in.h>
54#include <netinet/tcp.h>
55#include <poll.h>
56#include <sys/socket.h>
57#include <sys/un.h>
58
59
60
61#include <langinfo.h>
62#include <locale.h>
63#include <wchar.h>
64#include <wctype.h>
65
66
67#include <sys/ioctl.h>
68#include <sys/syscall.h>
69
70#include "lib/lib.h"
71#include "lib/lsm.h"
72#include "lib/toyflags.h"
73
74
75
76#define NEWTOY(name, opts, flags) void name##_main(void);
77#define OLDTOY(name, oldname, flags) void oldname##_main(void);
78#include "generated/newtoys.h"
79#include "generated/flags.h"
80#include "generated/globals.h"
81#include "generated/tags.h"
82
83
84
85struct toy_list *toy_find(char *name);
86void show_help(FILE *out, int full);
87void check_help(char **arg);
88void toy_singleinit(struct toy_list *which, char *argv[]);
89void toy_init(struct toy_list *which, char *argv[]);
90void toy_exec(char *argv[]);
91
92
93
94extern struct toy_list {
95 char *name;
96 void (*toy_main)(void);
97 char *options;
98 unsigned flags;
99} toy_list[];
100
101
102
103extern struct toy_context {
104 struct toy_list *which;
105 char **argv;
106 char **optargs;
107 unsigned long long optflags;
108 int optc;
109 short toycount;
110 char exitval;
111 char wasroot;
112
113
114 sigjmp_buf *rebound;
115 struct arg_list *xexit;
116 void *stacktop;
117 int envc;
118 int old_umask;
119 short signal;
120 int signalfd;
121} toys;
122
123
124
125extern char **environ, *toybox_version, toybuf[4096], libbuf[4096];
126
127#define FLAG(x) (toys.optflags&FLAG_##x)
128
129#define GLOBALS(...)
130#define ARRAY_LEN(array) (sizeof(array)/sizeof(*array))
131#define TAGGED_ARRAY(X, ...) {__VA_ARGS__}
132
133#ifndef TOYBOX_VERSION
134#ifndef TOYBOX_VENDOR
135#define TOYBOX_VENDOR ""
136#endif
137#define TOYBOX_VERSION "0.8.8"TOYBOX_VENDOR
138#endif
139