busybox.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * Busybox main internal header file
  4. *
  5. * Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
  6. */
  7. #ifndef _BB_INTERNAL_H_
  8. #define _BB_INTERNAL_H_ 1
  9. #include "libbb.h"
  10. /* order matters: used as index into "install_dir[]" in appletlib.c */
  11. typedef enum bb_install_loc_t {
  12. _BB_DIR_ROOT = 0,
  13. _BB_DIR_BIN,
  14. _BB_DIR_SBIN,
  15. _BB_DIR_USR_BIN,
  16. _BB_DIR_USR_SBIN
  17. } bb_install_loc_t;
  18. typedef enum bb_suid_t {
  19. _BB_SUID_NEVER = 0,
  20. _BB_SUID_MAYBE,
  21. _BB_SUID_ALWAYS
  22. } bb_suid_t;
  23. /* Defined in appletlib.c (by including generated applet_tables.h) */
  24. /* Keep in sync with applets/applet_tables.c! */
  25. extern const char applet_names[];
  26. extern int (*const applet_main[])(int argc, char **argv);
  27. extern const uint16_t applet_nameofs[];
  28. extern const uint8_t applet_install_loc[];
  29. #if ENABLE_FEATURE_SUID || ENABLE_FEATURE_PREFER_APPLETS
  30. #define APPLET_NAME(i) (applet_names + (applet_nameofs[i] & 0x0fff))
  31. #else
  32. #define APPLET_NAME(i) (applet_names + applet_nameofs[i])
  33. #endif
  34. #if ENABLE_FEATURE_PREFER_APPLETS
  35. #define APPLET_IS_NOFORK(i) (applet_nameofs[i] & (1 << 12))
  36. #define APPLET_IS_NOEXEC(i) (applet_nameofs[i] & (1 << 13))
  37. #endif
  38. #if ENABLE_FEATURE_SUID
  39. #define APPLET_SUID(i) ((applet_nameofs[i] >> 14) & 0x3)
  40. #endif
  41. #if ENABLE_FEATURE_INSTALLER
  42. #define APPLET_INSTALL_LOC(i) ({ \
  43. unsigned v = (i); \
  44. if (v & 1) v = applet_install_loc[v/2] >> 4; \
  45. else v = applet_install_loc[v/2] & 0xf; \
  46. v; })
  47. #endif
  48. /* Length of these names has effect on size of libbusybox
  49. * and "individual" binaries. Keep them short.
  50. */
  51. void lbb_prepare(const char *applet
  52. USE_FEATURE_INDIVIDUAL(, char **argv)
  53. ) MAIN_EXTERNALLY_VISIBLE;
  54. #if ENABLE_BUILD_LIBBUSYBOX
  55. #if ENABLE_FEATURE_SHARED_BUSYBOX
  56. int lbb_main(char **argv) EXTERNALLY_VISIBLE;
  57. #else
  58. int lbb_main(char **argv);
  59. #endif
  60. #endif
  61. #endif /* _BB_INTERNAL_H_ */