X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=lib%2Flib.h;h=0b93bde9b6b43db151f1b786f2d5524d49f6eb94;hb=2457d26b6dc10554b29a1ef13faf943f7fc574ef;hp=61a1975fb4938fe699b80b8dca2b271d4dd9943b;hpb=5aa757651911bc3395b9317e55d8685fad7abe73;p=android-x86%2Fexternal-toybox.git diff --git a/lib/lib.h b/lib/lib.h index 61a1975f..0b93bde9 100644 --- a/lib/lib.h +++ b/lib/lib.h @@ -73,6 +73,8 @@ void get_optflags(void); #define DIRTREE_SHUTUP 16 // Breadth first traversal, conserves filehandles at the expense of memory #define DIRTREE_BREADTH 32 +// skip non-numeric entries +#define DIRTREE_PROC 64 // Don't look at any more files in this directory. #define DIRTREE_ABORT 256 @@ -113,6 +115,7 @@ void xstrncpy(char *dest, char *src, size_t size); void xstrncat(char *dest, char *src, size_t size); void _xexit(void) noreturn; void xexit(void) noreturn; +void *xmmap(void *addr, size_t length, int prot, int flags, int fd, off_t off); void *xmalloc(size_t size); void *xzalloc(size_t size); void *xrealloc(void *ptr, size_t size); @@ -128,7 +131,7 @@ void xexec(char **argv); pid_t xpopen_both(char **argv, int *pipes); int xwaitpid(pid_t pid); int xpclose_both(pid_t pid, int *pipes); -pid_t xpopen(char **argv, int *pipe, int stdout); +pid_t xpopen(char **argv, int *pipe, int isstdout); pid_t xpclose(pid_t pid, int pipe); int xrun(char **argv); int xpspawn(char **argv, int*pipes); @@ -190,6 +193,7 @@ struct string_list **splitpath(char *path, struct string_list **list); char *readfileat(int dirfd, char *name, char *buf, off_t *len); char *readfile(char *name, char *buf, off_t len); void msleep(long miliseconds); +int highest_bit(unsigned long l); int64_t peek_le(void *ptr, unsigned size); int64_t peek_be(void *ptr, unsigned size); int64_t peek(void *ptr, unsigned size); @@ -204,12 +208,13 @@ char *strlower(char *s); char *strafter(char *haystack, char *needle); char *chomp(char *s); int unescape(char c); +char *strend(char *str, char *suffix); int strstart(char **a, char *b); off_t fdlength(int fd); void loopfiles_rw(char **argv, int flags, int permissions, void (*function)(int fd, char *name)); void loopfiles(char **argv, void (*function)(int fd, char *name)); -void xsendfile(int in, int out); +long long xsendfile(int in, int out); int wfchmodat(int rc, char *name, mode_t mode); int copy_tempfile(int fdin, char *name, char **tempname); void delete_tempfile(int fdin, int fdout, char **tempname); @@ -320,7 +325,7 @@ void mode_to_string(mode_t mode, char *buf); char *getbasename(char *name); void names_to_pid(char **names, int (*callback)(pid_t pid, char *name)); -pid_t xvforkwrap(pid_t pid); +pid_t __attribute__((returns_twice)) xvforkwrap(pid_t pid); #define XVFORK() xvforkwrap(vfork()) // Wrapper to make xfuncs() return (via longjmp) instead of exiting. @@ -337,5 +342,8 @@ pid_t xvforkwrap(pid_t pid); // Wrapper that discards true/false "did it exit" value. #define NOEXIT(x) WOULD_EXIT(_noexit_res, x) +#define minof(a, b) ({typeof(a) aa = (a); typeof(b) bb = (b); aabb ? aa : bb;}) + // Functions in need of further review/cleanup #include "lib/pending.h"