1/* vi: set sw=4 ts=4: */ 2/* 3 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 4 */ 5#ifndef BUSYBOX_H 6#define BUSYBOX_H 1 7 8#include "libbb.h" 9/* BB_DIR_foo and BB_SUID_bar constants: */ 10#include "applet_metadata.h" 11 12PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN 13 14/* Defined in appletlib.c (by including generated applet_tables.h) */ 15/* Keep in sync with applets/applet_tables.c! */ 16extern const char applet_names[] ALIGN1; 17extern int (*const applet_main[])(int argc, char **argv); 18extern const uint8_t applet_flags[] ALIGN1; 19extern const uint8_t applet_suid[] ALIGN1; 20extern const uint8_t applet_install_loc[] ALIGN1; 21 22#if ENABLE_FEATURE_PREFER_APPLETS \ 23 || ENABLE_FEATURE_SH_STANDALONE \ 24 || ENABLE_FEATURE_SH_NOFORK 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))) 27#else 28# define APPLET_IS_NOFORK(i) 0 29# define APPLET_IS_NOEXEC(i) 0 30#endif 31 32#if ENABLE_FEATURE_SUID 33# define APPLET_SUID(i) ((applet_suid[(i)/4] >> (2 * ((i)%4)) & 3)) 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; }) 42#endif 43 44 45/* Length of these names has effect on size of libbusybox 46 * and "individual" binaries. Keep them short. 47 */ 48#if ENABLE_BUILD_LIBBUSYBOX 49#if ENABLE_FEATURE_SHARED_BUSYBOX 50int lbb_main(char **argv) EXTERNALLY_VISIBLE; 51#else 52int lbb_main(char **argv); 53#endif 54#endif 55 56POP_SAVED_FUNCTION_VISIBILITY 57 58#endif 59