2 /* Toybox infrastructure.
4 * Copyright 2006 Rob Landley <rob@landley.net>
6 * Licensed under GPL version 2, see file LICENSE in this tarball for details.
9 #include "generated/config.h"
11 #include "lib/portability.h"
28 #include <sys/ioctl.h>
30 #include <sys/mount.h>
32 #include <sys/statvfs.h>
33 #include <sys/types.h>
38 #define _XOPEN_SOURCE 600
42 #include "toys/e2fs.h"
44 // Get list of function prototypes for all enabled command_main() functions.
46 #define NEWTOY(name, opts, flags) void name##_main(void);
47 #define OLDTOY(name, oldname, opts, flags)
48 #include "generated/newtoys.h"
49 #include "generated/globals.h"
51 // These live in main.c
53 struct toy_list *toy_find(char *name);
54 void toy_init(struct toy_list *which, char *argv[]);
55 void toy_exec(char *argv[]);
57 // List of available applets
59 #define TOYFLAG_USR (1<<0)
60 #define TOYFLAG_BIN (1<<1)
61 #define TOYFLAG_SBIN (1<<2)
62 #define TOYMASK_LOCATION ((1<<4)-1)
64 #define TOYFLAG_NOFORK (1<<4)
65 #define TOYFLAG_UMASK (1<<5)
67 extern struct toy_list {
69 void (*toy_main)(void);
74 // Global context for any applet.
76 extern struct toy_context {
77 struct toy_list *which; // Which entry in toy_list is this one?
78 int exitval; // Value error_exit feeds to exit()
79 char **argv; // Original command line arguments
80 unsigned optflags; // Command line option flags from get_optflags()
81 char **optargs; // Arguments left over from get_optflags()
82 int optc; // Count of optargs
83 int exithelp; // Should error_exit print a usage message first? (Option parsing.)
87 // One big temporary buffer, for use by applets (not library functions).
89 extern char toybuf[4096];
91 #define DEFINE_GLOBALS(...)