mirror of
https://github.com/sheumann/hush.git
synced 2024-12-25 18:33:06 +00:00
- use STD*_FILENO some more. No object-code changes
This commit is contained in:
parent
636a1f85e8
commit
5e25ddb7d3
@ -13,6 +13,6 @@ static const char usage_messages[] = ""
|
|||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
write(1, usage_messages, sizeof(usage_messages));
|
write(STDOUT_FILENO, usage_messages, sizeof(usage_messages));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -762,7 +762,7 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
if (i < 0)
|
if (i < 0)
|
||||||
fprintf(stderr,"%s\n", bunzip_errors[-i]);
|
fprintf(stderr,"%s\n", bunzip_errors[-i]);
|
||||||
else if (read(0, &c, 1))
|
else if (read(STDIN_FILENO, &c, 1))
|
||||||
fprintf(stderr,"Trailing garbage ignored\n");
|
fprintf(stderr,"Trailing garbage ignored\n");
|
||||||
return -i;
|
return -i;
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,7 @@ int split_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
bytes_read = safe_read(0, read_buffer, READ_BUFFER_SIZE);
|
bytes_read = safe_read(STDIN_FILENO, read_buffer, READ_BUFFER_SIZE);
|
||||||
if (!bytes_read)
|
if (!bytes_read)
|
||||||
break;
|
break;
|
||||||
if (bytes_read < 0)
|
if (bytes_read < 0)
|
||||||
@ -130,7 +130,7 @@ int split_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
xwrite(1, src, to_write);
|
xwrite(STDOUT_FILENO, src, to_write);
|
||||||
bytes_read -= to_write;
|
bytes_read -= to_write;
|
||||||
src += to_write;
|
src += to_write;
|
||||||
} while (bytes_read);
|
} while (bytes_read);
|
||||||
|
@ -825,7 +825,7 @@ static int printLines(int num1, int num2, int expandFlag)
|
|||||||
|
|
||||||
while (num1 <= num2) {
|
while (num1 <= num2) {
|
||||||
if (!expandFlag) {
|
if (!expandFlag) {
|
||||||
write(1, lp->data, lp->len);
|
write(STDOUT_FILENO, lp->data, lp->len);
|
||||||
setCurNum(num1++);
|
setCurNum(num1++);
|
||||||
lp = lp->next;
|
lp = lp->next;
|
||||||
continue;
|
continue;
|
||||||
|
@ -2220,7 +2220,7 @@ static char readit(void) // read (maybe cursor) key from stdin
|
|||||||
// get input from User- are there already input chars in Q?
|
// get input from User- are there already input chars in Q?
|
||||||
if (n <= 0) {
|
if (n <= 0) {
|
||||||
// the Q is empty, wait for a typed char
|
// the Q is empty, wait for a typed char
|
||||||
n = safe_read(0, readbuffer, sizeof(readbuffer));
|
n = safe_read(STDIN_FILENO, readbuffer, sizeof(readbuffer));
|
||||||
if (n < 0) {
|
if (n < 0) {
|
||||||
if (errno == EBADF || errno == EFAULT || errno == EINVAL
|
if (errno == EBADF || errno == EFAULT || errno == EINVAL
|
||||||
|| errno == EIO)
|
|| errno == EIO)
|
||||||
@ -2243,7 +2243,7 @@ static char readit(void) // read (maybe cursor) key from stdin
|
|||||||
&& ((size_t)n <= (sizeof(readbuffer) - 8))
|
&& ((size_t)n <= (sizeof(readbuffer) - 8))
|
||||||
) {
|
) {
|
||||||
// read the rest of the ESC string
|
// read the rest of the ESC string
|
||||||
int r = safe_read(0, readbuffer + n, sizeof(readbuffer) - n);
|
int r = safe_read(STDIN_FILENO, readbuffer + n, sizeof(readbuffer) - n);
|
||||||
if (r > 0)
|
if (r > 0)
|
||||||
n += r;
|
n += r;
|
||||||
}
|
}
|
||||||
@ -4035,7 +4035,7 @@ static void crash_test()
|
|||||||
printf("\n\n%d: \'%c\' %s\n\n\n%s[Hit return to continue]%s",
|
printf("\n\n%d: \'%c\' %s\n\n\n%s[Hit return to continue]%s",
|
||||||
totalcmds, last_input_char, msg, SOs, SOn);
|
totalcmds, last_input_char, msg, SOs, SOn);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
while (safe_read(0, d, 1) > 0) {
|
while (safe_read(STDIN_FILENO, d, 1) > 0) {
|
||||||
if (d[0] == '\n' || d[0] == '\r')
|
if (d[0] == '\n' || d[0] == '\r')
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -175,7 +175,7 @@ static void message(int where, const char *fmt, ...)
|
|||||||
|
|
||||||
if (where & L_CONSOLE) {
|
if (where & L_CONSOLE) {
|
||||||
/* Send console messages to console so people will see them. */
|
/* Send console messages to console so people will see them. */
|
||||||
full_write(2, msg, l);
|
full_write(STDERR_FILENO, msg, l);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -471,8 +471,8 @@ static pid_t run(const struct init_action *a)
|
|||||||
messageD(L_LOG, "waiting for enter to start '%s'"
|
messageD(L_LOG, "waiting for enter to start '%s'"
|
||||||
"(pid %d, tty '%s')\n",
|
"(pid %d, tty '%s')\n",
|
||||||
a->command, getpid(), a->terminal);
|
a->command, getpid(), a->terminal);
|
||||||
full_write(1, press_enter, sizeof(press_enter) - 1);
|
full_write(STDOUT_FILENO, press_enter, sizeof(press_enter) - 1);
|
||||||
while (safe_read(0, &c, 1) == 1 && c != '\n')
|
while (safe_read(STDIN_FILENO, &c, 1) == 1 && c != '\n')
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ static const char *unpack_usage_messages(void)
|
|||||||
|
|
||||||
static void full_write2_str(const char *str)
|
static void full_write2_str(const char *str)
|
||||||
{
|
{
|
||||||
full_write(2, str, strlen(str));
|
full_write(STDERR_FILENO, str, strlen(str));
|
||||||
}
|
}
|
||||||
|
|
||||||
void bb_show_usage(void)
|
void bb_show_usage(void)
|
||||||
|
@ -56,7 +56,7 @@ void bb_verror_msg(const char *s, va_list p, const char* strerr)
|
|||||||
|
|
||||||
if (logmode & LOGMODE_STDIO) {
|
if (logmode & LOGMODE_STDIO) {
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
full_write(2, msg, used + msgeol_len);
|
full_write(STDERR_FILENO, msg, used + msgeol_len);
|
||||||
}
|
}
|
||||||
if (logmode & LOGMODE_SYSLOG) {
|
if (logmode & LOGMODE_SYSLOG) {
|
||||||
syslog(LOG_ERR, "%s", msg + applet_len);
|
syslog(LOG_ERR, "%s", msg + applet_len);
|
||||||
|
@ -344,7 +344,7 @@ static void auto_baud(char *buf, unsigned size_buf, struct termios *tp)
|
|||||||
* try to extract the speed of the dial-in call.
|
* try to extract the speed of the dial-in call.
|
||||||
*/
|
*/
|
||||||
sleep(1);
|
sleep(1);
|
||||||
nread = safe_read(0, buf, size_buf - 1);
|
nread = safe_read(STDIN_FILENO, buf, size_buf - 1);
|
||||||
if (nread > 0) {
|
if (nread > 0) {
|
||||||
buf[nread] = '\0';
|
buf[nread] = '\0';
|
||||||
for (bp = buf; bp < buf + nread; bp++) {
|
for (bp = buf; bp < buf + nread; bp++) {
|
||||||
@ -421,7 +421,7 @@ static char *get_logname(char *logname, unsigned size_logname,
|
|||||||
while (cp->eol == '\0') {
|
while (cp->eol == '\0') {
|
||||||
|
|
||||||
/* Do not report trivial EINTR/EIO errors. */
|
/* Do not report trivial EINTR/EIO errors. */
|
||||||
if (read(0, &c, 1) < 1) {
|
if (read(STDIN_FILENO, &c, 1) < 1) {
|
||||||
if (errno == EINTR || errno == EIO)
|
if (errno == EINTR || errno == EIO)
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
bb_perror_msg_and_die("%s: read", op->tty);
|
bb_perror_msg_and_die("%s: read", op->tty);
|
||||||
@ -460,7 +460,7 @@ static char *get_logname(char *logname, unsigned size_logname,
|
|||||||
#endif
|
#endif
|
||||||
cp->erase = ascval; /* set erase character */
|
cp->erase = ascval; /* set erase character */
|
||||||
if (bp > logname) {
|
if (bp > logname) {
|
||||||
full_write(1, erase[cp->parity], 3);
|
full_write(STDOUT_FILENO, erase[cp->parity], 3);
|
||||||
bp--;
|
bp--;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -470,7 +470,7 @@ static char *get_logname(char *logname, unsigned size_logname,
|
|||||||
#endif
|
#endif
|
||||||
cp->kill = ascval; /* set kill character */
|
cp->kill = ascval; /* set kill character */
|
||||||
while (bp > logname) {
|
while (bp > logname) {
|
||||||
full_write(1, erase[cp->parity], 3);
|
full_write(STDOUT_FILENO, erase[cp->parity], 3);
|
||||||
bp--;
|
bp--;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -482,7 +482,7 @@ static char *get_logname(char *logname, unsigned size_logname,
|
|||||||
} else if ((int)(bp - logname) >= size_logname - 1) {
|
} else if ((int)(bp - logname) >= size_logname - 1) {
|
||||||
bb_error_msg_and_die("%s: input overrun", op->tty);
|
bb_error_msg_and_die("%s: input overrun", op->tty);
|
||||||
} else {
|
} else {
|
||||||
full_write(1, &c, 1); /* echo the character */
|
full_write(STDOUT_FILENO, &c, 1); /* echo the character */
|
||||||
*bp++ = ascval; /* and store it */
|
*bp++ = ascval; /* and store it */
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -715,7 +715,7 @@ int getty_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
|||||||
/* Write the modem init string and DON'T flush the buffers */
|
/* Write the modem init string and DON'T flush the buffers */
|
||||||
if (options.flags & F_INITSTRING) {
|
if (options.flags & F_INITSTRING) {
|
||||||
debug("writing init string\n");
|
debug("writing init string\n");
|
||||||
full_write(1, options.initstring, strlen(options.initstring));
|
full_write(STDOUT_FILENO, options.initstring, strlen(options.initstring));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Optionally detect the baud rate from the modem status message */
|
/* Optionally detect the baud rate from the modem status message */
|
||||||
@ -731,7 +731,7 @@ int getty_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
|||||||
char ch;
|
char ch;
|
||||||
|
|
||||||
debug("waiting for cr-lf\n");
|
debug("waiting for cr-lf\n");
|
||||||
while (safe_read(0, &ch, 1) == 1) {
|
while (safe_read(STDIN_FILENO, &ch, 1) == 1) {
|
||||||
debug("read %x\n", (unsigned char)ch);
|
debug("read %x\n", (unsigned char)ch);
|
||||||
ch &= 0x7f; /* strip "parity bit" */
|
ch &= 0x7f; /* strip "parity bit" */
|
||||||
if (ch == '\n' || ch == '\r')
|
if (ch == '\n' || ch == '\r')
|
||||||
@ -767,7 +767,7 @@ int getty_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
|||||||
termios_final(&options, &termios, &chardata);
|
termios_final(&options, &termios, &chardata);
|
||||||
|
|
||||||
/* Now the newline character should be properly written. */
|
/* Now the newline character should be properly written. */
|
||||||
full_write(1, "\n", 1);
|
full_write(STDOUT_FILENO, "\n", 1);
|
||||||
|
|
||||||
/* Let the login program take care of password validation. */
|
/* Let the login program take care of password validation. */
|
||||||
/* We use PATH because we trust that root doesn't set "bad" PATH,
|
/* We use PATH because we trust that root doesn't set "bad" PATH,
|
||||||
|
@ -1924,7 +1924,7 @@ static void identify_from_stdin(void)
|
|||||||
unsigned char *b = (unsigned char *)buf;
|
unsigned char *b = (unsigned char *)buf;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
xread(0, buf, 1280);
|
xread(STDIN_FILENO, buf, 1280);
|
||||||
|
|
||||||
// Convert the newline-separated hex data into an identify block.
|
// Convert the newline-separated hex data into an identify block.
|
||||||
|
|
||||||
|
@ -273,7 +273,7 @@ static void read_lines(void)
|
|||||||
/* if no unprocessed chars left, eat more */
|
/* if no unprocessed chars left, eat more */
|
||||||
if (readpos >= readeof) {
|
if (readpos >= readeof) {
|
||||||
ndelay_on(0);
|
ndelay_on(0);
|
||||||
eof_error = safe_read(0, readbuf, sizeof(readbuf));
|
eof_error = safe_read(STDIN_FILENO, readbuf, sizeof(readbuf));
|
||||||
ndelay_off(0);
|
ndelay_off(0);
|
||||||
readpos = 0;
|
readpos = 0;
|
||||||
readeof = eof_error;
|
readeof = eof_error;
|
||||||
|
@ -947,7 +947,7 @@ static void log_and_exit(void)
|
|||||||
/* Why??
|
/* Why??
|
||||||
(this also messes up stdin when user runs httpd -i from terminal)
|
(this also messes up stdin when user runs httpd -i from terminal)
|
||||||
ndelay_on(0);
|
ndelay_on(0);
|
||||||
while (read(0, iobuf, IOBUF_SIZE) > 0)
|
while (read(STDIN_FILENO, iobuf, IOBUF_SIZE) > 0)
|
||||||
continue;
|
continue;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -1023,7 +1023,7 @@ static void send_headers(int responseNum)
|
|||||||
|
|
||||||
if (DEBUG)
|
if (DEBUG)
|
||||||
fprintf(stderr, "headers: '%s'\n", iobuf);
|
fprintf(stderr, "headers: '%s'\n", iobuf);
|
||||||
full_write(1, iobuf, len);
|
full_write(STDOUT_FILENO, iobuf, len);
|
||||||
if (DEBUG)
|
if (DEBUG)
|
||||||
fprintf(stderr, "writing error page: '%s'\n", error_page);
|
fprintf(stderr, "writing error page: '%s'\n", error_page);
|
||||||
return send_file_and_exit(error_page, SEND_BODY);
|
return send_file_and_exit(error_page, SEND_BODY);
|
||||||
@ -1062,7 +1062,7 @@ static void send_headers(int responseNum)
|
|||||||
}
|
}
|
||||||
if (DEBUG)
|
if (DEBUG)
|
||||||
fprintf(stderr, "headers: '%s'\n", iobuf);
|
fprintf(stderr, "headers: '%s'\n", iobuf);
|
||||||
if (full_write(1, iobuf, len) != len) {
|
if (full_write(STDOUT_FILENO, iobuf, len) != len) {
|
||||||
if (verbose > 1)
|
if (verbose > 1)
|
||||||
bb_perror_msg("error");
|
bb_perror_msg("error");
|
||||||
log_and_exit();
|
log_and_exit();
|
||||||
@ -1090,7 +1090,7 @@ static int get_line(void)
|
|||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
if (hdr_cnt <= 0) {
|
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)
|
if (hdr_cnt <= 0)
|
||||||
break;
|
break;
|
||||||
hdr_ptr = hdr_buf;
|
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
|
* and there *is* data to read from the peer
|
||||||
* (POSTDATA) */
|
* (POSTDATA) */
|
||||||
//count = post_len > (int)sizeof(hdr_buf) ? (int)sizeof(hdr_buf) : post_len;
|
//count = post_len > (int)sizeof(hdr_buf) ? (int)sizeof(hdr_buf) : post_len;
|
||||||
//count = safe_read(0, hdr_buf, count);
|
//count = safe_read(STDIN_FILENO, hdr_buf, count);
|
||||||
count = safe_read(0, hdr_buf, sizeof(hdr_buf));
|
count = safe_read(STDIN_FILENO, hdr_buf, sizeof(hdr_buf));
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
hdr_cnt = count;
|
hdr_cnt = count;
|
||||||
hdr_ptr = hdr_buf;
|
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",
|
/* eof (or error) and there was no "HTTP",
|
||||||
* so write it, then write received data */
|
* so write it, then write received data */
|
||||||
if (out_cnt) {
|
if (out_cnt) {
|
||||||
full_write(1, HTTP_200, sizeof(HTTP_200)-1);
|
full_write(STDOUT_FILENO, HTTP_200, sizeof(HTTP_200)-1);
|
||||||
full_write(1, rbuf, out_cnt);
|
full_write(STDOUT_FILENO, rbuf, out_cnt);
|
||||||
}
|
}
|
||||||
break; /* CGI stdout is closed, exiting */
|
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" */
|
/* "Status" header format is: "Status: 302 Redirected\r\n" */
|
||||||
if (out_cnt >= 8 && memcmp(rbuf, "Status: ", 8) == 0) {
|
if (out_cnt >= 8 && memcmp(rbuf, "Status: ", 8) == 0) {
|
||||||
/* send "HTTP/1.0 " */
|
/* send "HTTP/1.0 " */
|
||||||
if (full_write(1, HTTP_200, 9) != 9)
|
if (full_write(STDOUT_FILENO, HTTP_200, 9) != 9)
|
||||||
break;
|
break;
|
||||||
rbuf += 8; /* skip "Status: " */
|
rbuf += 8; /* skip "Status: " */
|
||||||
count = out_cnt - 8;
|
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"? */
|
/* Did CGI add "HTTP"? */
|
||||||
if (memcmp(rbuf, HTTP_200, 4) != 0) {
|
if (memcmp(rbuf, HTTP_200, 4) != 0) {
|
||||||
/* there is no "HTTP", do it ourself */
|
/* 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;
|
break;
|
||||||
}
|
}
|
||||||
/* Commented out:
|
/* 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)
|
if (count <= 0)
|
||||||
break; /* eof (or error) */
|
break; /* eof (or error) */
|
||||||
}
|
}
|
||||||
if (full_write(1, rbuf, count) != count)
|
if (full_write(STDOUT_FILENO, rbuf, count) != count)
|
||||||
break;
|
break;
|
||||||
if (DEBUG)
|
if (DEBUG)
|
||||||
fprintf(stderr, "cgi read %d bytes: '%.*s'\n", count, count, rbuf);
|
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) {
|
while ((count = safe_read(f, iobuf, IOBUF_SIZE)) > 0) {
|
||||||
ssize_t n;
|
ssize_t n;
|
||||||
USE_FEATURE_HTTPD_RANGES(if (count > range_len) count = range_len;)
|
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)
|
if (count != n)
|
||||||
break;
|
break;
|
||||||
USE_FEATURE_HTTPD_RANGES(range_len -= count;)
|
USE_FEATURE_HTTPD_RANGES(range_len -= count;)
|
||||||
|
@ -125,7 +125,7 @@ static void guarantee(int size)
|
|||||||
{
|
{
|
||||||
if (buffer + (BUFFER_SIZE-HEADROOM) - dst >= size)
|
if (buffer + (BUFFER_SIZE-HEADROOM) - dst >= size)
|
||||||
return;
|
return;
|
||||||
write(1, buffer, dst - buffer);
|
write(STDOUT_FILENO, buffer, dst - buffer);
|
||||||
dst = buffer;
|
dst = buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -562,7 +562,7 @@ static int readwrite(void)
|
|||||||
/* if we have a timeout AND stdin is closed AND we haven't heard anything
|
/* 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. */
|
from the net during that time, assume it's dead and close it too. */
|
||||||
if (rr == 0) {
|
if (rr == 0) {
|
||||||
if (!FD_ISSET(0, &ding1))
|
if (!FD_ISSET(STDIN_FILENO, &ding1))
|
||||||
netretry--; /* we actually try a coupla times. */
|
netretry--; /* we actually try a coupla times. */
|
||||||
if (!netretry) {
|
if (!netretry) {
|
||||||
if (o_verbose > 1) /* normally we don't care */
|
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;
|
goto shovel;
|
||||||
|
|
||||||
/* okay, suck more stdin */
|
/* okay, suck more stdin */
|
||||||
if (FD_ISSET(0, &ding2)) { /* stdin: ding! */
|
if (FD_ISSET(STDIN_FILENO, &ding2)) { /* stdin: ding! */
|
||||||
rr = read(0, bigbuf_in, BIGSIZ);
|
rr = read(STDIN_FILENO, bigbuf_in, BIGSIZ);
|
||||||
/* Considered making reads here smaller for UDP mode, but 8192-byte
|
/* Considered making reads here smaller for UDP mode, but 8192-byte
|
||||||
mobygrams are kinda fun and exercise the reassembler. */
|
mobygrams are kinda fun and exercise the reassembler. */
|
||||||
if (rr <= 0) { /* at end, or fukt, or ... */
|
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);
|
close(0);
|
||||||
} else {
|
} else {
|
||||||
rzleft = rr;
|
rzleft = rr;
|
||||||
@ -625,7 +625,7 @@ Debug("got %d from the net, errno %d", rr, errno);
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (rnleft) {
|
if (rnleft) {
|
||||||
rr = write(1, np, rnleft);
|
rr = write(STDOUT_FILENO, np, rnleft);
|
||||||
if (rr > 0) {
|
if (rr > 0) {
|
||||||
if (o_ofile) /* log the stdout */
|
if (o_ofile) /* log the stdout */
|
||||||
oprint('<', (unsigned char *)np, rr);
|
oprint('<', (unsigned char *)np, rr);
|
||||||
@ -783,7 +783,7 @@ int nc_main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FD_SET(0, &ding1); /* stdin *is* initially open */
|
FD_SET(STDIN_FILENO, &ding1); /* stdin *is* initially open */
|
||||||
if (proggie) {
|
if (proggie) {
|
||||||
close(0); /* won't need stdin */
|
close(0); /* won't need stdin */
|
||||||
option_mask32 &= ~OPT_o; /* -o with -e is meaningless! */
|
option_mask32 &= ~OPT_o; /* -o with -e is meaningless! */
|
||||||
|
@ -121,7 +121,7 @@ static void conescape(void)
|
|||||||
" z suspend telnet\r\n"
|
" z suspend telnet\r\n"
|
||||||
" e exit telnet\r\n");
|
" e exit telnet\r\n");
|
||||||
|
|
||||||
if (read(0, &b, 1) <= 0)
|
if (read(STDIN_FILENO, &b, 1) <= 0)
|
||||||
doexit(EXIT_FAILURE);
|
doexit(EXIT_FAILURE);
|
||||||
|
|
||||||
switch (b) {
|
switch (b) {
|
||||||
@ -256,7 +256,7 @@ static void handlenetinput(int len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (len)
|
if (len)
|
||||||
write(1, G.buf, len);
|
write(STDOUT_FILENO, G.buf, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void putiac(int c)
|
static void putiac(int c)
|
||||||
@ -601,7 +601,7 @@ int telnet_main(int argc, char **argv)
|
|||||||
ufds[0].events = ufds[1].events = POLLIN;
|
ufds[0].events = ufds[1].events = POLLIN;
|
||||||
#else
|
#else
|
||||||
FD_ZERO(&readfds);
|
FD_ZERO(&readfds);
|
||||||
FD_SET(0, &readfds);
|
FD_SET(STDIN_FILENO, &readfds);
|
||||||
FD_SET(G.netfd, &readfds);
|
FD_SET(G.netfd, &readfds);
|
||||||
maxfd = G.netfd + 1;
|
maxfd = G.netfd + 1;
|
||||||
#endif
|
#endif
|
||||||
@ -629,10 +629,10 @@ int telnet_main(int argc, char **argv)
|
|||||||
#ifdef USE_POLL
|
#ifdef USE_POLL
|
||||||
if (ufds[0].revents) /* well, should check POLLIN, but ... */
|
if (ufds[0].revents) /* well, should check POLLIN, but ... */
|
||||||
#else
|
#else
|
||||||
if (FD_ISSET(0, &rfds))
|
if (FD_ISSET(STDIN_FILENO, &rfds))
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
len = read(0, G.buf, DATABUFSIZE);
|
len = read(STDIN_FILENO, G.buf, DATABUFSIZE);
|
||||||
if (len <= 0)
|
if (len <= 0)
|
||||||
doexit(EXIT_SUCCESS);
|
doexit(EXIT_SUCCESS);
|
||||||
TRACE(0, ("Read con: %d\n", len));
|
TRACE(0, ("Read con: %d\n", len));
|
||||||
|
@ -98,7 +98,7 @@ static void print_outbuf(void)
|
|||||||
{
|
{
|
||||||
int sz = cur_outbuf - outbuf;
|
int sz = cur_outbuf - outbuf;
|
||||||
if (sz > 0) {
|
if (sz > 0) {
|
||||||
xwrite(1, outbuf, sz);
|
xwrite(STDOUT_FILENO, outbuf, sz);
|
||||||
cur_outbuf = outbuf;
|
cur_outbuf = outbuf;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -888,7 +888,7 @@ int top_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
|||||||
/* batch mode, or EOF on stdin ("top </dev/null") */
|
/* batch mode, or EOF on stdin ("top </dev/null") */
|
||||||
sleep(interval);
|
sleep(interval);
|
||||||
else if (safe_poll(pfd, 1, interval * 1000) > 0) {
|
else if (safe_poll(pfd, 1, interval * 1000) > 0) {
|
||||||
if (safe_read(0, &c, 1) != 1) { /* error/EOF? */
|
if (safe_read(STDIN_FILENO, &c, 1) != 1) { /* error/EOF? */
|
||||||
option_mask32 |= OPT_EOF;
|
option_mask32 |= OPT_EOF;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -748,7 +748,7 @@ static int buffer_pread(/*int fd, */char *s, unsigned len)
|
|||||||
poll(&input, 1, i * 1000);
|
poll(&input, 1, i * 1000);
|
||||||
sigprocmask(SIG_BLOCK, &blocked_sigset, NULL);
|
sigprocmask(SIG_BLOCK, &blocked_sigset, NULL);
|
||||||
|
|
||||||
i = ndelay_read(0, s, len);
|
i = ndelay_read(STDIN_FILENO, s, len);
|
||||||
if (i >= 0)
|
if (i >= 0)
|
||||||
break;
|
break;
|
||||||
if (errno == EINTR)
|
if (errno == EINTR)
|
||||||
@ -994,7 +994,7 @@ int svlogd_main(int argc, char **argv)
|
|||||||
logmatch(ld);
|
logmatch(ld);
|
||||||
if (ld->matcherr == 'e') {
|
if (ld->matcherr == 'e') {
|
||||||
/* runit-1.8.0 compat: if timestamping, do it on stderr too */
|
/* runit-1.8.0 compat: if timestamping, do it on stderr too */
|
||||||
////full_write(2, printptr, printlen);
|
////full_write(STDERR_FILENO, printptr, printlen);
|
||||||
fwrite(printptr, 1, printlen, stderr);
|
fwrite(printptr, 1, printlen, stderr);
|
||||||
}
|
}
|
||||||
if (ld->match != '+') continue;
|
if (ld->match != '+') continue;
|
||||||
@ -1022,7 +1022,7 @@ int svlogd_main(int argc, char **argv)
|
|||||||
for (i = 0; i < dirn; ++i) {
|
for (i = 0; i < dirn; ++i) {
|
||||||
if (dir[i].fddir == -1) continue;
|
if (dir[i].fddir == -1) continue;
|
||||||
if (dir[i].matcherr == 'e') {
|
if (dir[i].matcherr == 'e') {
|
||||||
////full_write(2, lineptr, linelen);
|
////full_write(STDERR_FILENO, lineptr, linelen);
|
||||||
fwrite(lineptr, 1, linelen, stderr);
|
fwrite(lineptr, 1, linelen, stderr);
|
||||||
}
|
}
|
||||||
if (dir[i].match != '+') continue;
|
if (dir[i].match != '+') continue;
|
||||||
|
@ -1258,7 +1258,7 @@ stunalloc(void *p)
|
|||||||
{
|
{
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
if (!p || (g_stacknxt < (char *)p) || ((char *)p < g_stackp->space)) {
|
if (!p || (g_stacknxt < (char *)p) || ((char *)p < g_stackp->space)) {
|
||||||
write(2, "stunalloc\n", 10);
|
write(STDERR_FILENO, "stunalloc\n", 10);
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -743,7 +743,7 @@ static void print_tree(struct op *head)
|
|||||||
static void prs(const char *s)
|
static void prs(const char *s)
|
||||||
{
|
{
|
||||||
if (*s)
|
if (*s)
|
||||||
write(2, s, strlen(s));
|
write(STDERR_FILENO, s, strlen(s));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void prn(unsigned u)
|
static void prn(unsigned u)
|
||||||
@ -3384,7 +3384,7 @@ static int doread(struct op *t ATTRIBUTE_UNUSED, char **args)
|
|||||||
}
|
}
|
||||||
for (wp = args + 1; *wp; wp++) {
|
for (wp = args + 1; *wp; wp++) {
|
||||||
for (cp = global_env.linep; !nl && cp < elinep - 1; cp++) {
|
for (cp = global_env.linep; !nl && cp < elinep - 1; cp++) {
|
||||||
nb = nonblock_safe_read(0, cp, sizeof(*cp));
|
nb = nonblock_safe_read(STDIN_FILENO, cp, sizeof(*cp));
|
||||||
if (nb != sizeof(*cp))
|
if (nb != sizeof(*cp))
|
||||||
break;
|
break;
|
||||||
nl = (*cp == '\n');
|
nl = (*cp == '\n');
|
||||||
@ -4522,7 +4522,7 @@ static int readc(void)
|
|||||||
static void ioecho(char c)
|
static void ioecho(char c)
|
||||||
{
|
{
|
||||||
if (FLAG['v'])
|
if (FLAG['v'])
|
||||||
write(2, &c, sizeof c);
|
write(STDERR_FILENO, &c, sizeof c);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pushio(struct ioarg *argp, int (*fn) (struct ioarg *))
|
static void pushio(struct ioarg *argp, int (*fn) (struct ioarg *))
|
||||||
|
@ -124,7 +124,7 @@ int script_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
|||||||
goto restore;
|
goto restore;
|
||||||
}
|
}
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
full_write(1, buf, count);
|
full_write(STDOUT_FILENO, buf, count);
|
||||||
full_write(outfd, buf, count);
|
full_write(outfd, buf, count);
|
||||||
if (opt & 4) { /* -f */
|
if (opt & 4) { /* -f */
|
||||||
fsync(outfd);
|
fsync(outfd);
|
||||||
@ -132,7 +132,7 @@ int script_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (pfd[1].revents) {
|
if (pfd[1].revents) {
|
||||||
count = safe_read(0, buf, sizeof(buf));
|
count = safe_read(STDIN_FILENO, buf, sizeof(buf));
|
||||||
if (count <= 0) {
|
if (count <= 0) {
|
||||||
/* err/eof from stdin: don't read stdin anymore */
|
/* err/eof from stdin: don't read stdin anymore */
|
||||||
pfd[1].revents = 0;
|
pfd[1].revents = 0;
|
||||||
@ -152,7 +152,7 @@ int script_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
|||||||
loop = 999;
|
loop = 999;
|
||||||
/* pty is in O_NONBLOCK mode, we exit as soon as buffer is empty */
|
/* pty is in O_NONBLOCK mode, we exit as soon as buffer is empty */
|
||||||
while (--loop && (count = safe_read(pty, buf, sizeof(buf))) > 0) {
|
while (--loop && (count = safe_read(pty, buf, sizeof(buf))) > 0) {
|
||||||
full_write(1, buf, count);
|
full_write(STDOUT_FILENO, buf, count);
|
||||||
full_write(outfd, buf, count);
|
full_write(outfd, buf, count);
|
||||||
}
|
}
|
||||||
restore:
|
restore:
|
||||||
|
Loading…
Reference in New Issue
Block a user