OSDN Git Service

Next drop of toysh, plus more infratructure.
[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 <limits.h>
10 #include <stdarg.h>
11 #include <stdio.h>
12 #include <stdlib.h>
13 #include <string.h>
14 #include <strings.h>
15 #include <unistd.h>
16
17 #include "lib/lib.h"
18
19 int cd_main(void);
20 int df_main(void);
21 int exit_main(void);
22 int toybox_main(void);
23 int toysh_main(void);
24
25 #define TOYFLAG_USR      (1<<0)
26 #define TOYFLAG_BIN      (1<<1)
27 #define TOYFLAG_SBIN     (1<<2)
28 #define TOYMASK_LOCATION ((1<<4)-1)
29
30 #define TOYFLAG_NOFORK   (1<<4)
31
32 extern struct toy_list {
33         char *name;
34         int (*toy_main)(void);
35         int flags;
36 } toy_list[];
37 struct toy_list *toy_find(char *name);
38 void toy_init(struct toy_list *which, char *argv[]);
39 void toy_exec(char *argv[]);
40
41 // Global context for this applet.
42
43 extern struct toy_context {
44         struct toy_list *which;  // Which entry in toy_list is this one?
45         int exitval;             // Value error_exit feeds to exit()
46         int argc;
47         char **argv;
48         char buf[4096];
49 } toys;
50
51 struct exit_data {;};
52 struct cd_data {;};
53 struct toybox_data {;};
54 struct toysh_data {;};
55 struct df_data {;};
56
57 union toy_union {
58         struct exit_data exit;
59         struct cd_data cd;
60         struct toybox_data toybox;
61         struct toysh_data toysh;
62         struct df_data df;
63 } toy;
64
65 // Pending the addition of menuconfig...
66
67 #define CFG_TOYS_FREE     0
68
69 #define CFG_TOYSH_TTY     0  // Terminal control
70 #define CFG_TOYSH_JOBCTL  0  // &, fg, bg, jobs.  ctrl-z with tty.
71 #define CFG_TOYSH_FLOWCTL 0  // if, while, for, functions { }
72 #define CFG_TOYSH_ENVVARS 0  // Environment variables
73 #define CFG_TOYSH_LOCVARS 0  // Local, synthetic, fancy prompts, set, $?
74 #define CFG_TOYSH_PIPES   0  // Pipes and redirects: | > < >> << && || & () ;