aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/applets.src.h2
-rw-r--r--include/bb_archive.h (renamed from include/archive.h)0
-rw-r--r--include/libbb.h114
-rw-r--r--include/platform.h6
4 files changed, 74 insertions, 48 deletions
diff --git a/include/applets.src.h b/include/applets.src.h
index 87d9cbb7b..252a060fb 100644
--- a/include/applets.src.h
+++ b/include/applets.src.h
@@ -176,7 +176,6 @@ IF_HD(APPLET_NOEXEC(hd, hexdump, BB_DIR_USR_BIN, BB_SUID_DROP, hd))
176IF_HDPARM(APPLET(hdparm, BB_DIR_SBIN, BB_SUID_DROP)) 176IF_HDPARM(APPLET(hdparm, BB_DIR_SBIN, BB_SUID_DROP))
177IF_HEAD(APPLET_NOEXEC(head, head, BB_DIR_USR_BIN, BB_SUID_DROP, head)) 177IF_HEAD(APPLET_NOEXEC(head, head, BB_DIR_USR_BIN, BB_SUID_DROP, head))
178IF_HEXDUMP(APPLET_NOEXEC(hexdump, hexdump, BB_DIR_USR_BIN, BB_SUID_DROP, hexdump)) 178IF_HEXDUMP(APPLET_NOEXEC(hexdump, hexdump, BB_DIR_USR_BIN, BB_SUID_DROP, hexdump))
179IF_HOSTID(APPLET_NOFORK(hostid, hostid, BB_DIR_USR_BIN, BB_SUID_DROP, hostid))
180IF_HOSTNAME(APPLET(hostname, BB_DIR_BIN, BB_SUID_DROP)) 179IF_HOSTNAME(APPLET(hostname, BB_DIR_BIN, BB_SUID_DROP))
181IF_HTTPD(APPLET(httpd, BB_DIR_USR_SBIN, BB_SUID_DROP)) 180IF_HTTPD(APPLET(httpd, BB_DIR_USR_SBIN, BB_SUID_DROP))
182IF_HWCLOCK(APPLET(hwclock, BB_DIR_SBIN, BB_SUID_DROP)) 181IF_HWCLOCK(APPLET(hwclock, BB_DIR_SBIN, BB_SUID_DROP))
@@ -240,7 +239,6 @@ IF_MAKEMIME(APPLET(makemime, BB_DIR_BIN, BB_SUID_DROP))
240IF_MAN(APPLET(man, BB_DIR_SBIN, BB_SUID_DROP)) 239IF_MAN(APPLET(man, BB_DIR_SBIN, BB_SUID_DROP))
241IF_MATCHPATHCON(APPLET(matchpathcon, BB_DIR_USR_SBIN, BB_SUID_DROP)) 240IF_MATCHPATHCON(APPLET(matchpathcon, BB_DIR_USR_SBIN, BB_SUID_DROP))
242IF_MD5SUM(APPLET_NOEXEC(md5sum, md5_sha1_sum, BB_DIR_USR_BIN, BB_SUID_DROP, md5sum)) 241IF_MD5SUM(APPLET_NOEXEC(md5sum, md5_sha1_sum, BB_DIR_USR_BIN, BB_SUID_DROP, md5sum))
243IF_MDEV(APPLET(mdev, BB_DIR_SBIN, BB_SUID_DROP))
244IF_MICROCOM(APPLET(microcom, BB_DIR_USR_BIN, BB_SUID_DROP)) 242IF_MICROCOM(APPLET(microcom, BB_DIR_USR_BIN, BB_SUID_DROP))
245IF_MKDIR(APPLET_NOFORK(mkdir, mkdir, BB_DIR_BIN, BB_SUID_DROP, mkdir)) 243IF_MKDIR(APPLET_NOFORK(mkdir, mkdir, BB_DIR_BIN, BB_SUID_DROP, mkdir))
246IF_MKFS_VFAT(APPLET_ODDNAME(mkdosfs, mkfs_vfat, BB_DIR_SBIN, BB_SUID_DROP, mkfs_vfat)) 244IF_MKFS_VFAT(APPLET_ODDNAME(mkdosfs, mkfs_vfat, BB_DIR_SBIN, BB_SUID_DROP, mkfs_vfat))
diff --git a/include/archive.h b/include/bb_archive.h
index 9e176d335..9e176d335 100644
--- a/include/archive.h
+++ b/include/bb_archive.h
diff --git a/include/libbb.h b/include/libbb.h
index 6e63e65f5..a6ecac932 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -32,6 +32,11 @@
32#include <stdarg.h> 32#include <stdarg.h>
33#include <stddef.h> 33#include <stddef.h>
34#include <string.h> 34#include <string.h>
35/* There are two incompatible basename's, let not use them! */
36/* See the dirname/basename man page for details */
37#include <libgen.h> /* dirname,basename */
38#undef basename
39#define basename dont_use_basename
35#include <sys/poll.h> 40#include <sys/poll.h>
36#include <sys/ioctl.h> 41#include <sys/ioctl.h>
37#include <sys/mman.h> 42#include <sys/mman.h>
@@ -142,12 +147,6 @@ int vdprintf(int d, const char *format, va_list ap);
142#endif 147#endif
143/* klogctl is in libc's klog.h, but we cheat and not #include that */ 148/* klogctl is in libc's klog.h, but we cheat and not #include that */
144int klogctl(int type, char *b, int len); 149int klogctl(int type, char *b, int len);
145/* This is declared here rather than #including <libgen.h> in order to avoid
146 * confusing the two versions of basename. See the dirname/basename man page
147 * for details. */
148#if !defined __FreeBSD__
149char *dirname(char *path);
150#endif
151#ifndef PATH_MAX 150#ifndef PATH_MAX
152# define PATH_MAX 256 151# define PATH_MAX 256
153#endif 152#endif
@@ -268,13 +267,6 @@ typedef unsigned long uoff_t;
268#undef SKIP 267#undef SKIP
269#define SKIP ((int) 2) 268#define SKIP ((int) 2)
270 269
271/* for mtab.c */
272#define MTAB_GETMOUNTPT '1'
273#define MTAB_GETDEVICE '2'
274
275#define BUF_SIZE 8192
276#define EXPAND_ALLOC 1024
277
278/* Macros for min/max. */ 270/* Macros for min/max. */
279#ifndef MIN 271#ifndef MIN
280#define MIN(a,b) (((a)<(b))?(a):(b)) 272#define MIN(a,b) (((a)<(b))?(a):(b))
@@ -653,6 +645,7 @@ ssize_t recv_from_to(int fd, void *buf, size_t len, int flags,
653 struct sockaddr *to, 645 struct sockaddr *to,
654 socklen_t sa_size) FAST_FUNC; 646 socklen_t sa_size) FAST_FUNC;
655 647
648uint16_t inet_cksum(uint16_t *addr, int len) FAST_FUNC;
656 649
657char *xstrdup(const char *s) FAST_FUNC RETURNS_MALLOC; 650char *xstrdup(const char *s) FAST_FUNC RETURNS_MALLOC;
658char *xstrndup(const char *s, int n) FAST_FUNC RETURNS_MALLOC; 651char *xstrndup(const char *s, int n) FAST_FUNC RETURNS_MALLOC;
@@ -697,10 +690,13 @@ void *malloc_or_warn(size_t size) FAST_FUNC RETURNS_MALLOC;
697void *xmalloc(size_t size) FAST_FUNC RETURNS_MALLOC; 690void *xmalloc(size_t size) FAST_FUNC RETURNS_MALLOC;
698void *xzalloc(size_t size) FAST_FUNC RETURNS_MALLOC; 691void *xzalloc(size_t size) FAST_FUNC RETURNS_MALLOC;
699void *xrealloc(void *old, size_t size) FAST_FUNC; 692void *xrealloc(void *old, size_t size) FAST_FUNC;
700/* After xrealloc_vector(v, 4, idx) it's ok to use 693/* After v = xrealloc_vector(v, SHIFT, idx) it's ok to use
701 * at least v[idx] and v[idx+1], for all idx values. 694 * at least v[idx] and v[idx+1], for all idx values.
702 * shift specifies how many new elements are added (1: 2, 2: 4... 8: 256...) 695 * SHIFT specifies how many new elements are added (1:2, 2:4, ..., 8:256...)
703 * when all elements are used up. New elements are zeroed out. */ 696 * when all elements are used up. New elements are zeroed out.
697 * xrealloc_vector(v, SHIFT, idx) *MUST* be called with consecutive IDXs -
698 * skipping an index is a bad bug - it may miss a realloc!
699 */
704#define xrealloc_vector(vector, shift, idx) \ 700#define xrealloc_vector(vector, shift, idx) \
705 xrealloc_vector_helper((vector), (sizeof((vector)[0]) << 8) + (shift), (idx)) 701 xrealloc_vector_helper((vector), (sizeof((vector)[0]) << 8) + (shift), (idx))
706void* xrealloc_vector_helper(void *vector, unsigned sizeof_and_shift, int idx) FAST_FUNC; 702void* xrealloc_vector_helper(void *vector, unsigned sizeof_and_shift, int idx) FAST_FUNC;
@@ -827,9 +823,9 @@ void smart_ulltoa5(unsigned long long ul, char buf[5], const char *scale) FAST_F
827const char *make_human_readable_str(unsigned long long size, 823const char *make_human_readable_str(unsigned long long size,
828 unsigned long block_size, unsigned long display_unit) FAST_FUNC; 824 unsigned long block_size, unsigned long display_unit) FAST_FUNC;
829/* Put a string of hex bytes ("1b2e66fe"...), return advanced pointer */ 825/* Put a string of hex bytes ("1b2e66fe"...), return advanced pointer */
830char *bin2hex(char *buf, const char *cp, int count) FAST_FUNC; 826char *bin2hex(char *dst, const char *src, int count) FAST_FUNC;
831/* Reverse */ 827/* Reverse */
832char* hex2bin(char *dst, const char *str, int count) FAST_FUNC; 828char* hex2bin(char *dst, const char *src, int count) FAST_FUNC;
833 829
834/* Generate a UUID */ 830/* Generate a UUID */
835void generate_uuid(uint8_t *buf) FAST_FUNC; 831void generate_uuid(uint8_t *buf) FAST_FUNC;
@@ -1180,7 +1176,7 @@ extern int del_loop(const char *device) FAST_FUNC;
1180/* If *devname is not NULL, use that name, otherwise try to find free one, 1176/* If *devname is not NULL, use that name, otherwise try to find free one,
1181 * malloc and return it in *devname. 1177 * malloc and return it in *devname.
1182 * return value: 1: read-only loopdev was setup, 0: rw, < 0: error */ 1178 * return value: 1: read-only loopdev was setup, 0: rw, < 0: error */
1183extern int set_loop(char **devname, const char *file, unsigned long long offset) FAST_FUNC; 1179extern int set_loop(char **devname, const char *file, unsigned long long offset, int ro) FAST_FUNC;
1184 1180
1185/* Like bb_ask below, but asks on stdin with no timeout. */ 1181/* Like bb_ask below, but asks on stdin with no timeout. */
1186char *bb_ask_stdin(const char * prompt) FAST_FUNC; 1182char *bb_ask_stdin(const char * prompt) FAST_FUNC;
@@ -1378,25 +1374,37 @@ enum {
1378 KEYCODE_DELETE = -9, 1374 KEYCODE_DELETE = -9,
1379 KEYCODE_PAGEUP = -10, 1375 KEYCODE_PAGEUP = -10,
1380 KEYCODE_PAGEDOWN = -11, 1376 KEYCODE_PAGEDOWN = -11,
1381 1377 // -12 is reserved for Alt/Ctrl/Shift-TAB
1382 KEYCODE_CTRL_UP = KEYCODE_UP & ~0x40, 1378#if 0
1383 KEYCODE_CTRL_DOWN = KEYCODE_DOWN & ~0x40, 1379 KEYCODE_FUN1 = -13,
1380 KEYCODE_FUN2 = -14,
1381 KEYCODE_FUN3 = -15,
1382 KEYCODE_FUN4 = -16,
1383 KEYCODE_FUN5 = -17,
1384 KEYCODE_FUN6 = -18,
1385 KEYCODE_FUN7 = -19,
1386 KEYCODE_FUN8 = -20,
1387 KEYCODE_FUN9 = -21,
1388 KEYCODE_FUN10 = -22,
1389 KEYCODE_FUN11 = -23,
1390 KEYCODE_FUN12 = -24,
1391#endif
1392 /* Be sure that last defined value is small enough
1393 * to not interfere with Alt/Ctrl/Shift bits.
1394 * So far we do not exceed -31 (0xfff..fffe1),
1395 * which gives us three upper bits in LSB to play with.
1396 */
1397 //KEYCODE_SHIFT_TAB = (-12) & ~0x80,
1398 //KEYCODE_SHIFT_... = KEYCODE_... & ~0x80,
1399 //KEYCODE_CTRL_UP = KEYCODE_UP & ~0x40,
1400 //KEYCODE_CTRL_DOWN = KEYCODE_DOWN & ~0x40,
1384 KEYCODE_CTRL_RIGHT = KEYCODE_RIGHT & ~0x40, 1401 KEYCODE_CTRL_RIGHT = KEYCODE_RIGHT & ~0x40,
1385 KEYCODE_CTRL_LEFT = KEYCODE_LEFT & ~0x40, 1402 KEYCODE_CTRL_LEFT = KEYCODE_LEFT & ~0x40,
1386#if 0 1403 //KEYCODE_ALT_UP = KEYCODE_UP & ~0x20,
1387 KEYCODE_FUN1 = -12, 1404 //KEYCODE_ALT_DOWN = KEYCODE_DOWN & ~0x20,
1388 KEYCODE_FUN2 = -13, 1405 KEYCODE_ALT_RIGHT = KEYCODE_RIGHT & ~0x20,
1389 KEYCODE_FUN3 = -14, 1406 KEYCODE_ALT_LEFT = KEYCODE_LEFT & ~0x20,
1390 KEYCODE_FUN4 = -15, 1407
1391 KEYCODE_FUN5 = -16,
1392 KEYCODE_FUN6 = -17,
1393 KEYCODE_FUN7 = -18,
1394 KEYCODE_FUN8 = -19,
1395 KEYCODE_FUN9 = -20,
1396 KEYCODE_FUN10 = -21,
1397 KEYCODE_FUN11 = -22,
1398 KEYCODE_FUN12 = -23,
1399#endif
1400 KEYCODE_CURSOR_POS = -0x100, /* 0xfff..fff00 */ 1408 KEYCODE_CURSOR_POS = -0x100, /* 0xfff..fff00 */
1401 /* How long is the longest ESC sequence we know? 1409 /* How long is the longest ESC sequence we know?
1402 * We want it big enough to be able to contain 1410 * We want it big enough to be able to contain
@@ -1437,6 +1445,12 @@ typedef struct line_input_t {
1437 int cur_history; 1445 int cur_history;
1438 int max_history; /* must never be <= 0 */ 1446 int max_history; /* must never be <= 0 */
1439# if ENABLE_FEATURE_EDITING_SAVEHISTORY 1447# if ENABLE_FEATURE_EDITING_SAVEHISTORY
1448 /* meaning of this field depends on FEATURE_EDITING_SAVE_ON_EXIT:
1449 * if !FEATURE_EDITING_SAVE_ON_EXIT: "how many lines are
1450 * in on-disk history"
1451 * if FEATURE_EDITING_SAVE_ON_EXIT: "how many in-memory lines are
1452 * also in on-disk history (and thus need to be skipped on save)"
1453 */
1440 unsigned cnt_history_in_file; 1454 unsigned cnt_history_in_file;
1441 const char *hist_file; 1455 const char *hist_file;
1442# endif 1456# endif
@@ -1444,13 +1458,12 @@ typedef struct line_input_t {
1444# endif 1458# endif
1445} line_input_t; 1459} line_input_t;
1446enum { 1460enum {
1447 DO_HISTORY = 1 * (MAX_HISTORY > 0), 1461 DO_HISTORY = 1 * (MAX_HISTORY > 0),
1448 SAVE_HISTORY = 2 * (MAX_HISTORY > 0) * ENABLE_FEATURE_EDITING_SAVEHISTORY, 1462 TAB_COMPLETION = 2 * ENABLE_FEATURE_TAB_COMPLETION,
1449 TAB_COMPLETION = 4 * ENABLE_FEATURE_TAB_COMPLETION, 1463 USERNAME_COMPLETION = 4 * ENABLE_FEATURE_USERNAME_COMPLETION,
1450 USERNAME_COMPLETION = 8 * ENABLE_FEATURE_USERNAME_COMPLETION, 1464 VI_MODE = 8 * ENABLE_FEATURE_EDITING_VI,
1451 VI_MODE = 0x10 * ENABLE_FEATURE_EDITING_VI, 1465 WITH_PATH_LOOKUP = 0x10,
1452 WITH_PATH_LOOKUP = 0x20, 1466 FOR_SHELL = DO_HISTORY | TAB_COMPLETION | USERNAME_COMPLETION,
1453 FOR_SHELL = DO_HISTORY | SAVE_HISTORY | TAB_COMPLETION | USERNAME_COMPLETION,
1454}; 1467};
1455line_input_t *new_line_input_t(int flags) FAST_FUNC; 1468line_input_t *new_line_input_t(int flags) FAST_FUNC;
1456/* So far static: void free_line_input_t(line_input_t *n) FAST_FUNC; */ 1469/* So far static: void free_line_input_t(line_input_t *n) FAST_FUNC; */
@@ -1462,6 +1475,9 @@ line_input_t *new_line_input_t(int flags) FAST_FUNC;
1462 * >0 length of input string, including terminating '\n' 1475 * >0 length of input string, including terminating '\n'
1463 */ 1476 */
1464int read_line_input(line_input_t *st, const char *prompt, char *command, int maxsize, int timeout) FAST_FUNC; 1477int read_line_input(line_input_t *st, const char *prompt, char *command, int maxsize, int timeout) FAST_FUNC;
1478# if ENABLE_FEATURE_EDITING_SAVE_ON_EXIT
1479void save_history(line_input_t *st);
1480# endif
1465#else 1481#else
1466#define MAX_HISTORY 0 1482#define MAX_HISTORY 0
1467int read_line_input(const char* prompt, char* command, int maxsize) FAST_FUNC; 1483int read_line_input(const char* prompt, char* command, int maxsize) FAST_FUNC;
@@ -1589,6 +1605,15 @@ int starts_with_cpu(const char *str) FAST_FUNC;
1589unsigned get_cpu_count(void) FAST_FUNC; 1605unsigned get_cpu_count(void) FAST_FUNC;
1590 1606
1591 1607
1608/* Use strict=1 if you process input from untrusted source:
1609 * it will return NULL on invalid %xx (bad hex chars)
1610 * and str + 1 if decoded char is / or NUL.
1611 * In non-strict mode, it always succeeds (returns str),
1612 * and also it additionally decoded '+' to space.
1613 */
1614char *percent_decode_in_place(char *str, int strict) FAST_FUNC;
1615
1616
1592extern const char bb_uuenc_tbl_base64[]; 1617extern const char bb_uuenc_tbl_base64[];
1593extern const char bb_uuenc_tbl_std[]; 1618extern const char bb_uuenc_tbl_std[];
1594void bb_uuencode(char *store, const void *s, int length, const char *tbl) FAST_FUNC; 1619void bb_uuencode(char *store, const void *s, int length, const char *tbl) FAST_FUNC;
@@ -1597,7 +1622,8 @@ enum {
1597 /* Sign-extends to a value which never matches fgetc result: */ 1622 /* Sign-extends to a value which never matches fgetc result: */
1598 BASE64_FLAG_NO_STOP_CHAR = 0x80, 1623 BASE64_FLAG_NO_STOP_CHAR = 0x80,
1599}; 1624};
1600void FAST_FUNC read_base64(FILE *src_stream, FILE *dst_stream, int flags); 1625const char *decode_base64(char **pp_dst, const char *src) FAST_FUNC;
1626void read_base64(FILE *src_stream, FILE *dst_stream, int flags) FAST_FUNC;
1601 1627
1602typedef struct md5_ctx_t { 1628typedef struct md5_ctx_t {
1603 uint8_t wbuffer[64]; /* always correctly aligned for uint64_t */ 1629 uint8_t wbuffer[64]; /* always correctly aligned for uint64_t */
diff --git a/include/platform.h b/include/platform.h
index e22c42007..96c603c1f 100644
--- a/include/platform.h
+++ b/include/platform.h
@@ -383,7 +383,7 @@ typedef unsigned smalluint;
383#if defined(__UCLIBC_MAJOR__) 383#if defined(__UCLIBC_MAJOR__)
384# if __UCLIBC_MAJOR__ == 0 \ 384# if __UCLIBC_MAJOR__ == 0 \
385 && ( __UCLIBC_MINOR__ < 9 \ 385 && ( __UCLIBC_MINOR__ < 9 \
386 || (__UCLIBC_MINOR__ == 9 && __UCLIBC_SUBLEVEL__ < 31) \ 386 || (__UCLIBC_MINOR__ == 9 && __UCLIBC_SUBLEVEL__ < 32) \
387 ) 387 )
388# undef HAVE_STRVERSCMP 388# undef HAVE_STRVERSCMP
389# endif 389# endif
@@ -451,6 +451,8 @@ typedef unsigned smalluint;
451# undef HAVE_STRVERSCMP 451# undef HAVE_STRVERSCMP
452# undef HAVE_XTABS 452# undef HAVE_XTABS
453# undef HAVE_DPRINTF 453# undef HAVE_DPRINTF
454# undef HAVE_UNLOCKED_STDIO
455# undef HAVE_UNLOCKED_LINE_OPS
454#endif 456#endif
455 457
456#if defined(__FreeBSD__) 458#if defined(__FreeBSD__)
@@ -465,7 +467,7 @@ typedef unsigned smalluint;
465# undef HAVE_STPCPY 467# undef HAVE_STPCPY
466#endif 468#endif
467 469
468#if defined(ANDROID) 470#if defined(ANDROID) || defined(__ANDROID__)
469# undef HAVE_DPRINTF 471# undef HAVE_DPRINTF
470# undef HAVE_GETLINE 472# undef HAVE_GETLINE
471# undef HAVE_STPCPY 473# undef HAVE_STPCPY