Magellan Linux

Diff of /trunk/mkinitrd-magellan/busybox/include/libbb.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 984 by niro, Sun May 30 11:32:42 2010 UTC revision 1123 by niro, Wed Aug 18 21:56:57 2010 UTC
# Line 20  Line 20 
20  #include <netdb.h>  #include <netdb.h>
21  #include <setjmp.h>  #include <setjmp.h>
22  #include <signal.h>  #include <signal.h>
23    #include <stdint.h>
24  #include <stdio.h>  #include <stdio.h>
25  #include <stdlib.h>  #include <stdlib.h>
26  #include <stdarg.h>  #include <stdarg.h>
# Line 29  Line 30 
30  #include <sys/ioctl.h>  #include <sys/ioctl.h>
31  #include <sys/mman.h>  #include <sys/mman.h>
32  #include <sys/socket.h>  #include <sys/socket.h>
 #if defined __FreeBSD__  
 # include <netinet/in.h>  
 # include <arpa/inet.h>  
 #endif  
33  #include <sys/stat.h>  #include <sys/stat.h>
34  #include <sys/time.h>  #include <sys/time.h>
35  #include <sys/types.h>  #include <sys/types.h>
# Line 43  Line 40 
40  /* Try to pull in PATH_MAX */  /* Try to pull in PATH_MAX */
41  #include <limits.h>  #include <limits.h>
42  #include <sys/param.h>  #include <sys/param.h>
 #ifndef PATH_MAX  
 # define PATH_MAX 256  
 #endif  
   
 #ifndef BUFSIZ  
 # define BUFSIZ 4096  
 #endif  
   
43  #ifdef HAVE_MNTENT_H  #ifdef HAVE_MNTENT_H
44  #include <mntent.h>  #include <mntent.h>
45  #endif  #endif
   
46  #ifdef HAVE_SYS_STATFS_H  #ifdef HAVE_SYS_STATFS_H
47  #include <sys/statfs.h>  #include <sys/statfs.h>
48  #endif  #endif
   
49  #if ENABLE_SELINUX  #if ENABLE_SELINUX
50  #include <selinux/selinux.h>  #include <selinux/selinux.h>
51  #include <selinux/context.h>  #include <selinux/context.h>
52  #include <selinux/flask.h>  #include <selinux/flask.h>
53  #include <selinux/av_permissions.h>  #include <selinux/av_permissions.h>
54  #endif  #endif
   
55  #if ENABLE_LOCALE_SUPPORT  #if ENABLE_LOCALE_SUPPORT
56  # include <locale.h>  # include <locale.h>
57  #else  #else
58  # define setlocale(x,y) ((void)0)  # define setlocale(x,y) ((void)0)
59  #endif  #endif
   
60  #ifdef DMALLOC  #ifdef DMALLOC
61  # include <dmalloc.h>  # include <dmalloc.h>
62  #endif  #endif
   
