Rewrote to use new getcap(3) library. Major prototyping and cleanup.
authorElan Amir <elan@ucbvax.Berkeley.EDU>
Wed, 2 Sep 1992 02:09:01 +0000 (18:09 -0800)
committerElan Amir <elan@ucbvax.Berkeley.EDU>
Wed, 2 Sep 1992 02:09:01 +0000 (18:09 -0800)
SCCS-vsn: usr.sbin/lpr/common_source/common.c 5.9
SCCS-vsn: usr.sbin/lpr/common_source/displayq.c 5.15
SCCS-vsn: usr.sbin/lpr/common_source/lp.h 5.7
SCCS-vsn: usr.sbin/lpr/common_source/pathnames.h 5.5
SCCS-vsn: usr.sbin/lpr/common_source/rmjob.c 5.9
SCCS-vsn: usr.sbin/lpr/lpc/lpc.c 5.13
SCCS-vsn: usr.sbin/lpr/lpc/cmds.c 5.9
SCCS-vsn: usr.sbin/lpr/lpc/extern.h 5.2

usr/src/usr.sbin/lpr/common_source/common.c
usr/src/usr.sbin/lpr/common_source/displayq.c
usr/src/usr.sbin/lpr/common_source/lp.h
usr/src/usr.sbin/lpr/common_source/pathnames.h
usr/src/usr.sbin/lpr/common_source/rmjob.c
usr/src/usr.sbin/lpr/lpc/cmds.c
usr/src/usr.sbin/lpr/lpc/extern.h
usr/src/usr.sbin/lpr/lpc/lpc.c

index 8e19ed4..14617f8 100644 (file)
@@ -2,11 +2,37 @@
  * Copyright (c) 1983 Regents of the University of California.
  * All rights reserved.
  *
  * Copyright (c) 1983 Regents of the University of California.
  * All rights reserved.
  *
- * %sccs.include.redist.c%
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)common.c   5.8 (Berkeley) %G%";
+static char sccsid[] = "@(#)common.c   5.9 (Berkeley) 8/6/92";
 #endif /* not lint */
 
 #include <sys/param.h>
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -23,60 +49,62 @@ static char sccsid[] = "@(#)common.c        5.8 (Berkeley) %G%";
 #include <stdio.h>
 #include <string.h>
 #include "lp.h"
 #include <stdio.h>
 #include <string.h>
 #include "lp.h"
+#include "pathnames.h"
 
 /*
  * Routines and data common to all the line printer functions.
  */
 
 
 /*
  * Routines and data common to all the line printer functions.
  */
 
-int    DU;             /* daeomon user-id */
-int    MX;             /* maximum number of blocks to copy */
-int    MC;             /* maximum number of copies allowed */
-char   *LP;            /* line printer device name */
-char   *RM;            /* remote machine name */
-char   *RP;            /* remote printer name */
-char   *LO;            /* lock file name */
-char   *ST;            /* status file name */
-char   *SD;            /* spool directory */
 char   *AF;            /* accounting file */
 char   *AF;            /* accounting file */
+long    BR;            /* baud rate if lp is a tty */
+char   *CF;            /* name of cifplot filter (per job) */
+char   *DF;            /* name of tex filter (per job) */
+long    DU;            /* daeomon user-id */
+long    FC;            /* flags to clear if lp is a tty */
+char   *FF;            /* form feed string */
+long    FS;            /* flags to set if lp is a tty */
+char   *GF;            /* name of graph(1G) filter (per job) */
+long    HL;            /* print header last */
+char   *IF;            /* name of input filter (created per job) */
 char   *LF;            /* log file for error messages */
 char   *LF;            /* log file for error messages */
+char   *LO;            /* lock file name */
+char   *LP;            /* line printer device name */
+long    MC;            /* maximum number of copies allowed */
+long    MX;            /* maximum number of blocks to copy */
+char   *NF;            /* name of ditroff filter (per job) */
 char   *OF;            /* name of output filter (created once) */
 char   *OF;            /* name of output filter (created once) */
-char   *IF;            /* name of input filter (created per job) */
+char   *PF;            /* name of vrast filter (per job) */
+long    PL;            /* page length */
+long    PW;            /* page width */
+long    PX;            /* page width in pixels */
+long    PY;            /* page length in pixels */
 char   *RF;            /* name of fortran text filter (per job) */
 char   *RF;            /* name of fortran text filter (per job) */
+char    *RG;           /* resricted group */
+char   *RM;            /* remote machine name */
+char   *RP;            /* remote printer name */
+long    RS;            /* restricted to those with local accounts */
+long    RW;            /* open LP for reading and writing */
+long    SB;            /* short banner instead of normal header */
+long    SC;            /* suppress multiple copies */
+char   *SD;            /* spool directory */
+long    SF;            /* suppress FF on each print job */
+long    SH;            /* suppress header page */
+char   *ST;            /* status file name */
 char   *TF;            /* name of troff filter (per job) */
 char   *TF;            /* name of troff filter (per job) */
-char   *NF;            /* name of ditroff filter (per job) */
-char   *DF;            /* name of tex filter (per job) */
-char   *GF;            /* name of graph(1G) filter (per job) */
-char   *VF;            /* name of vplot filter (per job) */
-char   *CF;            /* name of cifplot filter (per job) */
-char   *PF;            /* name of vrast filter (per job) */
-char   *FF;            /* form feed string */
 char   *TR;            /* trailer string to be output when Q empties */
 char   *TR;            /* trailer string to be output when Q empties */
-short  SC;             /* suppress multiple copies */
-short  SF;             /* suppress FF on each print job */
-short  SH;             /* suppress header page */
-short  SB;             /* short banner instead of normal header */
-short  HL;             /* print header last */
-short  RW;             /* open LP for reading and writing */
-short  PW;             /* page width */
-short  PL;             /* page length */
-short  PX;             /* page width in pixels */
-short  PY;             /* page length in pixels */
-short  BR;             /* baud rate if lp is a tty */
-int    FC;             /* flags to clear if lp is a tty */
-int    FS;             /* flags to set if lp is a tty */
-int    XC;             /* flags to clear for local mode */
-int    XS;             /* flags to set for local mode */
-short  RS;             /* restricted to those with local accounts */
+char   *VF;            /* name of vplot filter (per job) */
+long    XC;            /* flags to clear for local mode */
+long    XS;            /* flags to set for local mode */
 
 char   line[BUFSIZ];
 
 char   line[BUFSIZ];
