Eric Andersen | f6b7139 | 2000-09-26 01:09:18 +0000 | [diff] [blame] | 1 | /* vi: set sw=4 ts=4: */ |
| 2 | /* |
Denys Vlasenko | 0ef64bd | 2010-08-16 20:14:46 +0200 | [diff] [blame] | 3 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
Eric Andersen | f6b7139 | 2000-09-26 01:09:18 +0000 | [diff] [blame] | 4 | */ |
Denis Vlasenko | f81e8db | 2009-04-09 12:35:13 +0000 | [diff] [blame] | 5 | #ifndef BUSYBOX_H |
| 6 | #define BUSYBOX_H 1 |
Eric Andersen | f6b7139 | 2000-09-26 01:09:18 +0000 | [diff] [blame] | 7 | |
Robert Griebl | c9aca45 | 2002-06-04 20:06:25 +0000 | [diff] [blame] | 8 | #include "libbb.h" |
Denys Vlasenko | 6ec1510 | 2011-03-28 01:23:38 +0200 | [diff] [blame] | 9 | /* BB_DIR_foo and BB_SUID_bar constants: */ |
| 10 | #include "applet_metadata.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 | /* Defined in appletlib.c (by including generated applet_tables.h) */ |
| 15 | /* Keep in sync with applets/applet_tables.c! */ |
Michael Tokarev | 32f774c | 2012-07-24 15:56:37 +0200 | [diff] [blame] | 16 | extern const char applet_names[] ALIGN1; |
Denis Vlasenko | 745cd17 | 2007-11-29 03:31:20 +0000 | [diff] [blame] | 17 | extern int (*const applet_main[])(int argc, char **argv); |
Ron Yorston | 610c4c3 | 2016-03-30 00:42:05 +0200 | [diff] [blame] | 18 | extern const uint8_t applet_flags[] ALIGN1; |
| 19 | extern const uint8_t applet_suid[] ALIGN1; |
Michael Tokarev | 32f774c | 2012-07-24 15:56:37 +0200 | [diff] [blame] | 20 | extern const uint8_t applet_install_loc[] ALIGN1; |
Robert Griebl | c9aca45 | 2002-06-04 20:06:25 +0000 | [diff] [blame] | 21 | |
Denys Vlasenko | 0fb0045 | 2016-07-22 18:48:38 +0200 | [diff] [blame^] | 22 | #if ENABLE_FEATURE_PREFER_APPLETS \ |
| 23 | || ENABLE_FEATURE_SH_STANDALONE \ |
| 24 | || ENABLE_FEATURE_SH_NOFORK |
Ron Yorston | 610c4c3 | 2016-03-30 00:42:05 +0200 | [diff] [blame] | 25 | # define APPLET_IS_NOFORK(i) (applet_flags[(i)/4] & (1 << (2 * ((i)%4)))) |
| 26 | # define APPLET_IS_NOEXEC(i) (applet_flags[(i)/4] & (1 << ((2 * ((i)%4))+1))) |
Denys Vlasenko | 8fa1f5d | 2010-07-15 08:18:46 +0200 | [diff] [blame] | 27 | #else |
| 28 | # define APPLET_IS_NOFORK(i) 0 |
| 29 | # define APPLET_IS_NOEXEC(i) 0 |
Denis Vlasenko | 745cd17 | 2007-11-29 03:31:20 +0000 | [diff] [blame] | 30 | #endif |
| 31 | |
| 32 | #if ENABLE_FEATURE_SUID |
Ron Yorston | 610c4c3 | 2016-03-30 00:42:05 +0200 | [diff] [blame] | 33 | # define APPLET_SUID(i) ((applet_suid[(i)/4] >> (2 * ((i)%4)) & 3)) |
Denis Vlasenko | 745cd17 | 2007-11-29 03:31:20 +0000 | [diff] [blame] | 34 | #endif |
| 35 | |
| 36 | #if ENABLE_FEATURE_INSTALLER |
| 37 | #define APPLET_INSTALL_LOC(i) ({ \ |
| 38 | unsigned v = (i); \ |
| 39 | if (v & 1) v = applet_install_loc[v/2] >> 4; \ |
| 40 | else v = applet_install_loc[v/2] & 0xf; \ |
| 41 | v; }) |
Denis Vlasenko | 335b63d | 2007-04-10 21:38:30 +0000 | [diff] [blame] | 42 | #endif |
Glenn L McGrath | 60a22ad | 2002-08-22 15:54:22 +0000 | [diff] [blame] | 43 | |
Denis Vlasenko | 9b49a5e | 2007-10-11 10:05:36 +0000 | [diff] [blame] | 44 | |
Denis Vlasenko | 9b49a5e | 2007-10-11 10:05:36 +0000 | [diff] [blame] | 45 | /* Length of these names has effect on size of libbusybox |
| 46 | * and "individual" binaries. Keep them short. |
| 47 | */ |
Denis Vlasenko | 724d196 | 2007-10-10 14:41:07 +0000 | [diff] [blame] | 48 | #if ENABLE_BUILD_LIBBUSYBOX |
Denis Vlasenko | 9b49a5e | 2007-10-11 10:05:36 +0000 | [diff] [blame] | 49 | #if ENABLE_FEATURE_SHARED_BUSYBOX |
Denis Vlasenko | 85c2471 | 2008-03-17 09:04:04 +0000 | [diff] [blame] | 50 | int lbb_main(char **argv) EXTERNALLY_VISIBLE; |
Denis Vlasenko | 9b49a5e | 2007-10-11 10:05:36 +0000 | [diff] [blame] | 51 | #else |
Denis Vlasenko | 85c2471 | 2008-03-17 09:04:04 +0000 | [diff] [blame] | 52 | int lbb_main(char **argv); |
Denis Vlasenko | 724d196 | 2007-10-10 14:41:07 +0000 | [diff] [blame] | 53 | #endif |
Denis Vlasenko | 9b49a5e | 2007-10-11 10:05:36 +0000 | [diff] [blame] | 54 | #endif |
| 55 | |
Denis Vlasenko | f81e8db | 2009-04-09 12:35:13 +0000 | [diff] [blame] | 56 | POP_SAVED_FUNCTION_VISIBILITY |
Eric Andersen | f6b7139 | 2000-09-26 01:09:18 +0000 | [diff] [blame] | 57 | |
Denis Vlasenko | f81e8db | 2009-04-09 12:35:13 +0000 | [diff] [blame] | 58 | #endif |