comparison toys.h @ 237:7cb15eae1664

Zap toylist.h, moving contents of global structures into DEFINE_GLOBALS() macros in each C file, and making generated/globals.h from that. Rename "toy" to "this" along the way to avoid toy/toys confusion.
author Rob Landley <rob@landley.net>
date Sun, 20 Jan 2008 17:25:44 -0600
parents 163498bf547b
children 3fe66e630944
comparison
equal deleted inserted replaced
236:6b292ee780ab 237:7cb15eae1664
37 #define _XOPEN_SOURCE 600 37 #define _XOPEN_SOURCE 600
38 #include <time.h> 38 #include <time.h>
39 39
40 #include "lib/lib.h" 40 #include "lib/lib.h"
41 #include "toys/e2fs.h" 41 #include "toys/e2fs.h"
42 #include "toys/toylist.h"
43 42
44 // Get list of function prototypes for all enabled command_main() functions. 43 // Get list of function prototypes for all enabled command_main() functions.
45 44
46 #define NEWTOY(name, opts, flags) void name##_main(void); 45 #define NEWTOY(name, opts, flags) void name##_main(void);
47 #define OLDTOY(name, oldname, opts, flags) 46 #define OLDTOY(name, oldname, opts, flags)
48 #include "generated/newtoys.h" 47 #include "generated/newtoys.h"
48 #include "generated/globals.h"
49 49
50 // These live in main.c 50 // These live in main.c
51 51
52 struct toy_list *toy_find(char *name); 52 struct toy_list *toy_find(char *name);
53 void toy_init(struct toy_list *which, char *argv[]); 53 void toy_init(struct toy_list *which, char *argv[]);
54 void toy_exec(char *argv[]); 54 void toy_exec(char *argv[]);
55
56 // List of available applets
57
58 #define TOYFLAG_USR (1<<0)
59 #define TOYFLAG_BIN (1<<1)
60 #define TOYFLAG_SBIN (1<<2)
61 #define TOYMASK_LOCATION ((1<<4)-1)
62
63 #define TOYFLAG_NOFORK (1<<4)
64
65 extern struct toy_list {
66 char *name;
67 void (*toy_main)(void);
68 char *options;
69 int flags;
70 } toy_list[];
55 71
56 // Global context for any applet. 72 // Global context for any applet.
57 73
58 extern struct toy_context { 74 extern struct toy_context {
59 struct toy_list *which; // Which entry in toy_list is this one? 75 struct toy_list *which; // Which entry in toy_list is this one?
65 } toys; 81 } toys;
66 82
67 // One big temporary buffer, for use by applets (not library functions). 83 // One big temporary buffer, for use by applets (not library functions).
68 84
69 extern char toybuf[4096]; 85 extern char toybuf[4096];
86
87 #define DEFINE_GLOBALS(...)