X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=include%2Flibbb.h;h=6f66c8545350ab47a9b762c968b6581141c2bb8b;hb=62a6983a818ce701b924f84bf23716c4fbff170a;hp=fcd0dfa31a9e48463c4d53932f96d34be1b7a928;hpb=9f739445cd3deddd0343c3a8d5a981ede26bef30;p=oweals%2Fbusybox.git diff --git a/include/libbb.h b/include/libbb.h index fcd0dfa31..6f66c8545 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -39,25 +39,29 @@ #include #include -#ifdef CONFIG_SELINUX +#if ENABLE_SELINUX #include #endif -#ifdef CONFIG_LOCALE_SUPPORT +#if ENABLE_LOCALE_SUPPORT #include #else -#define setlocale(x,y) +#define setlocale(x,y) ((void)0) #endif #include "pwd_.h" #include "grp_.h" +/* ifdef it out, because it may include */ +/* and we may not even _have_ ! */ +#if ENABLE_FEATURE_SHADOWPASSWDS #include "shadow_.h" +#endif /* Try to pull in PATH_MAX */ #include #include #ifndef PATH_MAX -#define PATH_MAX 256 +#define PATH_MAX 256 #endif /* Tested to work correctly (IIRC :]) */ @@ -117,6 +121,38 @@ /* scary. better ideas? (but do *test* them first!) */ #define OFF_T_MAX ((off_t)~((off_t)1 << (sizeof(off_t)*8-1))) +/* This structure defines protocol families and their handlers. */ +struct aftype { + char *name; + char *title; + int af; + int alen; + char *(*print) (unsigned char *); + char *(*sprint) (struct sockaddr *, int numeric); + int (*input) (int type, char *bufp, struct sockaddr *); + void (*herror) (char *text); + int (*rprint) (int options); + int (*rinput) (int typ, int ext, char **argv); + + /* may modify src */ + int (*getmask) (char *src, struct sockaddr * mask, char *name); + + int fd; + char *flag_file; +}; + +/* This structure defines hardware protocols and their handlers. */ +struct hwtype { + char *name; + char *title; + int type; + int alen; + char *(*print) (unsigned char *); + int (*input) (char *, struct sockaddr *); + int (*activate) (int fd); + int suppress_null_addr; +}; + /* Some useful definitions */ #undef FALSE #define FALSE ((int) 0) @@ -142,12 +178,12 @@ #endif /* buffer allocation schemes */ -#ifdef CONFIG_FEATURE_BUFFERS_GO_ON_STACK +#if ENABLE_FEATURE_BUFFERS_GO_ON_STACK #define RESERVE_CONFIG_BUFFER(buffer,len) char buffer[len] #define RESERVE_CONFIG_UBUFFER(buffer,len) unsigned char buffer[len] #define RELEASE_CONFIG_BUFFER(buffer) ((void)0) #else -#ifdef CONFIG_FEATURE_BUFFERS_GO_IN_BSS +#if ENABLE_FEATURE_BUFFERS_GO_IN_BSS #define RESERVE_CONFIG_BUFFER(buffer,len) static char buffer[len] #define RESERVE_CONFIG_UBUFFER(buffer,len) static unsigned char buffer[len] #define RELEASE_CONFIG_BUFFER(buffer) ((void)0) @@ -159,7 +195,7 @@ #endif -#if (__GLIBC__ < 2) +#if defined(__GLIBC__) && __GLIBC__ < 2 int vdprintf(int d, const char *format, va_list ap); #endif // This is declared here rather than #including in order to avoid @@ -187,9 +223,22 @@ struct sysinfo { extern int sysinfo(struct sysinfo* info); +/* Size-saving "small" ints (arch-dependent) */ +#if defined(i386) || defined (__mips__) +/* add other arches which benefit from this... */ +typedef signed char smallint; +typedef unsigned char smalluint; +#else +/* for arches where byte accesses generate larger code: */ +typedef int smallint; +typedef unsigned smalluint; +#endif + + extern void chomp(char *s); extern void trim(char *s); extern char *skip_whitespace(const char *); +extern char *skip_non_whitespace(const char *); extern const char *bb_mode_string(int mode); extern int is_directory(const char *name, int followLinks, struct stat *statBuf); @@ -203,11 +252,17 @@ extern int recursive_action(const char *fileName, int recurse, extern int device_open(const char *device, int mode); extern int get_console_fd(void); extern char *find_block_device(char *path); -extern off_t bb_copyfd_size(int fd1, int fd2, off_t size); +/* bb_copyfd_XX print read/write errors and return -1 if they occur */ extern off_t bb_copyfd_eof(int fd1, int fd2); +extern off_t bb_copyfd_size(int fd1, int fd2, off_t size); +extern void bb_copyfd_exact_size(int fd1, int fd2, off_t size); +/* "short" copy can be detected by return value < size */ +/* this helper yells "short read!" if param is not -1 */ +extern void complain_copyfd_and_die(off_t sz) ATTRIBUTE_NORETURN; extern char bb_process_escape_sequence(const char **ptr); extern char *bb_get_last_path_component(char *path); extern int ndelay_on(int fd); +extern int ndelay_off(int fd); extern DIR *xopendir(const char *path); @@ -215,6 +270,7 @@ extern DIR *warn_opendir(const char *path); char *xgetcwd(char *cwd); char *xreadlink(const char *path); +char *xmalloc_realpath(const char *path); extern void xstat(char *filename, struct stat *buf); extern pid_t spawn(char **argv); extern pid_t xspawn(char **argv); @@ -263,6 +319,8 @@ extern char *xasprintf(const char *format, ...) __attribute__ ((format (printf, //int NOT_LONE_DASH(const char *s) { return s[0] != '-' || s[1]; } #define LONE_DASH(s) ((s)[0] == '-' && !(s)[1]) #define NOT_LONE_DASH(s) ((s)[0] != '-' || (s)[1]) +#define LONE_CHAR(s,c) ((s)[0] == (c) && !(s)[1]) +#define NOT_LONE_CHAR(s,c) ((s)[0] != (c) || (s)[1]) /* dmalloc will redefine these to it's own implementation. It is safe * to have the prototypes here unconditionally. */ @@ -327,17 +385,20 @@ uint16_t xatou16(const char *numstr); /* These parse entries in /etc/passwd and /etc/group. This is desirable * for BusyBox since we want to avoid using the glibc NSS stuff, which * increases target size and is often not needed on embedded systems. */ -extern long bb_xgetpwnam(const char *name); -extern long bb_xgetgrnam(const char *name); -/*extern char *bb_getug(char *buffer, char *idname, long id, int bufsize, char prefix);*/ -extern char *bb_getpwuid(char *name, long uid, int bufsize); -extern char *bb_getgrgid(char *group, long gid, int bufsize); -/* from chpst */ +extern long xuname2uid(const char *name); +extern long xgroup2gid(const char *name); +/* wrapper: allows string to contain numeric uid or gid */ +extern unsigned long get_ug_id(const char *s, long (*xname2id)(const char *)); +/* from chpst. Does not die, returns 0 on failure */ struct bb_uidgid_t { uid_t uid; gid_t gid; }; -extern unsigned uidgid_get(struct bb_uidgid_t*, const char* /*, unsigned*/); +extern int get_uidgid(struct bb_uidgid_t*, const char*, int numeric_ok); +/* what is this? */ +/*extern char *bb_getug(char *buffer, char *idname, long id, int bufsize, char prefix);*/ +extern char *bb_getpwuid(char *name, long uid, int bufsize); +extern char *bb_getgrgid(char *group, long gid, int bufsize); enum { BB_GETOPT_ERROR = 0x80000000 }; @@ -369,6 +430,7 @@ extern const char *msg_eol; extern int logmode; extern int die_sleep; extern int xfunc_error_retval; +extern void sleep_and_die(void) ATTRIBUTE_NORETURN; extern void bb_show_usage(void) ATTRIBUTE_NORETURN ATTRIBUTE_EXTERNALLY_VISIBLE; extern void bb_error_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2))); extern void bb_error_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2))); @@ -386,9 +448,25 @@ extern void bb_vperror_msg(const char *s, va_list p); extern void bb_vinfo_msg(const char *s, va_list p); -extern int bb_echo(int argc, char** argv); +/* applets which are useful from another applets */ +extern int bb_cat(char** argv); +extern int bb_echo(char** argv); extern int bb_test(int argc, char** argv); + +/* Networking */ +int create_icmp_socket(void); +int create_icmp6_socket(void); +/* interface.c */ +struct aftype; +struct hwtype; +extern int interface_opt_a; +int display_interfaces(char *ifname); +struct aftype *get_aftype(const char *name); +const struct hwtype *get_hwtype(const char *name); +const struct hwtype *get_hwntype(int type); + + #ifndef BUILD_INDIVIDUAL extern struct BB_applet *find_applet_by_name(const char *name); extern void run_applet_by_name(const char *name, int argc, char **argv); @@ -427,8 +505,6 @@ int exists_execable(const char *filename); USE_DESKTOP(long long) int uncompress(int fd_in, int fd_out); int inflate(int in, int out); -int create_icmp_socket(void); -int create_icmp6_socket(void); unsigned short bb_lookup_port(const char *port, const char *protocol, unsigned short default_port); void bb_lookup_host(struct sockaddr_in *s_in, const char *host); @@ -445,7 +521,7 @@ extern void bb_do_delay(int seconds); extern void change_identity(const struct passwd *pw); extern const char *change_identity_e2str(const struct passwd *pw); extern void run_shell(const char *shell, int loginshell, const char *command, const char **additional_args); -#ifdef CONFIG_SELINUX +#if ENABLE_SELINUX extern void renew_current_security_context(void); extern void set_current_security_context(security_context_t sid); #endif @@ -464,7 +540,6 @@ extern void vfork_daemon_rexec(int nochdir, int noclose, int argc, char **argv, char *foreground_opt); #endif extern int get_terminal_width_height(int fd, int *width, int *height); -extern unsigned long get_ug_id(const char *s, long (*__bb_getxxnam)(const char *)); int is_in_ino_dev_hashtable(const struct stat *statbuf, char **name); void add_to_ino_dev_hashtable(const struct stat *statbuf, const char *name); @@ -616,7 +691,7 @@ extern const char bb_default_login_shell[]; #define DEFAULT_SHELL_SHORT_NAME (bb_default_login_shell+6) -#ifdef CONFIG_FEATURE_DEVFS +#if ENABLE_FEATURE_DEVFS # define CURRENT_VC "/dev/vc/0" # define VC_1 "/dev/vc/1" # define VC_2 "/dev/vc/2"