diff options
37 files changed, 144 insertions, 110 deletions
diff --git a/bin/sh/memalloc.c b/bin/sh/memalloc.c index c106775..26b4b2d 100644 --- a/bin/sh/memalloc.c +++ b/bin/sh/memalloc.c @@ -161,7 +161,7 @@ stunalloc(p) pointer p; { if (p == NULL) { /*DEBUG */ - write(2, "stunalloc\n", 10); + write(STDERR_FILENO, "stunalloc\n", 10); abort(); } stacknleft += stacknxt - (char *)p; diff --git a/bin/sh/miscbltin.c b/bin/sh/miscbltin.c index 46d3950..5c5d154 100644 --- a/bin/sh/miscbltin.c +++ b/bin/sh/miscbltin.c @@ -171,7 +171,7 @@ readcmd(argc, argv) backslash = 0; STARTSTACKSTR(p); for (;;) { - if (read(0, &c, 1) != 1) { + if (read(STDIN_FILENO, &c, 1) != 1) { status = 1; break; } @@ -194,7 +194,7 @@ readcmd(argc, argv) } startword = 0; if (backslash && c == '\\') { - if (read(0, &c, 1) != 1) { + if (read(STDIN_FILENO, &c, 1) != 1) { status = 1; break; } diff --git a/libexec/rexecd/rexecd.c b/libexec/rexecd/rexecd.c index f820b90..57bb14c 100644 --- a/libexec/rexecd/rexecd.c +++ b/libexec/rexecd/rexecd.c @@ -237,7 +237,7 @@ doit(f, fromp) syslog(LOG_INFO, "login from %s as %s", remote, user); - (void) write(2, "\0", 1); + (void) write(STDERR_FILENO, "\0", 1); if (port) { (void) pipe(pv); pid = fork(); @@ -314,7 +314,7 @@ error(fmt, a1, a2, a3) buf[0] = 1; (void) snprintf(buf+1, sizeof(buf) - 1, fmt, a1, a2, a3); - (void) write(2, buf, strlen(buf)); + (void) write(STDERR_FILENO, buf, strlen(buf)); } void @@ -326,7 +326,7 @@ getstr(buf, cnt, err) char c; do { - if (read(0, &c, 1) != 1) + if (read(STDIN_FILENO, &c, 1) != 1) exit(1); *buf++ = c; if (--cnt == 0) { diff --git a/libexec/rlogind/rlogind.c b/libexec/rlogind/rlogind.c index f1cea97..f0df9df 100644 --- a/libexec/rlogind/rlogind.c +++ b/libexec/rlogind/rlogind.c @@ -586,7 +586,7 @@ getstr(buf, cnt, errmsg) char c; do { - if (read(0, &c, 1) != 1) + if (read(STDIN_FILENO, &c, 1) != 1) exit(1); if (--cnt < 0) fatal(STDOUT_FILENO, errmsg, 0); diff --git a/libexec/rtld-aout/rtld.c b/libexec/rtld-aout/rtld.c index 3a66319..7f0908b 100644 --- a/libexec/rtld-aout/rtld.c +++ b/libexec/rtld-aout/rtld.c @@ -2329,7 +2329,7 @@ char *fmt; #endif vsnprintf(buf, sizeof(buf), fmt, ap); - (void)write(1, buf, strlen(buf)); + (void)write(STDOUT_FILENO, buf, strlen(buf)); va_end(ap); } diff --git a/libexec/rtld-elf/debug.h b/libexec/rtld-elf/debug.h index 2600651..04314a9 100644 --- a/libexec/rtld-elf/debug.h +++ b/libexec/rtld-elf/debug.h @@ -53,7 +53,7 @@ extern int debug; #define assert(cond) ((cond) ? (void) 0 : \ (msg("ld-elf.so.1: assert failed: " __FILE__ ":" \ __XSTRING(__LINE__) "\n"), abort())) -#define msg(s) write(1, s, strlen(s)) +#define msg(s) write(STDOUT_FILENO, s, strlen(s)) #define trace() msg("ld-elf.so.1: " __XSTRING(__LINE__) "\n") #endif /* DEBUG_H */ diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index 4e907f3..3b67cb5 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -2107,6 +2107,6 @@ xprintf(const char *fmt, ...) va_start(ap, fmt); vsprintf(buf, fmt, ap); - (void)write(1, buf, strlen(buf)); + (void)write(STDOUT_FILENO, buf, strlen(buf)); va_end(ap); } diff --git a/libexec/uucpd/uucpd.c b/libexec/uucpd/uucpd.c index 7ca2b67..062c4ae 100644 --- a/libexec/uucpd/uucpd.c +++ b/libexec/uucpd/uucpd.c @@ -204,7 +204,7 @@ int readline(char start[], int num, int passw) register int n = num; while (n-- > 0) { - if (read(0, &c, 1) <= 0) + if (read(STDIN_FILENO, &c, 1) <= 0) return(-1); c &= 0177; if (c == '\n' || c == '\r' || c == '\0') { diff --git a/sbin/camcontrol/camcontrol.c b/sbin/camcontrol/camcontrol.c index 5d6dfc2..c82ef8b 100644 --- a/sbin/camcontrol/camcontrol.c +++ b/sbin/camcontrol/camcontrol.c @@ -1708,7 +1708,7 @@ scsicmd(struct cam_device *device, int argc, char **argv, char *combinedopt, u_int8_t *buf_ptr = data_ptr; for (amt_read = 0; amt_to_read > 0; - amt_read = read(0, buf_ptr, amt_to_read)) { + amt_read = read(STDIN_FILENO, buf_ptr, amt_to_read)) { if (amt_read == -1) { warn("error reading data from stdin"); error = 1; diff --git a/sbin/init/init.c b/sbin/init/init.c index 49aa374..81fe85e 100644 --- a/sbin/init/init.c +++ b/sbin/init/init.c @@ -663,7 +663,7 @@ single_user() pp = getpwnam("root"); if (typ && (typ->ty_status & TTY_SECURE) == 0 && pp && *pp->pw_passwd) { - write(2, banner, sizeof banner - 1); + write(STDERR_FILENO, banner, sizeof banner - 1); for (;;) { clear = getpass("Password:"); if (clear == 0 || *clear == '\0') diff --git a/usr.bin/chat/chat.c b/usr.bin/chat/chat.c index fd71405..03133d8 100644 --- a/usr.bin/chat/chat.c +++ b/usr.bin/chat/chat.c @@ -969,7 +969,7 @@ register char *s; if (say_next) { say_next = 0; s = clean(s,0); - write(2, s, strlen(s)); + write(STDERR_FILENO, s, strlen(s)); free(s); return; } @@ -1118,7 +1118,7 @@ int get_char() int status; char c; - status = read(0, &c, 1); + status = read(STDIN_FILENO, &c, 1); switch (status) { case 1: @@ -1146,7 +1146,7 @@ int c; usleep(10000); /* inter-character typing delay (?) */ - status = write(1, &ch, 1); + status = write(STDOUT_FILENO, &ch, 1); switch (status) { case 1: @@ -1253,12 +1253,12 @@ int n; break; /* fall through */ case '\n': - write(2, "\n", 1); + write(STDERR_FILENO, "\n", 1); need_lf = 0; break; default: s = character(n); - write(2, s, strlen(s)); + write(STDERR_FILENO, s, strlen(s)); need_lf = 1; break; } diff --git a/usr.bin/doscmd/tty.c b/usr.bin/doscmd/tty.c index 76c527f..6427b10 100644 --- a/usr.bin/doscmd/tty.c +++ b/usr.bin/doscmd/tty.c @@ -668,7 +668,7 @@ debug_event(void *pfd) char *ep; int r; - r = read(0, ibuf + icnt, sizeof(ibuf) - icnt); + r = read(STDIN_FILENO, ibuf + icnt, sizeof(ibuf) - icnt); if (r <= 0) return; @@ -1729,7 +1729,7 @@ tty_read(REGISTERS, int flag) if ((flag & TTYF_REDIRECT) && redirect0) { char c; - if (read(0, &c, 1) != 1) + if (read(STDIN_FILENO, &c, 1) != 1) return(-1); if (c == '\n') c = '\r'; diff --git a/usr.bin/ee/new_curse.c b/usr.bin/ee/new_curse.c index dd033be..cb55c18 100644 --- a/usr.bin/ee/new_curse.c +++ b/usr.bin/ee/new_curse.c @@ -2234,7 +2234,7 @@ timed_getchar() return(-1); } - return(read(0, &temp, 1)? temp : -1); + return(read(STDIN_FILENO, &temp, 1)? temp : -1); } #endif @@ -2252,11 +2252,11 @@ WINDOW *window; if (Noblock) in_value = ((bufp > 0) ? in_buff[--bufp] : timed_getchar()); else - in_value = ((bufp > 0) ? in_buff[--bufp] : read(0, &temp, 1)? temp : -1); + in_value = ((bufp > 0) ? in_buff[--bufp] : read(STDIN_FILENO, &temp, 1)? temp : -1); #else /* BSD_SELECT */ #ifdef SYS5 in_value = ((bufp > 0) ? in_buff[--bufp] : - (read(0, &temp, 1)> 0) ? temp : -1); + (read(STDIN_FILENO, &temp, 1)> 0) ? temp : -1); #else /* SYS5 */ if (Noblock) { @@ -2264,7 +2264,7 @@ WINDOW *window; old_arg = fcntl(0, F_GETFL, 0); in_value = fcntl(0, F_SETFL, old_arg | FNDELAY); } - in_value = ((bufp > 0) ? in_buff[--bufp] : read(0, &temp, 1)? temp : -1); + in_value = ((bufp > 0) ? in_buff[--bufp] : read(STDIN_FILENO, &temp, 1)? temp : -1); if (Noblock) { fcntl(0, F_SETFL, old_arg); diff --git a/usr.bin/leave/leave.c b/usr.bin/leave/leave.c index dbadc7e..37375e4 100644 --- a/usr.bin/leave/leave.c +++ b/usr.bin/leave/leave.c @@ -81,7 +81,7 @@ main(argc, argv) if (argc < 2) { #define MSG1 "When do you have to leave? " - (void)write(1, MSG1, sizeof(MSG1) - 1); + (void)write(STDOUT_FILENO, MSG1, sizeof(MSG1) - 1); cp = fgets(buf, sizeof(buf), stdin); if (cp == NULL || *cp == '\n') exit(0); @@ -166,7 +166,7 @@ doalarm(secs) #define MSG2 "\07\07You have to leave in 5 minutes.\n" if (secs >= FIVEMIN) { sleep(secs - FIVEMIN); - if (write(1, MSG2, sizeof(MSG2) - 1) != sizeof(MSG2) - 1) + if (write(STDOUT_FILENO, MSG2, sizeof(MSG2) - 1) != sizeof(MSG2) - 1) exit(0); secs = FIVEMIN; } @@ -175,19 +175,19 @@ doalarm(secs) #define MSG3 "\07\07Just one more minute!\n" if (secs >= ONEMIN) { sleep(secs - ONEMIN); - if (write(1, MSG3, sizeof(MSG3) - 1) != sizeof(MSG3) - 1) + if (write(STDOUT_FILENO, MSG3, sizeof(MSG3) - 1) != sizeof(MSG3) - 1) exit(0); } #define MSG4 "\07\07Time to leave!\n" for (bother = 10; bother--;) { sleep((u_int)ONEMIN); - if (write(1, MSG4, sizeof(MSG4) - 1) != sizeof(MSG4) - 1) + if (write(STDOUT_FILENO, MSG4, sizeof(MSG4) - 1) != sizeof(MSG4) - 1) exit(0); } #define MSG5 "\07\07That was the last time I'll tell you. Bye.\n" - (void)write(1, MSG5, sizeof(MSG5) - 1); + (void)write(STDOUT_FILENO, MSG5, sizeof(MSG5) - 1); exit(0); } diff --git a/usr.bin/make/compat.c b/usr.bin/make/compat.c index e68dd08..b4d2823 100644 --- a/usr.bin/make/compat.c +++ b/usr.bin/make/compat.c @@ -63,6 +63,7 @@ __RCSID("$FreeBSD$"); #include <ctype.h> #include <errno.h> #include <signal.h> +#include <unistd.h> #include "make.h" #include "hash.h" #include "dir.h" @@ -328,10 +329,10 @@ CompatRunCommand (cmdp, gnp) if (cpid == 0) { if (local) { execvp(av[0], av); - (void) write (2, av[0], strlen (av[0])); - (void) write (2, ":", 1); - (void) write (2, strerror(errno), strlen(strerror(errno))); - (void) write (2, "\n", 1); + (void) write (STDERR_FILENO, av[0], strlen (av[0])); + (void) write (STDERR_FILENO, ":", 1); + (void) write (STDERR_FILENO, strerror(errno), strlen(strerror(errno))); + (void) write (STDERR_FILENO, "\n", 1); } else { (void)execv(av[0], av); } diff --git a/usr.bin/make/hash.c b/usr.bin/make/hash.c index 684f3a6..c063f45 100644 --- a/usr.bin/make/hash.c +++ b/usr.bin/make/hash.c @@ -50,6 +50,7 @@ __RCSID("$FreeBSD$"); * table. Hash tables grow automatically as the amount of * information increases. */ +#include <unistd.h> #include "sprite.h" #include "make.h" #include "hash.h" @@ -293,7 +294,7 @@ Hash_DeleteEntry(t, e) return; } } - (void) write(2, "bad call to Hash_DeleteEntry\n", 29); + (void) write(STDERR_FILENO, "bad call to Hash_DeleteEntry\n", 29); abort(); } diff --git a/usr.bin/make/job.c b/usr.bin/make/job.c index 8fb15f2..72d3f3c 100644 --- a/usr.bin/make/job.c +++ b/usr.bin/make/job.c @@ -114,6 +114,7 @@ __RCSID("$FreeBSD$"); #include <stdio.h> #include <string.h> #include <signal.h> +#include <unistd.h> #include "make.h" #include "hash.h" #include "dir.h" @@ -1282,7 +1283,7 @@ JobExec(job, argv) #endif /* REMOTE */ (void) execv(shellPath, argv); - (void) write(2, "Could not execute shell\n", + (void) write(STDERR_FILENO, "Could not execute shell\n", sizeof("Could not execute shell")); _exit(1); } else { diff --git a/usr.bin/rsh/rsh.c b/usr.bin/rsh/rsh.c index 935515a..6067035 100644 --- a/usr.bin/rsh/rsh.c +++ b/usr.bin/rsh/rsh.c @@ -427,7 +427,7 @@ done: if (errno != EWOULDBLOCK) FD_CLR(rfd2, &readfrom); } else - (void)write(2, buf, cc); + (void)write(STDERR_FILENO, buf, cc); } if (FD_ISSET(rem, &ready)) { errno = 0; @@ -443,7 +443,7 @@ done: if (errno != EWOULDBLOCK) FD_CLR(rem, &readfrom); } else - (void)write(1, buf, cc); + (void)write(STDOUT_FILENO, buf, cc); } } while (FD_ISSET(rfd2, &readfrom) || FD_ISSET(rem, &readfrom)); } diff --git a/usr.bin/script/script.c b/usr.bin/script/script.c index b6a59c8..20c6a01 100644 --- a/usr.bin/script/script.c +++ b/usr.bin/script/script.c @@ -185,7 +185,7 @@ main(argc, argv) cc = read(master, obuf, sizeof (obuf)); if (cc <= 0) break; - (void)write(1, obuf, cc); + (void)write(STDOUT_FILENO, obuf, cc); (void)fwrite(obuf, 1, cc, fscript); } tvec = time(0); diff --git a/usr.bin/talk/io.c b/usr.bin/talk/io.c index 40604e0..4a6fd9e 100644 --- a/usr.bin/talk/io.c +++ b/usr.bin/talk/io.c @@ -48,6 +48,7 @@ static const char rcsid[] = #include <errno.h> #include <string.h> #include <sys/filio.h> +#include <unistd.h> #include "talk.h" #define A_LONG_TIME 10000000 @@ -105,7 +106,7 @@ talk() */ int i; ioctl(0, FIONREAD, (struct sgttyb *) &nb); - nb = read(0, buf, nb); + nb = read(STDIN_FILENO, buf, nb); display(&my_win, buf, nb); /* might lose data here because sockt is non-blocking */ for (i = 0; i < nb; ++i) diff --git a/usr.bin/tip/libacu/courier.c b/usr.bin/tip/libacu/courier.c index 84c710f..df19573 100644 --- a/usr.bin/tip/libacu/courier.c +++ b/usr.bin/tip/libacu/courier.c @@ -32,8 +32,9 @@ */ #ifndef lint -static char sccsid[] = "@(#)courier.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ +static const char rcsid[] = + "$FreeBSD$"; +#endif /* * Routines for calling up on a Courier modem. @@ -43,6 +44,7 @@ static char sccsid[] = "@(#)courier.c 8.1 (Berkeley) 6/6/93"; #include "tip.h" #include "acucommon.h" #include <stdio.h> +#include <unistd.h> #define MAXRETRY 5 @@ -299,7 +301,7 @@ int n; { #ifdef notdef if (boolean(value(VERBOSE))) - write(1, cp, n); + write(STDOUT_FILENO, cp, n); #endif acu_flush (); cour_nap(); @@ -322,7 +324,7 @@ cour_verbose_read() return; if (read(FD, buf, n) != n) return; - write(1, buf, n); + write(STDOUT_FILENO, buf, n); } #endif diff --git a/usr.bin/tip/libacu/multitech.c b/usr.bin/tip/libacu/multitech.c index 2eea101..2c3b2d9 100644 --- a/usr.bin/tip/libacu/multitech.c +++ b/usr.bin/tip/libacu/multitech.c @@ -32,8 +32,9 @@ */ #ifndef lint -static char sccsid[] = "@(#)multitech.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ +static const char rcsid[] = + "$FreeBSD$"; +#endif /* * Routines for calling up on a Courier modem. @@ -44,6 +45,7 @@ static char sccsid[] = "@(#)multitech.c 8.1 (Berkeley) 6/6/93"; #include "acucommon.h" #include <stdio.h> +#include <unistd.h> /* #define DEBUG */ #define MAXRETRY 5 @@ -395,7 +397,7 @@ multitech_verbose_read() return; if (read(FD, buf, n) != n) return; - write(1, buf, n); + write(STDOUT_FILENO, buf, n); } #endif diff --git a/usr.bin/tip/libacu/t3000.c b/usr.bin/tip/libacu/t3000.c index 1c9f472..b8caafe 100644 --- a/usr.bin/tip/libacu/t3000.c +++ b/usr.bin/tip/libacu/t3000.c @@ -32,8 +32,9 @@ */ #ifndef lint -static char sccsid[] = "@(#)t3000.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ +static const char rcsid[] = + "$FreeBSD$"; +#endif /* * Routines for calling up on a Telebit T3000 modem. @@ -43,6 +44,7 @@ static char sccsid[] = "@(#)t3000.c 8.1 (Berkeley) 6/6/93"; #include "tip.h" #include "acucommon.h" #include <stdio.h> +#include <unistd.h> #define MAXRETRY 5 @@ -315,7 +317,7 @@ int n; { #ifdef notdef if (boolean(value(VERBOSE))) - write(1, cp, n); + write(STDOUT_FILENO, cp, n); #endif acu_flush (); t3000_nap(); @@ -338,7 +340,7 @@ t3000_verbose_read() return; if (read(FD, buf, n) != n) return; - write(1, buf, n); + write(STDOUT_FILENO, buf, n); } #endif diff --git a/usr.bin/tip/libacu/unidialer.c b/usr.bin/tip/libacu/unidialer.c index 0206571..6fcec2f 100644 --- a/usr.bin/tip/libacu/unidialer.c +++ b/usr.bin/tip/libacu/unidialer.c @@ -53,6 +53,7 @@ static const char rcsid[] = #include <err.h> #include <stdio.h> #include <stdlib.h> +#include <unistd.h> #include "acucommon.h" #include "tod.h" @@ -798,7 +799,7 @@ static void unidialer_verbose_read() return; if (read(FD, buf, n) != n) return; - write(1, buf, n); + write(STDOUT_FILENO, buf, n); } #endif diff --git a/usr.bin/tip/tip/remcap.c b/usr.bin/tip/tip/remcap.c index 7a7e0c2..5a0e791 100644 --- a/usr.bin/tip/tip/remcap.c +++ b/usr.bin/tip/tip/remcap.c @@ -32,8 +32,9 @@ */ #ifndef lint -static char sccsid[] = "@(#)remcap.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ +static const char rcsid[] = + "$FreeBSD$"; +#endif /* * remcap - routines for dealing with the remote host data base @@ -44,6 +45,7 @@ static char sccsid[] = "@(#)remcap.c 8.1 (Berkeley) 6/6/93"; #include <fcntl.h> #include <ctype.h> #include <stdlib.h> +#include <unistd.h> #include "pathnames.h" #ifndef BUFSIZ @@ -112,7 +114,7 @@ tgetent(bp, name) while (*p++ != ':') ; if (strlen(bp) + strlen(p) > BUFSIZ) { - write(2, "Remcap entry too long\n", 23); + write(STDERR_FILENO, "Remcap entry too long\n", 23); return (-1); } strcat(bp, p); @@ -174,7 +176,7 @@ getent(bp, name, cp) break; } if (cp >= bp+BUFSIZ) { - write(2,"Remcap entry too long\n", 23); + write(STDERR_FILENO, "Remcap entry too long\n", 23); break; } else *cp++ = c; @@ -210,7 +212,7 @@ tnchktc() p = tbuf + strlen(tbuf) - 2; /* before the last colon */ while (*--p != ':') if (p<tbuf) { - write(2, "Bad remcap entry\n", 18); + write(STDERR_FILENO, "Bad remcap entry\n", 18); return (0); } p++; @@ -223,7 +225,7 @@ tnchktc() q++; *q = 0; if (++hopcount > MAXHOP) { - write(2, "Infinite tc= loop\n", 18); + write(STDERR_FILENO, "Infinite tc= loop\n", 18); return (0); } if (getent(tcbuf, tcname, remotefile) != 1) { @@ -236,7 +238,7 @@ tnchktc() ; l = p - holdtbuf + strlen(q); if (l > BUFSIZ) { - write(2, "Remcap entry too long\n", 23); + write(STDERR_FILENO, "Remcap entry too long\n", 23); q[BUFSIZ - (p-holdtbuf)] = 0; } strcpy(p, q); diff --git a/usr.bin/tip/tip/tipout.c b/usr.bin/tip/tip/tipout.c index 67932f6..ac40ec7 100644 --- a/usr.bin/tip/tip/tipout.c +++ b/usr.bin/tip/tip/tipout.c @@ -41,6 +41,7 @@ static const char rcsid[] = #include "tip.h" #include <errno.h> +#include <unistd.h> /* * tip * @@ -160,7 +161,7 @@ tipout() omask = sigblock(ALLSIGS); for (cp = buf; cp < buf + cnt; cp++) *cp &= 0177; - if (write(1, buf, cnt) < 0) + if (write(STDOUT_FILENO, buf, cnt) < 0) exit(1); if (boolean(value(SCRIPT)) && fscript != NULL) { if (!boolean(value(BEAUTIFY))) { diff --git a/usr.bin/vgrind/vgrindefs.c b/usr.bin/vgrind/vgrindefs.c index 23f06bd..2839d1f 100644 --- a/usr.bin/vgrind/vgrindefs.c +++ b/usr.bin/vgrind/vgrindefs.c @@ -32,13 +32,16 @@ */ #ifndef lint -static char sccsid[] = "@(#)vgrindefs.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ +static const char rcsid[] = + "$FreeBSD$"; +#endif #define BUFSIZ 1024 #define MAXHOP 32 /* max number of tc= indirections */ #include <ctype.h> +#include <unistd.h> + /* * grindcap - routines for dealing with the language definitions data base * (code stolen almost totally from termcap) @@ -103,7 +106,7 @@ tgetent(bp, name, file) break; } if (cp >= bp+BUFSIZ) { - write(2,"Vgrind entry too long\n", 23); + write(STDERR_FILENO, "Vgrind entry too long\n", 23); break; } else *cp++ = c; @@ -138,7 +141,7 @@ tnchktc() p = tbuf + strlen(tbuf) - 2; /* before the last colon */ while (*--p != ':') if (p<tbuf) { - write(2, "Bad vgrind entry\n", 18); + write(STDERR_FILENO, "Bad vgrind entry\n", 18); return (0); } p++; @@ -151,7 +154,7 @@ tnchktc() q++; *q = 0; if (++hopcount > MAXHOP) { - write(2, "Infinite tc= loop\n", 18); + write(STDERR_FILENO, "Infinite tc= loop\n", 18); return (0); } if (tgetent(tcbuf, tcname, filename) != 1) @@ -160,7 +163,7 @@ tnchktc() ; l = p - holdtbuf + strlen(q); if (l > BUFSIZ) { - write(2, "Vgrind entry too long\n", 23); + write(STDERR_FILENO, "Vgrind entry too long\n", 23); q[BUFSIZ - (p-tbuf)] = 0; } strcpy(p, q+1); diff --git a/usr.bin/window/ttoutput.c b/usr.bin/window/ttoutput.c index cc9afd9..1be0fa0 100644 --- a/usr.bin/window/ttoutput.c +++ b/usr.bin/window/ttoutput.c @@ -43,6 +43,7 @@ static char rcsid[] = #include "ww.h" #include "tt.h" #include <errno.h> +#include <unistd.h> /* * Buffered output package. @@ -65,7 +66,7 @@ ttflush() wwnflush++; for (p = tt_ob; p < tt_obp;) { wwnwr++; - n = write(1, p, tt_obp - p); + n = write(STDOUT_FILENO, p, tt_obp - p); if (n < 0) { wwnwre++; if (errno != EWOULDBLOCK) { diff --git a/usr.bin/window/wwrint.c b/usr.bin/window/wwrint.c index 5d753f5..3332273 100644 --- a/usr.bin/window/wwrint.c +++ b/usr.bin/window/wwrint.c @@ -46,6 +46,7 @@ static char rcsid[] = #include <fcntl.h> #endif +#include <unistd.h> /* * Tty input interrupt handler. * (1) Read input into buffer (wwib*). @@ -68,7 +69,7 @@ wwrint() /* we have set c_cc[VMIN] to 0 */ (void) fcntl(0, F_SETFL, O_NONBLOCK|wwnewtty.ww_fflags); #endif - n = read(0, wwibq, wwibe - wwibq); + n = read(STDIN_FILENO, wwibq, wwibe - wwibq); #if defined(OLD_TTY) || defined(VMIN_BUG) (void) fcntl(0, F_SETFL, wwnewtty.ww_fflags); #endif diff --git a/usr.sbin/ctm/ctm_rmail/options.h b/usr.sbin/ctm/ctm_rmail/options.h index 18b844c..5c8dd94 100644 --- a/usr.sbin/ctm/ctm_rmail/options.h +++ b/usr.sbin/ctm/ctm_rmail/options.h @@ -48,6 +48,8 @@ * * Based on recollection of the original options.h produced at the University * of Queensland by Ross Patterson (and possibly others). + * + * $FreeBSD$ */ static char *O_usage; @@ -60,11 +62,11 @@ pusage() /* * Avoid gratuitously loading stdio. */ - write(2, "Usage: ", 7); - write(2, O_name, strlen(O_name)); - write(2, " ", 1); - write(2, O_usage, strlen(O_usage)); - write(2, "\n", 1); + write(STDERR_FILENO, "Usage: ", 7); + write(STDERR_FILENO, O_name, strlen(O_name)); + write(STDERR_FILENO, " ", 1); + write(STDERR_FILENO, O_usage, strlen(O_usage)); + write(STDERR_FILENO, "\n", 1); } #define usage() (pusage(), exit(1)) diff --git a/usr.sbin/nghook/main.c b/usr.sbin/nghook/main.c index c0ef43d..c5fd205 100644 --- a/usr.sbin/nghook/main.c +++ b/usr.sbin/nghook/main.c @@ -156,7 +156,7 @@ main(int ac, char *av[]) /* Write packet to stdout */ if (asciiFlag) WriteAscii((u_char *) buf, rl); - else if ((wl = write(1, buf, rl)) != rl) { + else if ((wl = write(STDOUT_FILENO, buf, rl)) != rl) { if (wl < 0) { err(EX_OSERR, "write(stdout)"); } else { @@ -221,7 +221,7 @@ WriteAscii(u_char *buf, int len) sizeof(sbuf) - strlen(sbuf), " "); snprintf(sbuf + strlen(sbuf), sizeof(sbuf) - strlen(sbuf), "\n"); - (void) write(1, sbuf, strlen(sbuf)); + (void) write(STDOUT_FILENO, sbuf, strlen(sbuf)); } ch = '\n'; write(1, &ch, 1); diff --git a/usr.sbin/pcvt/keycap/keycap.c b/usr.sbin/pcvt/keycap/keycap.c index 9bbb7e5..9c276a3 100644 --- a/usr.sbin/pcvt/keycap/keycap.c +++ b/usr.sbin/pcvt/keycap/keycap.c @@ -35,6 +35,11 @@ * */ +#ifndef lint +static const char rcsid[] = + "$FreeBSD$"; +#endif + static char *id = "@(#)keycap.c, 3.20, Last Edit-Date: [Tue Dec 20 14:51:50 1994]"; @@ -64,6 +69,7 @@ static char *id = #include <stdio.h> #include <ctype.h> +#include <unistd.h> #include "keycap.h" @@ -137,7 +143,7 @@ char *bp, *name; break; } if (cp >= bp+KEYCAP_BUFSIZ) { - write(2,"Keycap entry too long\n", 23); + write(STDERR_FILENO, "Keycap entry too long\n", 23); break; } else *cp++ = c; @@ -170,7 +176,7 @@ static int knchktc() p = tbuf + strlen(tbuf) - 2; /* before the last colon */ while (*--p != ':') if (p<tbuf) { - write(2, "Bad keycap entry\n", 18); + write(STDERR_FILENO, "Bad keycap entry\n", 18); return (0); } p++; @@ -183,7 +189,7 @@ static int knchktc() q++; *q = 0; if (++hopcount > MAXHOP) { - write(2, "Infinite tc= loop\n", 18); + write(STDERR_FILENO, "Infinite tc= loop\n", 18); return (0); } if (kgetent(tcbuf, tcname) != 1) @@ -192,7 +198,7 @@ static int knchktc() ; l = p - holdtbuf + strlen(q); if (l > KEYCAP_BUFSIZ) { - write(2, "Keycap entry too long\n", 23); + write(STDERR_FILENO, "Keycap entry too long\n", 23); q[KEYCAP_BUFSIZ - (p-tbuf)] = 0; } strcpy(p, q+1); diff --git a/usr.sbin/pcvt/vttest/esc.c b/usr.sbin/pcvt/vttest/esc.c index b2bce92..e52cef2 100644 --- a/usr.sbin/pcvt/vttest/esc.c +++ b/usr.sbin/pcvt/vttest/esc.c @@ -1,5 +1,11 @@ +#include <unistd.h> #include "header.h" +#ifndef lint +static const char rcsid[] = + "$FreeBSD$"; +#endif + println(s) char *s; { printf("%s\n", s); } @@ -144,7 +150,7 @@ char inchar() { lval = val; brkrd = 0; reading = 1; - read(0,&ch,1); + read(STDIN_FILENO,&ch,1); reading = 0; if (brkrd) val = 0177; @@ -204,17 +210,17 @@ char *instr() { fflush(stdout); #ifdef XENIX while(rdchk(0)) { - read(0,result+i,1); + read(STDIN_FILENO,result+i,1); if (i++ == 78) break; } #else #ifdef SIII - while(read(2,result+i,1) == 1) + while(read(STDERR_FILENO,result+i,1) == 1) if (i++ == 78) break; #else while(ioctl(0,FIONREAD,&l1), l1 > 0L) { while(l1-- > 0L) { - read(0,result+i,1); + read(STDIN_FILENO,result+i,1); if (i++ == 78) goto out1; } } @@ -358,14 +364,14 @@ inflush() { #ifdef UNIX #ifdef XENIX - while(rdchk(0)) read(0,&val,1); + while(rdchk(0)) read(STDIN_FILENO,&val,1); #else #ifdef SIII - while(read(2,&val,1)); + while(read(STDERR_FILENO,&val,1)); #else long l1; ioctl (0, FIONREAD, &l1); - while(l1-- > 0L) read(0,&val,1); + while(l1-- > 0L) read(STDIN_FILENO,&val,1); #endif #endif #endif diff --git a/usr.sbin/pcvt/vttest/main.c b/usr.sbin/pcvt/vttest/main.c index 341de73..4093c57 100644 --- a/usr.sbin/pcvt/vttest/main.c +++ b/usr.sbin/pcvt/vttest/main.c @@ -93,8 +93,8 @@ main() { #ifdef UNIX initterminal(setjmp(intrenv)); - signal(SIGINT, onbrk); - signal(SIGTERM, onterm); + signal(SIGINT, (void *)onbrk); + signal(SIGTERM, (void *)onterm); reading = 0; #else initterminal(0); @@ -1914,7 +1914,7 @@ bye () { #ifdef UNIX onbrk() { - signal(SIGINT, onbrk); + signal(SIGINT, (void *)onbrk); if (reading) brkrd = 1; else @@ -1922,7 +1922,7 @@ onbrk() { } onterm() { - signal(SIGTERM, onterm); + signal(SIGTERM, (void *)onterm); longjmp(intrenv, 1); } #endif @@ -1939,7 +1939,7 @@ readnl() { fflush(stdout); brkrd = 0; reading = 1; - do { read(0,&ch,1); } while(ch != '\n' && !brkrd); + do { read(STDIN_FILENO,&ch,1); } while(ch != '\n' && !brkrd); if (brkrd) kill(getpid(), SIGTERM); reading = 0; diff --git a/usr.sbin/pppctl/pppctl.c b/usr.sbin/pppctl/pppctl.c index 753b32e..4ec2d94 100644 --- a/usr.sbin/pppctl/pppctl.c +++ b/usr.sbin/pppctl/pppctl.c @@ -147,7 +147,7 @@ Receive(int fd, int display) last = prompt; if (last) { last++; - write(1, Buffer, last-Buffer); + write(STDOUT_FILENO, Buffer, last-Buffer); } } prompt = prompt == NULL ? Buffer : prompt+1; @@ -162,7 +162,7 @@ Receive(int fd, int display) sprintf(Buffer, "passwd %s\n", passwd); memset(passwd, '\0', strlen(passwd)); if (display & REC_VERBOSE) - write(1, Buffer, strlen(Buffer)); + write(STDOUT_FILENO, Buffer, strlen(Buffer)); write(fd, Buffer, strlen(Buffer)); memset(Buffer, '\0', strlen(Buffer)); return Receive(fd, display & ~REC_PASSWD); @@ -180,13 +180,13 @@ Receive(int fd, int display) flush = sizeof Buffer / 2; else flush = last - Buffer + 1; - write(1, Buffer, flush); + write(STDOUT_FILENO, Buffer, flush); strcpy(Buffer, Buffer + flush); len -= flush; } if ((Result = select(fd + 1, &f, NULL, NULL, &t)) <= 0) { if (len) - write(1, Buffer, len); + write(STDOUT_FILENO, Buffer, len); break; } } @@ -217,7 +217,7 @@ InputHandler(int sig) len = read(data, buf, sizeof buf); if (len > 0) - write(1, buf, len); + write(STDOUT_FILENO, buf, len); else if (data != -1) longjmp(pppdead, -1); } @@ -613,7 +613,7 @@ main(int argc, char **argv) Buffer[sizeof(Buffer)-2] = '\0'; strcat(Buffer, "\n"); if (verbose) - write(1, Buffer, strlen(Buffer)); + write(STDOUT_FILENO, Buffer, strlen(Buffer)); write(fd, Buffer, strlen(Buffer)); if (Receive(fd, verbose | REC_SHOW) != 0) { fprintf(stderr, "Connection closed\n"); @@ -623,7 +623,7 @@ main(int argc, char **argv) start = ++next; } while (next && *next); if (verbose) - write(1, "quit\n", 5); + write(STDOUT_FILENO, "quit\n", 5); write(fd, "quit\n", 5); while (Receive(fd, verbose | REC_SHOW) == 0) ; diff --git a/usr.sbin/rmt/rmt.c b/usr.sbin/rmt/rmt.c index accebc6..c3e3615 100644 --- a/usr.sbin/rmt/rmt.c +++ b/usr.sbin/rmt/rmt.c @@ -98,7 +98,7 @@ main(argc, argv) top: errno = 0; rval = 0; - if (read(0, &c, 1) != 1) + if (read(STDIN_FILENO, &c, 1) != 1) exit(0); switch (c) { @@ -141,7 +141,7 @@ top: DEBUG1("rmtd: W %s\n", count); record = checkbuf(record, n); for (i = 0; i < n; i += cc) { - cc = read(0, &record[i], n - i); + cc = read(STDIN_FILENO, &record[i], n - i); if (cc <= 0) { DEBUG("rmtd: premature eof\n"); exit(2); @@ -161,8 +161,8 @@ top: if (rval < 0) goto ioerror; (void)sprintf(resp, "A%d\n", rval); - (void)write(1, resp, strlen(resp)); - (void)write(1, record, rval); + (void)write(STDOUT_FILENO, resp, strlen(resp)); + (void)write(STDOUT_FILENO, record, rval); goto top; case 'I': @@ -187,8 +187,8 @@ top: if (rval > 24) /* original mtget structure size */ rval = 24; (void)sprintf(resp, "A%d\n", rval); - (void)write(1, resp, strlen(resp)); - (void)write(1, (char *)&mtget, rval); + (void)write(STDOUT_FILENO, resp, strlen(resp)); + (void)write(STDOUT_FILENO, (char *)&mtget, rval); goto top; } @@ -205,7 +205,7 @@ top: respond: DEBUG1("rmtd: A %d\n", rval); (void)sprintf(resp, "A%d\n", rval); - (void)write(1, resp, strlen(resp)); + (void)write(STDOUT_FILENO, resp, strlen(resp)); goto top; ioerror: error(errno); @@ -220,7 +220,7 @@ getstring(bp) char *cp = bp; for (i = 0; i < SSIZE; i++) { - if (read(0, cp+i, 1) != 1) + if (read(STDIN_FILENO, cp+i, 1) != 1) exit(0); if (cp[i] == '\n') break; @@ -257,5 +257,5 @@ error(num) DEBUG2("rmtd: E %d (%s)\n", num, strerror(num)); (void)snprintf(resp, sizeof(resp), "E%d\n%s\n", num, strerror(num)); - (void)write(1, resp, strlen(resp)); + (void)write(STDOUT_FILENO, resp, strlen(resp)); } diff --git a/usr.sbin/rtadvd/advcap.c b/usr.sbin/rtadvd/advcap.c index 5cba1f5..d46cb89 100644 --- a/usr.sbin/rtadvd/advcap.c +++ b/usr.sbin/rtadvd/advcap.c @@ -162,7 +162,8 @@ getent(bp, name, cp) break; } if (cp >= bp+BUFSIZ) { - write(2,"Remcap entry too long\n", 23); + write(STDERR_FILENO, "Remcap entry too long\n", + 23); break; } else *cp++ = c; @@ -198,7 +199,7 @@ tnchktc() p = tbuf + strlen(tbuf) - 2; /* before the last colon */ while (*--p != ':') if (p<tbuf) { - write(2, "Bad remcap entry\n", 18); + write(STDERR_FILENO, "Bad remcap entry\n", 18); return (0); } p++; @@ -211,7 +212,7 @@ tnchktc() q++; *q = 0; if (++hopcount > MAXHOP) { - write(2, "Infinite tc= loop\n", 18); + write(STDERR_FILENO, "Infinite tc= loop\n", 18); return (0); } if (getent(tcbuf, tcname, remotefile) != 1) { @@ -221,7 +222,7 @@ tnchktc() ; l = p - holdtbuf + strlen(q); if (l > BUFSIZ) { - write(2, "Remcap entry too long\n", 23); + write(STDERR_FILENO, "Remcap entry too long\n", 23); q[BUFSIZ - (p-holdtbuf)] = 0; } strcpy(p, q); |