OSDN Git Service

Implement which. Add hello world to menuconfig. Wrap the various applet main
[android-x86/external-toybox.git] / toys.h
1 /* vi: set ts=4 :*/
2 /* Toybox infrastructure.
3  *
4  * Copyright 2006 Rob Landley <rob@landley.net>
5  *
6  * Licensed under GPL version 2, see file LICENSE in this tarball for details.
7  */
8
9 #include <ctype.h>
10 #include <errno.h>
11 #include <fcntl.h>
12 #include <inttypes.h>
13 #include <limits.h>
14 #include <stdarg.h>
15 #include <stdint.h>
16 #include <stdio.h>
17 #include <stdlib.h>
18 #include <string.h>
19 #include <strings.h>
20 #include <sys/stat.h>
21 #include <sys/statvfs.h>
22 #include <sys/types.h>
23 #include <sys/wait.h>
24 #include <unistd.h>
25
26 #include "lib/lib.h"
27
28 int cd_main(void);
29 int df_main(void);
30 int exit_main(void);
31 int hello_main(void);
32 int toybox_main(void);
33 int toysh_main(void);
34 int which_main(void);
35
36 #define TOYFLAG_USR      (1<<0)
37 #define TOYFLAG_BIN      (1<<1)
38 #define TOYFLAG_SBIN     (1<<2)
39 #define TOYMASK_LOCATION ((1<<4)-1)
40
41 #define TOYFLAG_NOFORK   (1<<4)
42
43 extern struct toy_list {
44         char *name;
45         int (*toy_main)(void);
46         int flags;
47 } toy_list[];
48 struct toy_list *toy_find(char *name);
49 void toy_init(struct toy_list *which, char *argv[]);
50 void toy_exec(char *argv[]);
51
52 // Global context for this applet.
53
54 extern struct toy_context {
55         struct toy_list *which;  // Which entry in toy_list is this one?
56         int exitval;             // Value error_exit feeds to exit()
57         int optflags;            // Command line option flags
58         char **argv;             // Command line arguments
59         char buf[4096];
60 } toys;
61
62 struct exit_data {;};
63 struct cd_data {;};
64 struct toybox_data {;};
65 struct toysh_data {;};
66 struct df_data {
67         struct string_list *fstype;
68         long units;
69 };
70
71 union toy_union {
72         struct exit_data exit;
73         struct cd_data cd;
74         struct toybox_data toybox;
75         struct toysh_data toysh;
76         struct df_data df;
77 } toy;
78
79 // Pending the addition of menuconfig...
80
81 #include "gen_config.h"