#include "Config.h"
+#include <stdio.h>
+#include <stdarg.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+
#ifdef DMALLOC
#include "dmalloc.h"
#endif
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <unistd.h>
-#include <errno.h>
-#include <sys/stat.h>
-#include <sys/param.h>
-#include <mntent.h>
-#include <regex.h>
-/* for the _syscall() macros */
-#include <sys/syscall.h>
-#include <linux/unistd.h>
+#include <features.h>
+/* Stupid libc doesn't have a reliable way for use to know
+ * that libc5 is being used. Assume this is good enough */
+#if ! defined __GLIBC__ && ! defined __UCLIBC__
+/* libc5 doesn't define socklen_t */
+typedef unsigned int socklen_t;
+#endif
/* Some useful definitions */
#endif
-/* I don't like nested includes, but the string and io functions are used
- * too often
- */
-#include <stdio.h>
-#if !defined(NO_STRING_H) || defined(STDC_HEADERS)
-# include <string.h>
-# if !defined(STDC_HEADERS) && !defined(NO_MEMORY_H) && !defined(__GNUC__)
-# include <memory.h>
-# endif
-# define memzero(s, n) memset ((void *)(s), 0, (n))
-#else
-# include <strings.h>
-# define strchr index
-# define strrchr rindex
-# define memcpy(d, s, n) bcopy((s), (d), (n))
-# define memcmp(s1, s2, n) bcmp((s1), (s2), (n))
-# define memzero(s, n) bzero((s), (n))
-#endif
-
-
enum Location {
_BB_DIR_ROOT = 0,
_BB_DIR_BIN,
const char* name;
int (*main)(int argc, char** argv);
enum Location location;
- const char* usage;
};
/* From busybox.c */
extern const struct BB_applet applets[];
#undef PROTOTYPES
extern const char *applet_name;
-extern int applet_name_compare(const void *x, const void *y);
-extern void usage(const char *usage) __attribute__ ((noreturn));
-extern void error_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
-extern void error_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
-extern void perror_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
-extern void perror_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
+extern void show_usage(void) __attribute__ ((noreturn));
+extern void error_msg(const char *s, ...);
+extern void error_msg_and_die(const char *s, ...) __attribute__ ((noreturn));
+extern void perror_msg(const char *s, ...);
+extern void perror_msg_and_die(const char *s, ...) __attribute__ ((noreturn));
const char *mode_string(int mode);
const char *time_string(time_t timeVal);
extern int print_file_by_name(char *filename);
extern char process_escape_sequence(char **ptr);
extern char *get_last_path_component(char *path);
-extern void xregcomp(regex_t *preg, const char *regex, int cflags);
extern FILE *wfopen(const char *path, const char *mode);
extern FILE *xfopen(const char *path, const char *mode);
+extern void chomp(char *s);
+extern void trim(char *s);
+extern struct BB_applet *find_applet_by_name(const char *name);
+void run_applet_by_name(const char *name, int argc, char **argv);
-#ifndef DMALLOC
+#ifndef DMALLOC
extern void *xmalloc (size_t size);
extern void *xrealloc(void *old, size_t size);
extern void *xcalloc(size_t nmemb, size_t size);
extern char *xstrdup (const char *s);
#endif
extern char *xstrndup (const char *s, int n);
+extern char * safe_strncpy(char *dst, const char *src, size_t size);
struct suffix_mult {
char *suffix;
int mult;
};
-extern unsigned long parse_number(const char *numstr, struct suffix_mult *suffixes);
+extern unsigned long parse_number(const char *numstr,
+ const struct suffix_mult *suffixes);
/* These parse entries in /etc/passwd and /etc/group. This is desirable
* for BusyBox since we want to avoid using the glibc NSS stuff, which
* increases target size and is often not needed embedded systems. */
-extern long my_getpwnam(char *name);
-extern long my_getgrnam(char *name);
+extern long my_getpwnam(const char *name);
+extern long my_getgrnam(const char *name);
extern void my_getpwuid(char *name, long uid);
extern void my_getgrgid(char *group, long gid);
-extern long my_getpwnamegid(char *name);
+extern long my_getpwnamegid(const char *name);
extern int device_open(char *device, int mode);
#define RB_POWER_OFF 0x4321fedc
#endif
+#if defined(BB_KLOGD) || defined(BB_LOGGER)
+void syslog_msg_with_name(const char *name, int facility, int pri, const char *msg);
+void syslog_msg(int facility, int pri, const char *msg);
+#endif
+
/* Include our own copy of struct sysinfo to avoid binary compatability
* problems with Linux 2.4, which changed things. Grumble, grumble. */
struct sysinfo {
#define isclr(a,i) (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
#endif
+#ifdef BB_FEATURE_HUMAN_READABLE
+const char *make_human_readable_str(unsigned long val, unsigned long hr);
+#endif
+enum {
+ KILOBYTE = 1024,
+ MEGABYTE = (KILOBYTE*1024),
+ GIGABYTE = (MEGABYTE*1024)
+};
+
+#ifdef BB_FEATURE_BUFFERS_GO_ON_STACK
+#define RESERVE_BB_BUFFER(buffer,len) char buffer[len]
+#define RESERVE_BB_UBUFFER(buffer,len) unsigned char buffer[len]
+#else
+#define RESERVE_BB_BUFFER(buffer,len) char *buffer=xmalloc(len)
+#define RESERVE_BB_UBUFFER(buffer,len) unsigned char *buffer=xmalloc(len)
+#endif
+
+#if defined(BB_FEATURE_RM_INTERACTIVE) && defined(BB_RM)
+int ask_confirmation(void);
+#endif
+
#endif /* _BB_INTERNAL_H_ */