aboutsummaryrefslogtreecommitdiff
path: root/include/busybox.h
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-11-28 06:49:03 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-11-28 06:49:03 +0000
commit1aa7e477b1b727db77cac2d717f0fcca40587f78 (patch)
tree247171517f0e01d32a71a5e96f4bef462cc0e9c6 /include/busybox.h
parent79c6904faff1ebd4bf4b7d9cd0c20ca70f4cec75 (diff)
downloadbusybox-w32-1aa7e477b1b727db77cac2d717f0fcca40587f78.tar.gz
busybox-w32-1aa7e477b1b727db77cac2d717f0fcca40587f78.tar.bz2
busybox-w32-1aa7e477b1b727db77cac2d717f0fcca40587f78.zip
reorganize applet table. Eliminates pointers to names.
Should be a big win for libbusybox. busybox wins too: text data bss dec hex filename 776524 929 9100 786553 c0079 busybox_old 775903 929 9100 785932 bfe0c busybox_unstripped
Diffstat (limited to 'include/busybox.h')
-rw-r--r--include/busybox.h46
1 files changed, 23 insertions, 23 deletions
diff --git a/include/busybox.h b/include/busybox.h
index 7ef36901a..f99901aa3 100644
--- a/include/busybox.h
+++ b/include/busybox.h
@@ -9,8 +9,7 @@
9 9
10#include "libbb.h" 10#include "libbb.h"
11 11
12#if ENABLE_FEATURE_INSTALLER 12/* order matters: used as index into "install_dir[]" in appletlib.c */
13/* order matters: used as index into "install_dir[]" in busybox.c */
14typedef enum bb_install_loc_t { 13typedef enum bb_install_loc_t {
15 _BB_DIR_ROOT = 0, 14 _BB_DIR_ROOT = 0,
16 _BB_DIR_BIN, 15 _BB_DIR_BIN,
@@ -18,40 +17,41 @@ typedef enum bb_install_loc_t {
18 _BB_DIR_USR_BIN, 17 _BB_DIR_USR_BIN,
19 _BB_DIR_USR_SBIN 18 _BB_DIR_USR_SBIN
20} bb_install_loc_t; 19} bb_install_loc_t;
21#endif
22 20
23#if ENABLE_FEATURE_SUID
24typedef enum bb_suid_t { 21typedef enum bb_suid_t {
25 _BB_SUID_NEVER = 0, 22 _BB_SUID_NEVER = 0,
26 _BB_SUID_MAYBE, 23 _BB_SUID_MAYBE,
27 _BB_SUID_ALWAYS 24 _BB_SUID_ALWAYS
28} bb_suid_t; 25} bb_suid_t;
29#endif
30 26
31struct bb_applet { 27
32 const char *name; 28/* Defined in appletlib.c (by including generated applet_tables.h) */
33 int (*main) (int argc, char **argv); 29/* Keep in sync with applets/applet_tables.c! */
34#if ENABLE_FEATURE_INSTALLER 30extern const char applet_names[];
35 __extension__ enum bb_install_loc_t install_loc:8; 31extern int (*const applet_mains[])(int argc, char **argv);
32
33#if ENABLE_FEATURE_INSTALLER || ENABLE_FEATURE_PREFER_APPLETS
34extern const uint32_t applet_nameofs[];
35#else
36extern const uint16_t applet_nameofs[];
36#endif 37#endif
38
37#if ENABLE_FEATURE_SUID 39#if ENABLE_FEATURE_SUID
38 __extension__ enum bb_suid_t need_suid:8; 40#define APPLET_NAME(i) (applet_names + (applet_nameofs[i] & 0x3fff))
41#define APPLET_SUID(i) ((applet_nameofs[i] >> 14) & 0x3)
42#else
43#define APPLET_NAME(i) (applet_names + (applet_nameofs[i] & 0xffff))
39#endif 44#endif
40#if ENABLE_FEATURE_PREFER_APPLETS 45
41 /* true if instead of fork(); exec("applet"); waitpid(); 46#if ENABLE_FEATURE_INSTALLER
42 * one can do fork(); exit(applet_main(argc,argv)); waitpid(); */ 47#define APPLET_INSTALL_LOC(i) ((applet_nameofs[i] >> 16) & 0x7)
43 unsigned char noexec;
44 /* Even nicer */
45 /* true if instead of fork(); exec("applet"); waitpid();
46 * one can simply call applet_main(argc,argv); */
47 unsigned char nofork;
48#endif 48#endif
49};
50 49
50#if ENABLE_FEATURE_PREFER_APPLETS
51#define APPLET_IS_NOFORK(i) (applet_nameofs[i] & (1 << 19))
52#define APPLET_IS_NOEXEC(i) (applet_nameofs[i] & (1 << 20))
53#endif
51 54
52/* Defined in appletlib.c */
53extern const struct bb_applet applets[];
54extern const unsigned short NUM_APPLETS;
55 55
56/* Length of these names has effect on size of libbusybox 56/* Length of these names has effect on size of libbusybox
57 * and "individual" binaries. Keep them short. 57 * and "individual" binaries. Keep them short.