busybox.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. || ENABLE_FEATURE_SH_STANDALONE \
  20. || ENABLE_FEATURE_SH_NOFORK
  21. # define APPLET_IS_NOFORK(i) (applet_flags[(i)/4] & (1 << (2 * ((i)%4))))
  22. # define APPLET_IS_NOEXEC(i) (applet_flags[(i)/4] & (1 << ((2 * ((i)%4))+1)))
  23. #else
  24. # define APPLET_IS_NOFORK(i) 0
  25. # define APPLET_IS_NOEXEC(i) 0
  26. #endif
  27. #if ENABLE_FEATURE_SUID
  28. # define APPLET_SUID(i) ((applet_suid[(i)/4] >> (2 * ((i)%4)) & 3))
  29. #endif
  30. #if ENABLE_FEATURE_INSTALLER
  31. #define APPLET_INSTALL_LOC(i) ({ \
  32. unsigned v = (i); \
  33. if (v & 1) v = applet_install_loc[v/2] >> 4; \
  34. else v = applet_install_loc[v/2] & 0xf; \
  35. v; })
  36. #endif
  37. /* Length of these names has effect on size of libbusybox
  38. * and "individual" binaries. Keep them short.
  39. */
  40. #if ENABLE_BUILD_LIBBUSYBOX
  41. #if ENABLE_FEATURE_SHARED_BUSYBOX
  42. int lbb_main(char **argv) EXTERNALLY_VISIBLE;
  43. #else
  44. int lbb_main(char **argv);
  45. #endif
  46. #endif
  47. POP_SAVED_FUNCTION_VISIBILITY
  48. #endif