diff options
author | gad <gad@FreeBSD.org> | 2001-06-12 16:38:20 +0000 |
---|---|---|
committer | gad <gad@FreeBSD.org> | 2001-06-12 16:38:20 +0000 |
commit | d61428321f0ceb41de748a616b592b50195c51fb (patch) | |
tree | 115b09aed7f19dda18dbe2e66eba92a08b0d2441 /usr.sbin/lpr/lpc | |
parent | b39990d7f9947621a844c7a4936eeb286a471c47 (diff) | |
download | FreeBSD-src-d61428321f0ceb41de748a616b592b50195c51fb.zip FreeBSD-src-d61428321f0ceb41de748a616b592b50195c51fb.tar.gz |
Fix about 90-100 warnings one gets when trying to compile lpr&friends
with BDECFLAGS on, mainly by adding 'const' to parameters in a number
of routine declarations. While I'm at it, ANSI-fy all of the routine
declarations. The resulting object code is exactly the same after
this update as before it, with the exception of one unavoidable
change to lpd.o on freebsd/alpha.
Also added $FreeBSD$ line to lpc/extern.h lpc/lpc.h lptest/lptest.c
Reviewed by: /sbin/md5, and no feedback from freebsd-audit
Diffstat (limited to 'usr.sbin/lpr/lpc')
-rw-r--r-- | usr.sbin/lpr/lpc/cmds.c | 162 | ||||
-rw-r--r-- | usr.sbin/lpr/lpc/extern.h | 31 | ||||
-rw-r--r-- | usr.sbin/lpr/lpc/lpc.c | 38 | ||||
-rw-r--r-- | usr.sbin/lpr/lpc/lpc.h | 10 |
4 files changed, 104 insertions, 137 deletions
diff --git a/usr.sbin/lpr/lpc/cmds.c b/usr.sbin/lpr/lpc/cmds.c index 97502f4..68bf804 100644 --- a/usr.sbin/lpr/lpc/cmds.c +++ b/usr.sbin/lpr/lpc/cmds.c @@ -70,27 +70,24 @@ static const char rcsid[] = #include "extern.h" #include "pathnames.h" -static void abortpr __P((struct printer *, int)); -static int doarg __P((char *)); -static int doselect __P((struct dirent *)); -static void putmsg __P((struct printer *, int, char **)); -static int sortq __P((const void *, const void *)); -static void startpr __P((struct printer *, int)); -static int touch __P((struct jobqueue *)); -static void unlinkf __P((char *)); -static void upstat __P((struct printer *, char *)); +static void abortpr(struct printer *_pp, int _dis); +static int doarg(char *_job); +static int doselect(struct dirent *_d); +static void putmsg(struct printer *_pp, int _argc, char **_argv); +static int sortq(const void *_a, const void *_b); +static void startpr(struct printer *_pp, int _chgenable); +static int touch(struct jobqueue *_jq); +static void unlinkf(char *_name); +static void upstat(struct printer *_pp, const char *_msg); /* * generic framework for commands which operate on all or a specified * set of printers */ void -generic(doit, argc, argv) - void (*doit) __P((struct printer *)); - int argc; - char *argv[]; +generic(void (*specificrtn)(struct printer *_pp), int argc, char *argv[]) { - int status, more; + int cmdstatus, more; struct printer myprinter, *pp = &myprinter; if (argc == 1) { @@ -98,15 +95,15 @@ generic(doit, argc, argv) return; } if (argc == 2 && strcmp(argv[1], "all") == 0) { - more = firstprinter(pp, &status); - if (status) + more = firstprinter(pp, &cmdstatus); + if (cmdstatus) goto looperr; while (more) { - (*doit)(pp); + (*specificrtn)(pp); do { - more = nextprinter(pp, &status); + more = nextprinter(pp, &cmdstatus); looperr: - switch (status) { + switch (cmdstatus) { case PCAPERR_TCOPEN: printf("warning: %s: unresolved " "tc= reference(s) ", @@ -114,19 +111,19 @@ looperr: case PCAPERR_SUCCESS: break; default: - fatal(pp, pcaperr(status)); + fatal(pp, pcaperr(cmdstatus)); } - } while (more && status); + } while (more && cmdstatus); } return; } while (--argc) { ++argv; init_printer(pp); - status = getprintcap(*argv, pp); - switch(status) { + cmdstatus = getprintcap(*argv, pp); + switch (cmdstatus) { default: - fatal(pp, pcaperr(status)); + fatal(pp, pcaperr(cmdstatus)); case PCAPERR_NOTFOUND: printf("unknown printer %s\n", *argv); continue; @@ -137,7 +134,7 @@ looperr: case PCAPERR_SUCCESS: break; } - (*doit)(pp); + (*specificrtn)(pp); } } @@ -145,16 +142,13 @@ looperr: * kill an existing daemon and disable printing. */ void -doabort(pp) - struct printer *pp; +doabort(struct printer *pp) { abortpr(pp, 1); } static void -abortpr(pp, dis) - struct printer *pp; - int dis; +abortpr(struct printer *pp, int dis) { register FILE *fp; struct stat stbuf; @@ -222,9 +216,7 @@ out: * Write a message into the status file. */ static void -upstat(pp, msg) - struct printer *pp; - char *msg; +upstat(struct printer *pp, const char *msg) { register int fd; char statfile[MAXPATHLEN]; @@ -245,8 +237,7 @@ upstat(pp, msg) } static int -doselect(d) - struct dirent *d; +doselect(struct dirent *d) { int c = d->d_name[0]; @@ -260,14 +251,13 @@ doselect(d) * by `cf', `tf', or `df', then by the sequence letter A-Z, a-z. */ static int -sortq(a, b) - const void *a, *b; +sortq(const void *a, const void *b) { - struct dirent **d1, **d2; + const struct dirent **d1, **d2; int c1, c2; - d1 = (struct dirent **)a; - d2 = (struct dirent **)b; + d1 = (const struct dirent **)a; + d2 = (const struct dirent **)b; if ((c1 = strcmp((*d1)->d_name + 3, (*d2)->d_name + 3))) return(c1); c1 = (*d1)->d_name[0]; @@ -287,8 +277,7 @@ sortq(a, b) * Remove incomplete jobs from spooling area. */ void -clean(pp) - struct printer *pp; +clean(struct printer *pp) { register int i, n; register char *cp, *cp1, *lp; @@ -345,8 +334,7 @@ clean(pp) } static void -unlinkf(name) - char *name; +unlinkf(char *name) { seteuid(euid); if (unlink(name) < 0) @@ -360,8 +348,7 @@ unlinkf(name) * Enable queuing to the printer (allow lpr's). */ void -enable(pp) - struct printer *pp; +enable(struct printer *pp) { struct stat stbuf; char lf[MAXPATHLEN]; @@ -386,8 +373,7 @@ enable(pp) * Disable queuing. */ void -disable(pp) - struct printer *pp; +disable(struct printer *pp) { register int fd; struct stat stbuf; @@ -424,11 +410,9 @@ disable(pp) * (reason for being down). */ void -down(argc, argv) - int argc; - char *argv[]; +down(int argc, char *argv[]) { - int status, more; + int cmdstatus, more; struct printer myprinter, *pp = &myprinter; if (argc == 1) { @@ -436,15 +420,15 @@ down(argc, argv) return; } if (!strcmp(argv[1], "all")) { - more = firstprinter(pp, &status); - if (status) + more = firstprinter(pp, &cmdstatus); + if (cmdstatus) goto looperr; while (more) { putmsg(pp, argc - 2, argv + 2); do { - more = nextprinter(pp, &status); + more = nextprinter(pp, &cmdstatus); looperr: - switch (status) { + switch (cmdstatus) { case PCAPERR_TCOPEN: printf("warning: %s: unresolved " "tc= reference(s) ", @@ -452,17 +436,17 @@ looperr: case PCAPERR_SUCCESS: break; default: - fatal(pp, pcaperr(status)); + fatal(pp, pcaperr(cmdstatus)); } - } while (more && status); + } while (more && cmdstatus); } return; } init_printer(pp); - status = getprintcap(argv[1], pp); - switch(status) { + cmdstatus = getprintcap(argv[1], pp); + switch (cmdstatus) { default: - fatal(pp, pcaperr(status)); + fatal(pp, pcaperr(cmdstatus)); case PCAPERR_NOTFOUND: printf("unknown printer %s\n", argv[1]); return; @@ -476,10 +460,7 @@ looperr: } static void -putmsg(pp, argc, argv) - struct printer *pp; - int argc; - char **argv; +putmsg(struct printer *pp, int argc, char **argv) { register int fd; register char *cp1, *cp2; @@ -547,9 +528,7 @@ putmsg(pp, argc, argv) * Exit lpc */ void -quit(argc, argv) - int argc; - char *argv[]; +quit(int argc __unused, char *argv[] __unused) { exit(0); } @@ -558,8 +537,7 @@ quit(argc, argv) * Kill and restart the daemon. */ void -restart(pp) - struct printer *pp; +restart(struct printer *pp) { abortpr(pp, 0); startpr(pp, 0); @@ -569,16 +547,13 @@ restart(pp) * Enable printing on the specified printer and startup the daemon. */ void -startcmd(pp) - struct printer *pp; +startcmd(struct printer *pp) { startpr(pp, 1); } static void -startpr(pp, enable) - struct printer *pp; - int enable; +startpr(struct printer *pp, int chgenable) { struct stat stbuf; char lf[MAXPATHLEN]; @@ -587,13 +562,13 @@ startpr(pp, enable) printf("%s:\n", pp->printer); /* - * For enable==1 ('start'), turn off the LFM_PRINT_DIS bit of the - * lock file to re-enable printing. For enable==2 ('up'), also + * For chgenable==1 ('start'), turn off the LFM_PRINT_DIS bit of the + * lock file to re-enable printing. For chgenable==2 ('up'), also * turn off the LFM_QUEUE_DIS bit to re-enable queueing. */ seteuid(euid); - if (enable && stat(lf, &stbuf) >= 0) { - mode_t bits = (enable == 2 ? 0 : LFM_QUEUE_DIS); + if (chgenable && stat(lf, &stbuf) >= 0) { + mode_t bits = (chgenable == 2 ? 0 : LFM_QUEUE_DIS); if (chmod(lf, stbuf.st_mode & (LOCK_FILE_MODE | bits)) < 0) printf("\tcannot enable printing\n"); else @@ -610,8 +585,7 @@ startpr(pp, enable) * Print the status of the printer queue. */ void -status(pp) - struct printer *pp; +status(struct printer *pp) { struct stat stbuf; register int fd, i; @@ -674,8 +648,7 @@ status(pp) * printing. */ void -stop(pp) - struct printer *pp; +stop(struct printer *pp) { register int fd; struct stat stbuf; @@ -719,13 +692,11 @@ time_t mtime; * Put the specified jobs at the top of printer queue. */ void -topq(argc, argv) - int argc; - char *argv[]; +topq(int argc, char *argv[]) { register int i; struct stat stbuf; - int status, changed; + int cmdstatus, changed; struct printer myprinter, *pp = &myprinter; if (argc < 3) { @@ -736,10 +707,10 @@ topq(argc, argv) --argc; ++argv; init_printer(pp); - status = getprintcap(*argv, pp); - switch(status) { + cmdstatus = getprintcap(*argv, pp); + switch(cmdstatus) { default: - fatal(pp, pcaperr(status)); + fatal(pp, pcaperr(cmdstatus)); case PCAPERR_NOTFOUND: printf("unknown printer %s\n", *argv); return; @@ -793,8 +764,7 @@ out: * the control file. */ static int -touch(q) - struct jobqueue *q; +touch(struct jobqueue *jq) { struct timeval tvp[2]; int ret; @@ -802,7 +772,7 @@ touch(q) tvp[0].tv_sec = tvp[1].tv_sec = --mtime; tvp[0].tv_usec = tvp[1].tv_usec = 0; seteuid(euid); - ret = utimes(q->job_cfname, tvp); + ret = utimes(jq->job_cfname, tvp); seteuid(uid); return (ret); } @@ -812,8 +782,7 @@ touch(q) * Returns: negative (-1) if argument name is not in the queue. */ static int -doarg(job) - char *job; +doarg(char *job) { register struct jobqueue **qq; register int jobnum, n; @@ -884,8 +853,7 @@ doarg(job) * Enable everything and start printer (undo `down'). */ void -up(pp) - struct printer *pp; +up(struct printer *pp) { startpr(pp, 2); } diff --git a/usr.sbin/lpr/lpc/extern.h b/usr.sbin/lpr/lpc/extern.h index a07a09a..ffcfd32 100644 --- a/usr.sbin/lpr/lpc/extern.h +++ b/usr.sbin/lpr/lpc/extern.h @@ -32,6 +32,8 @@ * SUCH DAMAGE. * * @(#)extern.h 8.1 (Berkeley) 6/6/93 + * + * $FreeBSD$ */ @@ -40,20 +42,21 @@ __BEGIN_DECLS -void clean __P((struct printer *)); -void disable __P((struct printer *)); -void doabort __P((struct printer *)); -void down __P((int, char **)); -void enable __P((struct printer *)); -void generic __P((void (*) __P((struct printer *)), int, char **)); -void help __P((int, char **)); -void quit __P((int, char **)); -void restart __P((struct printer *)); -void startcmd __P((struct printer *)); -void status __P((struct printer *)); -void stop __P((struct printer *)); -void topq __P((int, char **)); -void up __P((struct printer *)); +void clean(struct printer *_pp); +void disable(struct printer *_pp); +void doabort(struct printer *_pp); +void down(int _argc, char *_argv[]); +void enable(struct printer *_pp); +void generic(void (*_specificrtn)(struct printer *_pp), int _argc, + char *_argv[]); +void help(int _argc, char *_argv[]); +void quit(int _argc, char *_argv[]); +void restart(struct printer *_pp); +void startcmd(struct printer *_pp); +void status(struct printer *_pp); +void stop(struct printer *_pp); +void topq(int _argc, char *_argv[]); +void up(struct printer *_pp); __END_DECLS extern int NCMDS; diff --git a/usr.sbin/lpr/lpc/lpc.c b/usr.sbin/lpr/lpc/lpc.c index f1d2428..e4d0580 100644 --- a/usr.sbin/lpr/lpc/lpc.c +++ b/usr.sbin/lpr/lpc/lpc.c @@ -82,17 +82,15 @@ static int margc; static char *margv[MAX_MARGV]; uid_t uid, euid; -int main __P((int, char *[])); -static void cmdscanner __P((void)); -static struct cmd *getcmd __P((char *)); -static void intr __P((int)); -static void makeargv __P((void)); -static int ingroup __P((char *)); +int main(int _argc, char *_argv[]); +static void cmdscanner(void); +static struct cmd *getcmd(const char *_name); +static void intr(int _signo); +static void makeargv(void); +static int ingroup(const char *_grname); int -main(argc, argv) - int argc; - char *argv[]; +main(int argc, char *argv[]) { register struct cmd *c; @@ -131,13 +129,13 @@ main(argc, argv) } static void -intr(signo) - int signo; +intr(int signo __unused) { + /* (the '__unused' is just to avoid a compile-time warning) */ exit(0); } -static char * +static const char * lpc_prompt(void) { return ("lpc> "); @@ -147,7 +145,7 @@ lpc_prompt(void) * Command parser. */ static void -cmdscanner() +cmdscanner(void) { register struct cmd *c; static EditLine *el = NULL; @@ -210,10 +208,9 @@ cmdscanner() } static struct cmd * -getcmd(name) - register char *name; +getcmd(const char *name) { - register char *p, *q; + register const char *p, *q; register struct cmd *c, *found; register int nmatches, longest; @@ -242,7 +239,7 @@ getcmd(name) * Slice a string up into argc/argv. */ static void -makeargv() +makeargv(void) { register char *cp; register char **argp = margv; @@ -272,9 +269,7 @@ makeargv() * Help command. */ void -help(argc, argv) - int argc; - char *argv[]; +help(int argc, char *argv[]) { register struct cmd *c; @@ -330,8 +325,7 @@ help(argc, argv) * return non-zero if the user is a member of the given group */ static int -ingroup(grname) - char *grname; +ingroup(const char *grname) { static struct group *gptr=NULL; static int ngroups = 0; diff --git a/usr.sbin/lpr/lpc/lpc.h b/usr.sbin/lpr/lpc/lpc.h index eca7b91..bc034c3 100644 --- a/usr.sbin/lpr/lpc/lpc.h +++ b/usr.sbin/lpr/lpc/lpc.h @@ -31,6 +31,8 @@ * SUCH DAMAGE. * * @(#)lpc.h 8.1 (Berkeley) 6/6/93 + * + * $FreeBSD$ */ /* @@ -39,10 +41,10 @@ struct printer; struct cmd { - char *c_name; /* command name */ - char *c_help; /* help message */ + const char *c_name; /* command name */ + const char *c_help; /* help message */ /* routine to do the work */ - void (*c_handler) __P((int, char *[])); + void (*c_handler)(int, char *[]); int c_priv; /* privileged command */ - void (*c_generic) __P((struct printer *)); /* generic command */ + void (*c_generic)(struct printer *); /* generic command */ }; |