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 | |
| 27 | #include "Config.h" |
| 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 | 01bda5d | 2001-01-02 01:16:38 +0000 | [diff] [blame] | 34 | #ifdef DMALLOC |
| 35 | #include "dmalloc.h" |
| 36 | #endif |
Eric Andersen | f6b7139 | 2000-09-26 01:09:18 +0000 | [diff] [blame] | 37 | |
Eric Andersen | 2b1c367 | 2001-03-14 01:36:52 +0000 | [diff] [blame] | 38 | #include <features.h> |
Eric Andersen | c319601 | 2001-03-14 01:15:06 +0000 | [diff] [blame] | 39 | /* Stupid libc doesn't have a reliable way for use to know |
| 40 | * that libc5 is being used. Assume this is good enough */ |
Eric Andersen | 2b1c367 | 2001-03-14 01:36:52 +0000 | [diff] [blame] | 41 | #if ! defined __GLIBC__ && ! defined __UCLIBC__ |
Eric Andersen | c319601 | 2001-03-14 01:15:06 +0000 | [diff] [blame] | 42 | /* libc5 doesn't define socklen_t */ |
| 43 | typedef unsigned int socklen_t; |
| 44 | #endif |
| 45 | |
| 46 | |
Eric Andersen | f6b7139 | 2000-09-26 01:09:18 +0000 | [diff] [blame] | 47 | enum Location { |
| 48 | _BB_DIR_ROOT = 0, |
| 49 | _BB_DIR_BIN, |
| 50 | _BB_DIR_SBIN, |
| 51 | _BB_DIR_USR_BIN, |
| 52 | _BB_DIR_USR_SBIN |
| 53 | }; |
| 54 | |
| 55 | struct BB_applet { |
| 56 | const char* name; |
| 57 | int (*main)(int argc, char** argv); |
| 58 | enum Location location; |
Eric Andersen | f6b7139 | 2000-09-26 01:09:18 +0000 | [diff] [blame] | 59 | }; |
| 60 | /* From busybox.c */ |
| 61 | extern const struct BB_applet applets[]; |
| 62 | |
Eric Andersen | 8c725e6 | 2000-11-30 00:27:06 +0000 | [diff] [blame] | 63 | /* Automagically pull in all the applet function prototypes and |
Eric Andersen | 8755982 | 2000-12-01 19:02:24 +0000 | [diff] [blame] | 64 | * applet usage strings. These are all of the form: |
Eric Andersen | 8c725e6 | 2000-11-30 00:27:06 +0000 | [diff] [blame] | 65 | * extern int foo_main(int argc, char **argv); |
| 66 | * extern const char foo_usage[]; |
| 67 | * These are all autogenerated from the set of currently defined applets. |
| 68 | */ |
| 69 | #define PROTOTYPES |
| 70 | #include "applets.h" |
| 71 | #undef PROTOTYPES |
Eric Andersen | f6b7139 | 2000-09-26 01:09:18 +0000 | [diff] [blame] | 72 | |
| 73 | extern const char *applet_name; |
| 74 | |
Eric Andersen | aad1a88 | 2001-03-16 22:47:14 +0000 | [diff] [blame^] | 75 | #ifdef BB_FEATURE_BUFFERS_GO_ON_STACK |
| 76 | #define RESERVE_BB_BUFFER(buffer,len) char buffer[len] |
| 77 | #define RESERVE_BB_UBUFFER(buffer,len) unsigned char buffer[len] |
| 78 | #else |
| 79 | #define RESERVE_BB_BUFFER(buffer,len) char *buffer=xmalloc(len) |
| 80 | #define RESERVE_BB_UBUFFER(buffer,len) unsigned char *buffer=xmalloc(len) |
Eric Andersen | f6b7139 | 2000-09-26 01:09:18 +0000 | [diff] [blame] | 81 | #endif |
| 82 | |
| 83 | |
Eric Andersen | f6b7139 | 2000-09-26 01:09:18 +0000 | [diff] [blame] | 84 | /* Bit map related macros -- libc5 doens't provide these... sigh. */ |
| 85 | #ifndef setbit |
| 86 | #define NBBY CHAR_BIT |
| 87 | #define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY)) |
| 88 | #define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY))) |
| 89 | #define isset(a,i) ((a)[(i)/NBBY] & (1<<((i)%NBBY))) |
| 90 | #define isclr(a,i) (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0) |
| 91 | #endif |
| 92 | |
Eric Andersen | aad1a88 | 2001-03-16 22:47:14 +0000 | [diff] [blame^] | 93 | #ifndef RB_POWER_OFF |
| 94 | /* Stop system and switch power off if possible. */ |
| 95 | #define RB_POWER_OFF 0x4321fedc |
Eric Andersen | d35c215 | 2001-01-25 23:49:09 +0000 | [diff] [blame] | 96 | #endif |
| 97 | |
Eric Andersen | aad1a88 | 2001-03-16 22:47:14 +0000 | [diff] [blame^] | 98 | |
| 99 | /* Pull in the utility routines from libbb */ |
| 100 | #include "libbb/libbb.h" |
| 101 | |
| 102 | |
Mark Whitley | e0bf91d | 2001-03-13 00:40:19 +0000 | [diff] [blame] | 103 | |
Eric Andersen | f6b7139 | 2000-09-26 01:09:18 +0000 | [diff] [blame] | 104 | #endif /* _BB_INTERNAL_H_ */ |