diff options
author | Sheldon Hearn <sheldonh@FreeBSD.org> | 2001-07-26 11:02:39 +0000 |
---|---|---|
committer | Sheldon Hearn <sheldonh@FreeBSD.org> | 2001-07-26 11:02:39 +0000 |
commit | e1b4d8d0746069292d84708b0e11b17a7e1ef5e0 (patch) | |
tree | bd2ac2627dbeab7d3427432bb98d2c73085b61c1 /usr.bin | |
parent | 8155f5e200803441caa6e1bba5d9fa1f836d232f (diff) | |
download | src-e1b4d8d0746069292d84708b0e11b17a7e1ef5e0.tar.gz src-e1b4d8d0746069292d84708b0e11b17a7e1ef5e0.zip |
Use STD{ERR,IN,OUT}_FILENO instead of their numeric values. The
definitions are more readable, and it's possible that they're
more portable to pathalogical platforms.
Submitted by: David Hill <david@phobia.ms>
Notes
Notes:
svn path=/head/; revision=80381
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/chat/chat.c | 10 | ||||
-rw-r--r-- | usr.bin/doscmd/tty.c | 4 | ||||
-rw-r--r-- | usr.bin/ee/new_curse.c | 8 | ||||
-rw-r--r-- | usr.bin/leave/leave.c | 10 | ||||
-rw-r--r-- | usr.bin/make/compat.c | 9 | ||||
-rw-r--r-- | usr.bin/make/hash.c | 3 | ||||
-rw-r--r-- | usr.bin/make/job.c | 3 | ||||
-rw-r--r-- | usr.bin/rsh/rsh.c | 4 | ||||
-rw-r--r-- | usr.bin/script/script.c | 2 | ||||
-rw-r--r-- | usr.bin/talk/io.c | 3 | ||||
-rw-r--r-- | usr.bin/tip/libacu/courier.c | 10 | ||||
-rw-r--r-- | usr.bin/tip/libacu/multitech.c | 8 | ||||
-rw-r--r-- | usr.bin/tip/libacu/t3000.c | 10 | ||||
-rw-r--r-- | usr.bin/tip/libacu/unidialer.c | 3 | ||||
-rw-r--r-- | usr.bin/tip/tip/remcap.c | 16 | ||||
-rw-r--r-- | usr.bin/tip/tip/tipout.c | 3 | ||||
-rw-r--r-- | usr.bin/vgrind/vgrindefs.c | 15 | ||||
-rw-r--r-- | usr.bin/window/ttoutput.c | 3 | ||||
-rw-r--r-- | usr.bin/window/wwrint.c | 3 |
19 files changed, 73 insertions, 54 deletions
diff --git a/usr.bin/chat/chat.c b/usr.bin/chat/chat.c index fd71405d17b2..03133d84bd2a 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 76c527f65631..6427b109da59 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 dd033be368f2..cb55c18138ce 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 dbadc7e4f974..37375e417ccd 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 e68dd08c5540..b4d2823c300c 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 684f3a63a9f9..c063f454bfdc 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 8fb15f2c512a..72d3f3c050a7 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 935515a56b89..6067035ca350 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 b6a59c83a83d..20c6a0197645 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 40604e0105ef..4a6fd9e27f89 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 84c710f6b699..df19573d3094 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 2eea101a2071..2c3b2d992ae9 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 1c9f472e4203..b8caafe47d92 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 0206571007a1..6fcec2fb8684 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 7a7e0c2732ca..5a0e7911ee9f 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 67932f6f4045..ac40ec7d0bd2 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 23f06bd4c841..2839d1f2d3cc 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 cc9afd9c0e73..1be0fa056fd1 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 5d753f5e8540..3332273be459 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 |