blob: be06817e379031ed85f9a1cd4585bade71caf187 [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 *
Denys Vlasenko0ef64bd2010-08-16 20:14:46 +02005 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
Eric Andersenf6b71392000-09-26 01:09:18 +00006 */
Denis Vlasenkof81e8db2009-04-09 12:35:13 +00007#ifndef BUSYBOX_H
8#define BUSYBOX_H 1
Eric Andersenf6b71392000-09-26 01:09:18 +00009
Robert Grieblc9aca452002-06-04 20:06:25 +000010#include "libbb.h"
Eric Andersenc3196012001-03-14 01:15:06 +000011
Denis Vlasenkof81e8db2009-04-09 12:35:13 +000012PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN
Denis Vlasenko98636eb2008-05-09 17:59:34 +000013
Denis Vlasenko1aa7e472007-11-28 06:49:03 +000014/* order matters: used as index into "install_dir[]" in appletlib.c */
Denis Vlasenko335b63d2007-04-10 21:38:30 +000015typedef enum bb_install_loc_t {
Denys Vlasenkob9f2d9f2011-01-18 13:58:01 +010016 BB_DIR_ROOT = 0,
17 BB_DIR_BIN,
18 BB_DIR_SBIN,
Denys Vlasenkod4d289a2010-10-12 04:18:05 +020019#if ENABLE_INSTALL_NO_USR
Denys Vlasenkob9f2d9f2011-01-18 13:58:01 +010020 BB_DIR_USR_BIN = BB_DIR_BIN,
21 BB_DIR_USR_SBIN = BB_DIR_SBIN,
Denys Vlasenkod4d289a2010-10-12 04:18:05 +020022#else
Denys Vlasenkob9f2d9f2011-01-18 13:58:01 +010023 BB_DIR_USR_BIN,
24 BB_DIR_USR_SBIN,
Denys Vlasenkod4d289a2010-10-12 04:18:05 +020025#endif
Denis Vlasenko335b63d2007-04-10 21:38:30 +000026} bb_install_loc_t;
Eric Andersenf6b71392000-09-26 01:09:18 +000027
Denis Vlasenko335b63d2007-04-10 21:38:30 +000028typedef enum bb_suid_t {
Denys Vlasenkob9f2d9f2011-01-18 13:58:01 +010029 BB_SUID_DROP = 0,
30 BB_SUID_MAYBE,
31 BB_SUID_REQUIRE
Denis Vlasenko335b63d2007-04-10 21:38:30 +000032} bb_suid_t;
Denis Vlasenko1aa7e472007-11-28 06:49:03 +000033
34
35/* Defined in appletlib.c (by including generated applet_tables.h) */
36/* Keep in sync with applets/applet_tables.c! */
37extern const char applet_names[];
Denis Vlasenko745cd172007-11-29 03:31:20 +000038extern int (*const applet_main[])(int argc, char **argv);
Denis Vlasenko1aa7e472007-11-28 06:49:03 +000039extern const uint16_t applet_nameofs[];
Denis Vlasenko745cd172007-11-29 03:31:20 +000040extern const uint8_t applet_install_loc[];
Robert Grieblc9aca452002-06-04 20:06:25 +000041
Denis Vlasenko745cd172007-11-29 03:31:20 +000042#if ENABLE_FEATURE_SUID || ENABLE_FEATURE_PREFER_APPLETS
Denys Vlasenko8fa1f5d2010-07-15 08:18:46 +020043# define APPLET_NAME(i) (applet_names + (applet_nameofs[i] & 0x0fff))
Denis Vlasenko1aa7e472007-11-28 06:49:03 +000044#else
Denys Vlasenko8fa1f5d2010-07-15 08:18:46 +020045# define APPLET_NAME(i) (applet_names + applet_nameofs[i])
Denis Vlasenko1aa7e472007-11-28 06:49:03 +000046#endif
47
Denis Vlasenko80d14be2007-04-10 23:03:30 +000048#if ENABLE_FEATURE_PREFER_APPLETS
Denys Vlasenko8fa1f5d2010-07-15 08:18:46 +020049# define APPLET_IS_NOFORK(i) (applet_nameofs[i] & (1 << 12))
50# define APPLET_IS_NOEXEC(i) (applet_nameofs[i] & (1 << 13))
51#else
52# define APPLET_IS_NOFORK(i) 0
53# define APPLET_IS_NOEXEC(i) 0
Denis Vlasenko745cd172007-11-29 03:31:20 +000054#endif
55
56#if ENABLE_FEATURE_SUID
Denys Vlasenko8fa1f5d2010-07-15 08:18:46 +020057# define APPLET_SUID(i) ((applet_nameofs[i] >> 14) & 0x3)
Denis Vlasenko745cd172007-11-29 03:31:20 +000058#endif
59
60#if ENABLE_FEATURE_INSTALLER
61#define APPLET_INSTALL_LOC(i) ({ \
62 unsigned v = (i); \
63 if (v & 1) v = applet_install_loc[v/2] >> 4; \
64 else v = applet_install_loc[v/2] & 0xf; \
65 v; })
Denis Vlasenko335b63d2007-04-10 21:38:30 +000066#endif
Glenn L McGrath60a22ad2002-08-22 15:54:22 +000067
Denis Vlasenko9b49a5e2007-10-11 10:05:36 +000068
Denis Vlasenko9b49a5e2007-10-11 10:05:36 +000069/* Length of these names has effect on size of libbusybox
70 * and "individual" binaries. Keep them short.
71 */
Denis Vlasenko724d1962007-10-10 14:41:07 +000072#if ENABLE_BUILD_LIBBUSYBOX
Denis Vlasenko9b49a5e2007-10-11 10:05:36 +000073#if ENABLE_FEATURE_SHARED_BUSYBOX
Denis Vlasenko85c24712008-03-17 09:04:04 +000074int lbb_main(char **argv) EXTERNALLY_VISIBLE;
Denis Vlasenko9b49a5e2007-10-11 10:05:36 +000075#else
Denis Vlasenko85c24712008-03-17 09:04:04 +000076int lbb_main(char **argv);
Denis Vlasenko724d1962007-10-10 14:41:07 +000077#endif
Denis Vlasenko9b49a5e2007-10-11 10:05:36 +000078#endif
79
Denis Vlasenkof81e8db2009-04-09 12:35:13 +000080POP_SAVED_FUNCTION_VISIBILITY
Eric Andersenf6b71392000-09-26 01:09:18 +000081
Denis Vlasenkof81e8db2009-04-09 12:35:13 +000082#endif