blob: 18f9dd56ef13d99b7e6c2cb329c90a9695d1761b [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
"Vladimir N. Oleynik"dd1ccdd2006-02-16 15:40:24 +000024extern const char BB_BANNER[];
Matt Kraai6ba1a802001-04-12 20:11:55 +000025
Eric Andersen2b1c3672001-03-14 01:36:52 +000026#include <features.h>
Eric Andersenc3196012001-03-14 01:15:06 +000027
Glenn L McGrath60a22ad2002-08-22 15:54:22 +000028/* Pull in the utility routines from libbb */
Robert Grieblc9aca452002-06-04 20:06:25 +000029#include "libbb.h"
Eric Andersenc3196012001-03-14 01:15:06 +000030
Eric Andersenf6b71392000-09-26 01:09:18 +000031enum 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 Grieblc9aca452002-06-04 20:06:25 +000039enum SUIDRoot {
40 _BB_SUID_NEVER = 0,
41 _BB_SUID_MAYBE,
42 _BB_SUID_ALWAYS
43};
44
Eric Andersenf6b71392000-09-26 01:09:18 +000045struct BB_applet {
Glenn L McGrath60a22ad2002-08-22 15:54:22 +000046 const char *name;
47 int (*main) (int argc, char **argv);
Bernhard Reutner-Fischer86f5c992006-01-22 22:55:11 +000048 __extension__ enum Location location:4;
49 __extension__ enum SUIDRoot need_suid:4;
Eric Andersenf6b71392000-09-26 01:09:18 +000050};
Glenn L McGrath60a22ad2002-08-22 15:54:22 +000051
Eric Andersenf6b71392000-09-26 01:09:18 +000052/* From busybox.c */
53extern const struct BB_applet applets[];
54
Eric Andersen8c725e62000-11-30 00:27:06 +000055/* Automagically pull in all the applet function prototypes and
Eric Andersen87559822000-12-01 19:02:24 +000056 * applet usage strings. These are all of the form:
Eric Andersen8c725e62000-11-30 00:27:06 +000057 * extern int foo_main(int argc, char **argv);
58 * extern const char foo_usage[];
Eric Andersenc7bda1c2004-03-15 08:29:22 +000059 * These are all autogenerated from the set of currently defined applets.
Eric Andersen8c725e62000-11-30 00:27:06 +000060 */
61#define PROTOTYPES
62#include "applets.h"
63#undef PROTOTYPES
Eric Andersenf6b71392000-09-26 01:09:18 +000064
Eric Andersenbdfd0d72001-10-24 05:00:29 +000065#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 Andersenaad1a882001-03-16 22:47:14 +000069#else
Eric Andersenbdfd0d72001-10-24 05:00:29 +000070#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 Whitley3e310ac2001-04-20 17:40:33 +000074#else
Eric Andersenbdfd0d72001-10-24 05:00:29 +000075#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 Andersenf6b71392000-09-26 01:09:18 +000078#endif
Mark Whitley3e310ac2001-04-20 17:40:33 +000079#endif
Eric Andersenf6b71392000-09-26 01:09:18 +000080
81
Eric Andersenaad1a882001-03-16 22:47:14 +000082#ifndef RB_POWER_OFF
83/* Stop system and switch power off if possible. */
84#define RB_POWER_OFF 0x4321fedc
Eric Andersend35c2152001-01-25 23:49:09 +000085#endif
86
Eric Andersen38ddbed2002-03-16 02:12:30 +000087/* Try to pull in PATH_MAX */
88#include <limits.h>
Glenn L McGrath60a22ad2002-08-22 15:54:22 +000089
Eric Andersen38ddbed2002-03-16 02:12:30 +000090/* for PATH_MAX on systems that don't have it in limits.h */
Glenn L McGrath60a22ad2002-08-22 15:54:22 +000091#include <sys/param.h>
92#ifndef PATH_MAX
Eric Andersen20d739a2002-01-26 23:58:22 +000093#define PATH_MAX 256
94#endif
Mark Whitleye0bf91d2001-03-13 00:40:19 +000095
Bernhard Reutner-Fischerd4cffd12005-09-21 17:38:30 +000096#ifdef DMALLOC
97#include <dmalloc.h>
98#endif
99
Glenn L McGrath60a22ad2002-08-22 15:54:22 +0000100#endif /* _BB_INTERNAL_H_ */