63  #include <pwd.h>  #include <pwd.h>
64  #include <grp.h>  #include <grp.h>
65  #if ENABLE_FEATURE_SHADOWPASSWDS  #if ENABLE_FEATURE_SHADOWPASSWDS
# Line 86  Line 70 
70  #  include <shadow.h>  #  include <shadow.h>
71  # endif  # endif
72  #endif  #endif
73    #if defined __FreeBSD__
74    # include <netinet/in.h>
75    # include <arpa/inet.h>
76    #elif defined __APPLE__
77    # include <netinet/in.h>
78    #else
79    # include <arpa/inet.h>
80    # if !defined(__socklen_t_defined) && !defined(_SOCKLEN_T_DECLARED)
81    /* We #define socklen_t *after* includes, otherwise we get
82     * typedef redefinition errors from system headers
83     * (in case "is it defined already" detection above failed)
84     */
85    #  define socklen_t bb_socklen_t
86       typedef unsigned socklen_t;
87    # endif
88    #endif
89    
90    
91  /* Some libc's forget to declare these, do it ourself */  /* Some libc's forget to declare these, do it ourself */
92    
# Line 120  struct sysinfo { Line 121  struct sysinfo {
121   char _f[20 - 2 * sizeof(long) - sizeof(int)]; /* Padding: libc5 uses this.. */   char _f[20 - 2 * sizeof(long) - sizeof(int)]; /* Padding: libc5 uses this.. */
122  };  };
123  int sysinfo(struct sysinfo* info);  int sysinfo(struct sysinfo* info);
124    #ifndef PATH_MAX
125    # define PATH_MAX 256
126    #endif
127    #ifndef BUFSIZ
128    # define BUFSIZ 4096
129    #endif
130    
131    
132  /* Make all declarations hidden (-fvisibility flag only affects definitions) */  /* Make all declarations hidden (-fvisibility flag only affects definitions) */
# Line 256  extern void chomp(char *s) FAST_FUNC; Line 263  extern void chomp(char *s) FAST_FUNC;
263  extern void trim(char *s) FAST_FUNC;  extern void trim(char *s) FAST_FUNC;
264  extern char *skip_whitespace(const char *) FAST_FUNC;  extern char *skip_whitespace(const char *) FAST_FUNC;
265  extern char *skip_non_whitespace(const char *) FAST_FUNC;  extern char *skip_non_whitespace(const char *) FAST_FUNC;
266    extern char *skip_dev_pfx(const char *tty_name) FAST_FUNC;
267    
268  extern char *strrstr(const char *haystack, const char *needle) FAST_FUNC;  extern char *strrstr(const char *haystack, const char *needle) FAST_FUNC;
269    
270  //TODO: supply a pointer to char[11] buffer (avoid statics)?  //TODO: supply a pointer to char[11] buffer (avoid statics)?
# Line 332  void xmove_fd(int, int) FAST_FUNC; Line 341  void xmove_fd(int, int) FAST_FUNC;
341  DIR *xopendir(const char *path) FAST_FUNC;  DIR *xopendir(const char *path) FAST_FUNC;
342  DIR *warn_opendir(const char *path) FAST_FUNC;  DIR *warn_opendir(const char *path) FAST_FUNC;
343    
344  /* UNUSED: char *xmalloc_realpath(const char *path) FAST_FUNC RETURNS_MALLOC; */  char *xmalloc_realpath(const char *path) FAST_FUNC RETURNS_MALLOC;
345  char *xmalloc_readlink(const char *path) FAST_FUNC RETURNS_MALLOC;  char *xmalloc_readlink(const char *path) FAST_FUNC RETURNS_MALLOC;
346  char *xmalloc_readlink_or_warn(const char *path) FAST_FUNC RETURNS_MALLOC;  char *xmalloc_readlink_or_warn(const char *path) FAST_FUNC RETURNS_MALLOC;
347  /* !RETURNS_MALLOC: it's a realloc-like function */  /* !RETURNS_MALLOC: it's a realloc-like function */
# Line 399  void xchdir(const char *path) FAST_FUNC; Line 408  void xchdir(const char *path) FAST_FUNC;
408  void xchroot(const char *path) FAST_FUNC;  void xchroot(const char *path) FAST_FUNC;
409  void xsetenv(const char *key, const char *value) FAST_FUNC;  void xsetenv(const char *key, const char *value) FAST_FUNC;
410  void bb_unsetenv(const char *key) FAST_FUNC;  void bb_unsetenv(const char *key) FAST_FUNC;
411    void bb_unsetenv_and_free(char *key) FAST_FUNC;
412  void xunlink(const char *pathname) FAST_FUNC;  void xunlink(const char *pathname) FAST_FUNC;
413  void xstat(const char *pathname, struct stat *buf) FAST_FUNC;  void xstat(const char *pathname, struct stat *buf) FAST_FUNC;
414  int xopen(const char *pathname, int flags) FAST_FUNC;  int xopen(const char *pathname, int flags) FAST_FUNC;
# Line 412  int rename_or_warn(const char *oldpath, Line 422  int rename_or_warn(const char *oldpath,
422  off_t xlseek(int fd, off_t offset, int whence) FAST_FUNC;  off_t xlseek(int fd, off_t offset, int whence) FAST_FUNC;
423  off_t fdlength(int fd) FAST_FUNC;  off_t fdlength(int fd) FAST_FUNC;
424    
425    uoff_t FAST_FUNC get_volume_size_in_bytes(int fd,
426                    const char *override,
427                    unsigned override_units,
428                    int extend);
429    
430  void xpipe(int filedes[2]) FAST_FUNC;  void xpipe(int filedes[2]) FAST_FUNC;
431  /* In this form code with pipes is much more readable */  /* In this form code with pipes is much more readable */
432  struct fd_pair { int rd; int wr; };  struct fd_pair { int rd; int wr; };
# Line 518  int create_and_connect_stream_or_die(con Line 533  int create_and_connect_stream_or_die(con
533  int xconnect_stream(const len_and_sockaddr *lsa) FAST_FUNC;  int xconnect_stream(const len_and_sockaddr *lsa) FAST_FUNC;
534  /* Get local address of bound or accepted socket */  /* Get local address of bound or accepted socket */
535  len_and_sockaddr *get_sock_lsa(int fd) FAST_FUNC RETURNS_MALLOC;  len_and_sockaddr *get_sock_lsa(int fd) FAST_FUNC RETURNS_MALLOC;
536    /* Get remote address of connected or accepted socket */
537    len_and_sockaddr *get_peer_lsa(int fd) FAST_FUNC RETURNS_MALLOC;
538  /* Return malloc'ed len_and_sockaddr with socket address of host:port  /* Return malloc'ed len_and_sockaddr with socket address of host:port
539   * Currently will return IPv4 or IPv6 sockaddrs only   * Currently will return IPv4 or IPv6 sockaddrs only
540   * (depending on host), but in theory nothing prevents e.g.   * (depending on host), but in theory nothing prevents e.g.
# Line 576  char *strncpy_IFNAMSIZ(char *dst, const Line 593  char *strncpy_IFNAMSIZ(char *dst, const
593  /* Guaranteed to NOT be a macro (smallest code). Saves nearly 2k on uclibc.  /* Guaranteed to NOT be a macro (smallest code). Saves nearly 2k on uclibc.
594   * But potentially slow, don't use in one-billion-times loops */   * But potentially slow, don't use in one-billion-times loops */
595  int bb_putchar(int ch) FAST_FUNC;  int bb_putchar(int ch) FAST_FUNC;
596    /* Note: does not use stdio, writes to fd 2 directly */
597    int bb_putchar_stderr(char ch) FAST_FUNC;
598  char *xasprintf(const char *format, ...) __attribute__ ((format(printf, 1, 2))) FAST_FUNC RETURNS_MALLOC;  char *xasprintf(const char *format, ...) __attribute__ ((format(printf, 1, 2))) FAST_FUNC RETURNS_MALLOC;
 /* Prints unprintable chars ch as ^C or M-c to file  
  * (M-c is used only if ch is ORed with PRINTABLE_META),  
  * else it is printed as-is (except for ch = 0x9b) */  
 enum { PRINTABLE_META = 0x100 };  
 void fputc_printable(int ch, FILE *file) FAST_FUNC;  
