#include <sys/types.h>
#include <sys/stat.h>
#include <termios.h>
+#include <dirent.h>
#include <stdint.h>
+#include <netinet/in.h>
#include <netdb.h>
#include <features.h>
#define MAX(a,b) (((a)>(b))?(a):(b))
#endif
+/* buffer allocation schemes */
+#ifdef CONFIG_FEATURE_BUFFERS_GO_ON_STACK
+#define RESERVE_CONFIG_BUFFER(buffer,len) char buffer[len]
+#define RESERVE_CONFIG_UBUFFER(buffer,len) unsigned char buffer[len]
+#define RELEASE_CONFIG_BUFFER(buffer) ((void)0)
+#else
+#ifdef CONFIG_FEATURE_BUFFERS_GO_IN_BSS
+#define RESERVE_CONFIG_BUFFER(buffer,len) static char buffer[len]
+#define RESERVE_CONFIG_UBUFFER(buffer,len) static unsigned char buffer[len]
+#define RELEASE_CONFIG_BUFFER(buffer) ((void)0)
+#else
+#define RESERVE_CONFIG_BUFFER(buffer,len) char *buffer=xmalloc(len)
+#define RESERVE_CONFIG_UBUFFER(buffer,len) unsigned char *buffer=xmalloc(len)
+#define RELEASE_CONFIG_BUFFER(buffer) free (buffer)
+#endif
+#endif
+
+
extern void bb_show_usage(void) ATTRIBUTE_NORETURN ATTRIBUTE_EXTERNALLY_VISIBLE;
extern void bb_error_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
extern void bb_error_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
extern const char *bb_mode_string(int mode);
extern int is_directory(const char *name, int followLinks, struct stat *statBuf);
+extern DIR *bb_opendir(const char *path);
+extern DIR *bb_xopendir(const char *path);
extern int remove_file(const char *path, int flags);
extern int copy_file(const char *source, const char *dest, int flags);
extern int bb_fclose_nonstdin(FILE *f);
extern void bb_fflush_stdout_and_exit(int retval) ATTRIBUTE_NORETURN;
+extern void xstat(const char *filename, struct stat *buf);
+extern int bb_xsocket(int domain, int type, int protocol);
+extern void bb_xdaemon(int nochdir, int noclose);
+extern void bb_xbind(int sockfd, struct sockaddr *my_addr, socklen_t addrlen);
+extern void bb_xlisten(int s, int backlog);
+extern void bb_xchdir(const char *path);
+
#define BB_GETOPT_ERROR 0x80000000UL
extern const char *bb_opt_complementally;
extern const struct option *bb_applet_long_options;
int nfsmount(const char *spec, const char *node, int *flags,
char **mount_opts, int running_bg);
-/* Include our own copy of struct sysinfo to avoid binary compatability
+/* Include our own copy of struct sysinfo to avoid binary compatibility
* problems with Linux 2.4, which changed things. Grumble, grumble. */
struct sysinfo {
long uptime; /* Seconds since boot */
void add_to_ino_dev_hashtable(const struct stat *statbuf, const char *name);
void reset_ino_dev_hashtable(void);
-/* Stupid gcc always includes its own builtin strlen()... */
-extern size_t bb_strlen(const char *string);
-#ifndef BB_STRLEN_IMPLEMENTATION
-#define strlen(x) bb_strlen(x)
-#endif
-
char *bb_xasprintf(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
#define FAIL_DELAY 3
extern int obscure(const char *old, const char *newval, const struct passwd *pwdp);
extern int bb_xopen(const char *pathname, int flags);
+extern int bb_xopen3(const char *pathname, int flags, int mode);
extern ssize_t bb_xread(int fd, void *buf, size_t count);
extern void bb_xread_all(int fd, void *buf, size_t count);
extern unsigned char bb_xread_char(int fd);
extern void print_login_issue(const char *issue_file, const char *tty);
extern void print_login_prompt(void);
+#if defined(__uClinux__)
extern void vfork_daemon_rexec(int nochdir, int noclose,
int argc, char **argv, char *foreground_opt);
+#endif
+
extern int get_terminal_width_height(int fd, int *width, int *height);
extern unsigned long get_ug_id(const char *s, long (*__bb_getxxnam)(const char *));
void md5_hash(const void *data, size_t length, md5_ctx_t *ctx);
void *md5_end(void *resbuf, md5_ctx_t *ctx);
+extern uint32_t *bb_crc32_filltable (int endian);
+
/* busybox.h will include dmalloc later for us, else include it here. */
#if !defined _BB_INTERNAL_H_ && defined DMALLOC
#include <dmalloc.h>