summaryrefslogtreecommitdiff
path: root/networking
diff options
context:
space:
mode:
authorBernhard Reutner-Fischer2008-05-19 09:48:17 +0000
committerBernhard Reutner-Fischer2008-05-19 09:48:17 +0000
commit5e25ddb7d369b6785ec3aaa96cbc0521c22aeb0d (patch)
tree44b7cf5fb706b0816dd4525782ca8c37d07c2f43 /networking
parent636a1f85e89432601c59cdc3239fc867b4adf051 (diff)
downloadbusybox-5e25ddb7d369b6785ec3aaa96cbc0521c22aeb0d.zip
busybox-5e25ddb7d369b6785ec3aaa96cbc0521c22aeb0d.tar.gz
- use STD*_FILENO some more. No object-code changes
Diffstat (limited to 'networking')
-rw-r--r--networking/httpd.c24
-rw-r--r--networking/httpd_indexcgi.c2
-rw-r--r--networking/nc_bloaty.c12
-rw-r--r--networking/telnet.c10
4 files changed, 24 insertions, 24 deletions
diff --git a/networking/httpd.c b/networking/httpd.c
index 4094061..4da7e5c 100644
--- a/networking/httpd.c
+++ b/networking/httpd.c
@@ -947,7 +947,7 @@ static void log_and_exit(void)
/* Why??
(this also messes up stdin when user runs httpd -i from terminal)
ndelay_on(0);
- while (read(0, iobuf, IOBUF_SIZE) > 0)
+ while (read(STDIN_FILENO, iobuf, IOBUF_SIZE) > 0)
continue;
*/
@@ -1023,7 +1023,7 @@ static void send_headers(int responseNum)
if (DEBUG)
fprintf(stderr, "headers: '%s'\n", iobuf);
- full_write(1, iobuf, len);
+ full_write(STDOUT_FILENO, iobuf, len);
if (DEBUG)
fprintf(stderr, "writing error page: '%s'\n", error_page);
return send_file_and_exit(error_page, SEND_BODY);
@@ -1062,7 +1062,7 @@ static void send_headers(int responseNum)
}
if (DEBUG)
fprintf(stderr, "headers: '%s'\n", iobuf);
- if (full_write(1, iobuf, len) != len) {
+ if (full_write(STDOUT_FILENO, iobuf, len) != len) {
if (verbose > 1)
bb_perror_msg("error");
log_and_exit();
@@ -1090,7 +1090,7 @@ static int get_line(void)
while (1) {
if (hdr_cnt <= 0) {
- hdr_cnt = safe_read(0, hdr_buf, sizeof(hdr_buf));
+ hdr_cnt = safe_read(STDIN_FILENO, hdr_buf, sizeof(hdr_buf));
if (hdr_cnt <= 0)
break;
hdr_ptr = hdr_buf;
@@ -1202,8 +1202,8 @@ static NOINLINE void cgi_io_loop_and_exit(int fromCgi_rd, int toCgi_wr, int post
* and there *is* data to read from the peer
* (POSTDATA) */
//count = post_len > (int)sizeof(hdr_buf) ? (int)sizeof(hdr_buf) : post_len;
- //count = safe_read(0, hdr_buf, count);
- count = safe_read(0, hdr_buf, sizeof(hdr_buf));
+ //count = safe_read(STDIN_FILENO, hdr_buf, count);
+ count = safe_read(STDIN_FILENO, hdr_buf, sizeof(hdr_buf));
if (count > 0) {
hdr_cnt = count;
hdr_ptr = hdr_buf;
@@ -1237,8 +1237,8 @@ static NOINLINE void cgi_io_loop_and_exit(int fromCgi_rd, int toCgi_wr, int post
/* eof (or error) and there was no "HTTP",
* so write it, then write received data */
if (out_cnt) {
- full_write(1, HTTP_200, sizeof(HTTP_200)-1);
- full_write(1, rbuf, out_cnt);
+ full_write(STDOUT_FILENO, HTTP_200, sizeof(HTTP_200)-1);
+ full_write(STDOUT_FILENO, rbuf, out_cnt);
}
break; /* CGI stdout is closed, exiting */
}
@@ -1247,7 +1247,7 @@ static NOINLINE void cgi_io_loop_and_exit(int fromCgi_rd, int toCgi_wr, int post
/* "Status" header format is: "Status: 302 Redirected\r\n" */
if (out_cnt >= 8 && memcmp(rbuf, "Status: ", 8) == 0) {
/* send "HTTP/1.0 " */
- if (full_write(1, HTTP_200, 9) != 9)
+ if (full_write(STDOUT_FILENO, HTTP_200, 9) != 9)
break;
rbuf += 8; /* skip "Status: " */
count = out_cnt - 8;
@@ -1256,7 +1256,7 @@ static NOINLINE void cgi_io_loop_and_exit(int fromCgi_rd, int toCgi_wr, int post
/* Did CGI add "HTTP"? */
if (memcmp(rbuf, HTTP_200, 4) != 0) {
/* there is no "HTTP", do it ourself */
- if (full_write(1, HTTP_200, sizeof(HTTP_200)-1) != sizeof(HTTP_200)-1)
+ if (full_write(STDOUT_FILENO, HTTP_200, sizeof(HTTP_200)-1) != sizeof(HTTP_200)-1)
break;
}
/* Commented out:
@@ -1276,7 +1276,7 @@ static NOINLINE void cgi_io_loop_and_exit(int fromCgi_rd, int toCgi_wr, int post
if (count <= 0)
break; /* eof (or error) */
}
- if (full_write(1, rbuf, count) != count)
+ if (full_write(STDOUT_FILENO, rbuf, count) != count)
break;
if (DEBUG)
fprintf(stderr, "cgi read %d bytes: '%.*s'\n", count, count, rbuf);
@@ -1632,7 +1632,7 @@ static void send_file_and_exit(const char *url, int what)
while ((count = safe_read(f, iobuf, IOBUF_SIZE)) > 0) {
ssize_t n;
USE_FEATURE_HTTPD_RANGES(if (count > range_len) count = range_len;)
- n = full_write(1, iobuf, count);
+ n = full_write(STDOUT_FILENO, iobuf, count);
if (count != n)
break;
USE_FEATURE_HTTPD_RANGES(range_len -= count;)
diff --git a/networking/httpd_indexcgi.c b/networking/httpd_indexcgi.c
index fd64af3..94c6a69 100644
--- a/networking/httpd_indexcgi.c
+++ b/networking/httpd_indexcgi.c
@@ -125,7 +125,7 @@ static void guarantee(int size)
{
if (buffer + (BUFFER_SIZE-HEADROOM) - dst >= size)
return;
- write(1, buffer, dst - buffer);
+ write(STDOUT_FILENO, buffer, dst - buffer);
dst = buffer;
}
diff --git a/networking/nc_bloaty.c b/networking/nc_bloaty.c
index 4ba726e..5f7bd03 100644
--- a/networking/nc_bloaty.c
+++ b/networking/nc_bloaty.c
@@ -562,7 +562,7 @@ static int readwrite(void)
/* if we have a timeout AND stdin is closed AND we haven't heard anything
from the net during that time, assume it's dead and close it too. */
if (rr == 0) {
- if (!FD_ISSET(0, &ding1))
+ if (!FD_ISSET(STDIN_FILENO, &ding1))
netretry--; /* we actually try a coupla times. */
if (!netretry) {
if (o_verbose > 1) /* normally we don't care */
@@ -597,12 +597,12 @@ Debug("got %d from the net, errno %d", rr, errno);
goto shovel;
/* okay, suck more stdin */
- if (FD_ISSET(0, &ding2)) { /* stdin: ding! */
- rr = read(0, bigbuf_in, BIGSIZ);
+ if (FD_ISSET(STDIN_FILENO, &ding2)) { /* stdin: ding! */
+ rr = read(STDIN_FILENO, bigbuf_in, BIGSIZ);
/* Considered making reads here smaller for UDP mode, but 8192-byte
mobygrams are kinda fun and exercise the reassembler. */
if (rr <= 0) { /* at end, or fukt, or ... */
- FD_CLR(0, &ding1); /* disable and close stdin */
+ FD_CLR(STDIN_FILENO, &ding1); /* disable and close stdin */
close(0);
} else {
rzleft = rr;
@@ -625,7 +625,7 @@ Debug("got %d from the net, errno %d", rr, errno);
return 1;
}
if (rnleft) {
- rr = write(1, np, rnleft);
+ rr = write(STDOUT_FILENO, np, rnleft);
if (rr > 0) {
if (o_ofile) /* log the stdout */
oprint('<', (unsigned char *)np, rr);
@@ -783,7 +783,7 @@ int nc_main(int argc, char **argv)
}
#endif
- FD_SET(0, &ding1); /* stdin *is* initially open */
+ FD_SET(STDIN_FILENO, &ding1); /* stdin *is* initially open */
if (proggie) {
close(0); /* won't need stdin */
option_mask32 &= ~OPT_o; /* -o with -e is meaningless! */
diff --git a/networking/telnet.c b/networking/telnet.c
index b357e69..3a06c16 100644
--- a/networking/telnet.c
+++ b/networking/telnet.c
@@ -121,7 +121,7 @@ static void conescape(void)
" z suspend telnet\r\n"
" e exit telnet\r\n");
- if (read(0, &b, 1) <= 0)
+ if (read(STDIN_FILENO, &b, 1) <= 0)
doexit(EXIT_FAILURE);
switch (b) {
@@ -256,7 +256,7 @@ static void handlenetinput(int len)
}
if (len)
- write(1, G.buf, len);
+ write(STDOUT_FILENO, G.buf, len);
}
static void putiac(int c)
@@ -601,7 +601,7 @@ int telnet_main(int argc, char **argv)
ufds[0].events = ufds[1].events = POLLIN;
#else
FD_ZERO(&readfds);
- FD_SET(0, &readfds);
+ FD_SET(STDIN_FILENO, &readfds);
FD_SET(G.netfd, &readfds);
maxfd = G.netfd + 1;
#endif
@@ -629,10 +629,10 @@ int telnet_main(int argc, char **argv)
#ifdef USE_POLL
if (ufds[0].revents) /* well, should check POLLIN, but ... */
#else
- if (FD_ISSET(0, &rfds))
+ if (FD_ISSET(STDIN_FILENO, &rfds))
#endif
{
- len = read(0, G.buf, DATABUFSIZE);
+ len = read(STDIN_FILENO, G.buf, DATABUFSIZE);
if (len <= 0)
doexit(EXIT_SUCCESS);
TRACE(0, ("Read con: %d\n", len));