diff options
author | wollman <wollman@FreeBSD.org> | 1997-12-02 20:46:22 +0000 |
---|---|---|
committer | wollman <wollman@FreeBSD.org> | 1997-12-02 20:46:22 +0000 |
commit | bf21e6b4e0e85ae08cb5d1f2335da248f52e2d26 (patch) | |
tree | 041fd28f30eaadf848820e6ceed6899636d31478 /usr.sbin/lpr/pac | |
parent | fa82bf4e17d3b6422eb922374e04631e08af93ef (diff) | |
download | FreeBSD-src-bf21e6b4e0e85ae08cb5d1f2335da248f52e2d26.zip FreeBSD-src-bf21e6b4e0e85ae08cb5d1f2335da248f52e2d26.tar.gz |
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...
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 1f49dea..758045c 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 c89a526..bfb0f51 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"); |