Fix warning
[oweals/busybox.git] / busybox.h
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
27 #include "Config.h"
28
29 #include <stdio.h>
30 #include <stdarg.h>
31 #include <sys/stat.h>
32 #include <sys/types.h>
33
34 #ifdef DMALLOC
35 #include "dmalloc.h"
36 #endif
37
38 #include <features.h>
39
40
41 enum Location {
42         _BB_DIR_ROOT = 0,
43         _BB_DIR_BIN,
44         _BB_DIR_SBIN,
45         _BB_DIR_USR_BIN,
46         _BB_DIR_USR_SBIN
47 };
48
49 struct BB_applet {
50         const   char*   name;
51         int     (*main)(int argc, char** argv);
52         enum    Location        location;
53 };
54 /* From busybox.c */
55 extern const struct BB_applet applets[];
56
57 /* Automagically pull in all the applet function prototypes and
58  * applet usage strings.  These are all of the form:
59  *              extern int foo_main(int argc, char **argv);
60  *              extern const char foo_usage[];
61  * These are all autogenerated from the set of currently defined applets. 
62  */
63 #define PROTOTYPES
64 #include "applets.h"
65 #undef PROTOTYPES
66
67 extern const char *applet_name;
68
69 #ifdef BB_FEATURE_BUFFERS_GO_ON_STACK
70 #define RESERVE_BB_BUFFER(buffer,len)           char buffer[len]
71 #define RESERVE_BB_UBUFFER(buffer,len) unsigned char buffer[len]
72 #else
73 #define RESERVE_BB_BUFFER(buffer,len)           char *buffer=xmalloc(len)
74 #define RESERVE_BB_UBUFFER(buffer,len) unsigned char *buffer=xmalloc(len)
75 #endif
76
77
78 /* Bit map related macros -- libc5 doens't provide these... sigh.  */
79 #ifndef setbit
80 #define NBBY            CHAR_BIT
81 #define setbit(a,i)     ((a)[(i)/NBBY] |= 1<<((i)%NBBY))
82 #define clrbit(a,i)     ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
83 #define isset(a,i)      ((a)[(i)/NBBY] & (1<<((i)%NBBY)))
84 #define isclr(a,i)      (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
85 #endif
86
87 #ifndef RB_POWER_OFF
88 /* Stop system and switch power off if possible.  */
89 #define RB_POWER_OFF   0x4321fedc
90 #endif
91
92
93 /* Pull in the utility routines from libbb */
94 #include "libbb/libbb.h"
95
96
97
98 #endif /* _BB_INTERNAL_H_ */