-char   pbuf[BUFSIZ/2]; /* buffer for printcap strings */
-char   *bp = pbuf;     /* pointer into pbuf for pgetent() */
+char   *bp;            /* pointer into printcap buffer. */
 char   *name;          /* program name */
 char   *printer;       /* printer name */
                        /* host machine name */
 char   host[MAXHOSTNAMELEN];
 char   *from = host;   /* client's machine name */
 int    sendtorem;      /* are we sending to a remote? */
 char   *name;          /* program name */
 char   *printer;       /* printer name */
                        /* host machine name */
 char   host[MAXHOSTNAMELEN];
 char   *from = host;   /* client's machine name */
 int    sendtorem;      /* are we sending to a remote? */
+char   *printcapdb[2] = { _PATH_PRINTCAP, 0 };
 
 static int compar __P((const void *, const void *));
 
 
 static int compar __P((const void *, const void *));
 
index 8d3a26c..37409d7 100644 (file)
@@ -2,11 +2,37 @@
  * Copyright (c) 1983 Regents of the University of California.
  * All rights reserved.
  *
  * Copyright (c) 1983 Regents of the University of California.
  * All rights reserved.
  *
- * %sccs.include.redist.c%
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)displayq.c 5.14 (Berkeley) %G%";
+static char sccsid[] = "@(#)displayq.c 5.16 (Berkeley) 8/31/92";
 #endif /* not lint */
 
 #include <sys/param.h>
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -34,22 +60,22 @@ static char sccsid[] = "@(#)displayq.c      5.14 (Berkeley) %G%";
 /*
  * Stuff for handling job specifications
  */
 /*
  * Stuff for handling job specifications
  */
-extern char    *user[];        /* users to process */
-extern int     users;          /* # of users in user array */
 extern int     requ[];         /* job number of spool entries */
 extern int     requests;       /* # of spool requests */
 extern int     requ[];         /* job number of spool entries */
 extern int     requests;       /* # of spool requests */
+extern char    *user[];                /* users to process */
+extern int     users;          /* # of users in user array */
 
 
-int    lflag;          /* long output option */
-char   current[40];    /* current file being printed */
-int    garbage;        /* # of garbage cf files */
-int    rank;           /* order to be printed (-1=none, 0=active) */
-long   totsize;        /* total print job size in bytes */
-int    first;          /* first file in ``files'' column? */
-int    col;            /* column on screen */
-char   file[132];      /* print file name */
+static int     col;            /* column on screen */
+static char    current[40];    /* current file being printed */
+static char    file[132];      /* print file name */
+static int     first;          /* first file in ``files'' column? */
+static int     garbage;        /* # of garbage cf files */
+static int     lflag;          /* long output option */
+static int     rank;           /* order to be printed (-1=none, 0=active) */
+static long    totsize;        /* total print job size in bytes */
 
 
-char   *head0 = "Rank   Owner      Job  Files";
-char   *head1 = "Total Size\n";
+static char    *head0 = "Rank   Owner      Job  Files";
+static char    *head1 = "Total Size\n";
 
 /*
  * Display the current state of the queue. Format = 1 if long format.
 
 /*
  * Display the current state of the queue. Format = 1 if long format.
@@ -68,22 +94,23 @@ displayq(format)
        lflag = format;
        totsize = 0;
        rank = -1;
        lflag = format;
        totsize = 0;
        rank = -1;
-
-       if ((i = pgetent(line, printer)) < 0)
-               fatal("cannot open printer description file");
-       else if (i == 0)
+       if ((i = cgetent(&bp, printcapdb, printer)) == -2)
+               fatal("can't open printer description file");
+       else if (i == -1)
                fatal("unknown printer");
                fatal("unknown printer");
-       if ((LP = pgetstr("lp", &bp)) == NULL)
+       else if (i == -3)
+               fatal("potential reference loop detected in printcap file");
+       if (cgetstr(bp, "lp", &LP) < 0)
                LP = _PATH_DEFDEVLP;
                LP = _PATH_DEFDEVLP;
-       if ((RP = pgetstr("rp", &bp)) == NULL)
+       if (cgetstr(bp, "rp", &RP) < 0)
                RP = DEFLP;
                RP = DEFLP;
-       if ((SD = pgetstr("sd", &bp)) == NULL)
+       if (cgetstr(bp, "sd", &SD) < 0)
                SD = _PATH_DEFSPOOL;
                SD = _PATH_DEFSPOOL;
-       if ((LO = pgetstr("lo", &bp)) == NULL)
+       if (cgetstr(bp,"lo", &LO) < 0)
                LO = DEFLOCK;
                LO = DEFLOCK;
-       if ((ST = pgetstr("st", &bp)) == NULL)
+       if (cgetstr(bp, "st", &ST) < 0)
                ST = DEFSTAT;
                ST = DEFSTAT;
-       RM = pgetstr("rm", &bp);
+       cgetstr(bp, "rm", &RM);
        if (cp = checkremote())
                printf("Warning: %s\n", cp);
 
        if (cp = checkremote())
                printf("Warning: %s\n", cp);
 
index e1563e1..4226ae2 100644 (file)
@@ -2,65 +2,90 @@
  * Copyright (c) 1983 Regents of the University of California.
  * All rights reserved.
  *
  * Copyright (c) 1983 Regents of the University of California.
  * All rights reserved.
  *
- * %sccs.include.redist.c%
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
  *
  *
- *     @(#)lp.h        5.6 (Berkeley) %G%
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *     @(#)lp.h        5.7 (Berkeley) 8/6/92
  */
 
 /*
  * Global definitions for the line printer system.
  */
 
  */
 
 /*
  * Global definitions for the line printer system.
  */
 
-extern int     DU;             /* daeomon user-id */
-extern int     MX;             /* maximum number of blocks to copy */
-extern int     MC;             /* maximum number of copies allowed */
-extern char    *LP;            /* line printer device name */
-extern char    *RM;            /* remote machine name */
-extern char    *RG;            /* restricted group */
-extern char    *RP;            /* remote printer name */
-extern char    *LO;            /* lock file name */
-extern char    *ST;            /* status file name */
-extern char    *SD;            /* spool directory */
 extern char    *AF;            /* accounting file */
 extern char    *AF;            /* accounting file */
