diff options
author | tb <tb@cvs.openbsd.org> | 2016-01-12 23:35:14 +0000 |
---|---|---|
committer | tb <tb@cvs.openbsd.org> | 2016-01-12 23:35:14 +0000 |
commit | 3d5c344fff1f36da66bfb827bc53cab5ebaea055 (patch) | |
tree | 1902a939ed2a81c60d32ed7639240e8d3396162a /usr.sbin/lpr/common_source | |
parent | e610fca0ff631fc9fb7e58ac76d4b5f94a47b7ee (diff) |
Move prototypes of local functions from lp.h to the .c files and make
functions static if possible. Move delay() to lpd/printjob.c and fix
an annoying typo.
ok deraadt@
Diffstat (limited to 'usr.sbin/lpr/common_source')
-rw-r--r-- | usr.sbin/lpr/common_source/common.c | 15 | ||||
-rw-r--r-- | usr.sbin/lpr/common_source/displayq.c | 26 | ||||
-rw-r--r-- | usr.sbin/lpr/common_source/lp.h | 34 | ||||
-rw-r--r-- | usr.sbin/lpr/common_source/rmjob.c | 31 |
4 files changed, 50 insertions, 56 deletions
diff --git a/usr.sbin/lpr/common_source/common.c b/usr.sbin/lpr/common_source/common.c index 9d47ffd9094..af9bf9d6813 100644 --- a/usr.sbin/lpr/common_source/common.c +++ b/usr.sbin/lpr/common_source/common.c @@ -1,4 +1,4 @@ -/* $OpenBSD: common.c,v 1.39 2015/08/20 22:46:32 deraadt Exp $ */ +/* $OpenBSD: common.c,v 1.40 2016/01/12 23:35:13 tb Exp $ */ /* $NetBSD: common.c,v 1.21 2000/08/09 14:28:50 itojun Exp $ */ /* @@ -411,19 +411,6 @@ done: return NULL; } -/* sleep n milliseconds */ -void -delay(int n) -{ - struct timespec tdelay; - - if (n <= 0 || n > 10000) - fatal("unreasonable delay period (%d)", n); - tdelay.tv_sec = n / 1000; - tdelay.tv_nsec = n * 1000000 % 1000000000; - nanosleep(&tdelay, NULL); -} - __dead void fatal(const char *msg, ...) { diff --git a/usr.sbin/lpr/common_source/displayq.c b/usr.sbin/lpr/common_source/displayq.c index 947d1903c2e..866191736b9 100644 --- a/usr.sbin/lpr/common_source/displayq.c +++ b/usr.sbin/lpr/common_source/displayq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: displayq.c,v 1.37 2015/08/20 22:46:32 deraadt Exp $ */ +/* $OpenBSD: displayq.c,v 1.38 2016/01/12 23:35:13 tb Exp $ */ /* $NetBSD: displayq.c,v 1.21 2001/08/30 00:51:50 itojun Exp $ */ /* @@ -77,7 +77,15 @@ static const char head0[] = "Rank Owner Job Files"; static const char head1[] = "Total Size\n"; static void alarmer(int); +static void blankfill(int); +static void dump(char *, char *, int); +static void header(void); static void inform(char *, int); +static int inlist(char *, char *); +static void ldump(char *, char *, int); +static void nodaemon(void); +static void prank(int); +static void show(char *, char *, int); /* * Display the current state of the queue. Format = 1 if long format. @@ -311,7 +319,7 @@ alarmer(int s) /* * Print a warning message if there is no daemon present. */ -void +static void nodaemon(void) { if (remote) @@ -323,7 +331,7 @@ nodaemon(void) /* * Print the header for the short listing format */ -void +static void header(void) { printf(head0); @@ -395,7 +403,7 @@ inform(char *cf, int rank) } } -int +static int inlist(char *name, char *file) { int *r, n; @@ -420,7 +428,7 @@ inlist(char *name, char *file) return(0); } -void +static void show(char *nfile, char *file, int copies) { if (strcmp(nfile, " ") == 0) @@ -434,7 +442,7 @@ show(char *nfile, char *file, int copies) /* * Fill the line with blanks to the specified column */ -void +static void blankfill(int n) { while (col++ < n) @@ -444,7 +452,7 @@ blankfill(int n) /* * Give the abbreviated dump of the file names */ -void +static void dump(char *nfile, char *file, int copies) { int n, fill; @@ -478,7 +486,7 @@ dump(char *nfile, char *file, int copies) /* * Print the long info about the file */ -void +static void ldump(char *nfile, char *file, int copies) { struct stat lbuf; @@ -503,7 +511,7 @@ ldump(char *nfile, char *file, int copies) * Print the job's rank in the queue, * update col for screen management */ -void +static void prank(int n) { char rline[100]; diff --git a/usr.sbin/lpr/common_source/lp.h b/usr.sbin/lpr/common_source/lp.h index d1c997fd2e9..01c944de004 100644 --- a/usr.sbin/lpr/common_source/lp.h +++ b/usr.sbin/lpr/common_source/lp.h @@ -1,4 +1,4 @@ -/* $OpenBSD: lp.h,v 1.19 2015/01/16 06:40:17 deraadt Exp $ */ +/* $OpenBSD: lp.h,v 1.20 2016/01/12 23:35:13 tb Exp $ */ /* $NetBSD: lp.h,v 1.14 2000/04/16 14:43:58 mrg Exp $ */ /* @@ -118,28 +118,22 @@ struct queue { __BEGIN_DECLS struct dirent; -void blankfill(int); +/* common.c */ char *checkremote(void); -int chk(char *); -void displayq(int); -void dump(char *, char *, int); -__dead void fatal(const char *, ...) - __attribute__((__format__(__printf__, 1, 2))); +void fatal(const char *, ...) + __attribute__((__noreturn__,__format__(__printf__, 1, 2))); int get_line(FILE *); int getport(char *, int); int getq(struct queue ***); -void header(void); -int inlist(char *, char *); -int iscf(const struct dirent *); -int isowner(char *, char *); -void ldump(char *, char *, int); -void prank(int); -void process(char *); -void rmjob(void); -void rmremote(void); -void show(char *, char *, int); -int startdaemon(char *); -void nodaemon(void); -void delay(int); int safe_open(const char *, int, mode_t); + +/* displayq.c */ +void displayq(int); + +/* rmjob.c */ +void rmjob(void); + +/* startdaemon.c */ +int startdaemon(char *); + __END_DECLS diff --git a/usr.sbin/lpr/common_source/rmjob.c b/usr.sbin/lpr/common_source/rmjob.c index e58822aa349..0479e222003 100644 --- a/usr.sbin/lpr/common_source/rmjob.c +++ b/usr.sbin/lpr/common_source/rmjob.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rmjob.c,v 1.22 2015/01/16 06:40:17 deraadt Exp $ */ +/* $OpenBSD: rmjob.c,v 1.23 2016/01/12 23:35:13 tb Exp $ */ /* $NetBSD: rmjob.c,v 1.16 2000/04/16 14:43:58 mrg Exp $ */ /* @@ -62,15 +62,20 @@ static int all = 0; /* eliminate all files (root only) */ static int cur_daemon; /* daemon's pid */ static char current[NAME_MAX]; /* active control file name */ -static void do_unlink(char *); -static void alarmer(int); -static int lockchk(char *); +static void alarmer(int); +static int chk(char *); +static void do_unlink(char *); +static int iscf(const struct dirent *); +static int isowner(char *, char *); +static int lockchk(char *); +static void process(char *); +static void rmremote(void); void rmjob(void) { int i, nitems; - int assasinated = 0; + int assassinated = 0; struct dirent **files; char *cp; @@ -127,9 +132,9 @@ rmjob(void) */ if (lockchk(LO) && chk(current)) { PRIV_START; - assasinated = kill(cur_daemon, SIGINT) == 0; + assassinated = kill(cur_daemon, SIGINT) == 0; PRIV_END; - if (!assasinated) + if (!assassinated) fatal("cannot kill printer daemon"); } /* @@ -142,7 +147,7 @@ rmjob(void) /* * Restart the printer daemon if it was killed */ - if (assasinated && !startdaemon(printer)) + if (assassinated && !startdaemon(printer)) fatal("cannot restart printer daemon"); exit(0); } @@ -194,7 +199,7 @@ lockchk(char *s) /* * Process a control file. */ -void +static void process(char *file) { FILE *cfp = NULL; @@ -238,7 +243,7 @@ do_unlink(char *file) /* * Do the dirty work in checking */ -int +static int chk(char *file) { int *r, n, fd; @@ -298,7 +303,7 @@ chk(char *file) * files sent from the remote machine to be removed. * Normal users can only remove the file from where it was sent. */ -int +static int isowner(char *owner, char *file) { if (!strcmp(person, root) && (from == host || !strcmp(from, file+6))) @@ -315,7 +320,7 @@ isowner(char *owner, char *file) * Check to see if we are sending files to a remote machine. If we are, * then try removing files on the remote machine. */ -void +static void rmremote(void) { char *cp; @@ -391,7 +396,7 @@ alarmer(int s) /* * Return 1 if the filename begins with 'cf' */ -int +static int iscf(const struct dirent *d) { return(d->d_name[0] == 'c' && d->d_name[1] == 'f'); |