OSDN Git Service

Build vendor toybox unconditionally. am: 3829236617 am: cb54b3a2cf am: 4dfba4ea3a
[android-x86/external-toybox.git] / lib / lib.h
index 69692b7..0b93bde 100644 (file)
--- 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
 
@@ -88,6 +90,7 @@ struct dirtree {
   char name[];
 };
 
+int isdotdot(char *name);
 struct dirtree *dirtree_add_node(struct dirtree *p, char *name, int flags);
 char *dirtree_path(struct dirtree *node, int *plen);
 int dirtree_notdotdot(struct dirtree *catch);
@@ -112,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);
@@ -127,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);
@@ -189,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);
@@ -203,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);
@@ -281,6 +287,7 @@ void xsetsockopt(int fd, int level, int opt, void *val, socklen_t len);
 int xconnect(char *host, char *port, int family, int socktype, int protocol,
   int flags);
 int xpoll(struct pollfd *fds, int nfds, int timeout);
+int pollinate(int in1, int in2, int out1, int out2, int timeout, int shutdown_timeout);
 
 // password.c
 int get_salt(char *salt, char * algo);
@@ -318,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.
@@ -335,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); aa<bb ? aa : bb;})
+#define maxof(a, b) ({typeof(a) aa = (a); typeof(b) bb = (b); aa>bb ? aa : bb;})
+
 // Functions in need of further review/cleanup
 #include "lib/pending.h"