3
0

busybox.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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[];
  14. extern int (*const applet_main[])(int argc, char **argv);
  15. extern const uint16_t applet_nameofs[];
  16. extern const uint8_t applet_install_loc[];
  17. #if ENABLE_FEATURE_SUID || ENABLE_FEATURE_PREFER_APPLETS
  18. # define APPLET_NAME(i) (applet_names + (applet_nameofs[i] & 0x0fff))
  19. #else
  20. # define APPLET_NAME(i) (applet_names + applet_nameofs[i])
  21. #endif
  22. #if ENABLE_FEATURE_PREFER_APPLETS
  23. # define APPLET_IS_NOFORK(i) (applet_nameofs[i] & (1 << 12))
  24. # define APPLET_IS_NOEXEC(i) (applet_nameofs[i] & (1 << 13))
  25. #else
  26. # define APPLET_IS_NOFORK(i) 0
  27. # define APPLET_IS_NOEXEC(i) 0
  28. #endif
  29. #if ENABLE_FEATURE_SUID
  30. # define APPLET_SUID(i) ((applet_nameofs[i] >> 14) & 0x3)
  31. #endif
  32. #if ENABLE_FEATURE_INSTALLER
  33. #define APPLET_INSTALL_LOC(i) ({ \
  34. unsigned v = (i); \
  35. if (v & 1) v = applet_install_loc[v/2] >> 4; \
  36. else v = applet_install_loc[v/2] & 0xf; \
  37. v; })
  38. #endif
  39. /* Length of these names has effect on size of libbusybox
  40. * and "individual" binaries. Keep them short.
  41. */
  42. #if ENABLE_BUILD_LIBBUSYBOX
  43. #if ENABLE_FEATURE_SHARED_BUSYBOX
  44. int lbb_main(char **argv) EXTERNALLY_VISIBLE;
  45. #else
  46. int lbb_main(char **argv);
  47. #endif
  48. #endif
  49. POP_SAVED_FUNCTION_VISIBILITY
  50. #endif