diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2009-04-22 22:13:17 +1000 |
---|---|---|
committer | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2009-04-23 04:44:33 +1000 |
commit | 251687097b60bad7a88de930576b7177f34fa975 (patch) | |
tree | 79e04bf5487a27e1915f29778f6bff577a3a223b /include | |
parent | d791e72dc28009f36da26703fc007e40cfa79414 (diff) | |
download | busybox-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.h | 37 | ||||
-rw-r--r-- | include/platform.h | 14 | ||||
-rw-r--r-- | include/pwd_.h | 2 |
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); | |||
276 | int xsocket(int domain, int type, int protocol); | 289 | int xsocket(int domain, int type, int protocol); |
277 | void xbind(int sockfd, struct sockaddr *my_addr, socklen_t addrlen); | 290 | void xbind(int sockfd, struct sockaddr *my_addr, socklen_t addrlen); |
278 | void xlisten(int s, int backlog); | 291 | void xlisten(int s, int backlog); |
292 | #ifndef __MINGW32__ | ||
279 | void xconnect(int s, const struct sockaddr *s_addr, socklen_t addrlen); | 293 | void xconnect(int s, const struct sockaddr *s_addr, socklen_t addrlen); |
294 | #endif | ||
280 | ssize_t xsendto(int s, const void *buf, size_t len, const struct sockaddr *to, | 295 | ssize_t xsendto(int s, const void *buf, size_t len, const struct sockaddr *to, |
281 | socklen_t tolen); | 296 | socklen_t tolen); |
282 | int setsockopt_reuseaddr(int fd); | 297 | int 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 | ||
373 | extern char *xstrdup(const char *s); | 388 | extern char *xstrdup(const char *s); |
374 | extern char *xstrndup(const char *s, int n); | ||
375 | extern char *safe_strncpy(char *dst, const char *src, size_t size); | 389 | extern char *safe_strncpy(char *dst, const char *src, size_t size); |
376 | extern char *xasprintf(const char *format, ...) __attribute__ ((format (printf, 1, 2))); | 390 | extern 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 | ||
396 | extern ssize_t safe_read(int fd, void *buf, size_t count); | 410 | extern ssize_t safe_read(int fd, void *buf, size_t count); |
397 | extern ssize_t full_read(int fd, void *buf, size_t count); | 411 | extern ssize_t full_read(int fd, void *buf, size_t count); |
398 | extern void xread(int fd, void *buf, size_t count); | ||
399 | extern unsigned char xread_char(int fd); | 412 | extern unsigned char xread_char(int fd); |
400 | extern char *reads(int fd, char *buf, size_t count); | 413 | extern char *reads(int fd, char *buf, size_t count); |
401 | extern ssize_t read_close(int fd, void *buf, size_t count); | 414 | extern ssize_t read_close(int fd, void *buf, size_t count); |
402 | extern ssize_t open_read_close(const char *filename, void *buf, size_t count); | 415 | extern ssize_t open_read_close(const char *filename, void *buf, size_t count); |
403 | extern void *xmalloc_open_read_close(const char *filename, size_t *sizep); | 416 | extern 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) | ||
405 | extern ssize_t safe_write(int fd, const void *buf, size_t count); | 419 | extern ssize_t safe_write(int fd, const void *buf, size_t count); |
406 | extern ssize_t full_write(int fd, const void *buf, size_t count); | 420 | extern ssize_t full_write(int fd, const void *buf, size_t count); |
407 | extern 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: */ |
410 | extern void xprint_and_close_file(FILE *file); | 423 | extern void xprint_and_close_file(FILE *file); |
@@ -429,7 +442,11 @@ extern FILE *fopen_or_warn_stdin(const char *filename); | |||
429 | extern char* str_tolower(char *str); | 442 | extern char* str_tolower(char *str); |
430 | 443 | ||
431 | char *utoa(unsigned n); | 444 | char *utoa(unsigned n); |
445 | #ifdef __MINGW32__ | ||
446 | #define itoa bb_itoa | ||
447 | #else | ||
432 | char *itoa(int n); | 448 | char *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 */ |
434 | char *utoa_to_buf(unsigned n, char *buf, unsigned buflen); | 451 | char *utoa_to_buf(unsigned n, char *buf, unsigned buflen); |
435 | char *itoa_to_buf(int n, char *buf, unsigned buflen); | 452 | char *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); | |||
476 | char *bb_getpwuid(char *name, long uid, int bufsize); | 493 | char *bb_getpwuid(char *name, long uid, int bufsize); |
477 | char *bb_getgrgid(char *group, long gid, int bufsize); | 494 | char *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__ | ||
479 | const char* get_cached_username(uid_t uid); | 497 | const char* get_cached_username(uid_t uid); |
480 | const char* get_cached_groupname(gid_t gid); | 498 | const char* get_cached_groupname(gid_t gid); |
499 | #endif | ||
481 | void clear_username_cache(void); | 500 | void clear_username_cache(void); |
482 | /* internally usernames are saved in fixed-sized char[] buffers */ | 501 | /* internally usernames are saved in fixed-sized char[] buffers */ |
483 | enum { USERNAME_MAX_SIZE = 16 - sizeof(int) }; | 502 | enum { USERNAME_MAX_SIZE = 16 - sizeof(int) }; |
@@ -704,11 +723,13 @@ extern void run_applet_and_exit(const char *name, char **argv); | |||
704 | extern void run_current_applet_and_exit(char **argv) ATTRIBUTE_NORETURN; | 723 | extern void run_current_applet_and_exit(char **argv) ATTRIBUTE_NORETURN; |
705 | #endif | 724 | #endif |
706 | 725 | ||
726 | #ifndef __MINGW32__ | ||
707 | extern int match_fstype(const struct mntent *mt, const char *fstypes); | 727 | extern int match_fstype(const struct mntent *mt, const char *fstypes); |
708 | extern struct mntent *find_mount_point(const char *name, const char *table); | 728 | extern struct mntent *find_mount_point(const char *name, const char *table); |
709 | extern void erase_mtab(const char * name); | 729 | extern void erase_mtab(const char * name); |
710 | extern unsigned int tty_baud_to_value(speed_t speed); | 730 | extern unsigned int tty_baud_to_value(speed_t speed); |
711 | extern speed_t tty_value_to_baud(unsigned int value); | 731 | extern speed_t tty_value_to_baud(unsigned int value); |
732 | #endif | ||
712 | extern void bb_warn_ignoring_args(int n); | 733 | extern void bb_warn_ignoring_args(int n); |
713 | 734 | ||
714 | extern int get_linux_version_code(void); | 735 | extern 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 |
746 | extern void bb_do_delay(int seconds); | 767 | extern void bb_do_delay(int seconds); |
768 | #ifndef __MINGW32__ | ||
747 | extern void change_identity(const struct passwd *pw); | 769 | extern void change_identity(const struct passwd *pw); |
748 | extern const char *change_identity_e2str(const struct passwd *pw); | 770 | extern const char *change_identity_e2str(const struct passwd *pw); |
771 | #endif | ||
749 | extern void run_shell(const char *shell, int loginshell, const char *command, const char **additional_args); | 772 | extern void run_shell(const char *shell, int loginshell, const char *command, const char **additional_args); |
750 | #if ENABLE_SELINUX | 773 | #if ENABLE_SELINUX |
751 | extern void renew_current_security_context(void); | 774 | extern void renew_current_security_context(void); |
@@ -756,10 +779,14 @@ extern void setfscreatecon_or_die(security_context_t scontext); | |||
756 | #endif | 779 | #endif |
757 | extern void selinux_or_die(void); | 780 | extern void selinux_or_die(void); |
758 | extern int restricted_shell(const char *shell); | 781 | extern int restricted_shell(const char *shell); |
782 | #ifndef __MINGW32__ | ||
759 | extern void setup_environment(const char *shell, int loginshell, int changeenv, const struct passwd *pw); | 783 | extern void setup_environment(const char *shell, int loginshell, int changeenv, const struct passwd *pw); |
760 | extern int correct_password(const struct passwd *pw); | 784 | extern int correct_password(const struct passwd *pw); |
785 | #endif | ||
761 | extern char *pw_encrypt(const char *clear, const char *salt); | 786 | extern char *pw_encrypt(const char *clear, const char *salt); |
787 | #ifndef __MINGW32__ | ||
762 | extern int obscure(const char *old, const char *newval, const struct passwd *pwdp); | 788 | extern int obscure(const char *old, const char *newval, const struct passwd *pwdp); |
789 | #endif | ||
763 | extern int index_in_str_array(const char * const string_array[], const char *key); | 790 | extern int index_in_str_array(const char * const string_array[], const char *key); |
764 | extern int index_in_substr_array(const char * const string_array[], const char *key); | 791 | extern int index_in_substr_array(const char * const string_array[], const char *key); |
765 | extern void print_login_issue(const char *issue_file, const char *tty); | 792 | extern 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 | ||
770 | int get_terminal_width_height(const int fd, int *width, int *height); | 797 | int get_terminal_width_height(const int fd, int *width, int *height); |
771 | 798 | ||
799 | #ifndef __MINGW32__ | ||
772 | char *is_in_ino_dev_hashtable(const struct stat *statbuf); | 800 | char *is_in_ino_dev_hashtable(const struct stat *statbuf); |
773 | void add_to_ino_dev_hashtable(const struct stat *statbuf, const char *name); | 801 | void add_to_ino_dev_hashtable(const struct stat *statbuf, const char *name); |
802 | #endif | ||
774 | void reset_ino_dev_hashtable(void); | 803 | void 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 |
138 | typedef int socklen_t; | 148 | typedef 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__) |
241 | static ATTRIBUTE_ALWAYS_INLINE char* strchrnul(const char *s, char c) | 251 | static 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 | ||