+extern long     BR;            /* baud rate if lp is a tty */
+extern char    *CF;            /* name of cifplot filter (per job) */
+extern char    *DF;            /* name of tex filter (per job) */
+extern long     DU;            /* daeomon user-id */
+extern long     FC;            /* flags to clear if lp is a tty */
+extern char    *FF;            /* form feed string */
+extern long     FS;            /* flags to set if lp is a tty */
+extern char    *GF;            /* name of graph(1G) filter (per job) */
+extern long     HL;            /* print header last */
+extern char    *IF;            /* name of input filter (created per job) */
 extern char    *LF;            /* log file for error messages */
 extern char    *LF;            /* log file for error messages */
+extern char    *LO;            /* lock file name */
+extern char    *LP;            /* line printer device name */
+extern long     MC;            /* maximum number of copies allowed */
+extern long      MX;           /* maximum number of blocks to copy */
+extern char    *NF;            /* name of ditroff(1) filter (per job) */
 extern char    *OF;            /* name of output filter (created once) */
 extern char    *OF;            /* name of output filter (created once) */
-extern char    *IF;            /* name of input filter (created per job) */
+extern long     PL;            /* page length */
+extern long     PW;            /* page width */
+extern long     PX;            /* page width in pixels */
+extern long     PY;            /* page length in pixels */
 extern char    *RF;            /* name of fortran text filter (per job) */
 extern char    *RF;            /* name of fortran text filter (per job) */
+extern char    *RG;            /* restricted group */
+extern char    *RM;            /* remote machine name */
+extern char    *RP;            /* remote printer name */
+extern long     RS;            /* restricted to those with local accounts */
+extern long     RW;            /* open LP for reading and writing */
+extern long     SB;            /* short banner instead of normal header */
+extern long     SC;            /* suppress multiple copies */
+extern char    *SD;            /* spool directory */
+extern long     SF;            /* suppress FF on each print job */
+extern long     SH;            /* suppress header page */
+extern char    *ST;            /* status file name */
 extern char    *TF;            /* name of troff(1) filter (per job) */
 extern char    *TF;            /* name of troff(1) filter (per job) */
-extern char    *NF;            /* name of ditroff(1) filter (per job) */
-extern char    *DF;            /* name of tex filter (per job) */
-extern char    *GF;            /* name of graph(1G) filter (per job) */
-extern char    *VF;            /* name of raster filter (per job) */
-extern char    *CF;            /* name of cifplot filter (per job) */
-extern char    *FF;            /* form feed string */
 extern char    *TR;            /* trailer string to be output when Q empties */
 extern char    *TR;            /* trailer string to be output when Q empties */
-extern short   SC;             /* suppress multiple copies */
-extern short   SF;             /* suppress FF on each print job */
-extern short   SH;             /* suppress header page */
-extern short   SB;             /* short banner instead of normal header */
-extern short   HL;             /* print header last */
-extern short   RW;             /* open LP for reading and writing */
-extern short   PW;             /* page width */
-extern short   PX;             /* page width in pixels */
-extern short   PY;             /* page length in pixels */
-extern short   PL;             /* page length */
-extern short   BR;             /* baud rate if lp is a tty */
-extern int     FC;             /* flags to clear if lp is a tty */
-extern int     FS;             /* flags to set if lp is a tty */
-extern int     XC;             /* flags to clear for local mode */
-extern int     XS;             /* flags to set for local mode */
-extern short   RS;             /* restricted to those with local accounts */
+extern char    *VF;            /* name of raster filter (per job) */
+extern long     XC;            /* flags to clear for local mode */
+extern long     XS;            /* flags to set for local mode */
 
 extern char    line[BUFSIZ];
 
 extern char    line[BUFSIZ];
-extern char    pbuf[];         /* buffer for printcap entry */
-extern char    *bp;            /* pointer into ebuf for pgetent() */
+extern char    *bp;            /* pointer into printcap buffer */
 extern char    *name;          /* program name */
 extern char    *printer;       /* printer name */
                                /* host machine name */
 extern char    host[MAXHOSTNAMELEN];
 extern char    *from;          /* client's machine name */
 extern int     sendtorem;      /* are we sending to a remote? */
 extern char    *name;          /* program name */
 extern char    *printer;       /* printer name */
                                /* host machine name */
 extern char    host[MAXHOSTNAMELEN];
 extern char    *from;          /* client's machine name */
 extern int     sendtorem;      /* are we sending to a remote? */
-
+extern char    *printcapdb[];  /* printcap database array */
 /*
  * Structure used for building a sorted list of control files.
  */
 /*
  * Structure used for building a sorted list of control files.
  */
@@ -70,6 +95,8 @@ struct queue {
 };
 
 #include <sys/cdefs.h>
 };
 
 #include <sys/cdefs.h>
+
+_BEGIN_DECLS
 struct dirent;
 
 void     blankfill __P((int));
 struct dirent;
 
 void     blankfill __P((int));
@@ -77,11 +104,9 @@ char        *checkremote __P((void));
 int      chk __P((char *));
 void     displayq __P((int));
 void     dump __P((char *, char *, int));
 int      chk __P((char *));
 void     displayq __P((int));
 void     dump __P((char *, char *, int));
-void     endprent __P((void));
 void    fatal __P((const char *, ...));
 int     getline __P((FILE *));
 int     getport __P((char *));
 void    fatal __P((const char *, ...));
 int     getline __P((FILE *));
 int     getport __P((char *));
-int      getprent __P((char *));
 int     getq __P((struct queue *(*[])));
 void     header __P((void));
 void     inform __P((char *));
 int     getq __P((struct queue *(*[])));
 void     header __P((void));
 void     inform __P((char *));
@@ -96,10 +121,5 @@ void     rmjob __P((void));
 void     rmremote __P((void));
 void     show __P((char *, char *, int));
 int      startdaemon __P((char *));
 void     rmremote __P((void));
 void     show __P((char *, char *, int));
 int      startdaemon __P((char *));
-int      pgetent __P((char *, char *));
-int      pgetflag __P((char *));
-int      pgetnum __P((char *));
-char    *pgetstr __P((char *, char **));
-int      pnamatch __P((char *));
-int      pnchktc __P((void));
 void     warn __P((void));
 void     warn __P((void));
