Convert all the applets from #include to USE(). Had to fix some nonstandard
[oweals/busybox.git] / include / busybox.h
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
10 #include "bb_config.h"
11
12 #include <stdio.h>
13 #include <stdlib.h>
14 #include <stdarg.h>
15 #include <sys/types.h>
16 #include <sys/stat.h>
17
18 #if __GNU_LIBRARY__ < 5 && \
19     !defined(__dietlibc__) && \
20     !defined(_NEWLIB_VERSION)
21 #error "Sorry, this libc version is not supported :("
22 #endif
23
24 extern const char BB_BANNER[];
25
26 #include <features.h>
27
28 /* Pull in the utility routines from libbb */
29 #include "libbb.h"
30
31 enum Location {
32         _BB_DIR_ROOT = 0,
33         _BB_DIR_BIN,
34         _BB_DIR_SBIN,
35         _BB_DIR_USR_BIN,
36         _BB_DIR_USR_SBIN
37 };
38
39 enum SUIDRoot {
40         _BB_SUID_NEVER = 0,
41         _BB_SUID_MAYBE,
42         _BB_SUID_ALWAYS
43 };
44
45 struct BB_applet {
46         const char *name;
47         int (*main) (int argc, char **argv);
48         __extension__ enum Location location:4;
49         __extension__ enum SUIDRoot need_suid:4;
50 };
51
52 /* From busybox.c */
53 extern const struct BB_applet applets[];
54
55 /* Automagically pull in all the applet function prototypes and
56  * applet usage strings.  These are all of the form:
57  *              extern int foo_main(int argc, char **argv);
58  *              extern const char foo_usage[];
59  * These are all autogenerated from the set of currently defined applets.
60  */
61 #define PROTOTYPES
62 #include "applets.h"
63 #undef PROTOTYPES
64
65 #ifdef CONFIG_FEATURE_BUFFERS_GO_ON_STACK
66 #define RESERVE_CONFIG_BUFFER(buffer,len)           char buffer[len]
67 #define RESERVE_CONFIG_UBUFFER(buffer,len) unsigned char buffer[len]
68 #define RELEASE_CONFIG_BUFFER(buffer)      ((void)0)
69 #else
70 #ifdef CONFIG_FEATURE_BUFFERS_GO_IN_BSS
71 #define RESERVE_CONFIG_BUFFER(buffer,len)  static          char buffer[len]
72 #define RESERVE_CONFIG_UBUFFER(buffer,len) static unsigned char buffer[len]
73 #define RELEASE_CONFIG_BUFFER(buffer)      ((void)0)
74 #else
75 #define RESERVE_CONFIG_BUFFER(buffer,len)           char *buffer=xmalloc(len)
76 #define RESERVE_CONFIG_UBUFFER(buffer,len) unsigned char *buffer=xmalloc(len)
77 #define RELEASE_CONFIG_BUFFER(buffer)      free (buffer)
78 #endif
79 #endif
80
81
82 #ifndef RB_POWER_OFF
83 /* Stop system and switch power off if possible.  */
84 #define RB_POWER_OFF   0x4321fedc
85 #endif
86
87 /* Try to pull in PATH_MAX */
88 #include <limits.h>
89
90 /* for PATH_MAX on systems that don't have it in limits.h */
91 #include <sys/param.h>
92 #ifndef PATH_MAX
93 #define  PATH_MAX         256
94 #endif
95
96 #ifdef DMALLOC
97 #include <dmalloc.h>
98 #endif
99
100 #endif                                                  /* _BB_INTERNAL_H_ */