blob: 9460d36879db12afaaa7779e6815a987f21bdbb7 [file] [log] [blame]
landleyc5621502006-09-28 17:18:51 -04001/* 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
landley4f344e32006-10-05 16:18:03 -04009#include <limits.h>
10#include <stdarg.h>
landleyc5621502006-09-28 17:18:51 -040011#include <stdio.h>
landley4f344e32006-10-05 16:18:03 -040012#include <stdlib.h>
13#include <string.h>
landleyc5621502006-09-28 17:18:51 -040014#include <strings.h>
landley4f344e32006-10-05 16:18:03 -040015#include <unistd.h>
landleyc5621502006-09-28 17:18:51 -040016
landley4f344e32006-10-05 16:18:03 -040017#include "lib/lib.h"
landleyc5621502006-09-28 17:18:51 -040018
landley4f344e32006-10-05 16:18:03 -040019int cd_main(void);
landleycd9dfc32006-10-18 18:38:16 -040020int df_main(void);
landley4f344e32006-10-05 16:18:03 -040021int exit_main(void);
landleyc5621502006-09-28 17:18:51 -040022int toybox_main(void);
23int toysh_main(void);
landleyc5621502006-09-28 17:18:51 -040024
landley4f344e32006-10-05 16:18:03 -040025#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
landleyc5621502006-09-28 17:18:51 -040032extern struct toy_list {
33 char *name;
34 int (*toy_main)(void);
landley4f344e32006-10-05 16:18:03 -040035 int flags;
landleyc5621502006-09-28 17:18:51 -040036} toy_list[];
landley4f344e32006-10-05 16:18:03 -040037struct toy_list *toy_find(char *name);
landleycd9dfc32006-10-18 18:38:16 -040038void toy_init(struct toy_list *which, char *argv[]);
39void toy_exec(char *argv[]);
landleyc5621502006-09-28 17:18:51 -040040
41// Global context for this applet.
42
43extern struct toy_context {
landley4f344e32006-10-05 16:18:03 -040044 struct toy_list *which; // Which entry in toy_list is this one?
45 int exitval; // Value error_exit feeds to exit()
landleyc5621502006-09-28 17:18:51 -040046 int argc;
47 char **argv;
48 char buf[4096];
49} toys;
50
landley4f344e32006-10-05 16:18:03 -040051struct exit_data {;};
52struct cd_data {;};
landleyc5621502006-09-28 17:18:51 -040053struct toybox_data {;};
54struct toysh_data {;};
55struct df_data {;};
56
57union toy_union {
landley4f344e32006-10-05 16:18:03 -040058 struct exit_data exit;
59 struct cd_data cd;
landleyc5621502006-09-28 17:18:51 -040060 struct toybox_data toybox;
61 struct toysh_data toysh;
62 struct df_data df;
63} toy;
64
landleycd9dfc32006-10-18 18:38:16 -040065// 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: | > < >> << && || & () ;