blob: f99901aa3696c8c5436dcb6a1263eb45527b6a98 [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 Vlasenko1aa7e472007-11-28 06:49:03 +000012/* order matters: used as index into "install_dir[]" in appletlib.c */
Denis Vlasenko335b63d2007-04-10 21:38:30 +000013typedef enum bb_install_loc_t {
Eric Andersenf6b71392000-09-26 01:09:18 +000014 _BB_DIR_ROOT = 0,
15 _BB_DIR_BIN,
16 _BB_DIR_SBIN,
17 _BB_DIR_USR_BIN,
18 _BB_DIR_USR_SBIN
Denis Vlasenko335b63d2007-04-10 21:38:30 +000019} bb_install_loc_t;
Eric Andersenf6b71392000-09-26 01:09:18 +000020
Denis Vlasenko335b63d2007-04-10 21:38:30 +000021typedef enum bb_suid_t {
Robert Grieblc9aca452002-06-04 20:06:25 +000022 _BB_SUID_NEVER = 0,
23 _BB_SUID_MAYBE,
24 _BB_SUID_ALWAYS
Denis Vlasenko335b63d2007-04-10 21:38:30 +000025} bb_suid_t;
Denis Vlasenko1aa7e472007-11-28 06:49:03 +000026
27
28/* Defined in appletlib.c (by including generated applet_tables.h) */
29/* Keep in sync with applets/applet_tables.c! */
30extern const char applet_names[];
31extern int (*const applet_mains[])(int argc, char **argv);
32
33#if ENABLE_FEATURE_INSTALLER || ENABLE_FEATURE_PREFER_APPLETS
34extern const uint32_t applet_nameofs[];
35#else
36extern const uint16_t applet_nameofs[];
Denis Vlasenko335b63d2007-04-10 21:38:30 +000037#endif
Robert Grieblc9aca452002-06-04 20:06:25 +000038
Denis Vlasenko335b63d2007-04-10 21:38:30 +000039#if ENABLE_FEATURE_SUID
Denis Vlasenko1aa7e472007-11-28 06:49:03 +000040#define APPLET_NAME(i) (applet_names + (applet_nameofs[i] & 0x3fff))
41#define APPLET_SUID(i) ((applet_nameofs[i] >> 14) & 0x3)
42#else
43#define APPLET_NAME(i) (applet_names + (applet_nameofs[i] & 0xffff))
Denis Vlasenko335b63d2007-04-10 21:38:30 +000044#endif
Denis Vlasenko1aa7e472007-11-28 06:49:03 +000045
46#if ENABLE_FEATURE_INSTALLER
47#define APPLET_INSTALL_LOC(i) ((applet_nameofs[i] >> 16) & 0x7)
48#endif
49
Denis Vlasenko80d14be2007-04-10 23:03:30 +000050#if ENABLE_FEATURE_PREFER_APPLETS
Denis Vlasenko1aa7e472007-11-28 06:49:03 +000051#define APPLET_IS_NOFORK(i) (applet_nameofs[i] & (1 << 19))
52#define APPLET_IS_NOEXEC(i) (applet_nameofs[i] & (1 << 20))
Denis Vlasenko335b63d2007-04-10 21:38:30 +000053#endif
Glenn L McGrath60a22ad2002-08-22 15:54:22 +000054
Denis Vlasenko9b49a5e2007-10-11 10:05:36 +000055
Denis Vlasenko9b49a5e2007-10-11 10:05:36 +000056/* Length of these names has effect on size of libbusybox
57 * and "individual" binaries. Keep them short.
58 */
Denis Vlasenko15cb4a42007-10-11 10:06:26 +000059void lbb_prepare(const char *applet, char **argv) MAIN_EXTERNALLY_VISIBLE;
Denis Vlasenko724d1962007-10-10 14:41:07 +000060#if ENABLE_BUILD_LIBBUSYBOX
Denis Vlasenko9b49a5e2007-10-11 10:05:36 +000061#if ENABLE_FEATURE_SHARED_BUSYBOX
62int lbb_main(int argc, char **argv) EXTERNALLY_VISIBLE;
63#else
64int lbb_main(int argc, char **argv);
Denis Vlasenko724d1962007-10-10 14:41:07 +000065#endif
Denis Vlasenko9b49a5e2007-10-11 10:05:36 +000066#endif
67
Eric Andersenf6b71392000-09-26 01:09:18 +000068
Denis Vlasenkoc7ba8b92007-02-03 17:27:14 +000069#endif /* _BB_INTERNAL_H_ */