Replace 1 and 2 with STDOUT_FILENO and STDERR_FILENO.

ANSIfy and constify.
This commit is contained in:
mjl 2001-10-09 02:15:37 +00:00
parent 1c63cc9689
commit c903850da8
6 changed files with 65 additions and 99 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: key.c,v 1.3 1997/10/20 08:08:28 scottr Exp $ */
/* $NetBSD: key.c,v 1.4 2001/10/09 02:15:37 mjl Exp $ */
/*-
* Copyright (c) 1991, 1993, 1994
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)key.c 8.3 (Berkeley) 4/2/94";
#else
__RCSID("$NetBSD: key.c,v 1.3 1997/10/20 08:08:28 scottr Exp $");
__RCSID("$NetBSD: key.c,v 1.4 2001/10/09 02:15:37 mjl Exp $");
#endif
#endif /* not lint */
@ -78,7 +78,7 @@ static struct key {
#define F_NEEDARG 0x01 /* needs an argument */
#define F_OFFOK 0x02 /* can turn off */
int flags;
} keys[] = {
} const keys[] = {
{ "cbreak", f_cbreak, F_OFFOK },
{ "cols", f_columns, F_NEEDARG },
{ "columns", f_columns, F_NEEDARG },
@ -97,17 +97,14 @@ static struct key {
};
static int
c_key(a, b)
const void *a, *b;
c_key(const void *a, const void *b)
{
return (strcmp(((struct key *)a)->name, ((struct key *)b)->name));
}
int
ksearch(argvp, ip)
char ***argvp;
struct info *ip;
ksearch(char ***argvp, struct info *ip)
{
char *name;
struct key *kp, tmp;
@ -137,8 +134,7 @@ ksearch(argvp, ip)
}
void
f_cbreak(ip)
struct info *ip;
f_cbreak(struct info *ip)
{
if (ip->off)
@ -153,8 +149,7 @@ f_cbreak(ip)
}
void
f_columns(ip)
struct info *ip;
f_columns(struct info *ip)
{
ip->win.ws_col = atoi(ip->arg);
@ -162,8 +157,7 @@ f_columns(ip)
}
void
f_dec(ip)
struct info *ip;
f_dec(struct info *ip)
{
ip->t.c_cc[VERASE] = (u_char)0177;
@ -176,8 +170,7 @@ f_dec(ip)
}
void
f_extproc(ip)
struct info *ip;
f_extproc(struct info *ip)
{
if (ip->set) {
@ -190,8 +183,7 @@ f_extproc(ip)
}
void
f_ispeed(ip)
struct info *ip;
f_ispeed(struct info *ip)
{
cfsetispeed(&ip->t, atoi(ip->arg));
@ -199,8 +191,7 @@ f_ispeed(ip)
}
void
f_nl(ip)
struct info *ip;
f_nl(struct info *ip)
{
if (ip->off) {
@ -214,8 +205,7 @@ f_nl(ip)
}
void
f_ospeed(ip)
struct info *ip;
f_ospeed(struct info *ip)
{
cfsetospeed(&ip->t, atoi(ip->arg));
@ -223,8 +213,7 @@ f_ospeed(ip)
}
void
f_raw(ip)
struct info *ip;
f_raw(struct info *ip)
{
if (ip->off)
@ -238,8 +227,7 @@ f_raw(ip)
}
void
f_rows(ip)
struct info *ip;
f_rows(struct info *ip)
{
ip->win.ws_row = atoi(ip->arg);
@ -247,8 +235,7 @@ f_rows(ip)
}
void
f_sane(ip)
struct info *ip;
f_sane(struct info *ip)
{
ip->t.c_cflag = TTYDEF_CFLAG | (ip->t.c_cflag & (CLOCAL|CRTSCTS|CDTRCTS));
@ -262,8 +249,7 @@ f_sane(ip)
}
void
f_tty(ip)
struct info *ip;
f_tty(struct info *ip)
{
int tmp;

View File

@ -1,4 +1,4 @@
/* $NetBSD: lpd.c,v 1.30 2001/08/11 01:04:57 mjl Exp $ */
/* $NetBSD: lpd.c,v 1.31 2001/10/09 02:15:37 mjl Exp $ */
/*
* Copyright (c) 1983, 1993, 1994
@ -45,7 +45,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 1993, 1994\n\
#if 0
static char sccsid[] = "@(#)lpd.c 8.7 (Berkeley) 5/10/95";
#else
__RCSID("$NetBSD: lpd.c,v 1.30 2001/08/11 01:04:57 mjl Exp $");
__RCSID("$NetBSD: lpd.c,v 1.31 2001/10/09 02:15:37 mjl Exp $");
#endif
#endif /* not lint */
@ -440,7 +440,7 @@ doit(void)
do {
if (cp >= &cbuf[sizeof(cbuf) - 1])
fatal("Command line too long");
if ((n = read(1, cp, 1)) != 1) {
if ((n = read(STDOUT_FILENO, cp, 1)) != 1) {
if (n < 0)
fatal("Lost connection");
return;

View File

@ -1,4 +1,4 @@
/* $NetBSD: lpdchar.c,v 1.5 1997/07/17 05:44:32 mikel Exp $ */
/* $NetBSD: lpdchar.c,v 1.6 2001/10/09 02:15:38 mjl Exp $ */
/*
* Copyright (c) 1983, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)lpdchar.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: lpdchar.c,v 1.5 1997/07/17 05:44:32 mikel Exp $");
__RCSID("$NetBSD: lpdchar.c,v 1.6 2001/10/09 02:15:38 mjl Exp $");
#endif
#endif /* not lint */
@ -108,7 +108,7 @@ __RCSID("$NetBSD: lpdchar.c,v 1.5 1997/07/17 05:44:32 mikel Exp $");
#define c111111_ 0176
#define c1111111 0177
char scnkey[][HEIGHT] = /* this is relatively easy to modify */
const char scnkey[][HEIGHT] = /* this is relatively easy to modify */
/* just look: */
{
{ c_______,

View File

@ -1,4 +1,4 @@
/* $NetBSD: modes.c,v 1.3 1997/10/20 08:08:31 scottr Exp $ */
/* $NetBSD: modes.c,v 1.4 2001/10/09 02:15:38 mjl Exp $ */
/*-
* Copyright (c) 1991, 1993, 1994
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)modes.c 8.3 (Berkeley) 4/2/94";
#else
__RCSID("$NetBSD: modes.c,v 1.3 1997/10/20 08:08:31 scottr Exp $");
__RCSID("$NetBSD: modes.c,v 1.4 2001/10/09 02:15:38 mjl Exp $");
#endif
#endif /* not lint */
@ -59,7 +59,7 @@ struct modes {
* The code in optlist() depends on minus options following regular
* options, i.e. "foo" must immediately precede "-foo".
*/
struct modes cmodes[] = {
const struct modes cmodes[] = {
{ "cs5", CS5, CSIZE },
{ "cs6", CS6, CSIZE },
{ "cs7", CS7, CSIZE },
@ -95,7 +95,7 @@ struct modes cmodes[] = {
{ NULL },
};
struct modes imodes[] = {
const struct modes imodes[] = {
{ "ignbrk", IGNBRK, 0 },
{ "-ignbrk", 0, IGNBRK },
{ "brkint", BRKINT, 0 },
@ -131,7 +131,7 @@ struct modes imodes[] = {
{ NULL },
};
struct modes lmodes[] = {
const struct modes lmodes[] = {
{ "echo", ECHO, 0 },
{ "-echo", 0, ECHO },
{ "echoe", ECHOE, 0 },
@ -183,7 +183,7 @@ struct modes lmodes[] = {
{ NULL },
};
struct modes omodes[] = {
const struct modes omodes[] = {
{ "opost", OPOST, 0 },
{ "-opost", 0, OPOST },
{ "litout", 0, OPOST },
@ -200,11 +200,9 @@ struct modes omodes[] = {
#define CHK(s) (*name == s[0] && !strcmp(name, s))
int
msearch(argvp, ip)
char ***argvp;
struct info *ip;
msearch(char ***argvp, struct info *ip)
{
struct modes *mp;
const struct modes *mp;
char *name;
name = **argvp;

View File

@ -1,4 +1,4 @@
/* $NetBSD: printjob.c,v 1.29 2001/09/24 13:22:36 wiz Exp $ */
/* $NetBSD: printjob.c,v 1.30 2001/10/09 02:15:38 mjl Exp $ */
/*
* Copyright (c) 1983, 1993
@ -45,7 +45,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 1993\n\
#if 0
static char sccsid[] = "@(#)printjob.c 8.7 (Berkeley) 5/10/95";
#else
__RCSID("$NetBSD: printjob.c,v 1.29 2001/09/24 13:22:36 wiz Exp $");
__RCSID("$NetBSD: printjob.c,v 1.30 2001/10/09 02:15:38 mjl Exp $");
#endif
#endif /* not lint */
@ -142,7 +142,7 @@ static void setty __P((void));
static void alarmer __P((int));
void
printjob()
printjob(void)
{
struct stat stb;
struct queue *q, **qp;
@ -152,8 +152,8 @@ printjob()
int errcnt, count = 0;
init(); /* set up capabilities */
(void)write(1, "", 1); /* ack that daemon is started */
(void)close(2); /* set up log file */
(void)write(STDOUT_FILENO, "", 1); /* ack that daemon is started */
(void)close(STDERR_FILENO); /* set up log file */
if (open(LF, O_WRONLY|O_APPEND, 0664) < 0) {
syslog(LOG_ERR, "%s: %m", LF);
(void)open(_PATH_DEVNULL, O_WRONLY);
@ -316,8 +316,7 @@ char ifonts[4][40] = {
* and performing the various actions.
*/
static int
printit(file)
char *file;
printit(char *file)
{
int i;
char *cp;
@ -526,9 +525,7 @@ pass2:
* stderr as the log file, and must not ignore SIGINT.
*/
static int
print(format, file)
int format;
char *file;
print(int format, char *file)
{
FILE *fp;
int status;
@ -763,8 +760,7 @@ start:
* 0 if all is well.
*/
static int
sendit(file)
char *file;
sendit(char *file)
{
int i, err = OK;
char *cp, last[BUFSIZ];
@ -850,9 +846,7 @@ sendit(file)
* Return positive if we should try resending.
*/
static int
sendfile(type, file)
int type;
char *file;
sendfile(int type, char *file)
{
int f, i, amt;
struct stat stb;
@ -930,7 +924,7 @@ sendfile(type, file)
* Return non-zero if the connection was lost.
*/
static char
response()
response(void)
{
struct sigaction osa, nsa;
char resp;
@ -954,8 +948,7 @@ response()
* Banner printing stuff
*/
static void
banner(name1, name2)
char *name1, *name2;
banner(char *name1, char *name2)
{
time_t tvec;
@ -1011,9 +1004,7 @@ scnline(key, p, c)
#define TRC(q) (((q)-' ')&0177)
static void
scan_out(scfd, scsp, dlm)
int scfd, dlm;
char *scsp;
scan_out(int scfd, char *scsp, int dlm)
{
char *strp;
int nchrs, j;
@ -1072,9 +1063,7 @@ dropit(c)
* tell people about job completion
*/
static void
sendmail(user, bombed)
char *user;
int bombed;
sendmail(char *user, int bombed)
{
int i, p[2], s, nofile;
char *cp = NULL; /* XXX gcc */
@ -1154,8 +1143,7 @@ sendmail(user, bombed)
* dofork - fork with retries on failure
*/
static int
dofork(action)
int action;
dofork(int action)
{
int i, pid;
struct passwd *pw;
@ -1212,7 +1200,7 @@ abortpr(signo)
}
static void
init()
init(void)
{
int status;
char *s;
@ -1295,7 +1283,7 @@ init()
* Acquire line printer or remote connection.
*/
static void
openpr()
openpr(void)
{
int i, nofile;
char *cp;
@ -1349,8 +1337,7 @@ openpr()
* or to a terminal server on the net
*/
static void
opennet(cp)
char *cp;
opennet(char *cp)
{
int i;
int resp, port;
@ -1394,7 +1381,7 @@ opennet(cp)
* Printer is connected to an RS232 port on this host
*/
static void
opentty()
opentty(void)
{
int i;
@ -1422,7 +1409,7 @@ opentty()
* Printer is on a remote host
*/
static void
openrem()
openrem(void)
{
int i, n;
int resp;
@ -1452,8 +1439,7 @@ openrem()
}
static void
alarmer(s)
int s;
alarmer(int s)
{
/* nothing */
}
@ -1488,7 +1474,7 @@ struct bauds {
* setup tty lines.
*/
static void
setty()
setty(void)
{
struct info i;
char **argv, **ap, *p, *val;

View File

@ -1,4 +1,4 @@
/* $NetBSD: recvjob.c,v 1.12 2000/10/11 20:23:52 is Exp $ */
/* $NetBSD: recvjob.c,v 1.13 2001/10/09 02:15:38 mjl Exp $ */
/*
* Copyright (c) 1983, 1993
@ -45,7 +45,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 1993\n\
#if 0
static char sccsid[] = "@(#)recvjob.c 8.2 (Berkeley) 4/27/95";
#else
__RCSID("$NetBSD: recvjob.c,v 1.12 2000/10/11 20:23:52 is Exp $");
__RCSID("$NetBSD: recvjob.c,v 1.13 2001/10/09 02:15:38 mjl Exp $");
#endif
#endif /* not lint */
@ -70,7 +70,7 @@ __RCSID("$NetBSD: recvjob.c,v 1.12 2000/10/11 20:23:52 is Exp $");
#include "extern.h"
#include "pathnames.h"
#define ack() (void)write(1, sp, 1);
#define ack() (void)write(STDOUT_FILENO, sp, 1);
static char dfname[NAME_MAX]; /* data files */
static int minfree; /* keep at least minfree blocks available */
@ -88,7 +88,7 @@ static int readjob __P((void));
void
recvjob()
recvjob(void)
{
struct stat stb;
int status;
@ -139,7 +139,7 @@ recvjob()
* Return the number of jobs successfully transfered.
*/
static int
readjob()
readjob(void)
{
int size, nfiles;
char *cp;
@ -152,7 +152,7 @@ readjob()
*/
cp = line;
do {
if ((size = read(1, cp, 1)) != 1) {
if ((size = read(STDOUT_FILENO, cp, 1)) != 1) {
if (size < 0)
frecverr("%s: Lost connection",
printer);
@ -189,7 +189,7 @@ readjob()
frecverr("readjob: %s: illegal path name",
tfname);
if (!chksize(size)) {
(void)write(1, "\2", 1);
(void)write(STDOUT_FILENO, "\2", 1);
continue;
}
if (!readfile(tfname, size)) {
@ -210,7 +210,7 @@ readjob()
if (*cp++ != ' ')
break;
if (!chksize(size)) {
(void)write(1, "\2", 1);
(void)write(STDOUT_FILENO, "\2", 1);
continue;
}
(void)strncpy(dfname, cp, sizeof(dfname) - 1);
@ -229,9 +229,7 @@ readjob()
* Read files send by lpd and copy them to the spooling directory.
*/
static int
readfile(file, size)
char *file;
int size;
readfile(char *file, int size)
{
char *cp;
char buf[BUFSIZ];
@ -249,7 +247,7 @@ readfile(file, size)
if (i + amt > size)
amt = size - i;
do {
j = read(1, cp, amt);
j = read(STDOUT_FILENO, cp, amt);
if (j <= 0)
frecverr("Lost connection");
amt -= j;
@ -275,11 +273,11 @@ readfile(file, size)
}
static int
noresponse()
noresponse(void)
{
char resp;
if (read(1, &resp, 1) != 1)
if (read(STDOUT_FILENO, &resp, 1) != 1)
frecverr("Lost connection");
if (resp == '\0')
return(0);
@ -291,8 +289,7 @@ noresponse()
* 1 == OK, 0 == Not OK.
*/
static int
chksize(size)
int size;
chksize(int size)
{
int spacefree;
struct statfs sfb;
@ -329,8 +326,7 @@ read_number(fn)
* Remove all the files associated with the current job being transfered.
*/
static void
rcleanup(signo)
int signo;
rcleanup(int signo)
{
if (tfname[0])
(void)unlink(tfname);