blob: 4bf29b70dd27f912ed433c4013327b14819a14f2 [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);
20int exit_main(void);
landleyc5621502006-09-28 17:18:51 -040021int toybox_main(void);
22int toysh_main(void);
23int df_main(void);
24
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);
landleyc5621502006-09-28 17:18:51 -040038
39// Global context for this applet.
40
41extern struct toy_context {
landley4f344e32006-10-05 16:18:03 -040042 struct toy_list *which; // Which entry in toy_list is this one?
43 int exitval; // Value error_exit feeds to exit()
landleyc5621502006-09-28 17:18:51 -040044 int argc;
45 char **argv;
46 char buf[4096];
47} toys;
48
landley4f344e32006-10-05 16:18:03 -040049struct exit_data {;};
50struct cd_data {;};
landleyc5621502006-09-28 17:18:51 -040051struct toybox_data {;};
52struct toysh_data {;};
53struct df_data {;};
54
55union toy_union {
landley4f344e32006-10-05 16:18:03 -040056 struct exit_data exit;
57 struct cd_data cd;
landleyc5621502006-09-28 17:18:51 -040058 struct toybox_data toybox;
59 struct toysh_data toysh;
60 struct df_data df;
61} toy;
62
landley4f344e32006-10-05 16:18:03 -040063// I need a real config system.
64#define CFG_TOYS_FREE 0