diff options
author | Ron Yorston <rmy@pobox.com> | 2021-01-14 13:28:49 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2021-01-14 13:28:49 +0000 |
commit | 89963b524d211e1aec12b72b3725be05ee95c8cf (patch) | |
tree | 48590aef62b7ee7686b7898256f29def8d9c50b9 /include/libbb.h | |
parent | 9aa5a829070392c2ac6494d0c4e674c0c2bc7dab (diff) | |
parent | 2b7c1aa92c68524559a2067609d09309d5c09adc (diff) | |
download | busybox-w32-89963b524d211e1aec12b72b3725be05ee95c8cf.tar.gz busybox-w32-89963b524d211e1aec12b72b3725be05ee95c8cf.tar.bz2 busybox-w32-89963b524d211e1aec12b72b3725be05ee95c8cf.zip |
Merge branch 'busybox' into merge
Diffstat (limited to 'include/libbb.h')
-rw-r--r-- | include/libbb.h | 78 |
1 files changed, 63 insertions, 15 deletions
diff --git a/include/libbb.h b/include/libbb.h index eb8b63895..3d6a6a0cf 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -106,7 +106,11 @@ | |||
106 | # define updwtmpx updwtmp | 106 | # define updwtmpx updwtmp |
107 | # define _PATH_UTMPX _PATH_UTMP | 107 | # define _PATH_UTMPX _PATH_UTMP |
108 | # else | 108 | # else |
109 | # include <utmp.h> | 109 | # if !defined(__FreeBSD__) |
110 | # include <utmp.h> | ||
111 | # else | ||
112 | # define _PATH_UTMPX "/var/run/utx.active" | ||
113 | # endif | ||
110 | # include <utmpx.h> | 114 | # include <utmpx.h> |
111 | # if defined _PATH_UTMP && !defined _PATH_UTMPX | 115 | # if defined _PATH_UTMP && !defined _PATH_UTMPX |
112 | # define _PATH_UTMPX _PATH_UTMP | 116 | # define _PATH_UTMPX _PATH_UTMP |
@@ -405,6 +409,32 @@ void* xrealloc_vector_helper(void *vector, unsigned sizeof_and_shift, int idx) F | |||
405 | char *xstrdup(const char *s) FAST_FUNC RETURNS_MALLOC; | 409 | char *xstrdup(const char *s) FAST_FUNC RETURNS_MALLOC; |
406 | char *xstrndup(const char *s, int n) FAST_FUNC RETURNS_MALLOC; | 410 | char *xstrndup(const char *s, int n) FAST_FUNC RETURNS_MALLOC; |
407 | void *xmemdup(const void *s, int n) FAST_FUNC RETURNS_MALLOC; | 411 | void *xmemdup(const void *s, int n) FAST_FUNC RETURNS_MALLOC; |
412 | void *mmap_read(int fd, size_t size) FAST_FUNC; | ||
413 | void *mmap_anon(size_t size) FAST_FUNC; | ||
414 | void *xmmap_anon(size_t size) FAST_FUNC; | ||
415 | |||
416 | #if defined(__x86_64__) || defined(i386) | ||
417 | # define BB_ARCH_FIXED_PAGESIZE 4096 | ||
418 | #elif defined(__arm__) /* only 32bit, 64bit ARM has variable page size */ | ||
419 | # define BB_ARCH_FIXED_PAGESIZE 4096 | ||
420 | #else /* if defined(ARCH) */ | ||
421 | /* add you favorite arch today! */ | ||
422 | //From Linux kernel inspection: | ||
423 | //xtenza,s390[x],riscv,nios2,csky,sparc32: fixed 4k pages | ||
424 | //sparc64,alpha,openrisc: fixed 8k pages | ||
425 | #endif | ||
426 | |||
427 | #if defined BB_ARCH_FIXED_PAGESIZE | ||
428 | # define IF_VARIABLE_ARCH_PAGESIZE(...) /*nothing*/ | ||
429 | # define bb_getpagesize() BB_ARCH_FIXED_PAGESIZE | ||
430 | # define INIT_PAGESIZE(var) ((void)0) | ||
431 | # define cached_pagesize(var) BB_ARCH_FIXED_PAGESIZE | ||
432 | #else | ||
433 | # define IF_VARIABLE_ARCH_PAGESIZE(...) __VA_ARGS__ | ||
434 | # define bb_getpagesize() getpagesize() | ||
435 | # define INIT_PAGESIZE(var) ((var) = getpagesize()) | ||
436 | # define cached_pagesize(var) (var) | ||
437 | #endif | ||
408 | 438 | ||
409 | 439 | ||
410 | //TODO: supply a pointer to char[11] buffer (avoid statics)? | 440 | //TODO: supply a pointer to char[11] buffer (avoid statics)? |
@@ -670,6 +700,9 @@ void parse_datestr(const char *date_str, struct tm *ptm) FAST_FUNC; | |||
670 | time_t validate_tm_time(const char *date_str, struct tm *ptm) FAST_FUNC; | 700 | time_t validate_tm_time(const char *date_str, struct tm *ptm) FAST_FUNC; |
671 | char *strftime_HHMMSS(char *buf, unsigned len, time_t *tp) FAST_FUNC; | 701 | char *strftime_HHMMSS(char *buf, unsigned len, time_t *tp) FAST_FUNC; |
672 | char *strftime_YYYYMMDDHHMMSS(char *buf, unsigned len, time_t *tp) FAST_FUNC; | 702 | char *strftime_YYYYMMDDHHMMSS(char *buf, unsigned len, time_t *tp) FAST_FUNC; |
703 | void xgettimeofday(struct timeval *tv) FAST_FUNC; | ||
704 | void xsettimeofday(const struct timeval *tv) FAST_FUNC; | ||
705 | |||
673 | 706 | ||
674 | int xsocket(int domain, int type, int protocol) FAST_FUNC; | 707 | int xsocket(int domain, int type, int protocol) FAST_FUNC; |
675 | void xbind(int sockfd, struct sockaddr *my_addr, socklen_t addrlen) FAST_FUNC; | 708 | void xbind(int sockfd, struct sockaddr *my_addr, socklen_t addrlen) FAST_FUNC; |
@@ -1065,8 +1098,9 @@ void generate_uuid(uint8_t *buf) FAST_FUNC; | |||
1065 | /* Last element is marked by mult == 0 */ | 1098 | /* Last element is marked by mult == 0 */ |
1066 | struct suffix_mult { | 1099 | struct suffix_mult { |
1067 | char suffix[4]; | 1100 | char suffix[4]; |
1068 | unsigned mult; | 1101 | uint32_t mult; |
1069 | }; | 1102 | }; |
1103 | #define ALIGN_SUFFIX ALIGN4 | ||
1070 | extern const struct suffix_mult bkm_suffixes[]; | 1104 | extern const struct suffix_mult bkm_suffixes[]; |
1071 | #define km_suffixes (bkm_suffixes + 1) | 1105 | #define km_suffixes (bkm_suffixes + 1) |
1072 | extern const struct suffix_mult cwbkMG_suffixes[]; | 1106 | extern const struct suffix_mult cwbkMG_suffixes[]; |
@@ -1178,7 +1212,6 @@ int BB_EXECVP(const char *file, char *const argv[]) FAST_FUNC; | |||
1178 | #define BB_EXECLP(prog,cmd,...) execlp(prog,cmd,__VA_ARGS__) | 1212 | #define BB_EXECLP(prog,cmd,...) execlp(prog,cmd,__VA_ARGS__) |
1179 | #endif | 1213 | #endif |
1180 | void BB_EXECVP_or_die(char **argv) NORETURN FAST_FUNC; | 1214 | void BB_EXECVP_or_die(char **argv) NORETURN FAST_FUNC; |
1181 | void exec_prog_or_SHELL(char **argv) NORETURN FAST_FUNC; | ||
1182 | 1215 | ||
1183 | /* xvfork() can't be a _function_, return after vfork in child mangles stack | 1216 | /* xvfork() can't be a _function_, return after vfork in child mangles stack |
1184 | * in the parent. It must be a macro. */ | 1217 | * in the parent. It must be a macro. */ |
@@ -1644,12 +1677,14 @@ char *bb_simplify_path(const char *path) FAST_FUNC; | |||
1644 | /* Returns ptr to NUL */ | 1677 | /* Returns ptr to NUL */ |
1645 | char *bb_simplify_abs_path_inplace(char *path) FAST_FUNC; | 1678 | char *bb_simplify_abs_path_inplace(char *path) FAST_FUNC; |
1646 | 1679 | ||
1647 | #ifndef LOGIN_FAIL_DELAY | 1680 | void pause_after_failed_login(void) FAST_FUNC; |
1648 | #define LOGIN_FAIL_DELAY 3 | 1681 | void bb_do_delay(unsigned seconds) FAST_FUNC; |
1649 | #endif | 1682 | void msleep(unsigned ms) FAST_FUNC; |
1650 | extern void bb_do_delay(int seconds) FAST_FUNC; | 1683 | void sleep1(void) FAST_FUNC; |
1651 | extern void change_identity(const struct passwd *pw) FAST_FUNC; | 1684 | void change_identity(const struct passwd *pw) FAST_FUNC; |
1652 | extern void run_shell(const char *shell, int loginshell, const char **args) NORETURN FAST_FUNC; | 1685 | void exec_shell(const char *shell, int loginshell, const char **args) NORETURN FAST_FUNC; |
1686 | void exec_login_shell(const char *shell) NORETURN FAST_FUNC; | ||
1687 | void exec_prog_or_SHELL(char **argv) NORETURN FAST_FUNC; | ||
1653 | 1688 | ||
1654 | /* Returns $SHELL, getpwuid(getuid())->pw_shell, or DEFAULT_SHELL. | 1689 | /* Returns $SHELL, getpwuid(getuid())->pw_shell, or DEFAULT_SHELL. |
1655 | * Note that getpwuid result might need xstrdup'ing | 1690 | * Note that getpwuid result might need xstrdup'ing |
@@ -1884,14 +1919,20 @@ typedef const char *get_exe_name_t(int i) FAST_FUNC; | |||
1884 | typedef struct line_input_t { | 1919 | typedef struct line_input_t { |
1885 | int flags; | 1920 | int flags; |
1886 | int timeout; | 1921 | int timeout; |
1922 | # if ENABLE_FEATURE_TAB_COMPLETION | ||
1923 | # if ENABLE_SHELL_ASH | ||
1887 | const char *path_lookup; | 1924 | const char *path_lookup; |
1888 | # if ENABLE_FEATURE_TAB_COMPLETION \ | 1925 | # define EDITING_HAS_path_lookup 1 |
1889 | && (ENABLE_ASH || ENABLE_SH_IS_ASH || ENABLE_BASH_IS_ASH \ | 1926 | # else |
1890 | || ENABLE_HUSH || ENABLE_SH_IS_HUSH || ENABLE_BASH_IS_HUSH \ | 1927 | # define EDITING_HAS_path_lookup 0 |
1891 | ) | 1928 | # endif |
1929 | # if ENABLE_SHELL_ASH || ENABLE_SHELL_HUSH | ||
1892 | /* function to fetch additional application-specific names to match */ | 1930 | /* function to fetch additional application-specific names to match */ |
1893 | get_exe_name_t *get_exe_name; | 1931 | get_exe_name_t *get_exe_name; |
1894 | # define EDITING_HAS_get_exe_name 1 | 1932 | # define EDITING_HAS_get_exe_name 1 |
1933 | # else | ||
1934 | # define EDITING_HAS_get_exe_name 0 | ||
1935 | # endif | ||
1895 | # endif | 1936 | # endif |
1896 | # if MAX_HISTORY | 1937 | # if MAX_HISTORY |
1897 | int cnt_history; | 1938 | int cnt_history; |
@@ -1919,7 +1960,11 @@ enum { | |||
1919 | FOR_SHELL = DO_HISTORY | TAB_COMPLETION | USERNAME_COMPLETION, | 1960 | FOR_SHELL = DO_HISTORY | TAB_COMPLETION | USERNAME_COMPLETION, |
1920 | }; | 1961 | }; |
1921 | line_input_t *new_line_input_t(int flags) FAST_FUNC; | 1962 | line_input_t *new_line_input_t(int flags) FAST_FUNC; |
1963 | #if ENABLE_FEATURE_EDITING_SAVEHISTORY | ||
1922 | void free_line_input_t(line_input_t *n) FAST_FUNC; | 1964 | void free_line_input_t(line_input_t *n) FAST_FUNC; |
1965 | #else | ||
1966 | # define free_line_input_t(n) free(n) | ||
1967 | #endif | ||
1923 | /* | 1968 | /* |
1924 | * maxsize must be >= 2. | 1969 | * maxsize must be >= 2. |
1925 | * Returns: | 1970 | * Returns: |
@@ -2079,14 +2124,17 @@ char *percent_decode_in_place(char *str, int strict) FAST_FUNC; | |||
2079 | 2124 | ||
2080 | 2125 | ||
2081 | extern const char bb_uuenc_tbl_base64[] ALIGN1; | 2126 | extern const char bb_uuenc_tbl_base64[] ALIGN1; |
2127 | extern const char bb_uuenc_tbl_base32[] ALIGN1; | ||
2082 | extern const char bb_uuenc_tbl_std[] ALIGN1; | 2128 | extern const char bb_uuenc_tbl_std[] ALIGN1; |
2083 | void bb_uuencode(char *store, const void *s, int length, const char *tbl) FAST_FUNC; | 2129 | void bb_uuencode(char *store, const void *s, int length, const char *tbl) FAST_FUNC; |
2084 | enum { | 2130 | enum { |
2085 | BASE64_FLAG_UU_STOP = 0x100, | 2131 | BASE64_FLAG_UU_STOP = 0x100, |
2132 | BASE64_32 = 0x200, /* base32 */ | ||
2086 | /* Sign-extends to a value which never matches fgetc result: */ | 2133 | /* Sign-extends to a value which never matches fgetc result: */ |
2087 | BASE64_FLAG_NO_STOP_CHAR = 0x80, | 2134 | BASE64_FLAG_NO_STOP_CHAR = 0x80, |
2088 | }; | 2135 | }; |
2089 | const char *decode_base64(char **pp_dst, const char *src) FAST_FUNC; | 2136 | char *decode_base64(char *dst, const char **pp_src) FAST_FUNC; |
2137 | char *decode_base32(char *dst, const char **pp_src) FAST_FUNC; | ||
2090 | void read_base64(FILE *src_stream, FILE *dst_stream, int flags) FAST_FUNC; | 2138 | void read_base64(FILE *src_stream, FILE *dst_stream, int flags) FAST_FUNC; |
2091 | 2139 | ||
2092 | typedef struct md5_ctx_t { | 2140 | typedef struct md5_ctx_t { |