aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2009-04-22 22:13:17 +1000
committerNguyễn Thái Ngọc Duy <pclouds@gmail.com>2009-04-23 04:44:33 +1000
commit251687097b60bad7a88de930576b7177f34fa975 (patch)
tree79e04bf5487a27e1915f29778f6bff577a3a223b /include
parentd791e72dc28009f36da26703fc007e40cfa79414 (diff)
downloadbusybox-w32-251687097b60bad7a88de930576b7177f34fa975.tar.gz
busybox-w32-251687097b60bad7a88de930576b7177f34fa975.tar.bz2
busybox-w32-251687097b60bad7a88de930576b7177f34fa975.zip
adapt it to be buildable
Diffstat (limited to 'include')
-rw-r--r--include/libbb.h37
-rw-r--r--include/platform.h14
-rw-r--r--include/pwd_.h2
3 files changed, 47 insertions, 6 deletions
diff --git a/include/libbb.h b/include/libbb.h
index 385b30f16..5f496f435 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -17,8 +17,10 @@
17#include <errno.h> 17#include <errno.h>
18#include <fcntl.h> 18#include <fcntl.h>
19#include <inttypes.h> 19#include <inttypes.h>
20#ifndef __MINGW32__
20#include <mntent.h> 21#include <mntent.h>
21#include <netdb.h> 22#include <netdb.h>
23#endif
22#include <setjmp.h> 24#include <setjmp.h>
23#include <signal.h> 25#include <signal.h>
24#include <stdio.h> 26#include <stdio.h>
@@ -27,15 +29,19 @@
27#include <stddef.h> 29#include <stddef.h>
28#include <string.h> 30#include <string.h>
29#include <strings.h> 31#include <strings.h>
32#ifndef __MINGW32__
30#include <sys/ioctl.h> 33#include <sys/ioctl.h>
31#include <sys/mman.h> 34#include <sys/mman.h>
32#include <sys/socket.h> 35#include <sys/socket.h>
33#include <sys/stat.h>
34#include <sys/statfs.h> 36#include <sys/statfs.h>
37#endif
38#include <sys/stat.h>
35#include <sys/time.h> 39#include <sys/time.h>
36#include <sys/types.h> 40#include <sys/types.h>
41#ifndef __MINGW32__
37#include <sys/wait.h> 42#include <sys/wait.h>
38#include <termios.h> 43#include <termios.h>
44#endif
39#include <time.h> 45#include <time.h>
40#include <unistd.h> 46#include <unistd.h>
41#include <utime.h> 47#include <utime.h>
@@ -51,8 +57,15 @@
51#define setlocale(x,y) ((void)0) 57#define setlocale(x,y) ((void)0)
52#endif 58#endif
53 59
60#include "autoconf.h"
61#ifdef __MINGW32__
62#include "mingw.h"
63#endif
64
54#include "pwd_.h" 65#include "pwd_.h"
66#ifndef __MINGW32__
55#include "grp_.h" 67#include "grp_.h"
68#endif
56/* ifdef it out, because it may include <shadow.h> */ 69/* ifdef it out, because it may include <shadow.h> */
57/* and we may not even _have_ <shadow.h>! */ 70/* and we may not even _have_ <shadow.h>! */
58#if ENABLE_FEATURE_SHADOWPASSWDS 71#if ENABLE_FEATURE_SHADOWPASSWDS
@@ -276,7 +289,9 @@ off_t fdlength(int fd);
276int xsocket(int domain, int type, int protocol); 289int xsocket(int domain, int type, int protocol);
277void xbind(int sockfd, struct sockaddr *my_addr, socklen_t addrlen); 290void xbind(int sockfd, struct sockaddr *my_addr, socklen_t addrlen);
278void xlisten(int s, int backlog); 291void xlisten(int s, int backlog);
292#ifndef __MINGW32__
279void xconnect(int s, const struct sockaddr *s_addr, socklen_t addrlen); 293void xconnect(int s, const struct sockaddr *s_addr, socklen_t addrlen);
294#endif
280ssize_t xsendto(int s, const void *buf, size_t len, const struct sockaddr *to, 295ssize_t xsendto(int s, const void *buf, size_t len, const struct sockaddr *to,
281 socklen_t tolen); 296 socklen_t tolen);
282int setsockopt_reuseaddr(int fd); 297int setsockopt_reuseaddr(int fd);
@@ -371,7 +386,6 @@ ssize_t recv_from_to(int fd, void *buf, size_t len, int flags,
371 386
372 387
373extern char *xstrdup(const char *s); 388extern char *xstrdup(const char *s);
374extern char *xstrndup(const char *s, int n);
375extern char *safe_strncpy(char *dst, const char *src, size_t size); 389extern char *safe_strncpy(char *dst, const char *src, size_t size);
376extern char *xasprintf(const char *format, ...) __attribute__ ((format (printf, 1, 2))); 390extern char *xasprintf(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
377// gcc-4.1.1 still isn't good enough at optimizing it 391// gcc-4.1.1 still isn't good enough at optimizing it
@@ -395,16 +409,15 @@ extern void *xrealloc(void *old, size_t size);
395 409
396extern ssize_t safe_read(int fd, void *buf, size_t count); 410extern ssize_t safe_read(int fd, void *buf, size_t count);
397extern ssize_t full_read(int fd, void *buf, size_t count); 411extern ssize_t full_read(int fd, void *buf, size_t count);
398extern void xread(int fd, void *buf, size_t count);
399extern unsigned char xread_char(int fd); 412extern unsigned char xread_char(int fd);
400extern char *reads(int fd, char *buf, size_t count); 413extern char *reads(int fd, char *buf, size_t count);
401extern ssize_t read_close(int fd, void *buf, size_t count); 414extern ssize_t read_close(int fd, void *buf, size_t count);
402extern ssize_t open_read_close(const char *filename, void *buf, size_t count); 415extern ssize_t open_read_close(const char *filename, void *buf, size_t count);
403extern void *xmalloc_open_read_close(const char *filename, size_t *sizep); 416extern void *xmalloc_open_read_close(const char *filename, size_t *sizep);
404 417
418#define safe_write(fd, buf, count) bb_safe_write(fd, buf, count)
405extern ssize_t safe_write(int fd, const void *buf, size_t count); 419extern ssize_t safe_write(int fd, const void *buf, size_t count);
406extern ssize_t full_write(int fd, const void *buf, size_t count); 420extern ssize_t full_write(int fd, const void *buf, size_t count);
407extern void xwrite(int fd, const void *buf, size_t count);
408 421
409/* Reads and prints to stdout till eof, then closes FILE. Exits on error: */ 422/* Reads and prints to stdout till eof, then closes FILE. Exits on error: */
410extern void xprint_and_close_file(FILE *file); 423extern void xprint_and_close_file(FILE *file);
@@ -429,7 +442,11 @@ extern FILE *fopen_or_warn_stdin(const char *filename);
429extern char* str_tolower(char *str); 442extern char* str_tolower(char *str);
430 443
431char *utoa(unsigned n); 444char *utoa(unsigned n);
445#ifdef __MINGW32__
446#define itoa bb_itoa
447#else
432char *itoa(int n); 448char *itoa(int n);
449#endif
433/* Returns a pointer past the formatted number, does NOT null-terminate */ 450/* Returns a pointer past the formatted number, does NOT null-terminate */
434char *utoa_to_buf(unsigned n, char *buf, unsigned buflen); 451char *utoa_to_buf(unsigned n, char *buf, unsigned buflen);
435char *itoa_to_buf(int n, char *buf, unsigned buflen); 452char *itoa_to_buf(int n, char *buf, unsigned buflen);
@@ -476,8 +493,10 @@ void parse_chown_usergroup_or_die(struct bb_uidgid_t *u, char *user_group);
476char *bb_getpwuid(char *name, long uid, int bufsize); 493char *bb_getpwuid(char *name, long uid, int bufsize);
477char *bb_getgrgid(char *group, long gid, int bufsize); 494char *bb_getgrgid(char *group, long gid, int bufsize);
478/* versions which cache results (useful for ps, ls etc) */ 495/* versions which cache results (useful for ps, ls etc) */
496#ifndef __MINGW32__
479const char* get_cached_username(uid_t uid); 497const char* get_cached_username(uid_t uid);
480const char* get_cached_groupname(gid_t gid); 498const char* get_cached_groupname(gid_t gid);
499#endif
481void clear_username_cache(void); 500void clear_username_cache(void);
482/* internally usernames are saved in fixed-sized char[] buffers */ 501/* internally usernames are saved in fixed-sized char[] buffers */
483enum { USERNAME_MAX_SIZE = 16 - sizeof(int) }; 502enum { USERNAME_MAX_SIZE = 16 - sizeof(int) };
@@ -704,11 +723,13 @@ extern void run_applet_and_exit(const char *name, char **argv);
704extern void run_current_applet_and_exit(char **argv) ATTRIBUTE_NORETURN; 723extern void run_current_applet_and_exit(char **argv) ATTRIBUTE_NORETURN;
705#endif 724#endif
706 725
726#ifndef __MINGW32__
707extern int match_fstype(const struct mntent *mt, const char *fstypes); 727extern int match_fstype(const struct mntent *mt, const char *fstypes);
708extern struct mntent *find_mount_point(const char *name, const char *table); 728extern struct mntent *find_mount_point(const char *name, const char *table);
709extern void erase_mtab(const char * name); 729extern void erase_mtab(const char * name);
710extern unsigned int tty_baud_to_value(speed_t speed); 730extern unsigned int tty_baud_to_value(speed_t speed);
711extern speed_t tty_value_to_baud(unsigned int value); 731extern speed_t tty_value_to_baud(unsigned int value);
732#endif
712extern void bb_warn_ignoring_args(int n); 733extern void bb_warn_ignoring_args(int n);
713 734
714extern int get_linux_version_code(void); 735extern int get_linux_version_code(void);
@@ -744,8 +765,10 @@ char *bb_simplify_path(const char *path);
744 765
745#define FAIL_DELAY 3 766#define FAIL_DELAY 3
746extern void bb_do_delay(int seconds); 767extern void bb_do_delay(int seconds);
768#ifndef __MINGW32__
747extern void change_identity(const struct passwd *pw); 769extern void change_identity(const struct passwd *pw);
748extern const char *change_identity_e2str(const struct passwd *pw); 770extern const char *change_identity_e2str(const struct passwd *pw);
771#endif
749extern void run_shell(const char *shell, int loginshell, const char *command, const char **additional_args); 772extern void run_shell(const char *shell, int loginshell, const char *command, const char **additional_args);
750#if ENABLE_SELINUX 773#if ENABLE_SELINUX
751extern void renew_current_security_context(void); 774extern void renew_current_security_context(void);
@@ -756,10 +779,14 @@ extern void setfscreatecon_or_die(security_context_t scontext);
756#endif 779#endif
757extern void selinux_or_die(void); 780extern void selinux_or_die(void);
758extern int restricted_shell(const char *shell); 781extern int restricted_shell(const char *shell);
782#ifndef __MINGW32__
759extern void setup_environment(const char *shell, int loginshell, int changeenv, const struct passwd *pw); 783extern void setup_environment(const char *shell, int loginshell, int changeenv, const struct passwd *pw);
760extern int correct_password(const struct passwd *pw); 784extern int correct_password(const struct passwd *pw);
785#endif
761extern char *pw_encrypt(const char *clear, const char *salt); 786extern char *pw_encrypt(const char *clear, const char *salt);
787#ifndef __MINGW32__
762extern int obscure(const char *old, const char *newval, const struct passwd *pwdp); 788extern int obscure(const char *old, const char *newval, const struct passwd *pwdp);
789#endif
763extern int index_in_str_array(const char * const string_array[], const char *key); 790extern int index_in_str_array(const char * const string_array[], const char *key);
764extern int index_in_substr_array(const char * const string_array[], const char *key); 791extern int index_in_substr_array(const char * const string_array[], const char *key);
765extern void print_login_issue(const char *issue_file, const char *tty); 792extern void print_login_issue(const char *issue_file, const char *tty);
@@ -769,8 +796,10 @@ extern void crypt_make_salt(char *p, int cnt);
769 796
770int get_terminal_width_height(const int fd, int *width, int *height); 797int get_terminal_width_height(const int fd, int *width, int *height);
771 798
799#ifndef __MINGW32__
772char *is_in_ino_dev_hashtable(const struct stat *statbuf); 800char *is_in_ino_dev_hashtable(const struct stat *statbuf);
773void add_to_ino_dev_hashtable(const struct stat *statbuf, const char *name); 801void add_to_ino_dev_hashtable(const struct stat *statbuf, const char *name);
802#endif
774void reset_ino_dev_hashtable(void); 803void reset_ino_dev_hashtable(void);
775#ifdef __GLIBC__ 804#ifdef __GLIBC__
776/* At least glibc has horrendously large inline for this, so wrap it */ 805/* At least glibc has horrendously large inline for this, so wrap it */
diff --git a/include/platform.h b/include/platform.h
index c2013b39d..af6a79e99 100644
--- a/include/platform.h
+++ b/include/platform.h
@@ -91,6 +91,11 @@
91 91
92/* ---- Endian Detection ------------------------------------ */ 92/* ---- Endian Detection ------------------------------------ */
93 93
94#if defined __MINGW32__
95# define BB_BIG_ENDIAN 0
96# define BB_LITTLE_ENDIAN 1
97# define __BIG_ENDIAN__ 0
98#else
94#if (defined __digital__ && defined __unix__) 99#if (defined __digital__ && defined __unix__)
95# include <sex.h> 100# include <sex.h>
96# define __BIG_ENDIAN__ (BYTE_ORDER == BIG_ENDIAN) 101# define __BIG_ENDIAN__ (BYTE_ORDER == BIG_ENDIAN)
@@ -110,6 +115,7 @@
110# define BB_BIG_ENDIAN 0 115# define BB_BIG_ENDIAN 0
111# define BB_LITTLE_ENDIAN 1 116# define BB_LITTLE_ENDIAN 1
112#endif 117#endif
118#endif
113 119
114#if BB_BIG_ENDIAN 120#if BB_BIG_ENDIAN
115#define SWAP_BE16(x) (x) 121#define SWAP_BE16(x) (x)
@@ -128,11 +134,15 @@
128#endif 134#endif
129 135
130/* ---- Networking ------------------------------------------ */ 136/* ---- Networking ------------------------------------------ */
137#ifdef __MINGW32__
138# include <winsock2.h>
139#else
131#ifndef __APPLE__ 140#ifndef __APPLE__
132# include <arpa/inet.h> 141# include <arpa/inet.h>
133#else 142#else
134# include <netinet/in.h> 143# include <netinet/in.h>
135#endif 144#endif
145#endif
136 146
137#ifndef __socklen_t_defined 147#ifndef __socklen_t_defined
138typedef int socklen_t; 148typedef int socklen_t;
@@ -237,7 +247,7 @@ typedef unsigned smalluint;
237#define fdprintf dprintf 247#define fdprintf dprintf
238#endif 248#endif
239 249
240#if defined(__dietlibc__) 250#if defined(__dietlibc__) || defined(__MINGW32__)
241static ATTRIBUTE_ALWAYS_INLINE char* strchrnul(const char *s, char c) 251static ATTRIBUTE_ALWAYS_INLINE char* strchrnul(const char *s, char c)
242{ 252{
243 while (*s && *s != c) ++s; 253 while (*s && *s != c) ++s;
@@ -253,7 +263,7 @@ static ATTRIBUTE_ALWAYS_INLINE char* strchrnul(const char *s, char c)
253 263
254/* THIS SHOULD BE CLEANED OUT OF THE TREE ENTIRELY */ 264/* THIS SHOULD BE CLEANED OUT OF THE TREE ENTIRELY */
255/* FIXME: fix tar.c! */ 265/* FIXME: fix tar.c! */
256#ifndef FNM_LEADING_DIR 266#if !defined(FNM_LEADING_DIR) && !defined(__MINGW32__)
257#define FNM_LEADING_DIR 0 267#define FNM_LEADING_DIR 0
258#endif 268#endif
259 269
diff --git a/include/pwd_.h b/include/pwd_.h
index f47e4eb2c..86e507d06 100644
--- a/include/pwd_.h
+++ b/include/pwd_.h
@@ -23,7 +23,9 @@
23 23
24#if !ENABLE_USE_BB_PWD_GRP 24#if !ENABLE_USE_BB_PWD_GRP
25 25
26#ifndef __MINGW32__
26#include <pwd.h> 27#include <pwd.h>
28#endif
27 29
28#else 30#else
29 31