+_END_DECLS
index 398b241..5ec265d 100644 (file)
@@ -2,9 +2,35 @@
  * Copyright (c) 1989 The Regents of the University of California.
  * All rights reserved.
  *
  * Copyright (c) 1989 The Regents of the University of California.
  * All rights reserved.
  *
- * %sccs.include.redist.c%
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
  *
  *
- *     @(#)pathnames.h 5.4 (Berkeley) %G%
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *     @(#)pathnames.h 5.5 (Berkeley) 8/6/92
  */
 
 #include <paths.h>
  */
 
 #include <paths.h>
index 51ec5f6..7bf71a4 100644 (file)
@@ -2,11 +2,37 @@
  * Copyright (c) 1983 Regents of the University of California.
  * All rights reserved.
  *
  * Copyright (c) 1983 Regents of the University of California.
  * All rights reserved.
  *
- * %sccs.include.redist.c%
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)rmjob.c    5.8 (Berkeley) %G%";
+static char sccsid[] = "@(#)rmjob.c    5.10 (Berkeley) 8/31/92";
 #endif /* not lint */
 
 #include <sys/param.h>
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -36,10 +62,10 @@ extern int  requ[];                 /* job number of spool entries */
 extern int     requests;               /* # of spool requests */
 extern char    *person;                /* name of person doing lprm */
 
 extern int     requests;               /* # of spool requests */
 extern char    *person;                /* name of person doing lprm */
 
-char   root[] = "root";
-int    all = 0;                /* eliminate all files (root only) */
-int    cur_daemon;             /* daemon's pid */
-char   current[40];            /* active control file name */
+static char    root[] = "root";
+static int     all = 0;                /* eliminate all files (root only) */
+static int     cur_daemon;             /* daemon's pid */
+static char    current[40];            /* active control file name */
 
 void
 rmjob()
 
 void
 rmjob()
@@ -49,19 +75,21 @@ rmjob()
        struct dirent **files;
        char *cp;
 
        struct dirent **files;
        char *cp;
 
-       if ((i = pgetent(line, printer)) < 0)
-               fatal("cannot open printer description file");
-       else if (i == 0)
+       if ((i = cgetent(&bp, printcapdb, printer)) == -2)
+               fatal("can't open printer description file");
+       else if (i == -1)
                fatal("unknown printer");
                fatal("unknown printer");
-       if ((SD = pgetstr("sd", &bp)) == NULL)
-               SD = _PATH_DEFSPOOL;
-       if ((LO = pgetstr("lo", &bp)) == NULL)
-               LO = DEFLOCK;
-       if ((LP = pgetstr("lp", &bp)) == NULL)
+       else if (i == -3)
+               fatal("potential reference loop detected in printcap file");
+       if (cgetstr(bp, "lp", &LP) < 0)
                LP = _PATH_DEFDEVLP;
                LP = _PATH_DEFDEVLP;
-       if ((RP = pgetstr("rp", &bp)) == NULL)
+       if (cgetstr(bp, "rp", &RP) < 0)
                RP = DEFLP;
                RP = DEFLP;
-       RM = pgetstr("rm", &bp);
+       if (cgetstr(bp, "sd", &SD) < 0)
+               SD = _PATH_DEFSPOOL;
+       if (cgetstr(bp,"lo", &LO) < 0)
+               LO = DEFLOCK;
+       cgetstr(bp, "rm", &RM);
        if (cp = checkremote())
                printf("Warning: %s\n", cp);
 
        if (cp = checkremote())
                printf("Warning: %s\n", cp);
 
index 55b0fae..81c4d1c 100644 (file)
@@ -2,11 +2,37 @@
  * Copyright (c) 1983 Regents of the University of California.
  * All rights reserved.
  *
  * Copyright (c) 1983 Regents of the University of California.
  * All rights reserved.
  *
- * %sccs.include.redist.c%
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)cmds.c     5.8 (Berkeley) %G%";
+static char sccsid[] = "@(#)cmds.c     5.10 (Berkeley) 8/31/92";
 #endif /* not lint */
 
 /*
 #endif /* not lint */
 
 /*
@@ -34,19 +60,18 @@ static char sccsid[] = "@(#)cmds.c  5.8 (Berkeley) %G%";
 
 static void    abortpr __P((int));
 static void    cleanpr __P((void));
 
 static void    abortpr __P((int));
 static void    cleanpr __P((void));
-static int     doselect __P((struct dirent *));
-static void    upstat __P((char *));
-static int     sortq __P((const void *, const void *));
-static void    unlinkf __P((char *));
+static void    disablepr __P((void));
 static int     doarg __P((char *));
 static int     doarg __P((char *));
-static int     touch __P((struct queue *));
-static void    stoppr __P((void));
+static int     doselect __P((struct dirent *));
+static void    enablepr __P((void));
 static void    prstat __P((void));
 static void    prstat __P((void));
-static void    startpr __P((int));
 static void    putmsg __P((int, char **));
 static void    putmsg __P((int, char **));
-static void    disablepr __P((void));
-static void    enablepr __P((void));
-
+static int     sortq __P((const void *, const void *));
+static void    startpr __P((int));
+static void    stoppr __P((void));
+static int     touch __P((struct queue *));
+static void    unlinkf __P((char *));
+static void    upstat __P((char *));
 
 /*
  * kill an existing daemon and disable printing.
 
 /*
  * kill an existing daemon and disable printing.
@@ -66,9 +91,9 @@ doabort(argc, argv)
        }
        if (argc == 2 && !strcmp(argv[1], "all")) {
                printer = prbuf;
        }
        if (argc == 2 && !strcmp(argv[1], "all")) {
                printer = prbuf;
-               while (getprent(line) > 0) {
+               while (cgetnext(&bp, printcapdb) > 0) {
                        cp1 = prbuf;
                        cp1 = prbuf;
-                       cp2 = line;
+                       cp2 = bp;
                        while ((c = *cp2++) && c != '|' && c != ':')
                                *cp1++ = c;
                        *cp1 = '\0';
                        while ((c = *cp2++) && c != '|' && c != ':')
                                *cp1++ = c;
                        *cp1 = '\0';
@@ -78,13 +103,14 @@ doabort(argc, argv)
        }
        while (--argc) {
                printer = *++argv;
        }
        while (--argc) {
                printer = *++argv;
-               if ((status = pgetent(line, printer)) < 0) {
+               if ((status = cgetent(&bp, printcapdb, printer)) == -2) {
                        printf("cannot open printer description file\n");
                        continue;
                        printf("cannot open printer description file\n");
                        continue;
-               } else if (status == 0) {
+               } else if (status == -1) {
                        printf("unknown printer %s\n", printer);
                        continue;
                        printf("unknown printer %s\n", printer);
                        continue;
-               }
+               } else if (status == -3)
+                       fatal("potential reference loop detected in printcap file");
                abortpr(1);
        }
 }
                abortpr(1);
        }
 }
@@ -97,10 +123,9 @@ abortpr(dis)
        struct stat stbuf;
        int pid, fd;
 
        struct stat stbuf;
        int pid, fd;
 
-       bp = pbuf;
-       if ((SD = pgetstr("sd", &bp)) == NULL)
+       if (cgetstr(bp, "sd", &SD) == -1)
                SD = _PATH_DEFSPOOL;
                SD = _PATH_DEFSPOOL;
-       if ((LO = pgetstr("lo", &bp)) == NULL)
+       if (cgetstr(bp, "lo", &LO) == -1)
                LO = DEFLOCK;
        (void) sprintf(line, "%s/%s", SD, LO);
        printf("%s:\n", printer);
                LO = DEFLOCK;
        (void) sprintf(line, "%s/%s", SD, LO);
        printf("%s:\n", printer);
@@ -160,8 +185,7 @@ upstat(msg)
        register int fd;
        char statfile[BUFSIZ];
 
        register int fd;
        char statfile[BUFSIZ];
 
-       bp = pbuf;
-       if ((ST = pgetstr("st", &bp)) == NULL)
+       if (cgetstr(bp, "st", &ST) == -1)
                ST = DEFSTAT;
        (void) sprintf(statfile, "%s/%s", SD, ST);
        umask(0);
                ST = DEFSTAT;
        (void) sprintf(statfile, "%s/%s", SD, ST);
        umask(0);
@@ -196,9 +220,9 @@ clean(argc, argv)
        }
        if (argc == 2 && !strcmp(argv[1], "all")) {
                printer = prbuf;
        }
        if (argc == 2 && !strcmp(argv[1], "all")) {
                printer = prbuf;
-               while (getprent(line) > 0) {
+               while (cgetnext(&bp, printcapdb) > 0) {
                        cp1 = prbuf;
                        cp1 = prbuf;
-                       cp2 = line;
+                       cp2 = bp;
                        while ((c = *cp2++) && c != '|' && c != ':')
                                *cp1++ = c;
                        *cp1 = '\0';
                        while ((c = *cp2++) && c != '|' && c != ':')
                                *cp1++ = c;
                        *cp1 = '\0';
@@ -208,13 +232,15 @@ clean(argc, argv)
        }
        while (--argc) {
                printer = *++argv;
        }
        while (--argc) {
                printer = *++argv;
-               if ((status = pgetent(line, printer)) < 0) {
+               if ((status = cgetent(&bp, printcapdb, printer)) == -2) {
                        printf("cannot open printer description file\n");
                        continue;
                        printf("cannot open printer description file\n");
                        continue;
-               } else if (status == 0) {
+               } else if (status == -1) {
                        printf("unknown printer %s\n", printer);
                        continue;
                        printf("unknown printer %s\n", printer);
                        continue;
-               }
+               } else if (status == -3)
+                       fatal("potential reference loop detected in printcap file");
+
                cleanpr();
        }
 }
                cleanpr();
        }
 }
@@ -267,8 +293,7 @@ cleanpr()
        struct dirent **queue;
        int nitems;
 
        struct dirent **queue;
        int nitems;
 
-       bp = pbuf;
-       if ((SD = pgetstr("sd", &bp)) == NULL)
+       if (cgetstr(bp, "sd", &SD) == -1)
                SD = _PATH_DEFSPOOL;
        printf("%s:\n", printer);
 
                SD = _PATH_DEFSPOOL;
        printf("%s:\n", printer);
 
@@ -339,9 +364,9 @@ enable(argc, argv)
        }
        if (argc == 2 && !strcmp(argv[1], "all")) {
                printer = prbuf;
        }
        if (argc == 2 && !strcmp(argv[1], "all")) {
                printer = prbuf;
-               while (getprent(line) > 0) {
+               while (cgetnext(&bp, printcapdb) > 0) {
                        cp1 = prbuf;
                        cp1 = prbuf;
-                       cp2 = line;
+                       cp2 = bp;
                        while ((c = *cp2++) && c != '|' && c != ':')
                                *cp1++ = c;
                        *cp1 = '\0';
                        while ((c = *cp2++) && c != '|' && c != ':')
                                *cp1++ = c;
                        *cp1 = '\0';
@@ -351,13 +376,15 @@ enable(argc, argv)
        }
        while (--argc) {
                printer = *++argv;
        }
        while (--argc) {
                printer = *++argv;
-               if ((status = pgetent(line, printer)) < 0) {
+               if ((status = cgetent(&bp, printcapdb, printer)) == -2) {
                        printf("cannot open printer description file\n");
                        continue;
                        printf("cannot open printer description file\n");
                        continue;
-               } else if (status == 0) {
+               } else if (status == -1) {
                        printf("unknown printer %s\n", printer);
                        continue;
                        printf("unknown printer %s\n", printer);
                        continue;
-               }
+               } else if (status == -3)
+                       fatal("potential reference loop detected in printcap file");
+
                enablepr();
        }
 }
                enablepr();
        }
 }
@@ -367,10 +394,9 @@ enablepr()
 {
        struct stat stbuf;
 
 {
        struct stat stbuf;
 
-       bp = pbuf;
-       if ((SD = pgetstr("sd", &bp)) == NULL)
+       if (cgetstr(bp, "sd", &SD) == -1)
                SD = _PATH_DEFSPOOL;
                SD = _PATH_DEFSPOOL;
-       if ((LO = pgetstr("lo", &bp)) == NULL)
+       if (cgetstr(bp, "lo", &LO) == -1)
                LO = DEFLOCK;
        (void) sprintf(line, "%s/%s", SD, LO);
        printf("%s:\n", printer);
                LO = DEFLOCK;
        (void) sprintf(line, "%s/%s", SD, LO);
        printf("%s:\n", printer);
@@ -404,9 +430,9 @@ disable(argc, argv)
        }
        if (argc == 2 && !strcmp(argv[1], "all")) {
                printer = prbuf;
        }
        if (argc == 2 && !strcmp(argv[1], "all")) {
                printer = prbuf;
-               while (getprent(line) > 0) {
+               while (cgetnext(&bp, printcapdb) > 0) {
                        cp1 = prbuf;
                        cp1 = prbuf;
-                       cp2 = line;
+                       cp2 = bp;
                        while ((c = *cp2++) && c != '|' && c != ':')
                                *cp1++ = c;
                        *cp1 = '\0';
                        while ((c = *cp2++) && c != '|' && c != ':')
                                *cp1++ = c;
                        *cp1 = '\0';
@@ -416,13 +442,15 @@ disable(argc, argv)
        }
        while (--argc) {
                printer = *++argv;
        }
        while (--argc) {
                printer = *++argv;
-               if ((status = pgetent(line, printer)) < 0) {
+               if ((status = cgetent(&bp, printcapdb, printer)) == -2) {
                        printf("cannot open printer description file\n");
                        continue;
                        printf("cannot open printer description file\n");
                        continue;
-               } else if (status == 0) {
+               } else if (status == -1) {
                        printf("unknown printer %s\n", printer);
                        continue;
                        printf("unknown printer %s\n", printer);
                        continue;
-               }
+               } else if (status == -3)
+                       fatal("potential reference loop detected in printcap file");
+
                disablepr();
        }
 }
                disablepr();
        }
 }
@@ -433,10 +461,9 @@ disablepr()
        register int fd;
        struct stat stbuf;
 
        register int fd;
        struct stat stbuf;
 
-       bp = pbuf;
-       if ((SD = pgetstr("sd", &bp)) == NULL)
+       if (cgetstr(bp, "sd", &SD) == -1)
                SD = _PATH_DEFSPOOL;
                SD = _PATH_DEFSPOOL;
-       if ((LO = pgetstr("lo", &bp)) == NULL)
+       if (cgetstr(bp, "lo", &LO) == -1)
                LO = DEFLOCK;
        (void) sprintf(line, "%s/%s", SD, LO);
        printf("%s:\n", printer);
                LO = DEFLOCK;
        (void) sprintf(line, "%s/%s", SD, LO);
        printf("%s:\n", printer);
@@ -479,9 +506,9 @@ down(argc, argv)
        }
        if (!strcmp(argv[1], "all")) {
                printer = prbuf;
        }
        if (!strcmp(argv[1], "all")) {
                printer = prbuf;
-               while (getprent(line) > 0) {
+               while (cgetnext(&bp, printcapdb) > 0) {
                        cp1 = prbuf;
                        cp1 = prbuf;
-                       cp2 = line;
+                       cp2 = bp;
                        while ((c = *cp2++) && c != '|' && c != ':')
                                *cp1++ = c;
                        *cp1 = '\0';
                        while ((c = *cp2++) && c != '|' && c != ':')
                                *cp1++ = c;
                        *cp1 = '\0';
@@ -490,13 +517,15 @@ down(argc, argv)
                return;
        }
        printer = argv[1];
                return;
        }
        printer = argv[1];
-       if ((status = pgetent(line, printer)) < 0) {
+       if ((status = cgetent(&bp, printcapdb, printer)) == -2) {
                printf("cannot open printer description file\n");
                return;
                printf("cannot open printer description file\n");
                return;
-       } else if (status == 0) {
+       } else if (status == -1) {
                printf("unknown printer %s\n", printer);
                return;
                printf("unknown printer %s\n", printer);
                return;
-       }
+       } else if (status == -3)
+                       fatal("potential reference loop detected in printcap file");
+
        putmsg(argc - 2, argv + 2);
 }
 
        putmsg(argc - 2, argv + 2);
 }
 
@@ -510,12 +539,11 @@ putmsg(argc, argv)
        char buf[1024];
        struct stat stbuf;
 
        char buf[1024];
        struct stat stbuf;
 
-       bp = pbuf;
-       if ((SD = pgetstr("sd", &bp)) == NULL)
+       if (cgetstr(bp, "sd", &SD) == -1)
                SD = _PATH_DEFSPOOL;
                SD = _PATH_DEFSPOOL;
-       if ((LO = pgetstr("lo", &bp)) == NULL)
+       if (cgetstr(bp, "lo", &LO) == -1)
                LO = DEFLOCK;
                LO = DEFLOCK;
-       if ((ST = pgetstr("st", &bp)) == NULL)
+       if (cgetstr(bp, "st", &ST) == -1)
                ST = DEFSTAT;
        printf("%s:\n", printer);
        /*
                ST = DEFSTAT;
        printf("%s:\n", printer);
        /*
@@ -595,9 +623,9 @@ restart(argc, argv)
        }
        if (argc == 2 && !strcmp(argv[1], "all")) {
                printer = prbuf;
        }
        if (argc == 2 && !strcmp(argv[1], "all")) {
                printer = prbuf;
-               while (getprent(line) > 0) {
+               while (cgetnext(&bp, printcapdb) > 0) {
                        cp1 = prbuf;
                        cp1 = prbuf;
-                       cp2 = line;
+                       cp2 = bp;
                        while ((c = *cp2++) && c != '|' && c != ':')
                                *cp1++ = c;
                        *cp1 = '\0';
                        while ((c = *cp2++) && c != '|' && c != ':')
                                *cp1++ = c;
                        *cp1 = '\0';
@@ -608,13 +636,15 @@ restart(argc, argv)
        }
        while (--argc) {
                printer = *++argv;
        }
        while (--argc) {
                printer = *++argv;
-               if ((status = pgetent(line, printer)) < 0) {
+               if ((status = cgetent(&bp, printcapdb, printer)) == -2) {
                        printf("cannot open printer description file\n");
                        continue;
                        printf("cannot open printer description file\n");
                        continue;
-               } else if (status == 0) {
+               } else if (status == -1) {
                        printf("unknown printer %s\n", printer);
                        continue;
                        printf("unknown printer %s\n", printer);
                        continue;
-               }
+               } else if (status == -3)
+                       fatal("potential reference loop detected in printcap file");
+
                abortpr(0);
                startpr(0);
        }
                abortpr(0);
                startpr(0);
        }
@@ -638,9 +668,9 @@ start(argc, argv)
        }
        if (argc == 2 && !strcmp(argv[1], "all")) {
                printer = prbuf;
        }
        if (argc == 2 && !strcmp(argv[1], "all")) {
                printer = prbuf;
-               while (getprent(line) > 0) {
+               while (cgetnext(&bp, printcapdb) > 0) {
                        cp1 = prbuf;
                        cp1 = prbuf;
-                       cp2 = line;
+                       cp2 = bp;
                        while ((c = *cp2++) && c != '|' && c != ':')
                                *cp1++ = c;
                        *cp1 = '\0';
                        while ((c = *cp2++) && c != '|' && c != ':')
                                *cp1++ = c;
                        *cp1 = '\0';
@@ -650,13 +680,15 @@ start(argc, argv)
        }
        while (--argc) {
                printer = *++argv;
        }
        while (--argc) {
                printer = *++argv;
-               if ((status = pgetent(line, printer)) < 0) {
+               if ((status = cgetent(&bp, printcapdb, printer)) == -2) {
                        printf("cannot open printer description file\n");
                        continue;
                        printf("cannot open printer description file\n");
                        continue;
-               } else if (status == 0) {
+               } else if (status == -1) {
                        printf("unknown printer %s\n", printer);
                        continue;
                        printf("unknown printer %s\n", printer);
                        continue;
-               }
+               } else if (status == -3)
+                       fatal("potential reference loop detected in printcap file");
+
                startpr(1);
        }
 }
                startpr(1);
        }
 }
@@ -667,10 +699,9 @@ startpr(enable)
 {
        struct stat stbuf;
 
 {
        struct stat stbuf;
 
-       bp = pbuf;
-       if ((SD = pgetstr("sd", &bp)) == NULL)
+       if (cgetstr(bp, "sd", &SD) == -1)
                SD = _PATH_DEFSPOOL;
                SD = _PATH_DEFSPOOL;
-       if ((LO = pgetstr("lo", &bp)) == NULL)
+       if (cgetstr(bp, "lo", &LO) == -1)
                LO = DEFLOCK;
        (void) sprintf(line, "%s/%s", SD, LO);
        printf("%s:\n", printer);
                LO = DEFLOCK;
        (void) sprintf(line, "%s/%s", SD, LO);
        printf("%s:\n", printer);
@@ -704,9 +735,9 @@ status(argc, argv)
 
        if (argc == 1) {
                printer = prbuf;
 
        if (argc == 1) {
                printer = prbuf;
-               while (getprent(line) > 0) {
+               while (cgetnext(&bp, printcapdb) > 0) {
                        cp1 = prbuf;
                        cp1 = prbuf;
-                       cp2 = line;
+                       cp2 = bp;
                        while ((c = *cp2++) && c != '|' && c != ':')
                                *cp1++ = c;
                        *cp1 = '\0';
                        while ((c = *cp2++) && c != '|' && c != ':')
                                *cp1++ = c;
                        *cp1 = '\0';
@@ -716,13 +747,15 @@ status(argc, argv)
        }
        while (--argc) {
                printer = *++argv;
        }
        while (--argc) {
                printer = *++argv;
-               if ((status = pgetent(line, printer)) < 0) {
+               if ((status = cgetent(&bp, printcapdb, printer)) == -2) {
                        printf("cannot open printer description file\n");
                        continue;
                        printf("cannot open printer description file\n");
                        continue;
-               } else if (status == 0) {
+               } else if (status == -1) {
                        printf("unknown printer %s\n", printer);
                        continue;
                        printf("unknown printer %s\n", printer);
                        continue;
-               }
+               } else if (status == -3)
+                       fatal("potential reference loop detected in printcap file");
+
                prstat();
        }
 }
                prstat();
        }
 }
@@ -738,12 +771,11 @@ prstat()
        register struct dirent *dp;
        DIR *dirp;
 
        register struct dirent *dp;
        DIR *dirp;
 
-       bp = pbuf;
-       if ((SD = pgetstr("sd", &bp)) == NULL)
+       if (cgetstr(bp, "sd", &SD) == -1)
                SD = _PATH_DEFSPOOL;
                SD = _PATH_DEFSPOOL;
-       if ((LO = pgetstr("lo", &bp)) == NULL)
+       if (cgetstr(bp, "lo", &LO) == -1)
                LO = DEFLOCK;
                LO = DEFLOCK;
-       if ((ST = pgetstr("st", &bp)) == NULL)
+       if (cgetstr(bp, "st", &ST) == -1)
                ST = DEFSTAT;
        printf("%s:\n", printer);
        (void) sprintf(line, "%s/%s", SD, LO);
                ST = DEFSTAT;
        printf("%s:\n", printer);
        (void) sprintf(line, "%s/%s", SD, LO);
@@ -809,9 +841,9 @@ stop(argc, argv)
        }
        if (argc == 2 && !strcmp(argv[1], "all")) {
                printer = prbuf;
        }
        if (argc == 2 && !strcmp(argv[1], "all")) {
                printer = prbuf;
-               while (getprent(line) > 0) {
+               while (cgetnext(&bp, printcapdb) > 0) {
                        cp1 = prbuf;
                        cp1 = prbuf;
-                       cp2 = line;
+                       cp2 = bp;
                        while ((c = *cp2++) && c != '|' && c != ':')
                                *cp1++ = c;
                        *cp1 = '\0';
                        while ((c = *cp2++) && c != '|' && c != ':')
                                *cp1++ = c;
                        *cp1 = '\0';
@@ -821,13 +853,15 @@ stop(argc, argv)
        }
        while (--argc) {
                printer = *++argv;
        }
        while (--argc) {
                printer = *++argv;
-               if ((status = pgetent(line, printer)) < 0) {
+               if ((status = cgetent(&bp, printcapdb, printer)) == -2) {
                        printf("cannot open printer description file\n");
                        continue;
                        printf("cannot open printer description file\n");
                        continue;
-               } else if (status == 0) {
+               } else if (status == -1) {
                        printf("unknown printer %s\n", printer);
                        continue;
                        printf("unknown printer %s\n", printer);
                        continue;
-               }
+               } else if (status == -3)
+                       fatal("potential reference loop detected in printcap file");
+
                stoppr();
        }
 }
                stoppr();
        }
 }
@@ -838,10 +872,9 @@ stoppr()
        register int fd;
        struct stat stbuf;
 
        register int fd;
        struct stat stbuf;
 
-       bp = pbuf;
-       if ((SD = pgetstr("sd", &bp)) == NULL)
+       if (cgetstr(bp, "sd", &SD) == -1)
                SD = _PATH_DEFSPOOL;
                SD = _PATH_DEFSPOOL;
-       if ((LO = pgetstr("lo", &bp)) == NULL)
+       if (cgetstr(bp, "lo", &LO) == -1)
                LO = DEFLOCK;
        (void) sprintf(line, "%s/%s", SD, LO);
        printf("%s:\n", printer);
                LO = DEFLOCK;
        (void) sprintf(line, "%s/%s", SD, LO);
        printf("%s:\n", printer);
@@ -891,18 +924,19 @@ topq(argc, argv)
 
        --argc;
        printer = *++argv;
 
        --argc;
        printer = *++argv;
-       status = pgetent(line, printer);
-       if (status < 0) {
+       status = cgetent(&bp, printcapdb, printer);
+       if (status == -2) {
                printf("cannot open printer description file\n");
                return;
                printf("cannot open printer description file\n");
                return;
-       } else if (status == 0) {
+       } else if (status == -1) {
                printf("%s: unknown printer\n", printer);
                return;
                printf("%s: unknown printer\n", printer);
                return;
-       }
-       bp = pbuf;
-       if ((SD = pgetstr("sd", &bp)) == NULL)
+       } else if (status == -3)
+               fatal("potential reference loop detected in printcap file");
+
+       if (cgetstr(bp, "sd", &SD) == -1)
                SD = _PATH_DEFSPOOL;
                SD = _PATH_DEFSPOOL;
-       if ((LO = pgetstr("lo", &bp)) == NULL)
+       if (cgetstr(bp, "lo", &LO) == -1)
                LO = DEFLOCK;
        printf("%s:\n", printer);
 
                LO = DEFLOCK;
        printf("%s:\n", printer);
 
@@ -1040,9 +1074,9 @@ up(argc, argv)
        }
        if (argc == 2 && !strcmp(argv[1], "all")) {
                printer = prbuf;
        }
        if (argc == 2 && !strcmp(argv[1], "all")) {
                printer = prbuf;
-               while (getprent(line) > 0) {
+               while (cgetnext(&bp, printcapdb) > 0) {
                        cp1 = prbuf;
                        cp1 = prbuf;
-                       cp2 = line;
+                       cp2 = bp;
                        while ((c = *cp2++) && c != '|' && c != ':')
                                *cp1++ = c;
                        *cp1 = '\0';
                        while ((c = *cp2++) && c != '|' && c != ':')
                                *cp1++ = c;
                        *cp1 = '\0';
@@ -1052,13 +1086,15 @@ up(argc, argv)
        }
        while (--argc) {
                printer = *++argv;
        }
        while (--argc) {
                printer = *++argv;
-               if ((status = pgetent(line, printer)) < 0) {
+               if ((status = cgetent(&bp, printcapdb, printer)) == -2) {
                        printf("cannot open printer description file\n");
                        continue;
                        printf("cannot open printer description file\n");
                        continue;
-               } else if (status == 0) {
+               } else if (status == -1) {
                        printf("unknown printer %s\n", printer);
                        continue;
                        printf("unknown printer %s\n", printer);
                        continue;
-               }
+               } else if (status == -3)
+                       fatal("potential reference loop detected in printcap file");
+
                startpr(2);
        }
 }
                startpr(2);
        }
 }
index 941ed97..664bf1c 100644 (file)
@@ -2,14 +2,44 @@
  * Copyright (c) 1992 The Regents of the University of California.
  * All rights reserved.
  *
  * Copyright (c) 1992 The Regents of the University of California.
  * All rights reserved.
  *
- * %sccs.include.redist.c%
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
  *
  *
- *     @(#)extern.h    5.1 (Berkeley) %G%
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *     @(#)extern.h    5.3 (Berkeley) 8/6/92
  */
 
  */
 
