Added CONFIG_CLEAR and CONFIG_RESET to config.maemo
[busybox4maemo] / include / busybox.h
1 /* vi: set sw=4 ts=4: */
2 /*
3  * Busybox main internal header file
4  *
5  * Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
6  */
7 #ifndef _BB_INTERNAL_H_
8 #define _BB_INTERNAL_H_    1
9
10 #include "libbb.h"
11
12 /* order matters: used as index into "install_dir[]" in appletlib.c */
13 typedef enum bb_install_loc_t {
14         _BB_DIR_ROOT = 0,
15         _BB_DIR_BIN,
16         _BB_DIR_SBIN,
17         _BB_DIR_USR_BIN,
18         _BB_DIR_USR_SBIN
19 } bb_install_loc_t;
20
21 typedef enum bb_suid_t {
22         _BB_SUID_NEVER = 0,
23         _BB_SUID_MAYBE,
24         _BB_SUID_ALWAYS
25 } bb_suid_t;
26
27
28 /* Defined in appletlib.c (by including generated applet_tables.h) */
29 /* Keep in sync with applets/applet_tables.c! */
30 extern const char applet_names[];
31 extern int (*const applet_main[])(int argc, char **argv);
32 extern const uint16_t applet_nameofs[];
33 extern const uint8_t applet_install_loc[];
34
35 #if ENABLE_FEATURE_SUID || ENABLE_FEATURE_PREFER_APPLETS
36 #define APPLET_NAME(i) (applet_names + (applet_nameofs[i] & 0x0fff))
37 #else
38 #define APPLET_NAME(i) (applet_names + applet_nameofs[i])
39 #endif
40
41 #if ENABLE_FEATURE_PREFER_APPLETS
42 #define APPLET_IS_NOFORK(i) (applet_nameofs[i] & (1 << 12))
43 #define APPLET_IS_NOEXEC(i) (applet_nameofs[i] & (1 << 13))
44 #endif
45
46 #if ENABLE_FEATURE_SUID
47 #define APPLET_SUID(i) ((applet_nameofs[i] >> 14) & 0x3)
48 #endif
49
50 #if ENABLE_FEATURE_INSTALLER
51 #define APPLET_INSTALL_LOC(i) ({ \
52         unsigned v = (i); \
53         if (v & 1) v = applet_install_loc[v/2] >> 4; \
54         else v = applet_install_loc[v/2] & 0xf; \
55         v; })
56 #endif
57
58
59 /* Length of these names has effect on size of libbusybox
60  * and "individual" binaries. Keep them short.
61  */
62 void lbb_prepare(const char *applet
63         USE_FEATURE_INDIVIDUAL(, char **argv)
64         ) MAIN_EXTERNALLY_VISIBLE;
65 #if ENABLE_BUILD_LIBBUSYBOX
66 #if ENABLE_FEATURE_SHARED_BUSYBOX
67 int lbb_main(char **argv) EXTERNALLY_VISIBLE;
68 #else
69 int lbb_main(char **argv);
70 #endif
71 #endif
72
73
74 #endif  /* _BB_INTERNAL_H_ */