summaryrefslogtreecommitdiffstats
path: root/usr.sbin/lpr/lpd/lpd.c
diff options
context:
space:
mode:
authorjoerg <joerg@FreeBSD.org>1996-05-05 14:04:33 +0000
committerjoerg <joerg@FreeBSD.org>1996-05-05 14:04:33 +0000
commit0291e848bc787305335af649ac14bc8fe5a19a49 (patch)
treef679484620675241701b875cbab6124b83dc1136 /usr.sbin/lpr/lpd/lpd.c
parent825cd02612729df0559ca26d13d946c625215900 (diff)
downloadFreeBSD-src-0291e848bc787305335af649ac14bc8fe5a19a49.zip
FreeBSD-src-0291e848bc787305335af649ac14bc8fe5a19a49.tar.gz
Vendor-branch import of the 4.4BSD-Lite2 code for lpr. There are
several bugfixes in it that are worth considering. Don't be alarmed about the import conflicts... Obtained from: 4.4BSD-Lite2
Diffstat (limited to 'usr.sbin/lpr/lpd/lpd.c')
-rw-r--r--usr.sbin/lpr/lpd/lpd.c37
1 files changed, 36 insertions, 1 deletions
diff --git a/usr.sbin/lpr/lpd/lpd.c b/usr.sbin/lpr/lpd/lpd.c
index aaf72b7..3b23359 100644
--- a/usr.sbin/lpr/lpd/lpd.c
+++ b/usr.sbin/lpr/lpd/lpd.c
@@ -39,7 +39,7 @@ static char copyright[] =
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)lpd.c 8.4 (Berkeley) 4/17/94";
+static char sccsid[] = "@(#)lpd.c 8.7 (Berkeley) 5/10/95";
#endif /* not lint */
/*
@@ -77,6 +77,7 @@ static char sccsid[] = "@(#)lpd.c 8.4 (Berkeley) 4/17/94";
#include <sys/socket.h>
#include <sys/un.h>
#include <sys/stat.h>
+#include <sys/file.h>
#include <netinet/in.h>
#include <netdb.h>
@@ -103,6 +104,7 @@ static void mcleanup __P((int));
static void doit __P((void));
static void startup __P((void));
static void chkhost __P((struct sockaddr_in *));
+static int ckqueue __P((char *));
int
main(argc, argv)
@@ -429,11 +431,17 @@ startup()
* Restart the daemons.
*/
while (cgetnext(&buf, printcapdb) > 0) {
+ if (ckqueue(buf) <= 0) {
+ free(buf);
+ continue; /* no work to do for this printer */
+ }
for (cp = buf; *cp; cp++)
if (*cp == '|' || *cp == ':') {
*cp = '\0';
break;
}
+ if (lflag)
+ syslog(LOG_INFO, "work for %s", buf);
if ((pid = fork()) < 0) {
syslog(LOG_WARNING, "startup: cannot fork");
mcleanup(0);
@@ -442,8 +450,35 @@ startup()
printer = buf;
cgetclose();
printjob();
+ /* NOTREACHED */
}
+ else free(buf);
+ }
+}
+
+/*
+ * Make sure there's some work to do before forking off a child
+ */
+static int
+ckqueue(cap)
+ char *cap;
+{
+ register struct dirent *d;
+ DIR *dirp;
+ char *spooldir;
+
+ if (cgetstr(cap, "sd", &spooldir) == -1)
+ spooldir = _PATH_DEFSPOOL;
+ if ((dirp = opendir(spooldir)) == NULL)
+ return (-1);
+ while ((d = readdir(dirp)) != NULL) {
+ if (d->d_name[0] != 'c' || d->d_name[1] != 'f')
+ continue; /* daemon control files only */
+ closedir(dirp);
+ return (1); /* found something */
}
+ closedir(dirp);
+ return (0);
}
#define DUMMY ":nobody::"
OpenPOWER on IntegriCloud