busybox.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * Busybox main internal header file
  4. *
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19. *
  20. * Based in part on code from sash, Copyright (c) 1999 by David I. Bell
  21. * Permission has been granted to redistribute this code under the GPL.
  22. *
  23. */
  24. #ifndef _BB_INTERNAL_H_
  25. #define _BB_INTERNAL_H_ 1
  26. #include "config.h"
  27. #include <stdio.h>
  28. #include <stdlib.h>
  29. #include <stdarg.h>
  30. #include <sys/stat.h>
  31. #include <sys/types.h>
  32. #if __GNU_LIBRARY__ < 5 && \
  33. !defined(__dietlibc__) && \
  34. !defined(_NEWLIB_VERSION)
  35. #error "Sorry, this libc version is not supported :("
  36. #endif
  37. #ifndef BB_EXTRA_VERSION
  38. #define BB_BANNER "BusyBox v" BB_VER " (" BB_BT ")"
  39. #else
  40. #define BB_BANNER "BusyBox v" BB_VER " (" BB_EXTRA_VERSION ")"
  41. #endif
  42. #ifdef DMALLOC
  43. #include <dmalloc.h>
  44. #endif
  45. #include <features.h>
  46. /* Pull in the utility routines from libbb */
  47. #include "libbb.h"
  48. enum Location {
  49. _BB_DIR_ROOT = 0,
  50. _BB_DIR_BIN,
  51. _BB_DIR_SBIN,
  52. _BB_DIR_USR_BIN,
  53. _BB_DIR_USR_SBIN
  54. };
  55. enum SUIDRoot {
  56. _BB_SUID_NEVER = 0,
  57. _BB_SUID_MAYBE,
  58. _BB_SUID_ALWAYS
  59. };
  60. struct BB_applet {
  61. const char *name;
  62. int (*main) (int argc, char **argv);
  63. enum Location location:4;
  64. enum SUIDRoot need_suid:4;
  65. };
  66. /* From busybox.c */
  67. extern const struct BB_applet applets[];
  68. /* Automagically pull in all the applet function prototypes and
  69. * applet usage strings. These are all of the form:
  70. * extern int foo_main(int argc, char **argv);
  71. * extern const char foo_usage[];
  72. * These are all autogenerated from the set of currently defined applets.
  73. */
  74. #define PROTOTYPES
  75. #include "applets.h"
  76. #undef PROTOTYPES
  77. #ifdef CONFIG_FEATURE_BUFFERS_GO_ON_STACK
  78. #define RESERVE_CONFIG_BUFFER(buffer,len) char buffer[len]
  79. #define RESERVE_CONFIG_UBUFFER(buffer,len) unsigned char buffer[len]
  80. #define RELEASE_CONFIG_BUFFER(buffer) ((void)0)
  81. #else
  82. #ifdef CONFIG_FEATURE_BUFFERS_GO_IN_BSS
  83. #define RESERVE_CONFIG_BUFFER(buffer,len) static char buffer[len]
  84. #define RESERVE_CONFIG_UBUFFER(buffer,len) static unsigned char buffer[len]
  85. #define RELEASE_CONFIG_BUFFER(buffer) ((void)0)
  86. #else
  87. #define RESERVE_CONFIG_BUFFER(buffer,len) char *buffer=xmalloc(len)
  88. #define RESERVE_CONFIG_UBUFFER(buffer,len) unsigned char *buffer=xmalloc(len)
  89. #define RELEASE_CONFIG_BUFFER(buffer) free (buffer)
  90. #endif
  91. #endif
  92. #ifndef RB_POWER_OFF
  93. /* Stop system and switch power off if possible. */
  94. #define RB_POWER_OFF 0x4321fedc
  95. #endif
  96. /* Try to pull in PATH_MAX */
  97. #include <limits.h>
  98. /* for PATH_MAX on systems that don't have it in limits.h */
  99. #include <sys/param.h>
  100. #ifndef PATH_MAX
  101. #define PATH_MAX 256
  102. #endif
  103. #endif /* _BB_INTERNAL_H_ */