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>
This commit is contained in:
Sheldon Hearn 2001-07-26 11:02:39 +00:00
parent 8155f5e200
commit e1b4d8d074
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=80381
37 changed files with 144 additions and 110 deletions

View file

@ -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;

View file

@ -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;
}

View file

@ -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) {

View file

@ -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);

View file

@ -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);
}

View file

@ -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 */

View file

@ -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);
}

View file

@ -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') {

View file

@ -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;

View file

@ -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')

View file

@ -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;
}

View file

@ -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';

View file

@ -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);

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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();
}

View file

@ -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 {

View file

@ -427,7 +427,7 @@ reread: errno = 0;
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 @@ reread: errno = 0;
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));
}

View file

@ -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);

View file

@ -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)

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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);

View file

@ -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))) {

View file

@ -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);

View file

@ -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) {

View file

@ -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

View file

@ -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))

View file

@ -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);

View file

@ -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);

View file

@ -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

View file

@ -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;

View file

@ -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)
;

View file

@ -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 @@ main(argc, argv)
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 @@ main(argc, argv)
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 @@ main(argc, argv)
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 @@ main(argc, argv)
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));
}

View file

@ -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);