blob: 314b95126f82fad735a8f7230d603e5f772dd363 [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
Robert Grieblc9aca452002-06-04 20:06:25 +000010#include "libbb.h"
Eric Andersenc3196012001-03-14 01:15:06 +000011
Denis Vlasenko98636eb2008-05-09 17:59:34 +000012#if __GNUC_PREREQ(4,1)
13# pragma GCC visibility push(hidden)
14#endif
15
Denis Vlasenko1aa7e472007-11-28 06:49:03 +000016/* order matters: used as index into "install_dir[]" in appletlib.c */
Denis Vlasenko335b63d2007-04-10 21:38:30 +000017typedef enum bb_install_loc_t {
Eric Andersenf6b71392000-09-26 01:09:18 +000018 _BB_DIR_ROOT = 0,
19 _BB_DIR_BIN,
20 _BB_DIR_SBIN,
21 _BB_DIR_USR_BIN,
22 _BB_DIR_USR_SBIN
Denis Vlasenko335b63d2007-04-10 21:38:30 +000023} bb_install_loc_t;
Eric Andersenf6b71392000-09-26 01:09:18 +000024
Denis Vlasenko335b63d2007-04-10 21:38:30 +000025typedef enum bb_suid_t {
Robert Grieblc9aca452002-06-04 20:06:25 +000026 _BB_SUID_NEVER = 0,
27 _BB_SUID_MAYBE,
28 _BB_SUID_ALWAYS
Denis Vlasenko335b63d2007-04-10 21:38:30 +000029} bb_suid_t;
Denis Vlasenko1aa7e472007-11-28 06:49:03 +000030
31
32/* Defined in appletlib.c (by including generated applet_tables.h) */
33/* Keep in sync with applets/applet_tables.c! */
34extern const char applet_names[];
Denis Vlasenko745cd172007-11-29 03:31:20 +000035extern int (*const applet_main[])(int argc, char **argv);
Denis Vlasenko1aa7e472007-11-28 06:49:03 +000036extern const uint16_t applet_nameofs[];
Denis Vlasenko745cd172007-11-29 03:31:20 +000037extern const uint8_t applet_install_loc[];
Robert Grieblc9aca452002-06-04 20:06:25 +000038
Denis Vlasenko745cd172007-11-29 03:31:20 +000039#if ENABLE_FEATURE_SUID || ENABLE_FEATURE_PREFER_APPLETS
40#define APPLET_NAME(i) (applet_names + (applet_nameofs[i] & 0x0fff))
Denis Vlasenko1aa7e472007-11-28 06:49:03 +000041#else
Denis Vlasenko745cd172007-11-29 03:31:20 +000042#define APPLET_NAME(i) (applet_names + applet_nameofs[i])
Denis Vlasenko1aa7e472007-11-28 06:49:03 +000043#endif
44
Denis Vlasenko80d14be2007-04-10 23:03:30 +000045#if ENABLE_FEATURE_PREFER_APPLETS
Denis Vlasenko745cd172007-11-29 03:31:20 +000046#define APPLET_IS_NOFORK(i) (applet_nameofs[i] & (1 << 12))
47#define APPLET_IS_NOEXEC(i) (applet_nameofs[i] & (1 << 13))
48#endif
49
50#if ENABLE_FEATURE_SUID
51#define APPLET_SUID(i) ((applet_nameofs[i] >> 14) & 0x3)
52#endif
53
54#if ENABLE_FEATURE_INSTALLER
55#define APPLET_INSTALL_LOC(i) ({ \
56 unsigned v = (i); \
57 if (v & 1) v = applet_install_loc[v/2] >> 4; \
58 else v = applet_install_loc[v/2] & 0xf; \
59 v; })
Denis Vlasenko335b63d2007-04-10 21:38:30 +000060#endif
Glenn L McGrath60a22ad2002-08-22 15:54:22 +000061
Denis Vlasenko9b49a5e2007-10-11 10:05:36 +000062
Denis Vlasenko9b49a5e2007-10-11 10:05:36 +000063/* Length of these names has effect on size of libbusybox
64 * and "individual" binaries. Keep them short.
65 */
Denis Vlasenko724d1962007-10-10 14:41:07 +000066#if ENABLE_BUILD_LIBBUSYBOX
Denis Vlasenko9b49a5e2007-10-11 10:05:36 +000067#if ENABLE_FEATURE_SHARED_BUSYBOX
Denis Vlasenko85c24712008-03-17 09:04:04 +000068int lbb_main(char **argv) EXTERNALLY_VISIBLE;
Denis Vlasenko9b49a5e2007-10-11 10:05:36 +000069#else
Denis Vlasenko85c24712008-03-17 09:04:04 +000070int lbb_main(char **argv);
Denis Vlasenko724d1962007-10-10 14:41:07 +000071#endif
Denis Vlasenko9b49a5e2007-10-11 10:05:36 +000072#endif
73
Denis Vlasenko98636eb2008-05-09 17:59:34 +000074#if __GNUC_PREREQ(4,1)
75# pragma GCC visibility pop
76#endif
Eric Andersenf6b71392000-09-26 01:09:18 +000077
Denis Vlasenkoc7ba8b92007-02-03 17:27:14 +000078#endif /* _BB_INTERNAL_H_ */