Eric Andersen | f6b7139 | 2000-09-26 01:09:18 +0000 | [diff] [blame] | 1 | /* vi: set sw=4 ts=4: */ |
| 2 | /* |
| 3 | * Busybox main internal header file |
| 4 | * |
Bernhard Reutner-Fischer | 86f5c99 | 2006-01-22 22:55:11 +0000 | [diff] [blame] | 5 | * Licensed under the GPL v2 or later, see the file LICENSE in this tarball. |
Eric Andersen | f6b7139 | 2000-09-26 01:09:18 +0000 | [diff] [blame] | 6 | */ |
| 7 | #ifndef _BB_INTERNAL_H_ |
| 8 | #define _BB_INTERNAL_H_ 1 |
| 9 | |
Robert Griebl | c9aca45 | 2002-06-04 20:06:25 +0000 | [diff] [blame] | 10 | #include "libbb.h" |
Eric Andersen | c319601 | 2001-03-14 01:15:06 +0000 | [diff] [blame] | 11 | |
Denis Vlasenko | 1aa7e47 | 2007-11-28 06:49:03 +0000 | [diff] [blame] | 12 | /* order matters: used as index into "install_dir[]" in appletlib.c */ |
Denis Vlasenko | 335b63d | 2007-04-10 21:38:30 +0000 | [diff] [blame] | 13 | typedef enum bb_install_loc_t { |
Eric Andersen | f6b7139 | 2000-09-26 01:09:18 +0000 | [diff] [blame] | 14 | _BB_DIR_ROOT = 0, |
| 15 | _BB_DIR_BIN, |
| 16 | _BB_DIR_SBIN, |
| 17 | _BB_DIR_USR_BIN, |
| 18 | _BB_DIR_USR_SBIN |
Denis Vlasenko | 335b63d | 2007-04-10 21:38:30 +0000 | [diff] [blame] | 19 | } bb_install_loc_t; |
Eric Andersen | f6b7139 | 2000-09-26 01:09:18 +0000 | [diff] [blame] | 20 | |
Denis Vlasenko | 335b63d | 2007-04-10 21:38:30 +0000 | [diff] [blame] | 21 | typedef enum bb_suid_t { |
Robert Griebl | c9aca45 | 2002-06-04 20:06:25 +0000 | [diff] [blame] | 22 | _BB_SUID_NEVER = 0, |
| 23 | _BB_SUID_MAYBE, |
| 24 | _BB_SUID_ALWAYS |
Denis Vlasenko | 335b63d | 2007-04-10 21:38:30 +0000 | [diff] [blame] | 25 | } bb_suid_t; |
Denis Vlasenko | 1aa7e47 | 2007-11-28 06:49:03 +0000 | [diff] [blame] | 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_mains[])(int argc, char **argv); |
| 32 | |
| 33 | #if ENABLE_FEATURE_INSTALLER || ENABLE_FEATURE_PREFER_APPLETS |
| 34 | extern const uint32_t applet_nameofs[]; |
| 35 | #else |
| 36 | extern const uint16_t applet_nameofs[]; |
Denis Vlasenko | 335b63d | 2007-04-10 21:38:30 +0000 | [diff] [blame] | 37 | #endif |
Robert Griebl | c9aca45 | 2002-06-04 20:06:25 +0000 | [diff] [blame] | 38 | |
Denis Vlasenko | 335b63d | 2007-04-10 21:38:30 +0000 | [diff] [blame] | 39 | #if ENABLE_FEATURE_SUID |
Denis Vlasenko | 1aa7e47 | 2007-11-28 06:49:03 +0000 | [diff] [blame] | 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)) |
Denis Vlasenko | 335b63d | 2007-04-10 21:38:30 +0000 | [diff] [blame] | 44 | #endif |
Denis Vlasenko | 1aa7e47 | 2007-11-28 06:49:03 +0000 | [diff] [blame] | 45 | |
| 46 | #if ENABLE_FEATURE_INSTALLER |
| 47 | #define APPLET_INSTALL_LOC(i) ((applet_nameofs[i] >> 16) & 0x7) |
| 48 | #endif |
| 49 | |
Denis Vlasenko | 80d14be | 2007-04-10 23:03:30 +0000 | [diff] [blame] | 50 | #if ENABLE_FEATURE_PREFER_APPLETS |
Denis Vlasenko | 1aa7e47 | 2007-11-28 06:49:03 +0000 | [diff] [blame] | 51 | #define APPLET_IS_NOFORK(i) (applet_nameofs[i] & (1 << 19)) |
| 52 | #define APPLET_IS_NOEXEC(i) (applet_nameofs[i] & (1 << 20)) |
Denis Vlasenko | 335b63d | 2007-04-10 21:38:30 +0000 | [diff] [blame] | 53 | #endif |
Glenn L McGrath | 60a22ad | 2002-08-22 15:54:22 +0000 | [diff] [blame] | 54 | |
Denis Vlasenko | 9b49a5e | 2007-10-11 10:05:36 +0000 | [diff] [blame] | 55 | |
Denis Vlasenko | 9b49a5e | 2007-10-11 10:05:36 +0000 | [diff] [blame] | 56 | /* Length of these names has effect on size of libbusybox |
| 57 | * and "individual" binaries. Keep them short. |
| 58 | */ |
Denis Vlasenko | 15cb4a4 | 2007-10-11 10:06:26 +0000 | [diff] [blame] | 59 | void lbb_prepare(const char *applet, char **argv) MAIN_EXTERNALLY_VISIBLE; |
Denis Vlasenko | 724d196 | 2007-10-10 14:41:07 +0000 | [diff] [blame] | 60 | #if ENABLE_BUILD_LIBBUSYBOX |
Denis Vlasenko | 9b49a5e | 2007-10-11 10:05:36 +0000 | [diff] [blame] | 61 | #if ENABLE_FEATURE_SHARED_BUSYBOX |
| 62 | int lbb_main(int argc, char **argv) EXTERNALLY_VISIBLE; |
| 63 | #else |
| 64 | int lbb_main(int argc, char **argv); |
Denis Vlasenko | 724d196 | 2007-10-10 14:41:07 +0000 | [diff] [blame] | 65 | #endif |
Denis Vlasenko | 9b49a5e | 2007-10-11 10:05:36 +0000 | [diff] [blame] | 66 | #endif |
| 67 | |
Eric Andersen | f6b7139 | 2000-09-26 01:09:18 +0000 | [diff] [blame] | 68 | |
Denis Vlasenko | c7ba8b9 | 2007-02-03 17:27:14 +0000 | [diff] [blame] | 69 | #endif /* _BB_INTERNAL_H_ */ |