599  // gcc-4.1.1 still isn't good enough at optimizing it  // gcc-4.1.1 still isn't good enough at optimizing it
600  // (+200 bytes compared to macro)  // (+200 bytes compared to macro)
601  //static ALWAYS_INLINE  //static ALWAYS_INLINE
# Line 594  void fputc_printable(int ch, FILE *file) Line 608  void fputc_printable(int ch, FILE *file)
608  #define NOT_LONE_CHAR(s,c) ((s)[0] != (c) || (s)[1])  #define NOT_LONE_CHAR(s,c) ((s)[0] != (c) || (s)[1])
609  #define DOT_OR_DOTDOT(s) ((s)[0] == '.' && (!(s)[1] || ((s)[1] == '.' && !(s)[2])))  #define DOT_OR_DOTDOT(s) ((s)[0] == '.' && (!(s)[1] || ((s)[1] == '.' && !(s)[2])))
610    
611    typedef struct uni_stat_t {
612     unsigned byte_count;
613     unsigned unicode_count;
614     unsigned unicode_width;
615    } uni_stat_t;
616    /* Returns a string with unprintable chars replaced by '?' or
617     * SUBST_WCHAR. This function is unicode-aware. */
618    const char* FAST_FUNC printable_string(uni_stat_t *stats, const char *str);
619    /* Prints unprintable char ch as ^C or M-c to file
620     * (M-c is used only if ch is ORed with PRINTABLE_META),
621     * else it is printed as-is (except for ch = 0x9b) */
622    enum { PRINTABLE_META = 0x100 };
623    void fputc_printable(int ch, FILE *file) FAST_FUNC;
624    
625  /* dmalloc will redefine these to it's own implementation. It is safe  /* dmalloc will redefine these to it's own implementation. It is safe
626   * to have the prototypes here unconditionally.  */   * to have the prototypes here unconditionally.  */
627  void *malloc_or_warn(size_t size) FAST_FUNC RETURNS_MALLOC;  void *malloc_or_warn(size_t size) FAST_FUNC RETURNS_MALLOC;
# Line 626  extern char *xmalloc_reads(int fd, char Line 654  extern char *xmalloc_reads(int fd, char
654  extern void *xmalloc_read(int fd, size_t *maxsz_p) FAST_FUNC RETURNS_MALLOC;  extern void *xmalloc_read(int fd, size_t *maxsz_p) FAST_FUNC RETURNS_MALLOC;
655  /* Returns NULL if file can't be opened (default max size: INT_MAX - 4095) */  /* Returns NULL if file can't be opened (default max size: INT_MAX - 4095) */
656  extern void *xmalloc_open_read_close(const char *filename, size_t *maxsz_p) FAST_FUNC RETURNS_MALLOC;  extern void *xmalloc_open_read_close(const char *filename, size_t *maxsz_p) FAST_FUNC RETURNS_MALLOC;
657    /* Autodetects gzip/bzip2 formats. fd may be in the middle of the file! */
658    #if ENABLE_FEATURE_SEAMLESS_LZMA \
659     || ENABLE_FEATURE_SEAMLESS_BZ2 \
660     || ENABLE_FEATURE_SEAMLESS_GZ \
661     /* || ENABLE_FEATURE_SEAMLESS_Z */
662    extern void setup_unzip_on_fd(int fd /*, int fail_if_not_detected*/) FAST_FUNC;
663    #else
664    # define setup_unzip_on_fd(...) ((void)0)
665    #endif
666  /* Autodetects .gz etc */  /* Autodetects .gz etc */
667  extern int open_zipped(const char *fname) FAST_FUNC;  extern int open_zipped(const char *fname) FAST_FUNC;
668  extern void *xmalloc_open_zipped_read_close(const char *fname, size_t *maxsz_p) FAST_FUNC RETURNS_MALLOC;  extern void *xmalloc_open_zipped_read_close(const char *fname, size_t *maxsz_p) FAST_FUNC RETURNS_MALLOC;
# Line 638  extern ssize_t safe_write(int fd, const Line 675  extern ssize_t safe_write(int fd, const
675  extern ssize_t full_write(int fd, const void *buf, size_t count) FAST_FUNC;  extern ssize_t full_write(int fd, const void *buf, size_t count) FAST_FUNC;
676  extern void xwrite(int fd, const void *buf, size_t count) FAST_FUNC;  extern void xwrite(int fd, const void *buf, size_t count) FAST_FUNC;
677  extern void xwrite_str(int fd, const char *str) FAST_FUNC;  extern void xwrite_str(int fd, const char *str) FAST_FUNC;
678    extern ssize_t full_write1_str(const char *str) FAST_FUNC;
679    extern ssize_t full_write2_str(const char *str) FAST_FUNC;
680  extern void xopen_xwrite_close(const char* file, const char *str) FAST_FUNC;  extern void xopen_xwrite_close(const char* file, const char *str) FAST_FUNC;
681    
682  /* Close fd, but check for failures (some types of write errors) */  /* Close fd, but check for failures (some types of write errors) */
# Line 713  const char *make_human_readable_str(unsi Line 752  const char *make_human_readable_str(unsi
752   unsigned long block_size, unsigned long display_unit) FAST_FUNC;   unsigned long block_size, unsigned long display_unit) FAST_FUNC;
753  /* Put a string of hex bytes ("1b2e66fe"...), return advanced pointer */  /* Put a string of hex bytes ("1b2e66fe"...), return advanced pointer */
754  char *bin2hex(char *buf, const char *cp, int count) FAST_FUNC;  char *bin2hex(char *buf, const char *cp, int count) FAST_FUNC;
755    /* Reverse */
756    char* hex2bin(char *dst, const char *str, int count) FAST_FUNC;
757    
758  /* Generate a UUID */  /* Generate a UUID */
759  void generate_uuid(uint8_t *buf) FAST_FUNC;  void generate_uuid(uint8_t *buf) FAST_FUNC;
# Line 773  void die_if_bad_username(const char* nam Line 814  void die_if_bad_username(const char* nam
814  #define die_if_bad_username(name) ((void)(name))  #define die_if_bad_username(name) ((void)(name))
815  #endif  #endif
816    
817    #if ENABLE_FEATURE_UTMP
818    void FAST_FUNC write_new_utmp(pid_t pid, int new_type, const char *tty_name, const char *username, const char *hostname);
819    void FAST_FUNC update_utmp(pid_t pid, int new_type, const char *tty_name, const char *username, const char *hostname);
820    #else
821    # define write_new_utmp(pid, new_type, tty_name, username, hostname) ((void)0)
822    # define update_utmp(pid, new_type, tty_name, username, hostname) ((void)0)
823    #endif
824    
825  int execable_file(const char *name) FAST_FUNC;  int execable_file(const char *name) FAST_FUNC;
826  char *find_execable(const char *filename, char **PATHp) FAST_FUNC;  char *find_execable(const char *filename, char **PATHp) FAST_FUNC;
827  int exists_execable(const char *filename) FAST_FUNC;  int exists_execable(const char *filename) FAST_FUNC;
# Line 790  int bb_execvp(const char *file, char *co Line 839  int bb_execvp(const char *file, char *co
839  #define BB_EXECVP(prog,cmd)     execvp(prog,cmd)  #define BB_EXECVP(prog,cmd)     execvp(prog,cmd)
840  #define BB_EXECLP(prog,cmd,...) execlp(prog,cmd, __VA_ARGS__)  #define BB_EXECLP(prog,cmd,...) execlp(prog,cmd, __VA_ARGS__)
841  #endif  #endif
842    int BB_EXECVP_or_die(char **argv) NORETURN FAST_FUNC;
843    
844    /* xvfork() can't be a _function_, return after vfork mangles stack
845     * in the parent. It must be a macro. */
846    #define xvfork() \
847    ({ \
848     pid_t bb__xvfork_pid = vfork(); \
849     if (bb__xvfork_pid < 0) \
850     bb_perror_msg_and_die("vfork"); \
851     bb__xvfork_pid; \
852    })
853    #if BB_MMU
854    pid_t xfork(void) FAST_FUNC;
855    #endif
856    
857  /* NOMMU friendy fork+exec */  /* NOMMU friendy fork+exec: */
858  pid_t spawn(char **argv) FAST_FUNC;  pid_t spawn(char **argv) FAST_FUNC;
859  pid_t xspawn(char **argv) FAST_FUNC;  pid_t xspawn(char **argv) FAST_FUNC;
860    
861  pid_t safe_waitpid(pid_t pid, int *wstat, int options) FAST_FUNC;  pid_t safe_waitpid(pid_t pid, int *wstat, int options) FAST_FUNC;
862  /* Unlike waitpid, waits ONLY for one process.  pid_t wait_any_nohang(int *wstat) FAST_FUNC;
863    /* wait4pid: unlike waitpid, waits ONLY for one process.
864     * Returns sig + 0x180 if child is killed by signal.
865   * It's safe to pass negative 'pids' from failed [v]fork -   * It's safe to pass negative 'pids' from failed [v]fork -
866   * wait4pid will return -1 (and will not clobber [v]fork's errno).   * wait4pid will return -1 (and will not clobber [v]fork's errno).
867   * IOW: rc = wait4pid(spawn(argv));   * IOW: rc = wait4pid(spawn(argv));
868   *      if (rc < 0) bb_perror_msg("%s", argv[0]);   *      if (rc < 0) bb_perror_msg("%s", argv[0]);
869   *      if (rc > 0) bb_error_msg("exit code: %d", rc);   *      if (rc > 0) bb_error_msg("exit code: %d", rc & 0xff);
870   */   */
871  int wait4pid(pid_t pid) FAST_FUNC;  int wait4pid(pid_t pid) FAST_FUNC;
872  pid_t wait_any_nohang(int *wstat) FAST_FUNC;  /* Same as wait4pid(spawn(argv)), but with NOFORK/NOEXEC if configured: */
 /* wait4pid(spawn(argv)) + NOFORK/NOEXEC (if configured) */  
