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 | * |
Denys Vlasenko | 0ef64bd | 2010-08-16 20:14:46 +0200 | [diff] [blame] | 5 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
Eric Andersen | f6b7139 | 2000-09-26 01:09:18 +0000 | [diff] [blame] | 6 | */ |
Denis Vlasenko | f81e8db | 2009-04-09 12:35:13 +0000 | [diff] [blame] | 7 | #ifndef BUSYBOX_H |
| 8 | #define BUSYBOX_H 1 |
Eric Andersen | f6b7139 | 2000-09-26 01:09:18 +0000 | [diff] [blame] | 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 | f81e8db | 2009-04-09 12:35:13 +0000 | [diff] [blame] | 12 | PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN |
Denis Vlasenko | 98636eb | 2008-05-09 17:59:34 +0000 | [diff] [blame] | 13 | |
Denis Vlasenko | 1aa7e47 | 2007-11-28 06:49:03 +0000 | [diff] [blame] | 14 | /* order matters: used as index into "install_dir[]" in appletlib.c */ |
Denis Vlasenko | 335b63d | 2007-04-10 21:38:30 +0000 | [diff] [blame] | 15 | typedef enum bb_install_loc_t { |
Denys Vlasenko | b9f2d9f | 2011-01-18 13:58:01 +0100 | [diff] [blame] | 16 | BB_DIR_ROOT = 0, |
| 17 | BB_DIR_BIN, |
| 18 | BB_DIR_SBIN, |
Denys Vlasenko | d4d289a | 2010-10-12 04:18:05 +0200 | [diff] [blame] | 19 | #if ENABLE_INSTALL_NO_USR |
Denys Vlasenko | b9f2d9f | 2011-01-18 13:58:01 +0100 | [diff] [blame] | 20 | BB_DIR_USR_BIN = BB_DIR_BIN, |
| 21 | BB_DIR_USR_SBIN = BB_DIR_SBIN, |
Denys Vlasenko | d4d289a | 2010-10-12 04:18:05 +0200 | [diff] [blame] | 22 | #else |
Denys Vlasenko | b9f2d9f | 2011-01-18 13:58:01 +0100 | [diff] [blame] | 23 | BB_DIR_USR_BIN, |
| 24 | BB_DIR_USR_SBIN, |
Denys Vlasenko | d4d289a | 2010-10-12 04:18:05 +0200 | [diff] [blame] | 25 | #endif |
Denis Vlasenko | 335b63d | 2007-04-10 21:38:30 +0000 | [diff] [blame] | 26 | } bb_install_loc_t; |
Eric Andersen | f6b7139 | 2000-09-26 01:09:18 +0000 | [diff] [blame] | 27 | |
Denis Vlasenko | 335b63d | 2007-04-10 21:38:30 +0000 | [diff] [blame] | 28 | typedef enum bb_suid_t { |
Denys Vlasenko | b9f2d9f | 2011-01-18 13:58:01 +0100 | [diff] [blame] | 29 | BB_SUID_DROP = 0, |
| 30 | BB_SUID_MAYBE, |
| 31 | BB_SUID_REQUIRE |
Denis Vlasenko | 335b63d | 2007-04-10 21:38:30 +0000 | [diff] [blame] | 32 | } bb_suid_t; |
Denis Vlasenko | 1aa7e47 | 2007-11-28 06:49:03 +0000 | [diff] [blame] | 33 | |
| 34 | |
| 35 | /* Defined in appletlib.c (by including generated applet_tables.h) */ |
| 36 | /* Keep in sync with applets/applet_tables.c! */ |
| 37 | extern const char applet_names[]; |
Denis Vlasenko | 745cd17 | 2007-11-29 03:31:20 +0000 | [diff] [blame] | 38 | extern int (*const applet_main[])(int argc, char **argv); |
Denis Vlasenko | 1aa7e47 | 2007-11-28 06:49:03 +0000 | [diff] [blame] | 39 | extern const uint16_t applet_nameofs[]; |
Denis Vlasenko | 745cd17 | 2007-11-29 03:31:20 +0000 | [diff] [blame] | 40 | extern const uint8_t applet_install_loc[]; |
Robert Griebl | c9aca45 | 2002-06-04 20:06:25 +0000 | [diff] [blame] | 41 | |
Denis Vlasenko | 745cd17 | 2007-11-29 03:31:20 +0000 | [diff] [blame] | 42 | #if ENABLE_FEATURE_SUID || ENABLE_FEATURE_PREFER_APPLETS |
Denys Vlasenko | 8fa1f5d | 2010-07-15 08:18:46 +0200 | [diff] [blame] | 43 | # define APPLET_NAME(i) (applet_names + (applet_nameofs[i] & 0x0fff)) |
Denis Vlasenko | 1aa7e47 | 2007-11-28 06:49:03 +0000 | [diff] [blame] | 44 | #else |
Denys Vlasenko | 8fa1f5d | 2010-07-15 08:18:46 +0200 | [diff] [blame] | 45 | # define APPLET_NAME(i) (applet_names + applet_nameofs[i]) |
Denis Vlasenko | 1aa7e47 | 2007-11-28 06:49:03 +0000 | [diff] [blame] | 46 | #endif |
| 47 | |
Denis Vlasenko | 80d14be | 2007-04-10 23:03:30 +0000 | [diff] [blame] | 48 | #if ENABLE_FEATURE_PREFER_APPLETS |
Denys Vlasenko | 8fa1f5d | 2010-07-15 08:18:46 +0200 | [diff] [blame] | 49 | # define APPLET_IS_NOFORK(i) (applet_nameofs[i] & (1 << 12)) |
| 50 | # define APPLET_IS_NOEXEC(i) (applet_nameofs[i] & (1 << 13)) |
| 51 | #else |
| 52 | # define APPLET_IS_NOFORK(i) 0 |
| 53 | # define APPLET_IS_NOEXEC(i) 0 |
Denis Vlasenko | 745cd17 | 2007-11-29 03:31:20 +0000 | [diff] [blame] | 54 | #endif |
| 55 | |
| 56 | #if ENABLE_FEATURE_SUID |
Denys Vlasenko | 8fa1f5d | 2010-07-15 08:18:46 +0200 | [diff] [blame] | 57 | # define APPLET_SUID(i) ((applet_nameofs[i] >> 14) & 0x3) |
Denis Vlasenko | 745cd17 | 2007-11-29 03:31:20 +0000 | [diff] [blame] | 58 | #endif |
| 59 | |
| 60 | #if ENABLE_FEATURE_INSTALLER |
| 61 | #define APPLET_INSTALL_LOC(i) ({ \ |
| 62 | unsigned v = (i); \ |
| 63 | if (v & 1) v = applet_install_loc[v/2] >> 4; \ |
| 64 | else v = applet_install_loc[v/2] & 0xf; \ |
| 65 | v; }) |
Denis Vlasenko | 335b63d | 2007-04-10 21:38:30 +0000 | [diff] [blame] | 66 | #endif |
Glenn L McGrath | 60a22ad | 2002-08-22 15:54:22 +0000 | [diff] [blame] | 67 | |
Denis Vlasenko | 9b49a5e | 2007-10-11 10:05:36 +0000 | [diff] [blame] | 68 | |
Denis Vlasenko | 9b49a5e | 2007-10-11 10:05:36 +0000 | [diff] [blame] | 69 | /* Length of these names has effect on size of libbusybox |
| 70 | * and "individual" binaries. Keep them short. |
| 71 | */ |
Denis Vlasenko | 724d196 | 2007-10-10 14:41:07 +0000 | [diff] [blame] | 72 | #if ENABLE_BUILD_LIBBUSYBOX |
Denis Vlasenko | 9b49a5e | 2007-10-11 10:05:36 +0000 | [diff] [blame] | 73 | #if ENABLE_FEATURE_SHARED_BUSYBOX |
Denis Vlasenko | 85c2471 | 2008-03-17 09:04:04 +0000 | [diff] [blame] | 74 | int lbb_main(char **argv) EXTERNALLY_VISIBLE; |
Denis Vlasenko | 9b49a5e | 2007-10-11 10:05:36 +0000 | [diff] [blame] | 75 | #else |
Denis Vlasenko | 85c2471 | 2008-03-17 09:04:04 +0000 | [diff] [blame] | 76 | int lbb_main(char **argv); |
Denis Vlasenko | 724d196 | 2007-10-10 14:41:07 +0000 | [diff] [blame] | 77 | #endif |
Denis Vlasenko | 9b49a5e | 2007-10-11 10:05:36 +0000 | [diff] [blame] | 78 | #endif |
| 79 | |
Denis Vlasenko | f81e8db | 2009-04-09 12:35:13 +0000 | [diff] [blame] | 80 | POP_SAVED_FUNCTION_VISIBILITY |
Eric Andersen | f6b7139 | 2000-09-26 01:09:18 +0000 | [diff] [blame] | 81 | |
Denis Vlasenko | f81e8db | 2009-04-09 12:35:13 +0000 | [diff] [blame] | 82 | #endif |