blob: 9fb95036ead68b767a85fd3428aba28e6c8ef2a7 [file] [log] [blame]
Eric Andersenf6b71392000-09-26 01:09:18 +00001/* vi: set sw=4 ts=4: */
2/*
3 * Busybox main internal header file
4 *
Bernhard Reutner-Fischer86f5c992006-01-22 22:55:11 +00005 * Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
Eric Andersenf6b71392000-09-26 01:09:18 +00006 */
7#ifndef _BB_INTERNAL_H_
8#define _BB_INTERNAL_H_ 1
9
Rob Landley193c8c72005-07-27 06:55:36 +000010#include "bb_config.h"
Eric Andersenf6b71392000-09-26 01:09:18 +000011
Eric Andersened3ef502001-01-27 08:24:39 +000012#include <stdio.h>
Manuel Novoa III 68474f32004-02-05 14:45:58 +000013#include <stdlib.h>
Eric Andersenf6b71392000-09-26 01:09:18 +000014#include <stdarg.h>
Eric Andersen01bda5d2001-01-02 01:16:38 +000015#include <sys/types.h>
"Vladimir N. Oleynik"843c5ef2005-09-29 07:55:51 +000016#include <sys/stat.h>
Eric Andersenf6b71392000-09-26 01:09:18 +000017
Mike Frysingerca1b6fc2005-03-04 01:09:43 +000018#if __GNU_LIBRARY__ < 5 && \
19 !defined(__dietlibc__) && \
20 !defined(_NEWLIB_VERSION)
21#error "Sorry, this libc version is not supported :("
Eric Andersen85e5e722003-07-22 08:56:55 +000022#endif
23
Glenn L McGrath7c87b672004-01-13 10:57:32 +000024#ifndef BB_EXTRA_VERSION
Matt Kraai6ba1a802001-04-12 20:11:55 +000025#define BB_BANNER "BusyBox v" BB_VER " (" BB_BT ")"
Glenn L McGrath7c87b672004-01-13 10:57:32 +000026#else
27#define BB_BANNER "BusyBox v" BB_VER " (" BB_EXTRA_VERSION ")"
28#endif
Matt Kraai6ba1a802001-04-12 20:11:55 +000029
Eric Andersen2b1c3672001-03-14 01:36:52 +000030#include <features.h>
Eric Andersenc3196012001-03-14 01:15:06 +000031
Glenn L McGrath60a22ad2002-08-22 15:54:22 +000032/* Pull in the utility routines from libbb */
Robert Grieblc9aca452002-06-04 20:06:25 +000033#include "libbb.h"
Eric Andersenc3196012001-03-14 01:15:06 +000034
Eric Andersenf6b71392000-09-26 01:09:18 +000035enum Location {
36 _BB_DIR_ROOT = 0,
37 _BB_DIR_BIN,
38 _BB_DIR_SBIN,
39 _BB_DIR_USR_BIN,
40 _BB_DIR_USR_SBIN
41};
42
Robert Grieblc9aca452002-06-04 20:06:25 +000043enum SUIDRoot {
44 _BB_SUID_NEVER = 0,
45 _BB_SUID_MAYBE,
46 _BB_SUID_ALWAYS
47};
48
Eric Andersenf6b71392000-09-26 01:09:18 +000049struct BB_applet {
Glenn L McGrath60a22ad2002-08-22 15:54:22 +000050 const char *name;
51 int (*main) (int argc, char **argv);
Bernhard Reutner-Fischer86f5c992006-01-22 22:55:11 +000052 __extension__ enum Location location:4;
53 __extension__ enum SUIDRoot need_suid:4;
Eric Andersenf6b71392000-09-26 01:09:18 +000054};
Glenn L McGrath60a22ad2002-08-22 15:54:22 +000055
Eric Andersenf6b71392000-09-26 01:09:18 +000056/* From busybox.c */
57extern const struct BB_applet applets[];
58
Eric Andersen8c725e62000-11-30 00:27:06 +000059/* Automagically pull in all the applet function prototypes and
Eric Andersen87559822000-12-01 19:02:24 +000060 * applet usage strings. These are all of the form:
Eric Andersen8c725e62000-11-30 00:27:06 +000061 * extern int foo_main(int argc, char **argv);
62 * extern const char foo_usage[];
Eric Andersenc7bda1c2004-03-15 08:29:22 +000063 * These are all autogenerated from the set of currently defined applets.
Eric Andersen8c725e62000-11-30 00:27:06 +000064 */
65#define PROTOTYPES
66#include "applets.h"
67#undef PROTOTYPES
Eric Andersenf6b71392000-09-26 01:09:18 +000068
Eric Andersenbdfd0d72001-10-24 05:00:29 +000069#ifdef CONFIG_FEATURE_BUFFERS_GO_ON_STACK
70#define RESERVE_CONFIG_BUFFER(buffer,len) char buffer[len]
71#define RESERVE_CONFIG_UBUFFER(buffer,len) unsigned char buffer[len]
72#define RELEASE_CONFIG_BUFFER(buffer) ((void)0)
Eric Andersenaad1a882001-03-16 22:47:14 +000073#else
Eric Andersenbdfd0d72001-10-24 05:00:29 +000074#ifdef CONFIG_FEATURE_BUFFERS_GO_IN_BSS
75#define RESERVE_CONFIG_BUFFER(buffer,len) static char buffer[len]
76#define RESERVE_CONFIG_UBUFFER(buffer,len) static unsigned char buffer[len]
77#define RELEASE_CONFIG_BUFFER(buffer) ((void)0)
Mark Whitley3e310ac2001-04-20 17:40:33 +000078#else
Eric Andersenbdfd0d72001-10-24 05:00:29 +000079#define RESERVE_CONFIG_BUFFER(buffer,len) char *buffer=xmalloc(len)
80#define RESERVE_CONFIG_UBUFFER(buffer,len) unsigned char *buffer=xmalloc(len)
81#define RELEASE_CONFIG_BUFFER(buffer) free (buffer)
Eric Andersenf6b71392000-09-26 01:09:18 +000082#endif
Mark Whitley3e310ac2001-04-20 17:40:33 +000083#endif
Eric Andersenf6b71392000-09-26 01:09:18 +000084
85
Eric Andersenaad1a882001-03-16 22:47:14 +000086#ifndef RB_POWER_OFF
87/* Stop system and switch power off if possible. */
88#define RB_POWER_OFF 0x4321fedc
Eric Andersend35c2152001-01-25 23:49:09 +000089#endif
90
Eric Andersen38ddbed2002-03-16 02:12:30 +000091/* Try to pull in PATH_MAX */
92#include <limits.h>
Glenn L McGrath60a22ad2002-08-22 15:54:22 +000093
Eric Andersen38ddbed2002-03-16 02:12:30 +000094/* for PATH_MAX on systems that don't have it in limits.h */
Glenn L McGrath60a22ad2002-08-22 15:54:22 +000095#include <sys/param.h>
96#ifndef PATH_MAX
Eric Andersen20d739a2002-01-26 23:58:22 +000097#define PATH_MAX 256
98#endif
Mark Whitleye0bf91d2001-03-13 00:40:19 +000099
Bernhard Reutner-Fischerd4cffd12005-09-21 17:38:30 +0000100#ifdef DMALLOC
101#include <dmalloc.h>
102#endif
103
Glenn L McGrath60a22ad2002-08-22 15:54:22 +0000104#endif /* _BB_INTERNAL_H_ */