873  int spawn_and_wait(char **argv) FAST_FUNC;  int spawn_and_wait(char **argv) FAST_FUNC;
874  struct nofork_save_area {  struct nofork_save_area {
875   jmp_buf die_jmp;   jmp_buf die_jmp;
# Line 835  int run_nofork_applet_prime(struct nofor Line 899  int run_nofork_applet_prime(struct nofor
899   * Both of the above will redirect fd 0,1,2 to /dev/null and drop ctty   * Both of the above will redirect fd 0,1,2 to /dev/null and drop ctty
900   * (will do setsid()).   * (will do setsid()).
901   *   *
902   * fork_or_rexec(argv) = bare-bones "fork" on MMU,   * fork_or_rexec(argv) = bare-bones fork on MMU,
903   *      "vfork + re-exec ourself" on NOMMU. No fd redirection, no setsid().   *      "vfork + re-exec ourself" on NOMMU. No fd redirection, no setsid().
904   *      On MMU ignores argv.   *      On MMU ignores argv.
905   *   *
# Line 851  enum { Line 915  enum {
915   DAEMON_ONLY_SANITIZE = 8, /* internal use */   DAEMON_ONLY_SANITIZE = 8, /* internal use */
916  };  };
917  #if BB_MMU  #if BB_MMU
   pid_t fork_or_rexec(void) FAST_FUNC;  
