blob: 7ef36901afe02480dc2184ae22edd1dce1434eae [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 Vlasenko335b63d2007-04-10 21:38:30 +000012#if ENABLE_FEATURE_INSTALLER
Denis Vlasenko0ee39992006-12-24 15:23:28 +000013/* order matters: used as index into "install_dir[]" in busybox.c */
Denis Vlasenko335b63d2007-04-10 21:38:30 +000014typedef enum bb_install_loc_t {
Eric Andersenf6b71392000-09-26 01:09:18 +000015 _BB_DIR_ROOT = 0,
16 _BB_DIR_BIN,
17 _BB_DIR_SBIN,
18 _BB_DIR_USR_BIN,
19 _BB_DIR_USR_SBIN
Denis Vlasenko335b63d2007-04-10 21:38:30 +000020} bb_install_loc_t;
21#endif
Eric Andersenf6b71392000-09-26 01:09:18 +000022
Denis Vlasenko335b63d2007-04-10 21:38:30 +000023#if ENABLE_FEATURE_SUID
24typedef enum bb_suid_t {
Robert Grieblc9aca452002-06-04 20:06:25 +000025 _BB_SUID_NEVER = 0,
26 _BB_SUID_MAYBE,
27 _BB_SUID_ALWAYS
Denis Vlasenko335b63d2007-04-10 21:38:30 +000028} bb_suid_t;
29#endif
Robert Grieblc9aca452002-06-04 20:06:25 +000030
Denis Vlasenko335b63d2007-04-10 21:38:30 +000031struct bb_applet {
Glenn L McGrath60a22ad2002-08-22 15:54:22 +000032 const char *name;
33 int (*main) (int argc, char **argv);
Denis Vlasenko335b63d2007-04-10 21:38:30 +000034#if ENABLE_FEATURE_INSTALLER
35 __extension__ enum bb_install_loc_t install_loc:8;
36#endif
37#if ENABLE_FEATURE_SUID
38 __extension__ enum bb_suid_t need_suid:8;
39#endif
Denis Vlasenko80d14be2007-04-10 23:03:30 +000040#if ENABLE_FEATURE_PREFER_APPLETS
Denis Vlasenko03fc4082007-04-11 07:36:31 +000041 /* true if instead of fork(); exec("applet"); waitpid();
Denis Vlasenkoc44ab012007-04-09 03:11:58 +000042 * one can do fork(); exit(applet_main(argc,argv)); waitpid(); */
43 unsigned char noexec;
44 /* Even nicer */
Denis Vlasenko03fc4082007-04-11 07:36:31 +000045 /* true if instead of fork(); exec("applet"); waitpid();
Denis Vlasenkoc44ab012007-04-09 03:11:58 +000046 * one can simply call applet_main(argc,argv); */
47 unsigned char nofork;
Denis Vlasenko335b63d2007-04-10 21:38:30 +000048#endif
Eric Andersenf6b71392000-09-26 01:09:18 +000049};
Glenn L McGrath60a22ad2002-08-22 15:54:22 +000050
Denis Vlasenko9b49a5e2007-10-11 10:05:36 +000051
Denis Vlasenkod62fd842007-10-07 20:46:34 +000052/* Defined in appletlib.c */
Denis Vlasenko335b63d2007-04-10 21:38:30 +000053extern const struct bb_applet applets[];
Denis Vlasenko0ee39992006-12-24 15:23:28 +000054extern const unsigned short NUM_APPLETS;
Denis Vlasenko9b49a5e2007-10-11 10:05:36 +000055
56/* 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_ */