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 | * |
| 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 | |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 27 | #include "config.h" |
Eric Andersen | f6b7139 | 2000-09-26 01:09:18 +0000 | [diff] [blame] | 28 | |
Eric Andersen | ed3ef50 | 2001-01-27 08:24:39 +0000 | [diff] [blame] | 29 | #include <stdio.h> |
Eric Andersen | f6b7139 | 2000-09-26 01:09:18 +0000 | [diff] [blame] | 30 | #include <stdarg.h> |
Eric Andersen | f6b7139 | 2000-09-26 01:09:18 +0000 | [diff] [blame] | 31 | #include <sys/stat.h> |
Eric Andersen | 01bda5d | 2001-01-02 01:16:38 +0000 | [diff] [blame] | 32 | #include <sys/types.h> |
Eric Andersen | f6b7139 | 2000-09-26 01:09:18 +0000 | [diff] [blame] | 33 | |
Eric Andersen | 85e5e72 | 2003-07-22 08:56:55 +0000 | [diff] [blame] | 34 | #if __GNU_LIBRARY__ < 5 |
| 35 | #ifndef __dietlibc__ |
| 36 | #error "Sorry, libc5 is not supported" |
| 37 | #endif |
| 38 | #endif |
| 39 | |
Glenn L McGrath | 7c87b67 | 2004-01-13 10:57:32 +0000 | [diff] [blame^] | 40 | #ifndef BB_EXTRA_VERSION |
Matt Kraai | 6ba1a80 | 2001-04-12 20:11:55 +0000 | [diff] [blame] | 41 | #define BB_BANNER "BusyBox v" BB_VER " (" BB_BT ")" |
Glenn L McGrath | 7c87b67 | 2004-01-13 10:57:32 +0000 | [diff] [blame^] | 42 | #else |
| 43 | #define BB_BANNER "BusyBox v" BB_VER " (" BB_EXTRA_VERSION ")" |
| 44 | #endif |
Matt Kraai | 6ba1a80 | 2001-04-12 20:11:55 +0000 | [diff] [blame] | 45 | |
Eric Andersen | 01bda5d | 2001-01-02 01:16:38 +0000 | [diff] [blame] | 46 | #ifdef DMALLOC |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 47 | #include <dmalloc.h> |
Eric Andersen | 01bda5d | 2001-01-02 01:16:38 +0000 | [diff] [blame] | 48 | #endif |
Eric Andersen | f6b7139 | 2000-09-26 01:09:18 +0000 | [diff] [blame] | 49 | |
Eric Andersen | 2b1c367 | 2001-03-14 01:36:52 +0000 | [diff] [blame] | 50 | #include <features.h> |
Eric Andersen | c319601 | 2001-03-14 01:15:06 +0000 | [diff] [blame] | 51 | |
Glenn L McGrath | 60a22ad | 2002-08-22 15:54:22 +0000 | [diff] [blame] | 52 | /* Pull in the utility routines from libbb */ |
Robert Griebl | c9aca45 | 2002-06-04 20:06:25 +0000 | [diff] [blame] | 53 | #include "libbb.h" |
Eric Andersen | c319601 | 2001-03-14 01:15:06 +0000 | [diff] [blame] | 54 | |
Eric Andersen | f6b7139 | 2000-09-26 01:09:18 +0000 | [diff] [blame] | 55 | enum Location { |
| 56 | _BB_DIR_ROOT = 0, |
| 57 | _BB_DIR_BIN, |
| 58 | _BB_DIR_SBIN, |
| 59 | _BB_DIR_USR_BIN, |
| 60 | _BB_DIR_USR_SBIN |
| 61 | }; |
| 62 | |
Robert Griebl | c9aca45 | 2002-06-04 20:06:25 +0000 | [diff] [blame] | 63 | enum SUIDRoot { |
| 64 | _BB_SUID_NEVER = 0, |
| 65 | _BB_SUID_MAYBE, |
| 66 | _BB_SUID_ALWAYS |
| 67 | }; |
| 68 | |
Eric Andersen | f6b7139 | 2000-09-26 01:09:18 +0000 | [diff] [blame] | 69 | struct BB_applet { |
Glenn L McGrath | 60a22ad | 2002-08-22 15:54:22 +0000 | [diff] [blame] | 70 | const char *name; |
| 71 | int (*main) (int argc, char **argv); |
| 72 | enum Location location:4; |
| 73 | enum SUIDRoot need_suid:4; |
Eric Andersen | f6b7139 | 2000-09-26 01:09:18 +0000 | [diff] [blame] | 74 | }; |
Glenn L McGrath | 60a22ad | 2002-08-22 15:54:22 +0000 | [diff] [blame] | 75 | |
Eric Andersen | f6b7139 | 2000-09-26 01:09:18 +0000 | [diff] [blame] | 76 | /* From busybox.c */ |
| 77 | extern const struct BB_applet applets[]; |
| 78 | |
Eric Andersen | 8c725e6 | 2000-11-30 00:27:06 +0000 | [diff] [blame] | 79 | /* Automagically pull in all the applet function prototypes and |
Eric Andersen | 8755982 | 2000-12-01 19:02:24 +0000 | [diff] [blame] | 80 | * applet usage strings. These are all of the form: |
Eric Andersen | 8c725e6 | 2000-11-30 00:27:06 +0000 | [diff] [blame] | 81 | * extern int foo_main(int argc, char **argv); |
| 82 | * extern const char foo_usage[]; |
| 83 | * These are all autogenerated from the set of currently defined applets. |
| 84 | */ |
| 85 | #define PROTOTYPES |
| 86 | #include "applets.h" |
| 87 | #undef PROTOTYPES |
Eric Andersen | f6b7139 | 2000-09-26 01:09:18 +0000 | [diff] [blame] | 88 | |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 89 | #ifdef CONFIG_FEATURE_BUFFERS_GO_ON_STACK |
| 90 | #define RESERVE_CONFIG_BUFFER(buffer,len) char buffer[len] |
| 91 | #define RESERVE_CONFIG_UBUFFER(buffer,len) unsigned char buffer[len] |
| 92 | #define RELEASE_CONFIG_BUFFER(buffer) ((void)0) |
Eric Andersen | aad1a88 | 2001-03-16 22:47:14 +0000 | [diff] [blame] | 93 | #else |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 94 | #ifdef CONFIG_FEATURE_BUFFERS_GO_IN_BSS |
| 95 | #define RESERVE_CONFIG_BUFFER(buffer,len) static char buffer[len] |
| 96 | #define RESERVE_CONFIG_UBUFFER(buffer,len) static unsigned char buffer[len] |
| 97 | #define RELEASE_CONFIG_BUFFER(buffer) ((void)0) |
Mark Whitley | 3e310ac | 2001-04-20 17:40:33 +0000 | [diff] [blame] | 98 | #else |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 99 | #define RESERVE_CONFIG_BUFFER(buffer,len) char *buffer=xmalloc(len) |
| 100 | #define RESERVE_CONFIG_UBUFFER(buffer,len) unsigned char *buffer=xmalloc(len) |
| 101 | #define RELEASE_CONFIG_BUFFER(buffer) free (buffer) |
Eric Andersen | f6b7139 | 2000-09-26 01:09:18 +0000 | [diff] [blame] | 102 | #endif |
Mark Whitley | 3e310ac | 2001-04-20 17:40:33 +0000 | [diff] [blame] | 103 | #endif |
Eric Andersen | f6b7139 | 2000-09-26 01:09:18 +0000 | [diff] [blame] | 104 | |
| 105 | |
Eric Andersen | aad1a88 | 2001-03-16 22:47:14 +0000 | [diff] [blame] | 106 | #ifndef RB_POWER_OFF |
| 107 | /* Stop system and switch power off if possible. */ |
| 108 | #define RB_POWER_OFF 0x4321fedc |
Eric Andersen | d35c215 | 2001-01-25 23:49:09 +0000 | [diff] [blame] | 109 | #endif |
| 110 | |
Eric Andersen | 38ddbed | 2002-03-16 02:12:30 +0000 | [diff] [blame] | 111 | /* Try to pull in PATH_MAX */ |
| 112 | #include <limits.h> |
Glenn L McGrath | 60a22ad | 2002-08-22 15:54:22 +0000 | [diff] [blame] | 113 | |
Eric Andersen | 38ddbed | 2002-03-16 02:12:30 +0000 | [diff] [blame] | 114 | /* 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] | 115 | #include <sys/param.h> |
| 116 | #ifndef PATH_MAX |
Eric Andersen | 20d739a | 2002-01-26 23:58:22 +0000 | [diff] [blame] | 117 | #define PATH_MAX 256 |
| 118 | #endif |
Mark Whitley | e0bf91d | 2001-03-13 00:40:19 +0000 | [diff] [blame] | 119 | |
Glenn L McGrath | 60a22ad | 2002-08-22 15:54:22 +0000 | [diff] [blame] | 120 | #endif /* _BB_INTERNAL_H_ */ |