918    enum { re_execed = 0 };    enum { re_execed = 0 };
919  # define fork_or_rexec(argv)                fork_or_rexec()  # define fork_or_rexec(argv)                xfork()
920  # define bb_daemonize_or_rexec(flags, argv) bb_daemonize_or_rexec(flags)  # define bb_daemonize_or_rexec(flags, argv) bb_daemonize_or_rexec(flags)
921  # define bb_daemonize(flags)                bb_daemonize_or_rexec(flags, bogus)  # define bb_daemonize(flags)                bb_daemonize_or_rexec(flags, bogus)
922  #else  #else
923      extern bool re_execed;
924    void re_exec(char **argv) NORETURN FAST_FUNC;    void re_exec(char **argv) NORETURN FAST_FUNC;
925    pid_t fork_or_rexec(char **argv) FAST_FUNC;    pid_t fork_or_rexec(char **argv) FAST_FUNC;
   extern bool re_execed;  
926    int  BUG_fork_is_unavailable_on_nommu(void) FAST_FUNC;    int  BUG_fork_is_unavailable_on_nommu(void) FAST_FUNC;
927    int  BUG_daemon_is_unavailable_on_nommu(void) FAST_FUNC;    int  BUG_daemon_is_unavailable_on_nommu(void) FAST_FUNC;
928    void BUG_bb_daemonize_is_unavailable_on_nommu(void) FAST_FUNC;    void BUG_bb_daemonize_is_unavailable_on_nommu(void) FAST_FUNC;
929  # define fork()          BUG_fork_is_unavailable_on_nommu()  # define fork()          BUG_fork_is_unavailable_on_nommu()
930    # define xfork()         BUG_fork_is_unavailable_on_nommu()
931  # define daemon(a,b)     BUG_daemon_is_unavailable_on_nommu()  # define daemon(a,b)     BUG_daemon_is_unavailable_on_nommu()
932  # define bb_daemonize(a) BUG_bb_daemonize_is_unavailable_on_nommu()  # define bb_daemonize(a) BUG_bb_daemonize_is_unavailable_on_nommu()
933  #endif  #endif
# Line 1076  typedef struct parser_t { Line 1140  typedef struct parser_t {
1140  } parser_t;  } parser_t;
1141  parser_t* config_open(const char *filename) FAST_FUNC;  parser_t* config_open(const char *filename) FAST_FUNC;
1142  parser_t* config_open2(const char *filename, FILE* FAST_FUNC (*fopen_func)(const char *path)) FAST_FUNC;  parser_t* config_open2(const char *filename, FILE* FAST_FUNC (*fopen_func)(const char *path)) FAST_FUNC;
1143    /* delims[0] is a comment char (use '\0' to disable), the rest are token delimiters */
1144  int config_read(parser_t *parser, char **tokens, unsigned flags, const char *delims) FAST_FUNC;  int config_read(parser_t *parser, char **tokens, unsigned flags, const char *delims) FAST_FUNC;
1145  #define config_read(parser, tokens, max, min, str, flags) \  #define config_read(parser, tokens, max, min, str, flags) \
1146   config_read(parser, tokens, ((flags) | (((min) & 0xFF) << 8) | ((max) & 0xFF)), str)   config_read(parser, tokens, ((flags) | (((min) & 0xFF) << 8) | ((max) & 0xFF)), str)
# Line 1106  char *bb_simplify_abs_path_inplace(char Line 1171  char *bb_simplify_abs_path_inplace(char
1171  extern void bb_do_delay(int seconds) FAST_FUNC;  extern void bb_do_delay(int seconds) FAST_FUNC;
1172  extern void change_identity(const struct passwd *pw) FAST_FUNC;  extern void change_identity(const struct passwd *pw) FAST_FUNC;
1173  extern void run_shell(const char *shell, int loginshell, const char *command, const char **additional_args) NORETURN FAST_FUNC;  extern void run_shell(const char *shell, int loginshell, const char *command, const char **additional_args) NORETURN FAST_FUNC;
 extern void run_shell(const char *shell, int loginshell, const char *command, const char **additional_args) FAST_FUNC;  
