diff options
| author | Denis Vlasenko <vda.linux@googlemail.com> | 2006-12-18 22:10:24 +0000 |
|---|---|---|
| committer | Denis Vlasenko <vda.linux@googlemail.com> | 2006-12-18 22:10:24 +0000 |
| commit | c8e6e35ba4095846121d5b5a3eee57caa5e8e0fb (patch) | |
| tree | d310542c65bbfd183b50f156916ef3313721625f | |
| parent | 83e5d6f77237b64853c194b0ce592e77ef677c4d (diff) | |
| download | busybox-w32-c8e6e35ba4095846121d5b5a3eee57caa5e8e0fb.tar.gz busybox-w32-c8e6e35ba4095846121d5b5a3eee57caa5e8e0fb.tar.bz2 busybox-w32-c8e6e35ba4095846121d5b5a3eee57caa5e8e0fb.zip | |
nc: add missing cast
xfuncs: add dprintf for dietlibc
| -rw-r--r-- | include/platform.h | 3 | ||||
| -rw-r--r-- | libbb/xfuncs.c | 31 | ||||
| -rw-r--r-- | networking/nc.c | 2 |
3 files changed, 35 insertions, 1 deletions
diff --git a/include/platform.h b/include/platform.h index a1ec17a7b..860143f7f 100644 --- a/include/platform.h +++ b/include/platform.h | |||
| @@ -194,6 +194,9 @@ typedef unsigned long long int uintmax_t; | |||
| 194 | * libbb. This would require a platform.c. It's not going to be cleaned | 194 | * libbb. This would require a platform.c. It's not going to be cleaned |
| 195 | * out of the tree, so stop saying it should be. */ | 195 | * out of the tree, so stop saying it should be. */ |
| 196 | #define fdprintf dprintf | 196 | #define fdprintf dprintf |
| 197 | #ifdef __dietlibc__ | ||
| 198 | int dprintf(int fd, const char *format, ...); | ||
| 199 | #endif | ||
| 197 | 200 | ||
| 198 | /* Don't use lchown with glibc older than 2.1.x ... uC-libc lacks it */ | 201 | /* Don't use lchown with glibc older than 2.1.x ... uC-libc lacks it */ |
| 199 | #if (defined __GLIBC__ && __GLIBC__ <= 2 && __GLIBC_MINOR__ < 1) || \ | 202 | #if (defined __GLIBC__ && __GLIBC__ <= 2 && __GLIBC_MINOR__ < 1) || \ |
diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c index 313e32814..4790aa140 100644 --- a/libbb/xfuncs.c +++ b/libbb/xfuncs.c | |||
| @@ -411,6 +411,37 @@ char *xasprintf(const char *format, ...) | |||
| 411 | return string_ptr; | 411 | return string_ptr; |
| 412 | } | 412 | } |
| 413 | 413 | ||
| 414 | #ifdef __dietlibc__ | ||
| 415 | int dprintf(int fd, const char *format, ...) | ||
| 416 | { | ||
| 417 | va_list p; | ||
| 418 | int r; | ||
| 419 | char *string_ptr; | ||
| 420 | |||
| 421 | #if 1 | ||
| 422 | // GNU extension | ||
| 423 | va_start(p, format); | ||
| 424 | r = vasprintf(&string_ptr, format, p); | ||
| 425 | va_end(p); | ||
| 426 | #else | ||
| 427 | // Bloat for systems that haven't got the GNU extension. | ||
| 428 | va_start(p, format); | ||
| 429 | r = vsnprintf(NULL, 0, format, p); | ||
| 430 | va_end(p); | ||
| 431 | string_ptr = xmalloc(r+1); | ||
| 432 | va_start(p, format); | ||
| 433 | r = vsnprintf(string_ptr, r+1, format, p); | ||
| 434 | va_end(p); | ||
| 435 | #endif | ||
| 436 | |||
| 437 | if (r >= 0) { | ||
| 438 | full_write(fd, string_ptr, r); | ||
| 439 | free(string_ptr); | ||
| 440 | } | ||
| 441 | return r; | ||
| 442 | } | ||
| 443 | #endif | ||
| 444 | |||
| 414 | // Die with an error message if we can't copy an entire FILE * to stdout, then | 445 | // Die with an error message if we can't copy an entire FILE * to stdout, then |
| 415 | // close that file. | 446 | // close that file. |
| 416 | void xprint_and_close_file(FILE *file) | 447 | void xprint_and_close_file(FILE *file) |
diff --git a/networking/nc.c b/networking/nc.c index 5fd9242cc..b2a4596d6 100644 --- a/networking/nc.c +++ b/networking/nc.c | |||
| @@ -104,7 +104,7 @@ int nc_main(int argc, char **argv) | |||
| 104 | 104 | ||
| 105 | if (!lport) { | 105 | if (!lport) { |
| 106 | socklen_t len = sizeof(address); | 106 | socklen_t len = sizeof(address); |
| 107 | getsockname(sfd, &address, &len); | 107 | getsockname(sfd, (struct sockaddr *) &address, &len); |
| 108 | fdprintf(2, "%d\n", SWAP_BE16(address.sin_port)); | 108 | fdprintf(2, "%d\n", SWAP_BE16(address.sin_port)); |
| 109 | } | 109 | } |
| 110 | repeatyness: | 110 | repeatyness: |
