aboutsummaryrefslogtreecommitdiff
path: root/networking
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2006-07-16 08:14:35 +0000
committerRob Landley <rob@landley.net>2006-07-16 08:14:35 +0000
commit534374755d618c9c36c9940c82756241c4b25a67 (patch)
treefac906b4fa40a68c53cecf20215a7a25b3b1cab6 /networking
parentafb94ecf2bb6c53ce2a381d6ce45a426243c76d9 (diff)
downloadbusybox-534374755d618c9c36c9940c82756241c4b25a67.tar.gz
Cleaup read() and write() variants, plus a couple of new functions like
xlseek and fdlength() for the new mkswap.
Diffstat (limited to 'networking')
-rw-r--r--networking/httpd.c16
-rw-r--r--networking/nc.c12
-rw-r--r--networking/tftp.c4
3 files changed, 15 insertions, 17 deletions
diff --git a/networking/httpd.c b/networking/httpd.c
index 4cd09448c..452b56d19 100644
--- a/networking/httpd.c
+++ b/networking/httpd.c
@@ -961,7 +961,7 @@ static int sendHeaders(HttpResponseNum responseNum)
#if DEBUG
fprintf(stderr, "Headers: '%s'", buf);
#endif
- return bb_full_write(a_c_w, buf, len);
+ return full_write(a_c_w, buf, len);
}
/****************************************************************************
@@ -1222,7 +1222,7 @@ static int sendCgi(const char *url,
break;
}
} else if(post_readed_size > 0 && FD_ISSET(outFd, &writeSet)) {
- count = bb_full_write(outFd, wbuf + post_readed_idx, post_readed_size);
+ count = full_write(outFd, wbuf + post_readed_idx, post_readed_size);
if(count > 0) {
post_readed_size -= count;
post_readed_idx += count;
@@ -1263,14 +1263,14 @@ static int sendCgi(const char *url,
rbuf[count] = 0;
/* check to see if the user script added headers */
if(strncmp(rbuf, "HTTP/1.0 200 OK\r\n", 4) != 0) {
- bb_full_write(s, "HTTP/1.0 200 OK\r\n", 17);
+ full_write(s, "HTTP/1.0 200 OK\r\n", 17);
}
if (strstr(rbuf, "ontent-") == 0) {
- bb_full_write(s, "Content-type: text/plain\r\n\r\n", 28);
+ full_write(s, "Content-type: text/plain\r\n\r\n", 28);
}
firstLine = 0;
}
- if (bb_full_write(s, rbuf, count) != count)
+ if (full_write(s, rbuf, count) != count)
break;
#if DEBUG
@@ -1337,8 +1337,8 @@ static int sendFile(const char *url)
char *buf = config->buf;
sendHeaders(HTTP_OK);
- while ((count = bb_full_read(f, buf, MAX_MEMORY_BUFF)) > 0) {
- if (bb_full_write(a_c_w, buf, count) != count)
+ while ((count = full_read(f, buf, MAX_MEMORY_BUFF)) > 0) {
+ if (full_write(a_c_w, buf, count) != count)
break;
}
close(f);
@@ -2000,7 +2000,7 @@ int httpd_main(int argc, char *argv[])
# ifdef CONFIG_FEATURE_HTTPD_SETUID
/* drop privileges */
if(uid > 0)
- setuid(uid);
+ xsetuid(uid);
# endif
#endif
diff --git a/networking/nc.c b/networking/nc.c
index bda0c407b..117bbe20e 100644
--- a/networking/nc.c
+++ b/networking/nc.c
@@ -9,8 +9,6 @@
#include "busybox.h"
-#define xread bb_xread
-
static void timeout(int signum)
{
bb_error_msg_and_die("Timed out");
@@ -151,13 +149,14 @@ repeatyness:
for (fd = 0; fd < FD_SETSIZE; fd++) {
if (FD_ISSET(fd, &testfds)) {
- nread = xread(fd, bb_common_bufsiz1, sizeof(bb_common_bufsiz1));
+ nread = safe_read(fd, bb_common_bufsiz1,
+ sizeof(bb_common_bufsiz1));
if (fd == cfd) {
- if (!nread) exit(0);
+ if (nread<1) exit(0);
ofd = STDOUT_FILENO;
} else {
- if (!nread) {
+ if (nread<1) {
// Close outgoing half-connection so they get EOF, but
// leave incoming alone so we can see response.
shutdown(cfd, 1);
@@ -166,8 +165,7 @@ repeatyness:
ofd = cfd;
}
- if (bb_full_write(ofd, bb_common_bufsiz1, nread) < 0)
- bb_perror_msg_and_die(bb_msg_write_error);
+ xwrite(ofd, bb_common_bufsiz1, nread);
if (delay > 0) sleep(delay);
}
}
diff --git a/networking/tftp.c b/networking/tftp.c
index b0572c890..dfa599ab5 100644
--- a/networking/tftp.c
+++ b/networking/tftp.c
@@ -249,7 +249,7 @@ static int tftp(const int cmd, const struct hostent *host,
block_nr++;
if ((cmd & tftp_cmd_put) && (opcode == TFTP_DATA)) {
- len = bb_full_read(localfd, cp, tftp_bufsize - 4);
+ len = full_read(localfd, cp, tftp_bufsize - 4);
if (len < 0) {
bb_perror_msg(bb_msg_read_error);
@@ -420,7 +420,7 @@ static int tftp(const int cmd, const struct hostent *host,
if (tmp == block_nr) {
- len = bb_full_write(localfd, &buf[4], len - 4);
+ len = full_write(localfd, &buf[4], len - 4);
if (len < 0) {
bb_perror_msg(bb_msg_write_error);