X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=include%2Flibbb.h;h=f1f4f5c0a1a9adc1ae68aa8fd7535d8f5da49c24;hb=56f16b42c93af18fbb984e8d6384c03e5405e3ae;hp=f79def321fc59913db017aa50aeda4cacae611e4;hpb=cad5364599eb5062d59e0c397ed638ddd61a8d5d;p=oweals%2Fbusybox.git diff --git a/include/libbb.h b/include/libbb.h index f79def321..f1f4f5c0a 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -39,6 +40,9 @@ #include #include "config.h" +#ifdef CONFIG_SELINUX +#include +#endif #include "pwd_.h" #include "grp_.h" @@ -49,22 +53,18 @@ # include "sha1.h" #endif -/* Compatability with ANSI C */ -#ifndef inline -# define inline +/* Convenience macros to test the version of gcc. */ +#if defined __GNUC__ && defined __GNUC_MINOR__ +# define __GNUC_PREREQ(maj, min) \ + ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) +#else +# define __GNUC_PREREQ(maj, min) 0 #endif -#if (__GNU_LIBRARY__ < 5) && (!defined __dietlibc__) -/* libc5 doesn't define socklen_t */ -#ifndef _SOCKLEN_T -#define _SOCKLEN_T -typedef unsigned int socklen_t; +/* __restrict is known in EGCS 1.2 and above. */ +#if !__GNUC_PREREQ (2,92) +# define __restrict /* Ignore */ #endif -/* libc5 doesn't implement BSD 4.4 daemon() */ -extern int daemon (int nochdir, int noclose); -/* libc5 doesn't implement strtok_r */ -char *strtok_r(char *s, const char *delim, char **ptrptr); -#endif /* Some useful definitions */ #define FALSE ((int) 0) @@ -109,8 +109,9 @@ extern int is_directory(const char *name, int followLinks, struct stat *statBuf) extern int remove_file(const char *path, int flags); extern int copy_file(const char *source, const char *dest, int flags); extern ssize_t safe_read(int fd, void *buf, size_t count); -extern ssize_t bb_full_write(int fd, const void *buf, size_t len); extern ssize_t bb_full_read(int fd, void *buf, size_t len); +extern ssize_t safe_write(int fd, const void *buf, size_t count); +extern ssize_t bb_full_write(int fd, const void *buf, size_t len); extern int recursive_action(const char *fileName, int recurse, int followLinks, int depthFirst, int (*fileAction) (const char *fileName, struct stat* statbuf, void* userData), @@ -118,7 +119,7 @@ extern int recursive_action(const char *fileName, int recurse, void* userData); extern int bb_parse_mode( const char* s, mode_t* theMode); -extern long bb_xgetlarg(char *arg, int base, long lower, long upper); +extern long bb_xgetlarg(const char *arg, int base, long lower, long upper); extern unsigned long bb_baud_to_value(speed_t speed); extern speed_t bb_value_to_baud(unsigned long value); @@ -145,7 +146,11 @@ extern FILE *bb_xfopen(const char *path, const char *mode); //#warning rename? extern int bb_fclose_nonstdin(FILE *f); extern void bb_fflush_stdout_and_exit(int retval) __attribute__ ((noreturn)); -extern unsigned long bb_getopt_ulflags(int argc, char **argv, const char *applet_opts); + +extern const char *bb_opt_complementaly; +extern const struct option *bb_applet_long_options; +extern unsigned long bb_getopt_ulflags(int argc, char **argv, const char *applet_opts, ...); + //#warning rename? extern FILE *bb_wfopen_input(const char *filename); @@ -177,8 +182,8 @@ void run_applet_by_name(const char *name, int argc, char **argv); extern void *xmalloc (size_t size); extern void *xrealloc(void *old, size_t size); extern void *xcalloc(size_t nmemb, size_t size); -extern char *bb_xstrdup (const char *s); #endif +extern char *bb_xstrdup (const char *s); extern char *bb_xstrndup (const char *s, int n); extern char * safe_strncpy(char *dst, const char *src, size_t size); @@ -264,7 +269,8 @@ enum { MEGABYTE = (KILOBYTE*1024), GIGABYTE = (MEGABYTE*1024) }; -const char *make_human_readable_str(unsigned long size, unsigned long block_size, unsigned long display_unit); +const char *make_human_readable_str(unsigned long long size, + unsigned long block_size, unsigned long display_unit); int bb_ask_confirmation(void); int klogctl(int type, char * b, int len); @@ -272,6 +278,7 @@ int klogctl(int type, char * b, int len); char *xgetcwd(char *cwd); char *xreadlink(const char *path); char *concat_path_file(const char *path, const char *filename); +char *concat_subpath_file(const char *path, const char *filename); char *last_char_is(const char *s, int c); extern long arith (const char *startbuf, int *errcode); @@ -287,7 +294,9 @@ extern struct hostent *xgethostbyname(const char *name); extern struct hostent *xgethostbyname2(const char *name, int af); extern int create_icmp_socket(void); extern int create_icmp6_socket(void); -extern int xconnect(const char *host, const char *port); +extern int xconnect(struct sockaddr_in *s_addr); +extern int bb_getport(const char *port); +extern void bb_lookup_host(struct sockaddr_in *s_in, const char *host, const char *port); //#warning wrap this? char *dirname (char *path); @@ -327,6 +336,21 @@ extern const char * const bb_path_group_file; extern const char * const bb_path_securetty_file; extern const char * const bb_path_motd_file; +/* + * You can change LIBBB_DEFAULT_LOGIN_SHELL, but don`t use, + * use bb_default_login_shell and next defines, + * if you LIBBB_DEFAULT_LOGIN_SHELL change, + * don`t lose change increment constant! + */ +#define LIBBB_DEFAULT_LOGIN_SHELL "-/bin/sh" + +extern const char * const bb_default_login_shell; +/* "/bin/sh" */ +#define DEFAULT_SHELL (bb_default_login_shell+1) +/* "sh" */ +#define DEFAULT_SHELL_SHORT_NAME (bb_default_login_shell+6) + + extern const char bb_path_mtab_file[]; extern int bb_default_error_retval; @@ -338,11 +362,21 @@ extern int bb_default_error_retval; # define VC_3 "/dev/vc/3" # define VC_4 "/dev/vc/4" # define VC_5 "/dev/vc/5" -# define SC_0 "/dev/tts/0" -# define SC_1 "/dev/tts/1" +#if defined(__sh__) || defined(__H8300H__) || defined(__H8300S__) +/* Yes, this sucks, but both SH (including sh64) and H8 have a SCI(F) for their + respective serial ports .. as such, we can't use the common device paths for + these. -- PFM */ +# define SC_0 "/dev/ttsc/0" +# define SC_1 "/dev/ttsc/1" +# define SC_FORMAT "/dev/ttsc/%d" +#else +# define SC_0 "/dev/tts/0" +# define SC_1 "/dev/tts/1" +# define SC_FORMAT "/dev/tts/%d" +#endif # define VC_FORMAT "/dev/vc/%d" -# define SC_FORMAT "/dev/tts/%d" # define LOOP_FORMAT "/dev/loop/%d" +# define FB_0 "/dev/fb/0" #else # define CURRENT_VC "/dev/tty0" # define VC_1 "/dev/tty1" @@ -350,11 +384,18 @@ extern int bb_default_error_retval; # define VC_3 "/dev/tty3" # define VC_4 "/dev/tty4" # define VC_5 "/dev/tty5" -# define SC_0 "/dev/ttyS0" -# define SC_1 "/dev/ttyS1" +#if defined(__sh__) || defined(__H8300H__) || defined(__H8300S__) +# define SC_0 "/dev/ttySC0" +# define SC_1 "/dev/ttySC1" +# define SC_FORMAT "/dev/ttySC%d" +#else +# define SC_0 "/dev/ttyS0" +# define SC_1 "/dev/ttyS1" +# define SC_FORMAT "/dev/ttyS%d" +#endif # define VC_FORMAT "/dev/tty%d" -# define SC_FORMAT "/dev/ttyS%d" # define LOOP_FORMAT "/dev/loop%d" +# define FB_0 "/dev/fb0" #endif //#warning put these in .o files @@ -376,8 +417,13 @@ void bb_xasprintf(char **string_ptr, const char *format, ...) __attribute__ ((fo #define FAIL_DELAY 3 extern void change_identity ( const struct passwd *pw ); -extern void run_shell ( const char *shell, int loginshell, const char *command, const char **additional_args ); -extern int run_parts(char **args, const unsigned char test_mode); +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 + , security_id_t sid +#endif +); +extern int run_parts(char **args, const unsigned char test_mode, char **env); extern int restricted_shell ( const char *shell ); extern void setup_environment ( const char *shell, int loginshell, int changeenv, const struct passwd *pw ); extern int correct_password ( const struct passwd *pw ); @@ -407,7 +453,11 @@ typedef struct { char short_cmd[16]; } procps_status_t; -extern procps_status_t * procps_scan(int save_user_arg0); +extern procps_status_t * procps_scan(int save_user_arg0 +#ifdef CONFIG_SELINUX + , int use_selinux, security_id_t *sid +#endif +); extern unsigned short compare_string_array(const char *string_array[], const char *key); extern int my_query_module(const char *name, int which, void **buf, size_t *bufsize, size_t *ret); @@ -418,7 +468,17 @@ typedef struct llist_s { } llist_t; extern llist_t *llist_add_to(llist_t *old_head, char *new_item); -void print_login_issue(const char *issue_file, const char *tty); -void print_login_prompt(void); +extern void print_login_issue(const char *issue_file, const char *tty); +extern void print_login_prompt(void); + +extern void vfork_daemon_rexec(int argc, char **argv, char *foreground_opt); +extern void get_terminal_width_height(int fd, int *width, int *height); +extern unsigned long get_ug_id(const char *s, long (*my_getxxnam)(const char *)); +extern void xregcomp(regex_t *preg, const char *regex, int cflags); + +#define HASH_SHA1 1 +#define HASH_MD5 2 +extern int hash_fd(int fd, const off_t size, const uint8_t hash_algo, uint8_t *hashval); + #endif /* __LIBCONFIG_H__ */