aboutsummaryrefslogtreecommitdiff
path: root/include/libbb.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/libbb.h')
-rw-r--r--include/libbb.h46
1 files changed, 43 insertions, 3 deletions
diff --git a/include/libbb.h b/include/libbb.h
index 9aba71949..61ceb6085 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -138,6 +138,12 @@
138# include <arpa/inet.h> 138# include <arpa/inet.h>
139#elif defined __APPLE__ 139#elif defined __APPLE__
140# include <netinet/in.h> 140# include <netinet/in.h>
141#elif ENABLE_PLATFORM_MINGW32
142# ifndef WINVER
143# define WINVER 0x0501
144# endif
145# include <winsock2.h>
146# include <ws2tcpip.h>
141#else 147#else
142# include <arpa/inet.h> 148# include <arpa/inet.h>
143//This breaks on bionic: 149//This breaks on bionic:
@@ -166,7 +172,9 @@
166 172
167/* Some libc's forget to declare these, do it ourself */ 173/* Some libc's forget to declare these, do it ourself */
168 174
175#if !ENABLE_PLATFORM_MINGW32
169extern char **environ; 176extern char **environ;
177#endif
170/* klogctl is in libc's klog.h, but we cheat and not #include that */ 178/* klogctl is in libc's klog.h, but we cheat and not #include that */
171int klogctl(int type, char *b, int len); 179int klogctl(int type, char *b, int len);
172#ifndef PATH_MAX 180#ifndef PATH_MAX
@@ -176,6 +184,9 @@ int klogctl(int type, char *b, int len);
176# define BUFSIZ 4096 184# define BUFSIZ 4096
177#endif 185#endif
178 186
187#if ENABLE_PLATFORM_MINGW32
188# include "mingw.h"
189#endif
179 190
180/* Busybox does not use threads, we can speed up stdio. */ 191/* Busybox does not use threads, we can speed up stdio. */
181#ifdef HAVE_UNLOCKED_STDIO 192#ifdef HAVE_UNLOCKED_STDIO
@@ -238,6 +249,13 @@ PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN
238 : ((T)1 << (sizeof(T)*8-1)) \ 249 : ((T)1 << (sizeof(T)*8-1)) \
239 ) 250 )
240 251
252#if ENABLE_PLATFORM_MINGW32 && \
253 (!defined(__USE_MINGW_ANSI_STDIO) || !__USE_MINGW_ANSI_STDIO)
254#define LL_FMT "I64"
255#else
256#define LL_FMT "ll"
257#endif
258
241/* Large file support */ 259/* Large file support */
242/* Note that CONFIG_LFS=y forces bbox to be built with all common ops 260/* Note that CONFIG_LFS=y forces bbox to be built with all common ops
243 * (stat, lseek etc) mapped to "largefile" variants by libc. 261 * (stat, lseek etc) mapped to "largefile" variants by libc.
@@ -263,7 +281,7 @@ typedef unsigned long long uoff_t;
263# define XATOOFF(a) xatoull_range((a), 0, LLONG_MAX) 281# define XATOOFF(a) xatoull_range((a), 0, LLONG_MAX)
264# define BB_STRTOOFF bb_strtoull 282# define BB_STRTOOFF bb_strtoull
265# define STRTOOFF strtoull 283# define STRTOOFF strtoull
266# define OFF_FMT "ll" 284# define OFF_FMT LL_FMT
267# endif 285# endif
268#else 286#else
269/* CONFIG_LFS is off */ 287/* CONFIG_LFS is off */
@@ -510,6 +528,7 @@ enum {
510 + (1LL << SIGUSR2) 528 + (1LL << SIGUSR2)
511 + 0), 529 + 0),
512}; 530};
531#if !ENABLE_PLATFORM_MINGW32
513void bb_signals(int sigs, void (*f)(int)) FAST_FUNC; 532void bb_signals(int sigs, void (*f)(int)) FAST_FUNC;
514/* Unlike signal() and bb_signals, sets handler with sigaction() 533/* Unlike signal() and bb_signals, sets handler with sigaction()
515 * and in a way that while signal handler is run, no other signals 534 * and in a way that while signal handler is run, no other signals
@@ -527,6 +546,10 @@ void sig_unblock(int sig) FAST_FUNC;
527int sigaction_set(int sig, const struct sigaction *act) FAST_FUNC; 546int sigaction_set(int sig, const struct sigaction *act) FAST_FUNC;
528/* SIG_BLOCK/SIG_UNBLOCK all signals: */ 547/* SIG_BLOCK/SIG_UNBLOCK all signals: */
529int sigprocmask_allsigs(int how) FAST_FUNC; 548int sigprocmask_allsigs(int how) FAST_FUNC;
549#else
550#define bb_signals(s, f)
551#define kill_myself_with_sig(s)
552#endif
530/* Standard handler which just records signo */ 553/* Standard handler which just records signo */
531extern smallint bb_got_signal; 554extern smallint bb_got_signal;
532void record_signo(int signo); /* not FAST_FUNC! */ 555void record_signo(int signo); /* not FAST_FUNC! */
@@ -606,7 +629,7 @@ char *strftime_YYYYMMDDHHMMSS(char *buf, unsigned len, time_t *tp) FAST_FUNC;
606int xsocket(int domain, int type, int protocol) FAST_FUNC; 629int xsocket(int domain, int type, int protocol) FAST_FUNC;
607void xbind(int sockfd, struct sockaddr *my_addr, socklen_t addrlen) FAST_FUNC; 630void xbind(int sockfd, struct sockaddr *my_addr, socklen_t addrlen) FAST_FUNC;
608void xlisten(int s, int backlog) FAST_FUNC; 631void xlisten(int s, int backlog) FAST_FUNC;
609void xconnect(int s, const struct sockaddr *s_addr, socklen_t addrlen) FAST_FUNC; 632void xconnect(int s, const struct sockaddr *saddr, socklen_t addrlen) FAST_FUNC;
610ssize_t xsendto(int s, const void *buf, size_t len, const struct sockaddr *to, 633ssize_t xsendto(int s, const void *buf, size_t len, const struct sockaddr *to,
611 socklen_t tolen) FAST_FUNC; 634 socklen_t tolen) FAST_FUNC;
612 635
@@ -941,6 +964,9 @@ char *safe_gethostname(void) FAST_FUNC;
941char* str_tolower(char *str) FAST_FUNC; 964char* str_tolower(char *str) FAST_FUNC;
942 965
943char *utoa(unsigned n) FAST_FUNC; 966char *utoa(unsigned n) FAST_FUNC;
967#if ENABLE_PLATFORM_MINGW32
968# define itoa bb_itoa
969#endif
944char *itoa(int n) FAST_FUNC; 970char *itoa(int n) FAST_FUNC;
945/* Returns a pointer past the formatted number, does NOT null-terminate */ 971/* Returns a pointer past the formatted number, does NOT null-terminate */
946char *utoa_to_buf(unsigned n, char *buf, unsigned buflen) FAST_FUNC; 972char *utoa_to_buf(unsigned n, char *buf, unsigned buflen) FAST_FUNC;
@@ -1116,6 +1142,9 @@ int run_nofork_applet(int applet_no, char **argv) FAST_FUNC;
1116extern int find_applet_by_name(const char *name) FAST_FUNC; 1142extern int find_applet_by_name(const char *name) FAST_FUNC;
1117extern void run_applet_no_and_exit(int a, const char *name, char **argv) NORETURN FAST_FUNC; 1143extern void run_applet_no_and_exit(int a, const char *name, char **argv) NORETURN FAST_FUNC;
1118#endif 1144#endif
1145#if ENABLE_PLATFORM_MINGW32 && ENABLE_FEATURE_SH_NOFORK
1146extern int long_running_applet(int applet_no) FAST_FUNC;
1147#endif
1119 1148
1120/* Helpers for daemonization. 1149/* Helpers for daemonization.
1121 * 1150 *
@@ -1199,7 +1228,7 @@ extern uint32_t getopt32(char **argv, const char *applet_opts, ...) FAST_FUNC;
1199 * By ~2008, OpenBSD 3.4 was changed to survive glibc-like optind = 0 1228 * By ~2008, OpenBSD 3.4 was changed to survive glibc-like optind = 0
1200 * (to interpret it as if optreset was set). 1229 * (to interpret it as if optreset was set).
1201 */ 1230 */
1202#ifdef __GLIBC__ 1231#if defined(__GLIBC__) || ENABLE_PLATFORM_MINGW32
1203#define GETOPT_RESET() (optind = 0) 1232#define GETOPT_RESET() (optind = 0)
1204#else /* BSD style */ 1233#else /* BSD style */
1205#define GETOPT_RESET() (optind = 1) 1234#define GETOPT_RESET() (optind = 1)
@@ -1776,6 +1805,9 @@ typedef struct procps_status_t {
1776#if ENABLE_FEATURE_TOP_SMP_PROCESS 1805#if ENABLE_FEATURE_TOP_SMP_PROCESS
1777 int last_seen_on_cpu; 1806 int last_seen_on_cpu;
1778#endif 1807#endif
1808#if ENABLE_PLATFORM_MINGW32
1809 HANDLE snapshot;
1810#endif
1779} procps_status_t; 1811} procps_status_t;
1780/* flag bits for procps_scan(xx, flags) calls */ 1812/* flag bits for procps_scan(xx, flags) calls */
1781enum { 1813enum {
@@ -1814,7 +1846,11 @@ void free_procps_scan(procps_status_t* sp) FAST_FUNC;
1814procps_status_t* procps_scan(procps_status_t* sp, int flags) FAST_FUNC; 1846procps_status_t* procps_scan(procps_status_t* sp, int flags) FAST_FUNC;
1815/* Format cmdline (up to col chars) into char buf[size] */ 1847/* Format cmdline (up to col chars) into char buf[size] */
1816/* Puts [comm] if cmdline is empty (-> process is a kernel thread) */ 1848/* Puts [comm] if cmdline is empty (-> process is a kernel thread) */
1849#if !ENABLE_PLATFORM_MINGW32
1817void read_cmdline(char *buf, int size, unsigned pid, const char *comm) FAST_FUNC; 1850void read_cmdline(char *buf, int size, unsigned pid, const char *comm) FAST_FUNC;
1851#else
1852#define read_cmdline(buf, size, pid, comm) snprintf(buf, size, "[%s]", comm)
1853#endif
1818pid_t *find_pid_by_name(const char* procName) FAST_FUNC; 1854pid_t *find_pid_by_name(const char* procName) FAST_FUNC;
1819pid_t *pidlist_reverse(pid_t *pidList) FAST_FUNC; 1855pid_t *pidlist_reverse(pid_t *pidList) FAST_FUNC;
1820int starts_with_cpu(const char *str) FAST_FUNC; 1856int starts_with_cpu(const char *str) FAST_FUNC;
@@ -1958,7 +1994,11 @@ extern const char bb_path_wtmp_file[] ALIGN1;
1958#define bb_path_motd_file "/etc/motd" 1994#define bb_path_motd_file "/etc/motd"
1959 1995
1960#define bb_dev_null "/dev/null" 1996#define bb_dev_null "/dev/null"
1997#if ENABLE_PLATFORM_MINGW32
1998#define bb_busybox_exec_path get_busybox_exec_path()
1999#else
1961extern const char bb_busybox_exec_path[] ALIGN1; 2000extern const char bb_busybox_exec_path[] ALIGN1;
2001#endif
1962/* util-linux manpage says /sbin:/bin:/usr/sbin:/usr/bin, 2002/* util-linux manpage says /sbin:/bin:/usr/sbin:/usr/bin,
1963 * but I want to save a few bytes here */ 2003 * but I want to save a few bytes here */
1964extern const char bb_PATH_root_path[] ALIGN1; /* "PATH=/sbin:/usr/sbin:/bin:/usr/bin" */ 2004extern const char bb_PATH_root_path[] ALIGN1; /* "PATH=/sbin:/usr/sbin:/bin:/usr/bin" */