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 /libbb | |
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 'libbb')
-rw-r--r-- | libbb/copy_file.c | 10 | ||||
-rw-r--r-- | libbb/messages.c | 2 | ||||
-rw-r--r-- | libbb/mode_string.c | 3 | ||||
-rw-r--r-- | libbb/verror_msg.c | 4 | ||||
-rw-r--r-- | libbb/xfuncs.c | 9 |
5 files changed, 27 insertions, 1 deletions
diff --git a/libbb/copy_file.c b/libbb/copy_file.c index a6cfe122d..cf1c756d5 100644 --- a/libbb/copy_file.c +++ b/libbb/copy_file.c | |||
@@ -83,12 +83,14 @@ int copy_file(const char *source, const char *dest, int flags) | |||
83 | return -1; | 83 | return -1; |
84 | } | 84 | } |
85 | } else { | 85 | } else { |
86 | #ifndef __MINGW32__ | ||
86 | if (source_stat.st_dev == dest_stat.st_dev | 87 | if (source_stat.st_dev == dest_stat.st_dev |
87 | && source_stat.st_ino == dest_stat.st_ino | 88 | && source_stat.st_ino == dest_stat.st_ino |
88 | ) { | 89 | ) { |
89 | bb_error_msg("'%s' and '%s' are the same file", source, dest); | 90 | bb_error_msg("'%s' and '%s' are the same file", source, dest); |
90 | return -1; | 91 | return -1; |
91 | } | 92 | } |
93 | #endif | ||
92 | dest_exists = 1; | 94 | dest_exists = 1; |
93 | } | 95 | } |
94 | 96 | ||
@@ -178,6 +180,7 @@ int copy_file(const char *source, const char *dest, int flags) | |||
178 | // Hmm... maybe | 180 | // Hmm... maybe |
179 | // if (DEREF && MAKE_SOFTLINK) source = realpath(source) ? | 181 | // if (DEREF && MAKE_SOFTLINK) source = realpath(source) ? |
180 | // (but realpath returns NULL on dangling symlinks...) | 182 | // (but realpath returns NULL on dangling symlinks...) |
183 | #ifndef __MINGW32__ | ||
181 | lf = (flags & FILEUTILS_MAKE_SOFTLINK) ? symlink : link; | 184 | lf = (flags & FILEUTILS_MAKE_SOFTLINK) ? symlink : link; |
182 | if (lf(source, dest) < 0) { | 185 | if (lf(source, dest) < 0) { |
183 | ovr = ask_and_unlink(dest, flags); | 186 | ovr = ask_and_unlink(dest, flags); |
@@ -188,6 +191,7 @@ int copy_file(const char *source, const char *dest, int flags) | |||
188 | return -1; | 191 | return -1; |
189 | } | 192 | } |
190 | } | 193 | } |
194 | #endif | ||
191 | return 0; | 195 | return 0; |
192 | 196 | ||
193 | } else if (S_ISREG(source_stat.st_mode) | 197 | } else if (S_ISREG(source_stat.st_mode) |
@@ -196,6 +200,7 @@ int copy_file(const char *source, const char *dest, int flags) | |||
196 | ) { | 200 | ) { |
197 | int src_fd; | 201 | int src_fd; |
198 | int dst_fd; | 202 | int dst_fd; |
203 | #ifndef __MINGW32__ | ||
199 | if (ENABLE_FEATURE_PRESERVE_HARDLINKS) { | 204 | if (ENABLE_FEATURE_PRESERVE_HARDLINKS) { |
200 | char *link_name; | 205 | char *link_name; |
201 | 206 | ||
@@ -216,6 +221,7 @@ int copy_file(const char *source, const char *dest, int flags) | |||
216 | } | 221 | } |
217 | add_to_ino_dev_hashtable(&source_stat, dest); | 222 | add_to_ino_dev_hashtable(&source_stat, dest); |
218 | } | 223 | } |
224 | #endif | ||
219 | 225 | ||
220 | src_fd = open_or_warn(source, O_RDONLY); | 226 | src_fd = open_or_warn(source, O_RDONLY); |
221 | if (src_fd < 0) { | 227 | if (src_fd < 0) { |
@@ -274,6 +280,7 @@ int copy_file(const char *source, const char *dest, int flags) | |||
274 | status = -1; | 280 | status = -1; |
275 | } | 281 | } |
276 | 282 | ||
283 | #ifndef __MINGW32__ | ||
277 | } else if (S_ISBLK(source_stat.st_mode) || S_ISCHR(source_stat.st_mode) | 284 | } else if (S_ISBLK(source_stat.st_mode) || S_ISCHR(source_stat.st_mode) |
278 | || S_ISSOCK(source_stat.st_mode) || S_ISFIFO(source_stat.st_mode) | 285 | || S_ISSOCK(source_stat.st_mode) || S_ISFIFO(source_stat.st_mode) |
279 | || S_ISLNK(source_stat.st_mode) | 286 | || S_ISLNK(source_stat.st_mode) |
@@ -312,6 +319,7 @@ int copy_file(const char *source, const char *dest, int flags) | |||
312 | return -1; | 319 | return -1; |
313 | } | 320 | } |
314 | } | 321 | } |
322 | #endif | ||
315 | } else { | 323 | } else { |
316 | bb_error_msg("internal error: unrecognized file type"); | 324 | bb_error_msg("internal error: unrecognized file type"); |
317 | return -1; | 325 | return -1; |
@@ -319,6 +327,7 @@ int copy_file(const char *source, const char *dest, int flags) | |||
319 | 327 | ||
320 | preserve_status: | 328 | preserve_status: |
321 | 329 | ||
330 | #ifndef __MINGW32__ | ||
322 | if (flags & FILEUTILS_PRESERVE_STATUS | 331 | if (flags & FILEUTILS_PRESERVE_STATUS |
323 | /* Cannot happen: */ | 332 | /* Cannot happen: */ |
324 | /* && !(flags & (FILEUTILS_MAKE_SOFTLINK|FILEUTILS_MAKE_HARDLINK)) */ | 333 | /* && !(flags & (FILEUTILS_MAKE_SOFTLINK|FILEUTILS_MAKE_HARDLINK)) */ |
@@ -336,6 +345,7 @@ int copy_file(const char *source, const char *dest, int flags) | |||
336 | if (chmod(dest, source_stat.st_mode) < 0) | 345 | if (chmod(dest, source_stat.st_mode) < 0) |
337 | bb_perror_msg("cannot preserve %s of '%s'", "permissions", dest); | 346 | bb_perror_msg("cannot preserve %s of '%s'", "permissions", dest); |
338 | } | 347 | } |
348 | #endif | ||
339 | 349 | ||
340 | return status; | 350 | return status; |
341 | } | 351 | } |
diff --git a/libbb/messages.c b/libbb/messages.c index 3febe7645..c9a9d7387 100644 --- a/libbb/messages.c +++ b/libbb/messages.c | |||
@@ -43,6 +43,7 @@ const char bb_dev_null[] = "/dev/null"; | |||
43 | const int const_int_0; | 43 | const int const_int_0; |
44 | const int const_int_1 = 1; | 44 | const int const_int_1 = 1; |
45 | 45 | ||
46 | #ifndef __MINGW32__ | ||
46 | #include <utmp.h> | 47 | #include <utmp.h> |
47 | /* This is usually something like "/var/adm/wtmp" or "/var/log/wtmp" */ | 48 | /* This is usually something like "/var/adm/wtmp" or "/var/log/wtmp" */ |
48 | const char bb_path_wtmp_file[] = | 49 | const char bb_path_wtmp_file[] = |
@@ -53,6 +54,7 @@ WTMP_FILE; | |||
53 | #else | 54 | #else |
54 | # error unknown path to wtmp file | 55 | # error unknown path to wtmp file |
55 | #endif | 56 | #endif |
57 | #endif | ||
56 | 58 | ||
57 | char bb_common_bufsiz1[(BUFSIZ > 256*sizeof(void*) ? BUFSIZ : 256*sizeof(void*)) + 1]; | 59 | char bb_common_bufsiz1[(BUFSIZ > 256*sizeof(void*) ? BUFSIZ : 256*sizeof(void*)) + 1]; |
58 | 60 | ||
diff --git a/libbb/mode_string.c b/libbb/mode_string.c index d3ff18375..7afcaa61b 100644 --- a/libbb/mode_string.c +++ b/libbb/mode_string.c | |||
@@ -13,6 +13,7 @@ | |||
13 | 13 | ||
14 | 14 | ||
15 | #include <assert.h> | 15 | #include <assert.h> |
16 | #ifndef __MINGW32__ | ||
16 | #include <sys/stat.h> | 17 | #include <sys/stat.h> |
17 | 18 | ||
18 | #include "libbb.h" | 19 | #include "libbb.h" |
@@ -29,6 +30,7 @@ | |||
29 | || ( S_IFDIR != 0040000 ) || ( S_IFCHR != 0020000 ) \ | 30 | || ( S_IFDIR != 0040000 ) || ( S_IFCHR != 0020000 ) \ |
30 | || ( S_IFIFO != 0010000 ) | 31 | || ( S_IFIFO != 0010000 ) |
31 | #warning mode type bitflag value assumption(s) violated! falling back to larger version | 32 | #warning mode type bitflag value assumption(s) violated! falling back to larger version |
33 | #endif | ||
32 | 34 | ||
33 | #if (S_IRWXU | S_IRWXG | S_IRWXO | S_ISUID | S_ISGID | S_ISVTX) == 07777 | 35 | #if (S_IRWXU | S_IRWXG | S_IRWXO | S_ISUID | S_ISGID | S_ISVTX) == 07777 |
34 | #undef mode_t | 36 | #undef mode_t |
@@ -91,6 +93,7 @@ static const char type_chars[16] = "?pc?d?b?-?l?s???"; | |||
91 | /* 0123456789abcdef */ | 93 | /* 0123456789abcdef */ |
92 | static const char mode_chars[7] = "rwxSTst"; | 94 | static const char mode_chars[7] = "rwxSTst"; |
93 | 95 | ||
96 | #define mode_t unsigned short | ||
94 | const char *bb_mode_string(mode_t mode) | 97 | const char *bb_mode_string(mode_t mode) |
95 | { | 98 | { |
96 | static char buf[12]; | 99 | static char buf[12]; |
diff --git a/libbb/verror_msg.c b/libbb/verror_msg.c index 082e7bf3c..1c118e861 100644 --- a/libbb/verror_msg.c +++ b/libbb/verror_msg.c | |||
@@ -8,7 +8,9 @@ | |||
8 | */ | 8 | */ |
9 | 9 | ||
10 | #include "libbb.h" | 10 | #include "libbb.h" |
11 | #if ENABLE_FEATURE_SYSLOG | ||
11 | #include <syslog.h> | 12 | #include <syslog.h> |
13 | #endif | ||
12 | 14 | ||
13 | smallint logmode = LOGMODE_STDIO; | 15 | smallint logmode = LOGMODE_STDIO; |
14 | const char *msg_eol = "\n"; | 16 | const char *msg_eol = "\n"; |
@@ -34,6 +36,7 @@ void bb_verror_msg(const char *s, va_list p, const char* strerr) | |||
34 | s[0] ? ": " : "", | 36 | s[0] ? ": " : "", |
35 | strerr, msg_eol); | 37 | strerr, msg_eol); |
36 | } | 38 | } |
39 | #if ENABLE_FEATURE_SYSLOG | ||
37 | if (ENABLE_FEATURE_SYSLOG && (logmode & LOGMODE_SYSLOG)) { | 40 | if (ENABLE_FEATURE_SYSLOG && (logmode & LOGMODE_SYSLOG)) { |
38 | if (!strerr) | 41 | if (!strerr) |
39 | vsyslog(LOG_ERR, s, p2); | 42 | vsyslog(LOG_ERR, s, p2); |
@@ -47,5 +50,6 @@ void bb_verror_msg(const char *s, va_list p, const char* strerr) | |||
47 | free(msg); | 50 | free(msg); |
48 | } | 51 | } |
49 | } | 52 | } |
53 | #endif | ||
50 | va_end(p2); | 54 | va_end(p2); |
51 | } | 55 | } |
diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c index d02ef9c77..7803afcec 100644 --- a/libbb/xfuncs.c +++ b/libbb/xfuncs.c | |||
@@ -158,6 +158,7 @@ void xunlink(const char *pathname) | |||
158 | bb_perror_msg_and_die("can't remove file '%s'", pathname); | 158 | bb_perror_msg_and_die("can't remove file '%s'", pathname); |
159 | } | 159 | } |
160 | 160 | ||
161 | #ifndef __MINGW32__ | ||
161 | // Turn on nonblocking I/O on a fd | 162 | // Turn on nonblocking I/O on a fd |
162 | int ndelay_on(int fd) | 163 | int ndelay_on(int fd) |
163 | { | 164 | { |
@@ -168,6 +169,7 @@ int ndelay_off(int fd) | |||
168 | { | 169 | { |
169 | return fcntl(fd, F_SETFL, fcntl(fd,F_GETFL,0) & ~O_NONBLOCK); | 170 | return fcntl(fd, F_SETFL, fcntl(fd,F_GETFL,0) & ~O_NONBLOCK); |
170 | } | 171 | } |
172 | #endif | ||
171 | 173 | ||
172 | // "Renumber" opened fd | 174 | // "Renumber" opened fd |
173 | void xmove_fd(int from, int to) | 175 | void xmove_fd(int from, int to) |
@@ -224,6 +226,7 @@ void xfflush_stdout(void) | |||
224 | } | 226 | } |
225 | } | 227 | } |
226 | 228 | ||
229 | #ifndef __MINGW32__ | ||
227 | void sig_block(int sig) | 230 | void sig_block(int sig) |
228 | { | 231 | { |
229 | sigset_t ss; | 232 | sigset_t ss; |
@@ -264,6 +267,7 @@ void sig_pause(void) | |||
264 | sigemptyset(&ss); | 267 | sigemptyset(&ss); |
265 | sigsuspend(&ss); | 268 | sigsuspend(&ss); |
266 | } | 269 | } |
270 | #endif | ||
267 | 271 | ||
268 | 272 | ||
269 | void xsetenv(const char *key, const char *value) | 273 | void xsetenv(const char *key, const char *value) |
@@ -387,6 +391,7 @@ char *bin2hex(char *p, const char *cp, int count) | |||
387 | return p; | 391 | return p; |
388 | } | 392 | } |
389 | 393 | ||
394 | #ifndef __MINGW32__ | ||
390 | // Die with an error message if we can't set gid. (Because resource limits may | 395 | // Die with an error message if we can't set gid. (Because resource limits may |
391 | // limit this user to a given number of processes, and if that fills up the | 396 | // limit this user to a given number of processes, and if that fills up the |
392 | // setgid() will fail and we'll _still_be_root_, which is bad.) | 397 | // setgid() will fail and we'll _still_be_root_, which is bad.) |
@@ -440,7 +445,7 @@ off_t fdlength(int fd) | |||
440 | 445 | ||
441 | return pos + 1; | 446 | return pos + 1; |
442 | } | 447 | } |
443 | 448 | #endif | |
444 | // Die with an error message if we can't malloc() enough space and do an | 449 | // Die with an error message if we can't malloc() enough space and do an |
445 | // sprintf() into that space. | 450 | // sprintf() into that space. |
446 | char *xasprintf(const char *format, ...) | 451 | char *xasprintf(const char *format, ...) |
@@ -612,6 +617,7 @@ void selinux_or_die(void) | |||
612 | 617 | ||
613 | /* It is perfectly ok to pass in a NULL for either width or for | 618 | /* It is perfectly ok to pass in a NULL for either width or for |
614 | * height, in which case that value will not be set. */ | 619 | * height, in which case that value will not be set. */ |
620 | #ifndef __MINGW32__ | ||
615 | int get_terminal_width_height(const int fd, int *width, int *height) | 621 | int get_terminal_width_height(const int fd, int *width, int *height) |
616 | { | 622 | { |
617 | struct winsize win = { 0, 0, 0, 0 }; | 623 | struct winsize win = { 0, 0, 0, 0 }; |
@@ -639,3 +645,4 @@ int get_terminal_width_height(const int fd, int *width, int *height) | |||
639 | 645 | ||
640 | return ret; | 646 | return ret; |
641 | } | 647 | } |
648 | #endif | ||