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/lpd/recvjob.c | |
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/lpd/recvjob.c')
-rw-r--r-- | usr.sbin/lpr/lpd/recvjob.c | 53 |
1 files changed, 28 insertions, 25 deletions
diff --git a/usr.sbin/lpr/lpd/recvjob.c b/usr.sbin/lpr/lpd/recvjob.c index 0a10e49..6b1c8b0 100644 --- a/usr.sbin/lpr/lpd/recvjob.c +++ b/usr.sbin/lpr/lpd/recvjob.c @@ -43,7 +43,7 @@ static const char copyright[] = static char sccsid[] = "@(#)recvjob.c 8.2 (Berkeley) 4/27/95"; #endif static const char rcsid[] = - "$Id: recvjob.c,v 1.10 1997/09/24 06:47:55 charnier Exp $"; + "$Id: recvjob.c,v 1.11 1997/10/06 03:58:48 imp Exp $"; #endif /* not lint */ /* @@ -80,54 +80,56 @@ static int noresponse __P((void)); static void rcleanup __P((int)); static int read_number __P((char *)); static int readfile __P((char *, int)); -static int readjob __P((void)); +static int readjob __P((struct printer *pp)); void -recvjob() +recvjob(printer) + const char *printer; { struct stat stb; int status; + struct printer myprinter, *pp = &myprinter; /* * Perform lookup for printer name or abbreviation */ - if ((status = cgetent(&bp, printcapdb, printer)) == -2) + status = getprintcap(printer, pp); + switch (status) { + case PCAPERR_OSERR: frecverr("cannot open printer description file"); - else if (status == -1) + break; + case PCAPERR_NOTFOUND: frecverr("unknown printer %s", printer); - else if (status == -3) - fatal("potential reference loop detected in printcap file"); + break; + case PCAPERR_TCLOOP: + fatal(pp, "potential reference loop detected in printcap file"); + default: + break; + } - if (cgetstr(bp, "lf", &LF) == -1) - LF = _PATH_CONSOLE; - if (cgetstr(bp, "sd", &SD) == -1) - SD = _PATH_DEFSPOOL; - if (cgetstr(bp, "lo", &LO) == -1) - LO = DEFLOCK; - (void) close(2); /* set up log file */ - if (open(LF, O_WRONLY|O_APPEND, 0664) < 0) { - syslog(LOG_ERR, "%s: %m", LF); + if (open(pp->log_file, O_WRONLY|O_APPEND, 0664) < 0) { + syslog(LOG_ERR, "%s: %m", pp->log_file); (void) open(_PATH_DEVNULL, O_WRONLY); } - if (chdir(SD) < 0) - frecverr("%s: %s: %m", printer, SD); - if (stat(LO, &stb) == 0) { + if (chdir(pp->spool_dir) < 0) + frecverr("%s: %s: %m", pp->printer, pp->spool_dir); + if (stat(pp->lock_file, &stb) == 0) { if (stb.st_mode & 010) { /* queue is disabled */ putchar('\1'); /* return error code */ exit(1); } - } else if (stat(SD, &stb) < 0) - frecverr("%s: %s: %m", printer, SD); + } else if (stat(pp->spool_dir, &stb) < 0) + frecverr("%s: %s: %m", pp->printer, pp->spool_dir); minfree = 2 * read_number("minfree"); /* scale KB to 512 blocks */ signal(SIGTERM, rcleanup); signal(SIGPIPE, rcleanup); - if (readjob()) - printjob(); + if (readjob(pp)) + printjob(pp); } /* @@ -135,7 +137,8 @@ recvjob() * Return the number of jobs successfully transfered. */ static int -readjob() +readjob(pp) + struct printer *pp; { register int size, nfiles; register char *cp; @@ -151,7 +154,7 @@ readjob() if ((size = read(1, cp, 1)) != 1) { if (size < 0) frecverr("%s: lost connection", - printer); + pp->printer); return(nfiles); } } while (*cp++ != '\n' && (cp - line + 1) < sizeof(line)); |