busybox.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. #if __GNUC_PREREQ(4,1)
  11. # pragma GCC visibility push(hidden)
  12. #endif
  13. /* order matters: used as index into "install_dir[]" in appletlib.c */
  14. typedef enum bb_install_loc_t {
  15. _BB_DIR_ROOT = 0,
  16. _BB_DIR_BIN,
  17. _BB_DIR_SBIN,
  18. _BB_DIR_USR_BIN,
  19. _BB_DIR_USR_SBIN
  20. } bb_install_loc_t;
  21. typedef enum bb_suid_t {
  22. _BB_SUID_NEVER = 0,
  23. _BB_SUID_MAYBE,
  24. _BB_SUID_ALWAYS
  25. } bb_suid_t;
  26. /* Defined in appletlib.c (by including generated applet_tables.h) */
  27. /* Keep in sync with applets/applet_tables.c! */
  28. extern const char applet_names[];
  29. extern int (*const applet_main[])(int argc, char **argv);
  30. extern const uint16_t applet_nameofs[];
  31. extern const uint8_t applet_install_loc[];
  32. #if ENABLE_FEATURE_SUID || ENABLE_FEATURE_PREFER_APPLETS
  33. #define APPLET_NAME(i) (applet_names + (applet_nameofs[i] & 0x0fff))
  34. #else
  35. #define APPLET_NAME(i) (applet_names + applet_nameofs[i])
  36. #endif
  37. #if ENABLE_FEATURE_PREFER_APPLETS
  38. #define APPLET_IS_NOFORK(i) (applet_nameofs[i] & (1 << 12))
  39. #define APPLET_IS_NOEXEC(i) (applet_nameofs[i] & (1 << 13))
  40. #endif
  41. #if ENABLE_FEATURE_SUID
  42. #define APPLET_SUID(i) ((applet_nameofs[i] >> 14) & 0x3)
  43. #endif
  44. #if ENABLE_FEATURE_INSTALLER
  45. #define APPLET_INSTALL_LOC(i) ({ \
  46. unsigned v = (i); \
  47. if (v & 1) v = applet_install_loc[v/2] >> 4; \
  48. else v = applet_install_loc[v/2] & 0xf; \
  49. v; })
  50. #endif
  51. /* Length of these names has effect on size of libbusybox
  52. * and "individual" binaries. Keep them short.
  53. */
  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. #if __GNUC_PREREQ(4,1)
  62. # pragma GCC visibility pop
  63. #endif
  64. #endif /* _BB_INTERNAL_H_ */