1174  #if ENABLE_SELINUX  #if ENABLE_SELINUX
1175  extern void renew_current_security_context(void) FAST_FUNC;  extern void renew_current_security_context(void) FAST_FUNC;
1176  extern void set_current_security_context(security_context_t sid) FAST_FUNC;  extern void set_current_security_context(security_context_t sid) FAST_FUNC;
# Line 1118  extern void selinux_preserve_fcontext(in Line 1182  extern void selinux_preserve_fcontext(in
1182  #define selinux_preserve_fcontext(fdesc) ((void)0)  #define selinux_preserve_fcontext(fdesc) ((void)0)
1183  #endif  #endif
1184  extern void selinux_or_die(void) FAST_FUNC;  extern void selinux_or_die(void) FAST_FUNC;
 extern int restricted_shell(const char *shell) FAST_FUNC;  
1185    
1186  /* setup_environment:  /* setup_environment:
1187     * if chdir pw->pw_dir: ok: else if to_tmp == 1: goto /tmp else: goto / or die
1188   * if clear_env = 1: cd(pw->pw_dir), clear environment, then set   * if clear_env = 1: cd(pw->pw_dir), clear environment, then set
1189   *   TERM=(old value)   *   TERM=(old value)
1190   *   USER=pw->pw_name, LOGNAME=pw->pw_name   *   USER=pw->pw_name, LOGNAME=pw->pw_name
# Line 1134  extern int restricted_shell(const char * Line 1198  extern int restricted_shell(const char *
1198   *   SHELL=shell   *   SHELL=shell
1199   * else does nothing   * else does nothing
1200   */   */
1201  extern void setup_environment(const char *shell, int clear_env, int change_env, const struct passwd *pw) FAST_FUNC;  #define SETUP_ENV_CHANGEENV (1 << 0)
1202    #define SETUP_ENV_CLEARENV  (1 << 1)
1203    #define SETUP_ENV_TO_TMP    (1 << 2)
1204    extern void setup_environment(const char *shell, int flags, const struct passwd *pw) FAST_FUNC;
1205  extern int correct_password(const struct passwd *pw) FAST_FUNC;  extern int correct_password(const struct passwd *pw) FAST_FUNC;
1206  /* Returns a malloced string */  /* Returns a malloced string */
1207  #if !ENABLE_USE_BB_CRYPT  #if !ENABLE_USE_BB_CRYPT
# Line 1251  enum { Line 1318  enum {
1318   * Return of -1 means EOF or error (errno == 0 on EOF).   * Return of -1 means EOF or error (errno == 0 on EOF).
1319   * buffer[0] is used as a counter of buffered chars and must be 0   * buffer[0] is used as a counter of buffered chars and must be 0
1320   * on first call.   * on first call.
1321     * timeout:
1322     * -2: do not poll for input;
1323     * -1: poll(-1) (i.e. block);
1324     * >=0: poll for TIMEOUT milliseconds, return -1/EAGAIN on timeout
1325   */   */
1326  int64_t read_key(int fd, char *buffer) FAST_FUNC;  int64_t read_key(int fd, char *buffer, int timeout) FAST_FUNC;
1327    void read_key_ungets(char *buffer, const char *str, unsigned len) FAST_FUNC;
1328    
1329    
1330  #if ENABLE_FEATURE_EDITING  #if ENABLE_FEATURE_EDITING
# Line 1466  typedef struct bb_progress_t { Line 1538  typedef struct bb_progress_t {
1538   off_t lastsize;   off_t lastsize;
1539   unsigned lastupdate_sec;   unsigned lastupdate_sec;
1540   unsigned start_sec;   unsigned start_sec;
1541     smallint inited;
1542  } bb_progress_t;  } bb_progress_t;
1543    
1544  void bb_progress_init(bb_progress_t *p) FAST_FUNC;  void bb_progress_init(bb_progress_t *p) FAST_FUNC;
# Line 1533  extern struct globals *const ptr_to_glob Line 1606  extern struct globals *const ptr_to_glob
1606   * use bb_default_login_shell and following defines.   * use bb_default_login_shell and following defines.
1607   * If you change LIBBB_DEFAULT_LOGIN_SHELL,   * If you change LIBBB_DEFAULT_LOGIN_SHELL,
1608   * don't forget to change increment constant. */   * don't forget to change increment constant. */
1609  #define LIBBB_DEFAULT_LOGIN_SHELL      "-/bin/sh"  #define LIBBB_DEFAULT_LOGIN_SHELL  "-/bin/sh"
1610  extern const char bb_default_login_shell[];  extern const char bb_default_login_shell[];
1611  /* "/bin/sh" */  /* "/bin/sh" */
1612  #define DEFAULT_SHELL     (bb_default_login_shell+1)  #define DEFAULT_SHELL              (bb_default_login_shell+1)
1613  /* "sh" */  /* "sh" */
1614  #define DEFAULT_SHELL_SHORT_NAME     (bb_default_login_shell+6)  #define DEFAULT_SHELL_SHORT_NAME   (bb_default_login_shell+6)
1615    
1616  #if ENABLE_FEATURE_DEVFS  #if ENABLE_FEATURE_DEVFS
1617  # define CURRENT_VC "/dev/vc/0"  # define CURRENT_VC "/dev/vc/0"
# Line 1547  extern const char bb_default_login_shell Line 1620  extern const char bb_default_login_shell
1620  # define VC_3 "/dev/vc/3"  # define VC_3 "/dev/vc/3"
1621  # define VC_4 "/dev/vc/4"  # define VC_4 "/dev/vc/4"
1622  # define VC_5 "/dev/vc/5"  # define VC_5 "/dev/vc/5"
1623  #if defined(__sh__) || defined(__H8300H__) || defined(__H8300S__)  # if defined(__sh__) || defined(__H8300H__) || defined(__H8300S__)
1624  /* Yes, this sucks, but both SH (including sh64) and H8 have a SCI(F) for their  /* Yes, this sucks, but both SH (including sh64) and H8 have a SCI(F) for their
1625     respective serial ports .. as such, we can't use the common device paths for     respective serial ports .. as such, we can't use the common device paths for
1626     these. -- PFM */     these. -- PFM */
1627  #  define SC_0 "/dev/ttsc/0"  #  define SC_0 "/dev/ttsc/0"
1628  #  define SC_1 "/dev/ttsc/1"  #  define SC_1 "/dev/ttsc/1"
1629  #  define SC_FORMAT "/dev/ttsc/%d"  #  define SC_FORMAT "/dev/ttsc/%d"
1630  #else  # else
1631  #  define SC_0 "/dev/tts/0"  #  define SC_0 "/dev/tts/0"
1632  #  define SC_1 "/dev/tts/1"  #  define SC_1 "/dev/tts/1"
1633  #  define SC_FORMAT "/dev/tts/%d"  #  define SC_FORMAT "/dev/tts/%d"
1634  #endif  # endif
1635  # define VC_FORMAT "/dev/vc/%d"  # define VC_FORMAT "/dev/vc/%d"
1636  # define LOOP_FORMAT "/dev/loop/%d"  # define LOOP_FORMAT "/dev/loop/%d"
1637  # define LOOP_NAMESIZE (sizeof("/dev/loop/") + sizeof(int)*3 + 1)  # define LOOP_NAMESIZE (sizeof("/dev/loop/") + sizeof(int)*3 + 1)
# Line 1571  extern const char bb_default_login_shell Line 1644  extern const char bb_default_login_shell
1644  # define VC_3 "/dev/tty3"  # define VC_3 "/dev/tty3"
1645  # define VC_4 "/dev/tty4"  # define VC_4 "/dev/tty4"
1646  # define VC_5 "/dev/tty5"  # define VC_5 "/dev/tty5"
1647  #if defined(__sh__) || defined(__H8300H__) || defined(__H8300S__)  # if defined(__sh__) || defined(__H8300H__) || defined(__H8300S__)
1648  #  define SC_0 "/dev/ttySC0"  #  define SC_0 "/dev/ttySC0"
1649  #  define SC_1 "/dev/ttySC1"  #  define SC_1 "/dev/ttySC1"
1650  #  define SC_FORMAT "/dev/ttySC%d"  #  define SC_FORMAT "/dev/ttySC%d"
1651  #else  # else
1652  #  define SC_0 "/dev/ttyS0"  #  define SC_0 "/dev/ttyS0"
1653  #  define SC_1 "/dev/ttyS1"  #  define SC_1 "/dev/ttyS1"
1654  #  define SC_FORMAT "/dev/ttyS%d"  #  define SC_FORMAT "/dev/ttyS%d"
1655  #endif  # endif
1656  # define VC_FORMAT "/dev/tty%d"  # define VC_FORMAT "/dev/tty%d"
1657  # define LOOP_FORMAT "/dev/loop%d"  # define LOOP_FORMAT "/dev/loop%d"
1658  # define LOOP_NAMESIZE (sizeof("/dev/loop") + sizeof(int)*3 + 1)  # define LOOP_NAMESIZE (sizeof("/dev/loop") + sizeof(int)*3 + 1)

Legend:
Removed from v.984  
changed lines
  Added in v.1123