blob: e84736a0272c9d1d9f223058d16cae58c4ea9d03 [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>
landley00f87f12006-10-25 18:38:37 -040015#include <sys/stat.h>
landley4f344e32006-10-05 16:18:03 -040016#include <unistd.h>
landleyc5621502006-09-28 17:18:51 -040017
landley4f344e32006-10-05 16:18:03 -040018#include "lib/lib.h"
landleyc5621502006-09-28 17:18:51 -040019
landley4f344e32006-10-05 16:18:03 -040020int cd_main(void);
landleycd9dfc32006-10-18 18:38:16 -040021int df_main(void);
landley4f344e32006-10-05 16:18:03 -040022int exit_main(void);
landleyc5621502006-09-28 17:18:51 -040023int toybox_main(void);
24int toysh_main(void);
landleyc5621502006-09-28 17:18:51 -040025
landley4f344e32006-10-05 16:18:03 -040026#define TOYFLAG_USR (1<<0)
27#define TOYFLAG_BIN (1<<1)
28#define TOYFLAG_SBIN (1<<2)
29#define TOYMASK_LOCATION ((1<<4)-1)
30
31#define TOYFLAG_NOFORK (1<<4)
32
landleyc5621502006-09-28 17:18:51 -040033extern struct toy_list {
34 char *name;
35 int (*toy_main)(void);
landley4f344e32006-10-05 16:18:03 -040036 int flags;
landleyc5621502006-09-28 17:18:51 -040037} toy_list[];
landley4f344e32006-10-05 16:18:03 -040038struct toy_list *toy_find(char *name);
landleycd9dfc32006-10-18 18:38:16 -040039void toy_init(struct toy_list *which, char *argv[]);
40void toy_exec(char *argv[]);
landleyc5621502006-09-28 17:18:51 -040041
42// Global context for this applet.
43
44extern struct toy_context {
landley4f344e32006-10-05 16:18:03 -040045 struct toy_list *which; // Which entry in toy_list is this one?
46 int exitval; // Value error_exit feeds to exit()
landleyc5621502006-09-28 17:18:51 -040047 int argc;
48 char **argv;
49 char buf[4096];
50} toys;
51
landley4f344e32006-10-05 16:18:03 -040052struct exit_data {;};
53struct cd_data {;};
landleyc5621502006-09-28 17:18:51 -040054struct toybox_data {;};
55struct toysh_data {;};
56struct df_data {;};
57
58union toy_union {
landley4f344e32006-10-05 16:18:03 -040059 struct exit_data exit;
60 struct cd_data cd;
landleyc5621502006-09-28 17:18:51 -040061 struct toybox_data toybox;
62 struct toysh_data toysh;
63 struct df_data df;
64} toy;
65
landleycd9dfc32006-10-18 18:38:16 -040066// Pending the addition of menuconfig...
67
68#define CFG_TOYS_FREE 0
69
70#define CFG_TOYSH_TTY 0 // Terminal control
71#define CFG_TOYSH_JOBCTL 0 // &, fg, bg, jobs. ctrl-z with tty.
72#define CFG_TOYSH_FLOWCTL 0 // if, while, for, functions { }
73#define CFG_TOYSH_ENVVARS 0 // Environment variables
74#define CFG_TOYSH_LOCVARS 0 // Local, synthetic, fancy prompts, set, $?
75#define CFG_TOYSH_PIPES 0 // Pipes and redirects: | > < >> << && || & () ;