aboutsummaryrefslogtreecommitdiff
path: root/include/libbb.h
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2012-03-22 15:21:20 +0000
committerRon Yorston <rmy@pobox.com>2012-03-22 15:21:20 +0000
commit0d8b2c4a929ea9d3ac37499319fe0d8e7941a0c2 (patch)
tree6709ddd6071a9c238ba69233540bbcfe560c6a44 /include/libbb.h
parent67758035a4fe040c6ac69b39d61bcd6bddd7b827 (diff)
parent56a3b82e9692a25ef9c9269e88feac0d579ce8e8 (diff)
downloadbusybox-w32-0d8b2c4a929ea9d3ac37499319fe0d8e7941a0c2.tar.gz
busybox-w32-0d8b2c4a929ea9d3ac37499319fe0d8e7941a0c2.tar.bz2
busybox-w32-0d8b2c4a929ea9d3ac37499319fe0d8e7941a0c2.zip
Merge commit '56a3b82e9692a25ef9c9269e88feac0d579ce8e8' into merge
Conflicts: coreutils/ls.c include/platform.h libbb/bb_basename.c
Diffstat (limited to 'include/libbb.h')
-rw-r--r--include/libbb.h38
1 files changed, 28 insertions, 10 deletions
diff --git a/include/libbb.h b/include/libbb.h
index 4f46cf8c5..ac5722c89 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -20,6 +20,12 @@
20#include <netdb.h> 20#include <netdb.h>
21#include <setjmp.h> 21#include <setjmp.h>
22#include <signal.h> 22#include <signal.h>
23#if defined __UCLIBC__ /* TODO: and glibc? */
24/* use inlined versions of these: */
25# define sigfillset(s) __sigfillset(s)
26# define sigemptyset(s) __sigemptyset(s)
27# define sigisemptyset(s) __sigisemptyset(s)
28#endif
23#include <stdint.h> 29#include <stdint.h>
24#include <stdio.h> 30#include <stdio.h>
25#include <stdlib.h> 31#include <stdlib.h>
@@ -363,6 +369,7 @@ extern void bb_copyfd_exact_size(int fd1, int fd2, off_t size) FAST_FUNC;
363/* "short" copy can be detected by return value < size */ 369/* "short" copy can be detected by return value < size */
364/* this helper yells "short read!" if param is not -1 */ 370/* this helper yells "short read!" if param is not -1 */
365extern void complain_copyfd_and_die(off_t sz) NORETURN FAST_FUNC; 371extern void complain_copyfd_and_die(off_t sz) NORETURN FAST_FUNC;
372
366extern char bb_process_escape_sequence(const char **ptr) FAST_FUNC; 373extern char bb_process_escape_sequence(const char **ptr) FAST_FUNC;
367char* strcpy_and_process_escape_sequences(char *dst, const char *src) FAST_FUNC; 374char* strcpy_and_process_escape_sequences(char *dst, const char *src) FAST_FUNC;
368/* xxxx_strip version can modify its parameter: 375/* xxxx_strip version can modify its parameter:
@@ -371,9 +378,13 @@ char* strcpy_and_process_escape_sequences(char *dst, const char *src) FAST_FUNC;
371 * "abc/def" -> "def" 378 * "abc/def" -> "def"
372 * "abc/def/" -> "def" !! 379 * "abc/def/" -> "def" !!
373 */ 380 */
374extern char *bb_get_last_path_component_strip(char *path) FAST_FUNC; 381char *bb_get_last_path_component_strip(char *path) FAST_FUNC;
375/* "abc/def/" -> "" and it never modifies 'path' */ 382/* "abc/def/" -> "" and it never modifies 'path' */
376extern char *bb_get_last_path_component_nostrip(const char *path) FAST_FUNC; 383char *bb_get_last_path_component_nostrip(const char *path) FAST_FUNC;
384/* Simpler version: does not special case "/" string */
385const char *bb_basename(const char *name) FAST_FUNC;
386/* NB: can violate const-ness (similarly to strchr) */
387char *last_char_is(const char *s, int c) FAST_FUNC;
377 388
378void ndelay_on(int fd) FAST_FUNC; 389void ndelay_on(int fd) FAST_FUNC;
379void ndelay_off(int fd) FAST_FUNC; 390void ndelay_off(int fd) FAST_FUNC;
@@ -685,7 +696,7 @@ void* xrealloc_vector_helper(void *vector, unsigned sizeof_and_shift, int idx) F
685 696
686 697
687extern ssize_t safe_read(int fd, void *buf, size_t count) FAST_FUNC; 698extern ssize_t safe_read(int fd, void *buf, size_t count) FAST_FUNC;
688extern ssize_t nonblock_safe_read(int fd, void *buf, size_t count) FAST_FUNC; 699extern ssize_t nonblock_immune_read(int fd, void *buf, size_t count, int loop_on_EINTR) FAST_FUNC;
689// NB: will return short read on error, not -1, 700// NB: will return short read on error, not -1,
690// if some data was read before error occurred 701// if some data was read before error occurred
691extern ssize_t full_read(int fd, void *buf, size_t count) FAST_FUNC; 702extern ssize_t full_read(int fd, void *buf, size_t count) FAST_FUNC;
@@ -696,7 +707,7 @@ extern ssize_t open_read_close(const char *filename, void *buf, size_t maxsz) FA
696// Reads one line a-la fgets (but doesn't save terminating '\n'). 707// Reads one line a-la fgets (but doesn't save terminating '\n').
697// Reads byte-by-byte. Useful when it is important to not read ahead. 708// Reads byte-by-byte. Useful when it is important to not read ahead.
698// Bytes are appended to pfx (which must be malloced, or NULL). 709// Bytes are appended to pfx (which must be malloced, or NULL).
699extern char *xmalloc_reads(int fd, char *pfx, size_t *maxsz_p) FAST_FUNC; 710extern char *xmalloc_reads(int fd, size_t *maxsz_p) FAST_FUNC;
700/* Reads block up to *maxsz_p (default: INT_MAX - 4095) */ 711/* Reads block up to *maxsz_p (default: INT_MAX - 4095) */
701extern void *xmalloc_read(int fd, size_t *maxsz_p) FAST_FUNC RETURNS_MALLOC; 712extern void *xmalloc_read(int fd, size_t *maxsz_p) FAST_FUNC RETURNS_MALLOC;
702/* Returns NULL if file can't be opened (default max size: INT_MAX - 4095) */ 713/* Returns NULL if file can't be opened (default max size: INT_MAX - 4095) */
@@ -997,9 +1008,13 @@ extern uint32_t option_mask32;
997extern uint32_t getopt32(char **argv, const char *applet_opts, ...) FAST_FUNC; 1008extern uint32_t getopt32(char **argv, const char *applet_opts, ...) FAST_FUNC;
998 1009
999 1010
1011/* Having next pointer as a first member allows easy creation
1012 * of "llist-compatible" structs, and using llist_FOO functions
1013 * on them.
1014 */
1000typedef struct llist_t { 1015typedef struct llist_t {
1001 char *data;
1002 struct llist_t *link; 1016 struct llist_t *link;
1017 char *data;
1003} llist_t; 1018} llist_t;
1004void llist_add_to(llist_t **old_head, void *data) FAST_FUNC; 1019void llist_add_to(llist_t **old_head, void *data) FAST_FUNC;
1005void llist_add_to_end(llist_t **list_head, void *data) FAST_FUNC; 1020void llist_add_to_end(llist_t **list_head, void *data) FAST_FUNC;
@@ -1198,10 +1213,8 @@ void config_close(parser_t *parser) FAST_FUNC;
1198 * If path is NULL, it is assumed to be "/". 1213 * If path is NULL, it is assumed to be "/".
1199 * filename should not be NULL. */ 1214 * filename should not be NULL. */
1200char *concat_path_file(const char *path, const char *filename) FAST_FUNC; 1215char *concat_path_file(const char *path, const char *filename) FAST_FUNC;
1216/* Returns NULL on . and .. */
1201char *concat_subpath_file(const char *path, const char *filename) FAST_FUNC; 1217char *concat_subpath_file(const char *path, const char *filename) FAST_FUNC;
1202const char *bb_basename(const char *name) FAST_FUNC;
1203/* NB: can violate const-ness (similarly to strchr) */
1204char *last_char_is(const char *s, int c) FAST_FUNC;
1205 1218
1206 1219
1207int bb_make_directory(char *path, long mode, int flags) FAST_FUNC; 1220int bb_make_directory(char *path, long mode, int flags) FAST_FUNC;
@@ -1269,14 +1282,19 @@ extern int correct_password(const struct passwd *pw) FAST_FUNC;
1269#endif 1282#endif
1270extern char *pw_encrypt(const char *clear, const char *salt, int cleanup) FAST_FUNC; 1283extern char *pw_encrypt(const char *clear, const char *salt, int cleanup) FAST_FUNC;
1271extern int obscure(const char *old, const char *newval, const struct passwd *pwdp) FAST_FUNC; 1284extern int obscure(const char *old, const char *newval, const struct passwd *pwdp) FAST_FUNC;
1272/* rnd is additional random input. New one is returned. 1285/*
1286 * rnd is additional random input. New one is returned.
1273 * Useful if you call crypt_make_salt many times in a row: 1287 * Useful if you call crypt_make_salt many times in a row:
1274 * rnd = crypt_make_salt(buf1, 4, 0); 1288 * rnd = crypt_make_salt(buf1, 4, 0);
1275 * rnd = crypt_make_salt(buf2, 4, rnd); 1289 * rnd = crypt_make_salt(buf2, 4, rnd);
1276 * rnd = crypt_make_salt(buf3, 4, rnd); 1290 * rnd = crypt_make_salt(buf3, 4, rnd);
1277 * (otherwise we risk having same salt generated) 1291 * (otherwise we risk having same salt generated)
1278 */ 1292 */
1279extern int crypt_make_salt(char *p, int cnt, int rnd) FAST_FUNC; 1293extern int crypt_make_salt(char *p, int cnt /*, int rnd*/) FAST_FUNC;
1294/* "$N$" + sha_salt_16_bytes + NUL */
1295#define MAX_PW_SALT_LEN (3 + 16 + 1)
1296extern char* crypt_make_pw_salt(char p[MAX_PW_SALT_LEN], const char *algo) FAST_FUNC;
1297
1280 1298
1281/* Returns number of lines changed, or -1 on error */ 1299/* Returns number of lines changed, or -1 on error */
1282#if !(ENABLE_FEATURE_ADDUSER_TO_GROUP || ENABLE_FEATURE_DEL_USER_FROM_GROUP) 1300#if !(ENABLE_FEATURE_ADDUSER_TO_GROUP || ENABLE_FEATURE_DEL_USER_FROM_GROUP)