blob: b1e31e5ee6350e5d039352f5c0a8ce2470831c1d [file] [log] [blame]
Eric Andersenf6b71392000-09-26 01:09:18 +00001/* vi: set sw=4 ts=4: */
2/*
Denys Vlasenko0ef64bd2010-08-16 20:14:46 +02003 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
Eric Andersenf6b71392000-09-26 01:09:18 +00004 */
Denis Vlasenkof81e8db2009-04-09 12:35:13 +00005#ifndef BUSYBOX_H
6#define BUSYBOX_H 1
Eric Andersenf6b71392000-09-26 01:09:18 +00007
Robert Grieblc9aca452002-06-04 20:06:25 +00008#include "libbb.h"
Denys Vlasenko6ec15102011-03-28 01:23:38 +02009/* BB_DIR_foo and BB_SUID_bar constants: */
10#include "applet_metadata.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/* Defined in appletlib.c (by including generated applet_tables.h) */
15/* Keep in sync with applets/applet_tables.c! */
Michael Tokarev32f774c2012-07-24 15:56:37 +020016extern const char applet_names[] ALIGN1;
Denis Vlasenko745cd172007-11-29 03:31:20 +000017extern int (*const applet_main[])(int argc, char **argv);
Denis Vlasenko1aa7e472007-11-28 06:49:03 +000018extern const uint16_t applet_nameofs[];
Michael Tokarev32f774c2012-07-24 15:56:37 +020019extern const uint8_t applet_install_loc[] ALIGN1;
Robert Grieblc9aca452002-06-04 20:06:25 +000020
Denis Vlasenko745cd172007-11-29 03:31:20 +000021#if ENABLE_FEATURE_SUID || ENABLE_FEATURE_PREFER_APPLETS
Denys Vlasenko8fa1f5d2010-07-15 08:18:46 +020022# define APPLET_NAME(i) (applet_names + (applet_nameofs[i] & 0x0fff))
Denis Vlasenko1aa7e472007-11-28 06:49:03 +000023#else
Denys Vlasenko8fa1f5d2010-07-15 08:18:46 +020024# define APPLET_NAME(i) (applet_names + applet_nameofs[i])
Denis Vlasenko1aa7e472007-11-28 06:49:03 +000025#endif
26
Denis Vlasenko80d14be2007-04-10 23:03:30 +000027#if ENABLE_FEATURE_PREFER_APPLETS
Denys Vlasenko8fa1f5d2010-07-15 08:18:46 +020028# define APPLET_IS_NOFORK(i) (applet_nameofs[i] & (1 << 12))
29# define APPLET_IS_NOEXEC(i) (applet_nameofs[i] & (1 << 13))
30#else
31# define APPLET_IS_NOFORK(i) 0
32# define APPLET_IS_NOEXEC(i) 0
Denis Vlasenko745cd172007-11-29 03:31:20 +000033#endif
34
35#if ENABLE_FEATURE_SUID
Denys Vlasenko8fa1f5d2010-07-15 08:18:46 +020036# define APPLET_SUID(i) ((applet_nameofs[i] >> 14) & 0x3)
Denis Vlasenko745cd172007-11-29 03:31:20 +000037#endif
38
39#if ENABLE_FEATURE_INSTALLER
40#define APPLET_INSTALL_LOC(i) ({ \
41 unsigned v = (i); \
42 if (v & 1) v = applet_install_loc[v/2] >> 4; \
43 else v = applet_install_loc[v/2] & 0xf; \
44 v; })
Denis Vlasenko335b63d2007-04-10 21:38:30 +000045#endif
Glenn L McGrath60a22ad2002-08-22 15:54:22 +000046
Denis Vlasenko9b49a5e2007-10-11 10:05:36 +000047
Denis Vlasenko9b49a5e2007-10-11 10:05:36 +000048/* Length of these names has effect on size of libbusybox
49 * and "individual" binaries. Keep them short.
50 */
Denis Vlasenko724d1962007-10-10 14:41:07 +000051#if ENABLE_BUILD_LIBBUSYBOX
Denis Vlasenko9b49a5e2007-10-11 10:05:36 +000052#if ENABLE_FEATURE_SHARED_BUSYBOX
Denis Vlasenko85c24712008-03-17 09:04:04 +000053int lbb_main(char **argv) EXTERNALLY_VISIBLE;
Denis Vlasenko9b49a5e2007-10-11 10:05:36 +000054#else
Denis Vlasenko85c24712008-03-17 09:04:04 +000055int lbb_main(char **argv);
Denis Vlasenko724d1962007-10-10 14:41:07 +000056#endif
Denis Vlasenko9b49a5e2007-10-11 10:05:36 +000057#endif
58
Denis Vlasenkof81e8db2009-04-09 12:35:13 +000059POP_SAVED_FUNCTION_VISIBILITY
Eric Andersenf6b71392000-09-26 01:09:18 +000060
Denis Vlasenkof81e8db2009-04-09 12:35:13 +000061#endif