diff options
author | Garrett Wollman <wollman@FreeBSD.org> | 1997-12-02 20:46:22 +0000 |
---|---|---|
committer | Garrett Wollman <wollman@FreeBSD.org> | 1997-12-02 20:46:22 +0000 |
commit | 4a1a0dbedbb3fa74041adb9862f4608cd990a3c5 (patch) | |
tree | a2ac7bb3b38cf050182b615ae4230d8b779e5178 /usr.sbin/lpr/pac | |
parent | a846453c5ebbf21be4af27ac1e1679a3c00d8103 (diff) | |
download | src-4a1a0dbedbb3fa74041adb9862f4608cd990a3c5.tar.gz src-4a1a0dbedbb3fa74041adb9862f4608cd990a3c5.zip |
Mega lpd/lpd upgrade, part I:
- Get rid of a lot of the static variables which were shared by
many routines and programs in the suite.
- Create an abstract interface to the printcap database, so that
other retrieval and iteration mechanisms could be developed
(e.g., YP, Hesiod, or automatic retrieval from a trusted server).
- Give each capability a human-readable name in addition to the historic
two-character one.
- Otherwise generally clean up a lot of dark corners. Many still remain.
- When submitting jobs, use the official login name record (from getlogin())
if there is one, rather than reverse-mapping the uid.
More to come...
Notes
Notes:
svn path=/head/; revision=31492
Diffstat (limited to 'usr.sbin/lpr/pac')
-rw-r--r-- | usr.sbin/lpr/pac/Makefile | 6 | ||||
-rw-r--r-- | usr.sbin/lpr/pac/pac.c | 32 |
2 files changed, 21 insertions, 17 deletions
diff --git a/usr.sbin/lpr/pac/Makefile b/usr.sbin/lpr/pac/Makefile index 1f49dea1cec1..758045c3a131 100644 --- a/usr.sbin/lpr/pac/Makefile +++ b/usr.sbin/lpr/pac/Makefile @@ -1,10 +1,12 @@ -# @(#)Makefile 8.1 (Berkeley) 6/6/93 +# From: @(#)Makefile 8.1 (Berkeley) 6/6/93 +# $Id$ PROG= pac CFLAGS+=-I${.CURDIR}/../common_source MAN8= pac.8 -SRCS= pac.c common.c +SRCS= pac.c .PATH: ${.CURDIR}/../common_source +LDADD= -L${.OBJDIR}/../common_source -llpr .include "../../Makefile.inc" .include <bsd.prog.mk> diff --git a/usr.sbin/lpr/pac/pac.c b/usr.sbin/lpr/pac/pac.c index c89a52696d95..bfb0f513f7c5 100644 --- a/usr.sbin/lpr/pac/pac.c +++ b/usr.sbin/lpr/pac/pac.c @@ -43,7 +43,7 @@ static const char copyright[] = static char sccsid[] = "@(#)pac.c 8.1 (Berkeley) 6/6/93"; #endif static const char rcsid[] = - "$Id$"; + "$Id: pac.c,v 1.7 1997/09/24 06:48:24 charnier Exp $"; #endif /* not lint */ /* @@ -110,9 +110,10 @@ main(argc, argv) int argc; char **argv; { - register FILE *acct; - register char *cp; + FILE *acct; + char *cp, *printer; + printer = NULL; euid = geteuid(); /* these aren't used in pac(1) */ uid = getuid(); while (--argc) { @@ -433,21 +434,22 @@ chkprinter(s) register char *s; { int stat; + struct printer myprinter, *pp = &myprinter; - if ((stat = cgetent(&bp, printcapdb, s)) == -2) { - printf("pac: can't open printer description file\n"); + init_printer(&myprinter); + stat = getprintcap(s, pp); + switch(stat) { + case PCAPERR_OSERR: + printf("pac: getprintcap: %s\n", pcaperr(stat)); exit(3); - } else if (stat == -1) - return(0); - else if (stat == -3) - fatal("potential reference loop detected in printcap file"); - - if (cgetstr(bp, "af", &acctfile) == -1) { - printf("accounting not enabled for printer %s\n", printer); - exit(2); + case PCAPERR_NOTFOUND: + return 0; + case PCAPERR_TCLOOP: + fatal(pp, "%s", pcaperr(stat)); } - if (!pflag && (cgetnum(bp, "pc", &price100) == 0)) - price = price100/10000.0; + acctfile = pp->acct_file; + if (!pflag && pp->price100) + price = pp->price100/10000.0; sumfile = (char *) calloc(sizeof(char), strlen(acctfile)+5); if (sumfile == NULL) errx(1, "calloc failed"); |