-void   doabort __P((int, char **));
+#include <sys/cdefs.h>
+
+
+__BEGIN_DECLS
 void   clean __P((int, char **));
 void   disable __P((int, char **));
 void   clean __P((int, char **));
 void   disable __P((int, char **));
+void   doabort __P((int, char **));
 void   down __P((int, char **));
 void   enable __P((int, char **));
 void   help __P((int, char **));
 void   down __P((int, char **));
 void   enable __P((int, char **));
 void   help __P((int, char **));
@@ -20,6 +50,7 @@ void  status __P((int, char **));
 void   stop __P((int, char **));
 void   topq __P((int, char **));
 void   up __P((int, char **));
 void   stop __P((int, char **));
 void   topq __P((int, char **));
 void   up __P((int, char **));
+__END_DECLS
 
 extern int NCMDS;
 extern struct cmd cmdtab[];
 
 extern int NCMDS;
 extern struct cmd cmdtab[];
index b8f0c78..8536037 100644 (file)
@@ -2,7 +2,33 @@
  * Copyright (c) 1983 Regents of the University of California.
  * All rights reserved.
  *
  * Copyright (c) 1983 Regents of the University of California.
  * All rights reserved.
  *
- * %sccs.include.redist.c%
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
  */
 
 #ifndef lint
  */
 
 #ifndef lint
@@ -12,7 +38,7 @@ char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)lpc.c      5.12 (Berkeley) %G%";
+static char sccsid[] = "@(#)lpc.c      5.13 (Berkeley) 8/6/92";
 #endif /* not lint */
 
 #include <sys/param.h>
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -54,7 +80,6 @@ main(argc, argv)
        char *argv[];
 {
        register struct cmd *c;
        char *argv[];
 {
        register struct cmd *c;
-       extern char *name;
 
        name = argv[0];
        openlog("lpd", 0, LOG_LPR);
 
        name = argv[0];
        openlog("lpd", 0, LOG_LPR);