Eric Andersen | f6b7139 | 2000-09-26 01:09:18 +0000 | [diff] [blame] | 1 | /* vi: set sw=4 ts=4: */ |
| 2 | /* |
| 3 | * Busybox main internal header file |
| 4 | * |
Bernhard Reutner-Fischer | 86f5c99 | 2006-01-22 22:55:11 +0000 | [diff] [blame] | 5 | * Licensed under the GPL v2 or later, see the file LICENSE in this tarball. |
Eric Andersen | f6b7139 | 2000-09-26 01:09:18 +0000 | [diff] [blame] | 6 | */ |
| 7 | #ifndef _BB_INTERNAL_H_ |
| 8 | #define _BB_INTERNAL_H_ 1 |
| 9 | |
Rob Landley | 193c8c7 | 2005-07-27 06:55:36 +0000 | [diff] [blame] | 10 | #include "bb_config.h" |
Eric Andersen | f6b7139 | 2000-09-26 01:09:18 +0000 | [diff] [blame] | 11 | |
Eric Andersen | ed3ef50 | 2001-01-27 08:24:39 +0000 | [diff] [blame] | 12 | #include <stdio.h> |
Manuel Novoa III | 68474f3 | 2004-02-05 14:45:58 +0000 | [diff] [blame] | 13 | #include <stdlib.h> |
Eric Andersen | f6b7139 | 2000-09-26 01:09:18 +0000 | [diff] [blame] | 14 | #include <stdarg.h> |
Eric Andersen | 01bda5d | 2001-01-02 01:16:38 +0000 | [diff] [blame] | 15 | #include <sys/types.h> |
"Vladimir N. Oleynik" | 843c5ef | 2005-09-29 07:55:51 +0000 | [diff] [blame] | 16 | #include <sys/stat.h> |
Eric Andersen | f6b7139 | 2000-09-26 01:09:18 +0000 | [diff] [blame] | 17 | |
Mike Frysinger | ca1b6fc | 2005-03-04 01:09:43 +0000 | [diff] [blame] | 18 | #if __GNU_LIBRARY__ < 5 && \ |
| 19 | !defined(__dietlibc__) && \ |
| 20 | !defined(_NEWLIB_VERSION) |
| 21 | #error "Sorry, this libc version is not supported :(" |
Eric Andersen | 85e5e72 | 2003-07-22 08:56:55 +0000 | [diff] [blame] | 22 | #endif |
| 23 | |
"Vladimir N. Oleynik" | dd1ccdd | 2006-02-16 15:40:24 +0000 | [diff] [blame] | 24 | extern const char BB_BANNER[]; |
Matt Kraai | 6ba1a80 | 2001-04-12 20:11:55 +0000 | [diff] [blame] | 25 | |
Eric Andersen | 2b1c367 | 2001-03-14 01:36:52 +0000 | [diff] [blame] | 26 | #include <features.h> |
Eric Andersen | c319601 | 2001-03-14 01:15:06 +0000 | [diff] [blame] | 27 | |
Glenn L McGrath | 60a22ad | 2002-08-22 15:54:22 +0000 | [diff] [blame] | 28 | /* Pull in the utility routines from libbb */ |
Robert Griebl | c9aca45 | 2002-06-04 20:06:25 +0000 | [diff] [blame] | 29 | #include "libbb.h" |
Eric Andersen | c319601 | 2001-03-14 01:15:06 +0000 | [diff] [blame] | 30 | |
Eric Andersen | f6b7139 | 2000-09-26 01:09:18 +0000 | [diff] [blame] | 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 | |
Robert Griebl | c9aca45 | 2002-06-04 20:06:25 +0000 | [diff] [blame] | 39 | enum SUIDRoot { |
| 40 | _BB_SUID_NEVER = 0, |
| 41 | _BB_SUID_MAYBE, |
| 42 | _BB_SUID_ALWAYS |
| 43 | }; |
| 44 | |
Eric Andersen | f6b7139 | 2000-09-26 01:09:18 +0000 | [diff] [blame] | 45 | struct BB_applet { |
Glenn L McGrath | 60a22ad | 2002-08-22 15:54:22 +0000 | [diff] [blame] | 46 | const char *name; |
| 47 | int (*main) (int argc, char **argv); |
Bernhard Reutner-Fischer | 86f5c99 | 2006-01-22 22:55:11 +0000 | [diff] [blame] | 48 | __extension__ enum Location location:4; |
| 49 | __extension__ enum SUIDRoot need_suid:4; |
Eric Andersen | f6b7139 | 2000-09-26 01:09:18 +0000 | [diff] [blame] | 50 | }; |
Glenn L McGrath | 60a22ad | 2002-08-22 15:54:22 +0000 | [diff] [blame] | 51 | |
Eric Andersen | f6b7139 | 2000-09-26 01:09:18 +0000 | [diff] [blame] | 52 | /* From busybox.c */ |
| 53 | extern const struct BB_applet applets[]; |
| 54 | |
Eric Andersen | 8c725e6 | 2000-11-30 00:27:06 +0000 | [diff] [blame] | 55 | /* Automagically pull in all the applet function prototypes and |
Eric Andersen | 8755982 | 2000-12-01 19:02:24 +0000 | [diff] [blame] | 56 | * applet usage strings. These are all of the form: |
Eric Andersen | 8c725e6 | 2000-11-30 00:27:06 +0000 | [diff] [blame] | 57 | * extern int foo_main(int argc, char **argv); |
| 58 | * extern const char foo_usage[]; |
Eric Andersen | c7bda1c | 2004-03-15 08:29:22 +0000 | [diff] [blame] | 59 | * These are all autogenerated from the set of currently defined applets. |
Eric Andersen | 8c725e6 | 2000-11-30 00:27:06 +0000 | [diff] [blame] | 60 | */ |
| 61 | #define PROTOTYPES |
| 62 | #include "applets.h" |
| 63 | #undef PROTOTYPES |
Eric Andersen | f6b7139 | 2000-09-26 01:09:18 +0000 | [diff] [blame] | 64 | |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 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) |
Eric Andersen | aad1a88 | 2001-03-16 22:47:14 +0000 | [diff] [blame] | 69 | #else |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 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) |
Mark Whitley | 3e310ac | 2001-04-20 17:40:33 +0000 | [diff] [blame] | 74 | #else |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 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) |
Eric Andersen | f6b7139 | 2000-09-26 01:09:18 +0000 | [diff] [blame] | 78 | #endif |
Mark Whitley | 3e310ac | 2001-04-20 17:40:33 +0000 | [diff] [blame] | 79 | #endif |
Eric Andersen | f6b7139 | 2000-09-26 01:09:18 +0000 | [diff] [blame] | 80 | |
| 81 | |
Eric Andersen | aad1a88 | 2001-03-16 22:47:14 +0000 | [diff] [blame] | 82 | #ifndef RB_POWER_OFF |
| 83 | /* Stop system and switch power off if possible. */ |
| 84 | #define RB_POWER_OFF 0x4321fedc |
Eric Andersen | d35c215 | 2001-01-25 23:49:09 +0000 | [diff] [blame] | 85 | #endif |
| 86 | |
Eric Andersen | 38ddbed | 2002-03-16 02:12:30 +0000 | [diff] [blame] | 87 | /* Try to pull in PATH_MAX */ |
| 88 | #include <limits.h> |
Glenn L McGrath | 60a22ad | 2002-08-22 15:54:22 +0000 | [diff] [blame] | 89 | |
Eric Andersen | 38ddbed | 2002-03-16 02:12:30 +0000 | [diff] [blame] | 90 | /* for PATH_MAX on systems that don't have it in limits.h */ |
Glenn L McGrath | 60a22ad | 2002-08-22 15:54:22 +0000 | [diff] [blame] | 91 | #include <sys/param.h> |
| 92 | #ifndef PATH_MAX |
Eric Andersen | 20d739a | 2002-01-26 23:58:22 +0000 | [diff] [blame] | 93 | #define PATH_MAX 256 |
| 94 | #endif |
Mark Whitley | e0bf91d | 2001-03-13 00:40:19 +0000 | [diff] [blame] | 95 | |
Bernhard Reutner-Fischer | d4cffd1 | 2005-09-21 17:38:30 +0000 | [diff] [blame] | 96 | #ifdef DMALLOC |
| 97 | #include <dmalloc.h> |
| 98 | #endif |
| 99 | |
Glenn L McGrath | 60a22ad | 2002-08-22 15:54:22 +0000 | [diff] [blame] | 100 | #endif /* _BB_INTERNAL_H_ */ |