3
0

busybox.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. #include "libbb.h"
  8. /* BB_DIR_foo and BB_SUID_bar constants: */
  9. #include "applet_metadata.h"
  10. PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN
  11. /* Defined in appletlib.c (by including generated applet_tables.h) */
  12. /* Keep in sync with applets/applet_tables.c! */
  13. extern const char applet_names[] ALIGN1;
  14. extern int (*const applet_main[])(int argc, char **argv);
  15. extern const uint8_t applet_flags[] ALIGN1;
  16. extern const uint8_t applet_suid[] ALIGN1;
  17. extern const uint8_t applet_install_loc[] ALIGN1;
  18. #if ENABLE_FEATURE_PREFER_APPLETS
  19. # define APPLET_IS_NOFORK(i) (applet_flags[(i)/4] & (1 << (2 * ((i)%4))))
  20. # define APPLET_IS_NOEXEC(i) (applet_flags[(i)/4] & (1 << ((2 * ((i)%4))+1)))
  21. #else
  22. # define APPLET_IS_NOFORK(i) 0
  23. # define APPLET_IS_NOEXEC(i) 0
  24. #endif
  25. #if ENABLE_FEATURE_SUID
  26. # define APPLET_SUID(i) ((applet_suid[(i)/4] >> (2 * ((i)%4)) & 3))
  27. #endif
  28. #if ENABLE_FEATURE_INSTALLER
  29. #define APPLET_INSTALL_LOC(i) ({ \
  30. unsigned v = (i); \
  31. if (v & 1) v = applet_install_loc[v/2] >> 4; \
  32. else v = applet_install_loc[v/2] & 0xf; \
  33. v; })
  34. #endif
  35. /* Length of these names has effect on size of libbusybox
  36. * and "individual" binaries. Keep them short.
  37. */
  38. #if ENABLE_BUILD_LIBBUSYBOX
  39. #if ENABLE_FEATURE_SHARED_BUSYBOX
  40. int lbb_main(char **argv) EXTERNALLY_VISIBLE;
  41. #else
  42. int lbb_main(char **argv);
  43. #endif
  44. #endif
  45. POP_SAVED_FUNCTION_VISIBILITY
  46. #endif