svn commit: trunk/busybox: include libbb networking
vda at busybox.net
vda at busybox.net
Mon Dec 18 14:10:26 PST 2006
Author: vda
Date: 2006-12-18 14:10:24 -0800 (Mon, 18 Dec 2006)
New Revision: 16997
Log:
nc: add missing cast
xfuncs: add dprintf for dietlibc
Modified:
trunk/busybox/include/platform.h
trunk/busybox/libbb/xfuncs.c
trunk/busybox/networking/nc.c
Changeset:
Modified: trunk/busybox/include/platform.h
===================================================================
--- trunk/busybox/include/platform.h 2006-12-18 21:49:06 UTC (rev 16996)
+++ trunk/busybox/include/platform.h 2006-12-18 22:10:24 UTC (rev 16997)
@@ -194,6 +194,9 @@
* libbb. This would require a platform.c. It's not going to be cleaned
* out of the tree, so stop saying it should be. */
#define fdprintf dprintf
+#ifdef __dietlibc__
+int dprintf(int fd, const char *format, ...);
+#endif
/* Don't use lchown with glibc older than 2.1.x ... uC-libc lacks it */
#if (defined __GLIBC__ && __GLIBC__ <= 2 && __GLIBC_MINOR__ < 1) || \
Modified: trunk/busybox/libbb/xfuncs.c
===================================================================
--- trunk/busybox/libbb/xfuncs.c 2006-12-18 21:49:06 UTC (rev 16996)
+++ trunk/busybox/libbb/xfuncs.c 2006-12-18 22:10:24 UTC (rev 16997)
@@ -411,6 +411,37 @@
return string_ptr;
}
+#ifdef __dietlibc__
+int dprintf(int fd, const char *format, ...)
+{
+ va_list p;
+ int r;
+ char *string_ptr;
+
+#if 1
+ // GNU extension
+ va_start(p, format);
+ r = vasprintf(&string_ptr, format, p);
+ va_end(p);
+#else
+ // Bloat for systems that haven't got the GNU extension.
+ va_start(p, format);
+ r = vsnprintf(NULL, 0, format, p);
+ va_end(p);
+ string_ptr = xmalloc(r+1);
+ va_start(p, format);
+ r = vsnprintf(string_ptr, r+1, format, p);
+ va_end(p);
+#endif
+
+ if (r >= 0) {
+ full_write(fd, string_ptr, r);
+ free(string_ptr);
+ }
+ return r;
+}
+#endif
+
// Die with an error message if we can't copy an entire FILE * to stdout, then
// close that file.
void xprint_and_close_file(FILE *file)
Modified: trunk/busybox/networking/nc.c
===================================================================
--- trunk/busybox/networking/nc.c 2006-12-18 21:49:06 UTC (rev 16996)
+++ trunk/busybox/networking/nc.c 2006-12-18 22:10:24 UTC (rev 16997)
@@ -104,7 +104,7 @@
if (!lport) {
socklen_t len = sizeof(address);
- getsockname(sfd, &address, &len);
+ getsockname(sfd, (struct sockaddr *) &address, &len);
fdprintf(2, "%d\n", SWAP_BE16(address.sin_port));
}
repeatyness:
More information about the busybox-cvs
mailing list