summaryrefslogtreecommitdiff
path: root/usr.sbin/lpr/common_source
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/lpr/common_source')
-rw-r--r--usr.sbin/lpr/common_source/common.c57
-rw-r--r--usr.sbin/lpr/common_source/displayq.c64
-rw-r--r--usr.sbin/lpr/common_source/lp.h88
-rw-r--r--usr.sbin/lpr/common_source/net.c18
-rw-r--r--usr.sbin/lpr/common_source/printcap.c24
-rw-r--r--usr.sbin/lpr/common_source/rmjob.c44
-rw-r--r--usr.sbin/lpr/common_source/startdaemon.c3
7 files changed, 125 insertions, 173 deletions
diff --git a/usr.sbin/lpr/common_source/common.c b/usr.sbin/lpr/common_source/common.c
index e693e158d6365..2cf17ecf23d04 100644
--- a/usr.sbin/lpr/common_source/common.c
+++ b/usr.sbin/lpr/common_source/common.c
@@ -64,11 +64,11 @@ static const char rcsid[] =
* Routines and data common to all the line printer functions.
*/
char line[BUFSIZ];
-char *name; /* program name */
+const char *name; /* program name */
extern uid_t uid, euid;
-static int compar __P((const void *, const void *));
+static int compar(const void *_p1, const void *_p2);
/*
* Getline reads a line from the control file cfp, removes tabs, converts
@@ -76,8 +76,7 @@ static int compar __P((const void *, const void *));
* Returns 0 at EOF or the number of characters read.
*/
int
-getline(cfp)
- FILE *cfp;
+getline(FILE *cfp)
{
register int linel = 0;
register char *lp = line;
@@ -106,9 +105,7 @@ getline(cfp)
* Return the number of entries and a pointer to the list.
*/
int
-getq(pp, namelist)
- const struct printer *pp;
- struct jobqueue *(*namelist[]);
+getq(const struct printer *pp, struct jobqueue *(*namelist[]))
{
register struct dirent *d;
register struct jobqueue *q, **queue;
@@ -179,8 +176,7 @@ errdone:
* Compare modification times.
*/
static int
-compar(p1, p2)
- const void *p1, *p2;
+compar(const void *p1, const void *p2)
{
const struct jobqueue *qe1, *qe2;
@@ -207,24 +203,20 @@ compar(p1, p2)
/* sleep n milliseconds */
void
-delay(n)
- int n;
+delay(int millisec)
{
struct timeval tdelay;
- if (n <= 0 || n > 10000)
+ if (millisec <= 0 || millisec > 10000)
fatal((struct printer *)0, /* fatal() knows how to deal */
- "unreasonable delay period (%d)", n);
- tdelay.tv_sec = n / 1000;
- tdelay.tv_usec = n * 1000 % 1000000;
+ "unreasonable delay period (%d)", millisec);
+ tdelay.tv_sec = millisec / 1000;
+ tdelay.tv_usec = millisec * 1000 % 1000000;
(void) select(0, (fd_set *)0, (fd_set *)0, (fd_set *)0, &tdelay);
}
char *
-lock_file_name(pp, buf, len)
- const struct printer *pp;
- char *buf;
- size_t len;
+lock_file_name(const struct printer *pp, char *buf, size_t len)
{
static char staticbuf[MAXPATHLEN];
@@ -243,10 +235,7 @@ lock_file_name(pp, buf, len)
}
char *
-status_file_name(pp, buf, len)
- const struct printer *pp;
- char *buf;
- size_t len;
+status_file_name(const struct printer *pp, char *buf, size_t len)
{
static char staticbuf[MAXPATHLEN];
@@ -266,10 +255,7 @@ status_file_name(pp, buf, len)
/* routine to get a current timestamp, optionally in a standard-fmt string */
void
-lpd_gettime(tsp, strp, strsize)
- struct timespec *tsp;
- char *strp;
- int strsize;
+lpd_gettime(struct timespec *tsp, char *strp, int strsize)
{
struct timespec local_ts;
struct timeval btime;
@@ -331,10 +317,7 @@ lpd_gettime(tsp, strp, strsize)
/* routines for writing transfer-statistic records */
void
-trstat_init(pp, fname, filenum)
- struct printer *pp;
- const char *fname;
- int filenum;
+trstat_init(struct printer *pp, const char *fname, int filenum)
{
register const char *srcp;
register char *destp, *endp;
@@ -369,13 +352,8 @@ trstat_init(pp, fname, filenum)
}
void
-trstat_write(pp, sendrecv, bytecnt, userid, otherhost, orighost)
- struct printer *pp;
- tr_sendrecv sendrecv;
- size_t bytecnt;
- const char *userid;
- const char *otherhost;
- const char *orighost;
+trstat_write(struct printer *pp, tr_sendrecv sendrecv, size_t bytecnt,
+ const char *userid, const char *otherhost, const char *orighost)
{
#define STATLINE_SIZE 1024
double trtime;
@@ -594,8 +572,7 @@ fatal(pp, msg, va_alist)
* be better to close the first N fds, for some small value of N.
*/
void
-closeallfds(start)
- int start;
+closeallfds(int start)
{
int stop = getdtablesize();
for (; start < stop; start++)
diff --git a/usr.sbin/lpr/common_source/displayq.c b/usr.sbin/lpr/common_source/displayq.c
index 5dfe621968c9b..df82d56673b47 100644
--- a/usr.sbin/lpr/common_source/displayq.c
+++ b/usr.sbin/lpr/common_source/displayq.c
@@ -81,19 +81,17 @@ static int lflag; /* long output option */
static int rank; /* order to be printed (-1=none, 0=active) */
static long totsize; /* total print job size in bytes */
-static char *head0 = "Rank Owner Job Files";
-static char *head1 = "Total Size\n";
+static const char *head0 = "Rank Owner Job Files";
+static const char *head1 = "Total Size\n";
-static void alarmhandler __P((int));
-static void warn __P((const struct printer *pp));
+static void alarmhandler(int _signo);
+static void warn(const struct printer *_pp);
/*
* Display the current state of the queue. Format = 1 if long format.
*/
void
-displayq(pp, format)
- struct printer *pp;
- int format;
+displayq(struct printer *pp, int format)
{
register struct jobqueue *q;
register int i, nitems, fd, ret;
@@ -258,8 +256,7 @@ displayq(pp, format)
* Print a warning message if there is no daemon present.
*/
static void
-warn(pp)
- const struct printer *pp;
+warn(const struct printer *pp)
{
if (pp->remote)
printf("%s: ", host);
@@ -271,7 +268,7 @@ warn(pp)
* Print the header for the short listing format
*/
void
-header()
+header(void)
{
printf(head0);
col = strlen(head0)+1;
@@ -280,9 +277,7 @@ header()
}
void
-inform(pp, cf)
- const struct printer *pp;
- char *cf;
+inform(const struct printer *pp, char *cf)
{
register int copycnt;
char savedname[MAXPATHLEN+1];
@@ -382,8 +377,7 @@ inform(pp, cf)
}
int
-inlist(name, file)
- char *name, *file;
+inlist(char *uname, char *cfile)
{
register int *r, n;
register char **u, *cp;
@@ -394,12 +388,12 @@ inlist(name, file)
* Check to see if it's in the user list
*/
for (u = user; u < &user[users]; u++)
- if (!strcmp(*u, name))
+ if (!strcmp(*u, uname))
return(1);
/*
* Check the request list
*/
- for (n = 0, cp = file+3; isdigit(*cp); )
+ for (n = 0, cp = cfile+3; isdigit(*cp); )
n = n * 10 + (*cp++ - '0');
for (r = requ; r < &requ[requests]; r++)
if (*r == n && !strcmp(cp, from))
@@ -408,26 +402,23 @@ inlist(name, file)
}
void
-show(nfile, file, copies)
- register char *nfile, *file;
- int copies;
+show(const char *nfile, const char *datafile, int copies)
{
if (strcmp(nfile, " ") == 0)
nfile = "(standard input)";
if (lflag)
- ldump(nfile, file, copies);
+ ldump(nfile, datafile, copies);
else
- dump(nfile, file, copies);
+ dump(nfile, datafile, copies);
}
/*
* Fill the line with blanks to the specified column
*/
void
-blankfill(n)
- register int n;
+blankfill(int tocol)
{
- while (col++ < n)
+ while (col++ < tocol)
putchar(' ');
}
@@ -435,9 +426,7 @@ blankfill(n)
* Give the abbreviated dump of the file names
*/
void
-dump(nfile, file, copies)
- char *nfile, *file;
- int copies;
+dump(const char *nfile, const char *datafile, int copies)
{
struct stat lbuf;
const char etctmpl[] = ", ...";
@@ -488,7 +477,7 @@ dump(nfile, file, copies)
first = 0;
seteuid(euid);
- if (*file && !stat(file, &lbuf))
+ if (*datafile && !stat(datafile, &lbuf))
totsize += copies * lbuf.st_size;
seteuid(uid);
}
@@ -497,9 +486,7 @@ dump(nfile, file, copies)
* Print the long info about the file
*/
void
-ldump(nfile, file, copies)
- char *nfile, *file;
- int copies;
+ldump(const char *nfile, const char *datafile, int copies)
{
struct stat lbuf;
@@ -508,7 +495,7 @@ ldump(nfile, file, copies)
printf("%-2d copies of %-19s", copies, nfile);
else
printf("%-32s", nfile);
- if (*file && !stat(file, &lbuf))
+ if (*datafile && !stat(datafile, &lbuf))
printf(" %qd bytes", (long long) lbuf.st_size);
else
printf(" ??? bytes");
@@ -520,11 +507,10 @@ ldump(nfile, file, copies)
* update col for screen management
*/
void
-prank(n)
- int n;
+prank(int n)
{
char rline[100];
- static char *r[] = {
+ static const char *r[] = {
"th", "st", "nd", "rd", "th", "th", "th", "th", "th", "th"
};
@@ -542,8 +528,8 @@ prank(n)
}
void
-alarmhandler(signo)
- int signo;
+alarmhandler(int signo __unused)
{
- /* ignored */
+ /* the signal is ignored */
+ /* (the '__unused' is just to avoid a compile-time warning) */
}
diff --git a/usr.sbin/lpr/common_source/lp.h b/usr.sbin/lpr/common_source/lp.h
index 309a770744657..2bfd84c9403a7 100644
--- a/usr.sbin/lpr/common_source/lp.h
+++ b/usr.sbin/lpr/common_source/lp.h
@@ -153,7 +153,7 @@ struct request {
* Global definitions for the line printer system.
*/
extern char line[BUFSIZ];
-extern char *name; /* program name */
+extern const char *name; /* program name */
/* host machine name */
extern char host[MAXHOSTNAMELEN];
extern char *from; /* client's machine name */
@@ -221,48 +221,48 @@ typedef enum { TR_SENDING, TR_RECVING, TR_PRINTING } tr_sendrecv;
__BEGIN_DECLS
struct dirent;
-void blankfill __P((int));
-char *checkremote __P((struct printer *pp));
-int chk __P((char *));
-void closeallfds __P((int start));
-void delay __P((int));
-void displayq __P((struct printer *pp, int format));
-void dump __P((char *, char *, int));
-void fatal __P((const struct printer *pp, const char *fmp, ...));
-int firstprinter __P((struct printer *pp, int *status));
-void free_printer __P((struct printer *pp));
-void free_request __P((struct request *rp));
-int getline __P((FILE *));
-int getport __P((const struct printer *pp, const char *, int));
-int getprintcap __P((const char *printer, struct printer *pp));
-int getq __P((const struct printer *, struct jobqueue *(*[])));
-void header __P((void));
-void inform __P((const struct printer *pp, char *cf));
-void init_printer __P((struct printer *pp));
-void init_request __P((struct request *rp));
-int inlist __P((char *, char *));
-int iscf __P((struct dirent *));
-int isowner __P((char *, char *));
-void ldump __P((char *, char *, int));
-void lastprinter __P((void));
-int lockchk __P((struct printer *pp, char *));
-char *lock_file_name __P((const struct printer *pp, char *buf, size_t len));
-void lpd_gettime __P((struct timespec *_tsp, char *_strp, int _strsize));
-int nextprinter __P((struct printer *pp, int *status));
+void blankfill(int _tocol);
+char *checkremote(struct printer *_pp);
+int chk(char *_file);
+void closeallfds(int _start);
+void delay(int _millisec);
+void displayq(struct printer *_pp, int _format);
+void dump(const char *_nfile, const char *_datafile, int _copies);
+void fatal(const struct printer *_pp, const char *_msg, ...);
+int firstprinter(struct printer *_pp, int *_error);
+void free_printer(struct printer *_pp);
+void free_request(struct request *_rp);
+int getline(FILE *_cfp);
+int getport(const struct printer *_pp, const char *_rhost, int _rport);
+int getprintcap(const char *_printer, struct printer *_pp);
+int getq(const struct printer *_pp, struct jobqueue *(*_namelist[]));
+void header(void);
+void inform(const struct printer *_pp, char *_cf);
+void init_printer(struct printer *_pp);
+void init_request(struct request *_rp);
+int inlist(char *_uname, char *_cfile);
+int iscf(struct dirent *_d);
+int isowner(char *_owner, char *_file);
+void ldump(const char *_nfile, const char *_datafile, int _copies);
+void lastprinter(void);
+int lockchk(struct printer *_pp, char *_slockf);
+char *lock_file_name(const struct printer *_pp, char *_buf, size_t _len);
+void lpd_gettime(struct timespec *_tsp, char *_strp, int _strsize);
+int nextprinter(struct printer *_pp, int *_error);
const
-char *pcaperr __P((int error));
-void prank __P((int));
-void process __P((const struct printer *pp, char *));
-void rmjob __P((const char *printer));
-void rmremote __P((const struct printer *pp));
-void setprintcap __P((char *newprintcap));
-void show __P((char *, char *, int));
-int startdaemon __P((const struct printer *pp));
-char *status_file_name __P((const struct printer *pp, char *buf,
- size_t len));
-void trstat_init __P((struct printer *pp, const char *fname, int filenum));
-void trstat_write __P((struct printer *pp, tr_sendrecv sendrecv,
- size_t bytecnt, const char *userid,
- const char *otherhost, const char *orighost));
-ssize_t writel __P((int s, ...));
+char *pcaperr(int _error);
+void prank(int _n);
+void process(const struct printer *_pp, char *_file);
+void rmjob(const char *_printer);
+void rmremote(const struct printer *_pp);
+void setprintcap(char *_newfile);
+void show(const char *_nfile, const char *_datafile, int _copies);
+int startdaemon(const struct printer *_pp);
+char *status_file_name(const struct printer *_pp, char *_buf,
+ size_t _len);
+void trstat_init(struct printer *_pp, const char *_fname, int _filenum);
+void trstat_write(struct printer *_pp, tr_sendrecv _sendrecv,
+ size_t _bytecnt, const char *_userid, const char *_otherhost,
+ const char *_orighost);
+ssize_t writel(int _strm, ...);
__END_DECLS
diff --git a/usr.sbin/lpr/common_source/net.c b/usr.sbin/lpr/common_source/net.c
index 2f30d852586aa..619c253cbbb19 100644
--- a/usr.sbin/lpr/common_source/net.c
+++ b/usr.sbin/lpr/common_source/net.c
@@ -178,7 +178,7 @@ retry:
char *
checkremote(struct printer *pp)
{
- char name[MAXHOSTNAMELEN];
+ char lclhost[MAXHOSTNAMELEN];
struct addrinfo hints, *local_res, *remote_res, *lr, *rr;
char *err;
int ncommonaddrs, error;
@@ -194,17 +194,17 @@ checkremote(struct printer *pp)
return NULL;
/* get the addresses of the local host */
- gethostname(name, sizeof(name));
- name[sizeof(name) - 1] = '\0';
+ gethostname(lclhost, sizeof(lclhost));
+ lclhost[sizeof(lclhost) - 1] = '\0';
memset(&hints, 0, sizeof(hints));
hints.ai_family = family;
hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = AI_PASSIVE;
- if ((error = getaddrinfo(name, NULL, &hints, &local_res)) != 0) {
+ if ((error = getaddrinfo(lclhost, NULL, &hints, &local_res)) != 0) {
asprintf(&err, "unable to get official name "
"for local machine %s: %s",
- name, gai_strerror(error));
+ lclhost, gai_strerror(error));
return err;
}
@@ -256,7 +256,7 @@ checkremote(struct printer *pp)
* values are as for writev(2).
*/
ssize_t
-writel(int s, ...)
+writel(int strm, ...)
{
va_list ap;
int i, n;
@@ -266,7 +266,7 @@ writel(int s, ...)
ssize_t retval;
/* first count them */
- va_start(ap, s);
+ va_start(ap, strm);
n = 0;
do {
cp = va_arg(ap, char *);
@@ -282,13 +282,13 @@ writel(int s, ...)
}
/* now make up iovec and send */
- va_start(ap, s);
+ va_start(ap, strm);
for (i = 0; i < n; i++) {
iovp[i].iov_base = va_arg(ap, char *);
iovp[i].iov_len = strlen(iovp[i].iov_base);
}
va_end(ap);
- retval = writev(s, iovp, n);
+ retval = writev(strm, iovp, n);
if (iovp != iov)
free(iovp);
return retval;
diff --git a/usr.sbin/lpr/common_source/printcap.c b/usr.sbin/lpr/common_source/printcap.c
index 390de46f53480..d70c5b1003761 100644
--- a/usr.sbin/lpr/common_source/printcap.c
+++ b/usr.sbin/lpr/common_source/printcap.c
@@ -58,14 +58,16 @@ static const char rcsid[] =
/*
* Routines and data used in processing the printcap file.
*/
-static char *printcapdb[2] = { _PATH_PRINTCAP, 0 }; /* list for cget* */
+static char *printcapdb[2] = { _PATH_PRINTCAP, 0 }; /* list for cget* */
-static char *capdb_canonical_name(const char *);
-static int capdb_getaltlog(char *, const char *, const char *);
-static int capdb_getaltnum(char *, const char *, const char *, long, long *);
-static int capdb_getaltstr(char *, const char *, const char *, const char *,
- char **);
-static int getprintcap_int(char *bp, struct printer *pp);
+static char *capdb_canonical_name(const char *_bp);
+static int capdb_getaltlog(char *_bp, const char *_shrt,
+ const char *_lng);
+static int capdb_getaltnum(char *_bp, const char *_shrt,
+ const char *_lng, long _dflt, long *_result);
+static int capdb_getaltstr(char *_bp, const char *_shrt,
+ const char *lng, const char *_dflt, char **_result);
+static int getprintcap_int(char *_bp, struct printer *_pp);
/*
* Change the name of the printcap file. Used by chkprintcap(8),
@@ -210,9 +212,7 @@ static const char *longfilters[] = {
* and store a malloced copy of it in pp->printer.
*/
static int
-getprintcap_int(bp, pp)
- char *bp;
- struct printer *pp;
+getprintcap_int(char *bp, struct printer *pp)
{
enum lpd_filters filt;
char *rp_name;
@@ -371,7 +371,7 @@ free_printer(struct printer *pp)
*/
static int
capdb_getaltstr(char *bp, const char *shrt, const char *lng,
- const char *dflt, char **result)
+ const char *dflt, char **result)
{
int status;
@@ -395,7 +395,7 @@ capdb_getaltstr(char *bp, const char *shrt, const char *lng,
*/
static int
capdb_getaltnum(char *bp, const char *shrt, const char *lng, long dflt,
- long *result)
+ long *result)
{
int status;
diff --git a/usr.sbin/lpr/common_source/rmjob.c b/usr.sbin/lpr/common_source/rmjob.c
index f7419e02f676a..39a7d0f132be9 100644
--- a/usr.sbin/lpr/common_source/rmjob.c
+++ b/usr.sbin/lpr/common_source/rmjob.c
@@ -73,12 +73,11 @@ static char current[7+MAXHOSTNAMELEN]; /* active control file name */
extern uid_t uid, euid; /* real and effective user id's */
-static void alarmhandler __P((int));
-static void do_unlink __P((char *));
+static void alarmhandler(int _signo);
+static void do_unlink(char *_file);
void
-rmjob(printer)
- const char *printer;
+rmjob(const char *printer)
{
register int i, nitems;
int assasinated = 0;
@@ -154,17 +153,15 @@ rmjob(printer)
* Return boolean indicating existence of a lock file.
*/
int
-lockchk(pp, s)
- struct printer *pp;
- char *s;
+lockchk(struct printer *pp, char *slockf)
{
register FILE *fp;
register int i, n;
seteuid(euid);
- if ((fp = fopen(s, "r")) == NULL) {
+ if ((fp = fopen(slockf, "r")) == NULL) {
if (errno == EACCES)
- fatal(pp, "%s: %s", s, strerror(errno));
+ fatal(pp, "%s: %s", slockf, strerror(errno));
else
return(0);
}
@@ -194,9 +191,7 @@ lockchk(pp, s)
* Process a control file.
*/
void
-process(pp, file)
- const struct printer *pp;
- char *file;
+process(const struct printer *pp, char *file)
{
FILE *cfp;
@@ -219,8 +214,7 @@ process(pp, file)
}
static void
-do_unlink(file)
- char *file;
+do_unlink(char *file)
{
int ret;
@@ -236,8 +230,7 @@ do_unlink(file)
* Do the dirty work in checking
*/
int
-chk(file)
- char *file;
+chk(char *file)
{
register int *r, n;
register char **u, *cp;
@@ -293,13 +286,12 @@ chk(file)
* Normal users can only remove the file from where it was sent.
*/
int
-isowner(owner, file)
- char *owner, *file;
+isowner(char *owner, char *file)
{
if (!strcmp(person, root) && (from == host || !strcmp(from, file+6)))
- return(1);
+ return (1);
if (!strcmp(person, owner) && !strcmp(from, file+6))
- return(1);
+ return (1);
if (from != host)
printf("%s: ", host);
printf("%s: Permission denied\n", file);
@@ -311,8 +303,7 @@ isowner(owner, file)
* then try removing files on the remote machine.
*/
void
-rmremote(pp)
- const struct printer *pp;
+rmremote(const struct printer *pp)
{
int i, elem, firstreq, niov, rem, totlen;
char buf[BUFSIZ];
@@ -390,15 +381,14 @@ rmremote(pp)
* Return 1 if the filename begins with 'cf'
*/
int
-iscf(d)
- struct dirent *d;
+iscf(struct dirent *d)
{
return(d->d_name[0] == 'c' && d->d_name[1] == 'f');
}
void
-alarmhandler(signo)
- int signo;
+alarmhandler(int signo __unused)
{
- /* ignored */
+ /* the signal is ignored */
+ /* (the '__unused' is just to avoid a compile-time warning) */
}
diff --git a/usr.sbin/lpr/common_source/startdaemon.c b/usr.sbin/lpr/common_source/startdaemon.c
index 29866b28c8953..c9c978e106f27 100644
--- a/usr.sbin/lpr/common_source/startdaemon.c
+++ b/usr.sbin/lpr/common_source/startdaemon.c
@@ -60,8 +60,7 @@ extern uid_t uid, euid;
*/
int
-startdaemon(pp)
- const struct printer *pp;
+startdaemon(const struct printer *pp)
{
struct sockaddr_un un;
register int s, n;