Index: usr.sbin/lpr/common_source/common.c
===================================================================
RCS file: /cvs/src/usr.sbin/lpr/common_source/common.c,v
retrieving revision 1.40
diff -u -p -r1.40 common.c
--- usr.sbin/lpr/common_source/common.c 12 Jan 2016 23:35:13 -0000      1.40
+++ usr.sbin/lpr/common_source/common.c 28 Feb 2016 20:11:18 -0000
@@ -453,3 +453,32 @@ safe_open(const char *path, int flags, m
                (void)fchmod(fd, mode);
        return (fd);
 }
+
+/*
+ * Make sure there's some work to do before forking off a child - lpd
+ * Check to see if anything in queue - lpq
+ */
+int
+ckqueue(char *cap)
+{
+       struct dirent *d;
+       DIR *dirp;
+       char *spooldir;
+
+       if (cgetstr(cap, "sd", &spooldir) >= 0) {
+               dirp = opendir(spooldir);
+               free(spooldir);
+       } else
+               dirp = opendir(_PATH_DEFSPOOL);
+
+       if (dirp == NULL)
+               return (-1);
+       while ((d = readdir(dirp)) != NULL) {
+               if (d->d_name[0] == 'c' && d->d_name[1] == 'f') {
+                       closedir(dirp);
+                       return (1);             /* found a cf file */
+               }
+       }
+       closedir(dirp);
+       return (0);
+}
Index: usr.sbin/lpr/common_source/lp.h
===================================================================
RCS file: /cvs/src/usr.sbin/lpr/common_source/lp.h,v
retrieving revision 1.20
diff -u -p -r1.20 lp.h
--- usr.sbin/lpr/common_source/lp.h     12 Jan 2016 23:35:13 -0000      1.20
+++ usr.sbin/lpr/common_source/lp.h     28 Feb 2016 20:11:19 -0000
@@ -120,6 +120,7 @@ struct dirent;
 
 /* common.c */
 char   *checkremote(void);
+int     ckqueue(char *);
 void    fatal(const char *, ...)
     __attribute__((__noreturn__,__format__(__printf__, 1, 2)));
 int     get_line(FILE *);
Index: usr.sbin/lpr/lpd/lpd.c
===================================================================
RCS file: /cvs/src/usr.sbin/lpr/lpd/lpd.c,v
retrieving revision 1.63
diff -u -p -r1.63 lpd.c
--- usr.sbin/lpr/lpd/lpd.c      19 Dec 2015 19:59:07 -0000      1.63
+++ usr.sbin/lpr/lpd/lpd.c      28 Feb 2016 20:11:20 -0000
@@ -107,7 +107,6 @@ static void         mcleanup(int);
 static void            doit(void);
 static void            startup(void);
 static void            chkhost(struct sockaddr *);
-static int             ckqueue(char *);
 static __dead void     usage(void);
 static int             *socksetup(int, int, const char *);
 
@@ -593,35 +592,6 @@ startup(void)
                        free(buf);
                }
        }
-}
-
-/*
- * Make sure there's some work to do before forking off a child
- * XXX - could be common w/ lpq
- */
-static int
-ckqueue(char *cap)
-{
-       struct dirent *d;
-       DIR *dirp;
-       char *spooldir;
-
-       if (cgetstr(cap, "sd", &spooldir) >= 0) {
-               dirp = opendir(spooldir);
-               free(spooldir);
-       } else
-               dirp = opendir(_PATH_DEFSPOOL);
-
-       if (dirp == NULL)
-               return (-1);
-       while ((d = readdir(dirp)) != NULL) {
-               if (d->d_name[0] == 'c' && d->d_name[1] == 'f') {
-                       closedir(dirp);
-                       return (1);             /* found a cf file */
-               }
-       }
-       closedir(dirp);
-       return (0);
 }
 
 /*
Index: usr.sbin/lpr/lpq/lpq.c
===================================================================
RCS file: /cvs/src/usr.sbin/lpr/lpq/lpq.c,v
retrieving revision 1.22
diff -u -p -r1.22 lpq.c
--- usr.sbin/lpr/lpq/lpq.c      9 Feb 2015 23:00:14 -0000       1.22
+++ usr.sbin/lpr/lpq/lpq.c      28 Feb 2016 20:11:22 -0000
@@ -64,7 +64,6 @@ int    users;                 /* # of users in user arra
 
 volatile sig_atomic_t gotintr;
 
-static int ckqueue(char *);
 static __dead void usage(void);
 
 int
@@ -146,32 +145,6 @@ main(int argc, char **argv)
        } else
                displayq(lflag);
        exit(0);
-}
-
-/* XXX - could be common w/ lpd */
-static int
-ckqueue(char *cap)
-{
-       struct dirent *d;
-       DIR *dirp;
-       char *spooldir;
-
-       if (cgetstr(cap, "sd", &spooldir) >= 0) {
-               dirp = opendir(spooldir);
-               free(spooldir);
-       } else
-               dirp = opendir(_PATH_DEFSPOOL);
-
-       if (dirp == 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);
 }
 
 static __dead void

Reply via email to