- patch from Denis Vlasenko to add and use bb_xsocket() and to use
[oweals/busybox.git] / include / libbb.h
index bc3fa59908be126d062ba4bcb5daebb66ad83de0..c031f28415af71f90f9477a550048b8dcd602671 100644 (file)
 #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)));
@@ -79,6 +99,8 @@ extern int bb_echo(int argc, char** argv);
 
 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);
@@ -122,6 +144,9 @@ extern FILE *bb_xfopen(const char *path, const char *mode);
 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);
+
 #define BB_GETOPT_ERROR 0x80000000UL
 extern const char *bb_opt_complementally;
 extern const struct option *bb_applet_long_options;
@@ -216,7 +241,7 @@ extern int vdprintf(int d, const char *format, va_list ap);
 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 */
@@ -459,8 +484,11 @@ extern void llist_free(llist_t *elm);
 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 *));
 
@@ -488,6 +516,8 @@ void md5_begin(md5_ctx_t *ctx);
 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>