summaryrefslogtreecommitdiffstats
path: root/usr.sbin/lpr/common_source
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/lpr/common_source')
-rw-r--r--usr.sbin/lpr/common_source/aux.c400
-rw-r--r--usr.sbin/lpr/common_source/aux.h67
-rw-r--r--usr.sbin/lpr/common_source/displayq.c5
-rw-r--r--usr.sbin/lpr/common_source/lp.h9
-rw-r--r--usr.sbin/lpr/common_source/printcap.c551
-rw-r--r--usr.sbin/lpr/common_source/recvjob.c1
-rw-r--r--usr.sbin/lpr/common_source/rmjob.c6
-rw-r--r--usr.sbin/lpr/common_source/startdaemon.c2
8 files changed, 9 insertions, 1032 deletions
diff --git a/usr.sbin/lpr/common_source/aux.c b/usr.sbin/lpr/common_source/aux.c
deleted file mode 100644
index 8d7a936..0000000
--- a/usr.sbin/lpr/common_source/aux.c
+++ /dev/null
@@ -1,400 +0,0 @@
-/*
- * Copyright (c) 1995
- * The Regents of the University of California. All rights reserved.
- *
- * 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.
- */
-
-/*
- * Auxillary functions to aid portability to other systems.
- * These are 4.4BSD routines that are often not found on other systems.
- *
- * !!!USE THIS FILE ONLY IF YOU ARE NOT RUNNING 4.4BSD!!!
- */
-
-#if __STDC__
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-
-#ifdef NO_SNPRINTF
-#if __STDC__
-snprintf(char *str, size_t n, const char *fmt, ...)
-#else
-snprintf(str, n, fmt, va_alist)
- char *str;
- size_t n;
- char *fmt;
- va_dcl
-#endif
-{
- int ret;
- va_list ap;
-
-#if __STDC__
- va_start(ap, fmt);
-#else
- va_start(ap);
-#endif
- ret = vsprintf(str, fmt, ap);
- va_end(ap);
- if (strlen(str) > n)
- fatal("memory corrupted");
- return (ret);
-}
-
-vsnprintf(str, n, fmt, ap)
- char *str;
- size_t n;
- char *fmt;
- va_list ap;
-{
- int ret;
-
- ret = vsprintf(str, fmt, ap);
- if (strlen(str) > n)
- fatal("memory corrupted");
- return (ret);
-}
-#endif
-
-#ifdef NO_STRERROR
-char *
-strerror(num)
- int num;
-{
- extern int sys_nerr;
- extern char *sys_errlist[];
-#define UPREFIX "Unknown error: "
- static char ebuf[40] = UPREFIX; /* 64-bit number + slop */
- register unsigned int errnum;
- register char *p, *t;
- char tmp[40];
-
- errnum = num; /* convert to unsigned */
- if (errnum < sys_nerr)
- return(sys_errlist[errnum]);
-
- /* Do this by hand, so we don't include stdio(3). */
- t = tmp;
- do {
- *t++ = "0123456789"[errnum % 10];
- } while (errnum /= 10);
- for (p = ebuf + sizeof(UPREFIX) - 1;;) {
- *p++ = *--t;
- if (t <= tmp)
- break;
- }
- return(ebuf);
-}
-#endif
-
-#ifdef NO_STRDUP
-char *
-strdup(str)
- char *str;
-{
- int n;
- char *sp;
-
- n = strlen(str) + 1;
- if (sp = (char *) malloc(n))
- memcpy(sp, str, n);
- return (sp);
-}
-#endif
-
-#ifdef NO_DAEMON
-#include <fcntl.h>
-#include <paths.h>
-#include <unistd.h>
-#include <sgtty.h>
-#define STDIN_FILENO 0
-#define STDOUT_FILENO 1
-#define STDERR_FILENO 2
-
-int
-daemon(nochdir, noclose)
- int nochdir, noclose;
-{
- int fd;
-
- switch (fork()) {
- case -1:
- return (-1);
- case 0:
- break;
- default:
- _exit(0);
- }
-
- if (setsid() == -1)
- return (-1);
-
- if (!nochdir)
- (void)chdir("/");
-
- if (!noclose && (fd = open(_PATH_DEVNULL, O_RDWR, 0)) != -1) {
- (void)dup2(fd, STDIN_FILENO);
- (void)dup2(fd, STDOUT_FILENO);
- (void)dup2(fd, STDERR_FILENO);
- if (fd > 2)
- (void)close (fd);
- }
- return (0);
-}
-#endif
-
-
-#ifdef NO_SETSID
-int
-setsid()
-{
- int f;
-
- f = open("/dev/tty", O_RDWR);
- if (f > 0) {
- ioctl(f, TIOCNOTTY, 0);
- (void) close(f);
- }
- return f;
-}
-#endif
-
-
-#ifdef NO_VSYSLOG
-#include <stdio.h>
-#include <errno.h>
-#if __STDC__
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-
-vsyslog(pri, fmt, ap)
- int pri;
- const char *fmt;
- va_list ap;
-{
- char buf[2048], fmt_cpy[1024];
-
- /* substitute error message for %m */
- {
- register char ch, *t1, *t2;
- char *strerror();
-
- for (t1 = fmt_cpy; ch = *fmt; ++fmt)
- if (ch == '%' && fmt[1] == 'm') {
- ++fmt;
- for (t2 = strerror(errno);
- *t1 = *t2++; ++t1);
- }
- else
- *t1++ = ch;
- *t1 = '\0';
- }
- vsprintf(buf, fmt_cpy, ap);
- syslog(pri, "%s", buf);
-}
-#endif
-
-
-#ifdef NO_IVALIDUSER
-#include <stdio.h>
-#include <ctype.h>
-#include <netdb.h>
-#include <netinet/in.h>
-#include <sys/types.h>
-#include <sys/param.h>
-#include "pathnames.h"
-
-/*
- * Returns 0 if ok, -1 if not ok.
- */
-int
-__ivaliduser(hostf, raddr, luser, ruser)
- FILE *hostf;
- struct in_addr raddr;
- const char *luser, *ruser;
-{
- register char *user, *p;
- int ch;
- char buf[MAXHOSTNAMELEN + 128]; /* host + login */
-
- while (fgets(buf, sizeof(buf), hostf)) {
- p = buf;
- /* Skip lines that are too long. */
- if (strchr(p, '\n') == NULL) {
- while ((ch = getc(hostf)) != '\n' && ch != EOF);
- continue;
- }
- while (*p != '\n' && *p != ' ' && *p != '\t' && *p != '\0') {
- *p = isupper(*p) ? tolower(*p) : *p;
- p++;
- }
- if (*p == ' ' || *p == '\t') {
- *p++ = '\0';
- while (*p == ' ' || *p == '\t')
- p++;
- user = p;
- while (*p != '\n' && *p != ' ' &&
- *p != '\t' && *p != '\0')
- p++;
- } else
- user = p;
- *p = '\0';
- if (__icheckhost(raddr, buf) &&
- strcmp(ruser, *user ? user : luser) == 0) {
- return (0);
- }
- }
- return (-1);
-}
-
-/*
- * Returns "true" if match, 0 if no match.
- */
-__icheckhost(raddr, lhost)
- struct in_addr raddr;
- register char *lhost;
-{
- register struct hostent *hp;
- struct in_addr laddr;
- register char **pp;
-
- /* Try for raw ip address first. */
- if (isdigit(*lhost) && (laddr.s_addr = inet_addr(lhost)) != INADDR_NONE)
- return (raddr.s_addr == laddr.s_addr);
-
- /* Better be a hostname. */
- if ((hp = gethostbyname(lhost)) == NULL)
- return (0);
-
- /* Spin through ip addresses. */
- for (pp = hp->h_addr_list; *pp; ++pp)
- if (!bcmp(&raddr, *pp, sizeof(struct in_addr)))
- return (1);
-
- /* No match. */
- return (0);
-}
-#endif /* NO_IVALIDUSER */
-
-
-#ifdef NO_STATFS
-#include <sys/types.h>
-#include <sys/file.h>
-#include <sys/stat.h>
-#include <sys/dir.h>
-#include <sys/param.h>
-#include <ufs/fs.h>
-
-/*
- * Check to see if there is enough space on the disk for size bytes.
- * 1 == OK, 0 == Not OK.
- */
-static int
-chksize(size)
- int size;
-{
- struct stat stb;
- int spacefree;
- struct fs fs;
- static int dfd;
- static char *find_dev();
-
-#ifndef SBOFF
-#define SBOFF ((off_t)(BBSIZE))
-#endif
- if (dfd <= 0) {
- char *ddev;
-
- if (stat(".", &stb) < 0) {
- syslog(LOG_ERR, "%s: %m", "statfs(\".\")");
- return (1);
- }
- ddev = find_dev(stb.st_dev, S_IFBLK);
- if ((dfd = open(ddev, O_RDONLY)) < 0) {
- syslog(LOG_WARNING, "%s: %s: %m", printer, ddev);
- return (1);
- }
- }
- if (lseek(dfd, (off_t)(SBOFF), 0) < 0)
- return(1);
- if (read(dfd, (char *)&fs, sizeof fs) != sizeof fs
- || fs.fs_magic != FS_MAGIC) {
- syslog(LOG_ERR, "Can't calculate free space on spool device");
- return(1);
- }
- spacefree = freespace(&fs, fs.fs_minfree) * fs.fs_fsize / 512;
- size = (size + 511) / 512;
- if (minfree + size > spacefree)
- return(0);
- return(1);
-}
-
-static char *
-find_dev(dev, type)
- register dev_t dev;
- register int type;
-{
- register DIR *dfd;
- struct direct *dir;
- struct stat stb;
- char devname[MAXNAMLEN+6];
- char *dp;
- int n;
-
- strcpy(devname, "/dev/dsk");
- if ((dfd = opendir(devname)) == NULL) {
- strcpy(devname, "/dev");
- dfd = opendir(devname);
- }
- strcat(devname, "/");
- n = strlen(devname);
-
- while ((dir = readdir(dfd))) {
- strcpy(devname + n, dir->d_name);
- if (stat(devname, &stb))
- continue;
- if ((stb.st_mode & S_IFMT) != type)
- continue;
- if (dev == stb.st_rdev) {
- closedir(dfd);
- dp = (char *)malloc(strlen(devname)+1);
- strcpy(dp, devname);
- return(dp);
- }
- }
- closedir(dfd);
- frecverr("cannot find device %d, %d", major(dev), minor(dev));
- /*NOTREACHED*/
-}
-#endif /* NOSTATFS */
diff --git a/usr.sbin/lpr/common_source/aux.h b/usr.sbin/lpr/common_source/aux.h
deleted file mode 100644
index d9bb0bf..0000000
--- a/usr.sbin/lpr/common_source/aux.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (c) 1995
- * The Regents of the University of California. All rights reserved.
- *
- * 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.
- */
-
-/*
- * Auxillary functions to aid portability to other systems.
- * These are 4.4BSD routines that are often not found on other systems.
- *
- * !!!USE THIS FILE ONLY IF YOU ARE NOT RUNNING 4.4BSD!!!
- */
-
-#ifdef PREPOSIX
-#define dirent direct
-extern int errno;
-#endif
-
-#ifdef NO_RINDEX
-#define index strchr
-#define rindex strrchr
-#endif
-
-#ifdef BSDWAIT
-#define WAITARG_T(a) ((int *)(a))
-#else
-#define WAITARG_T(a) (a)
-#endif
-
-#ifdef SETPGID
-#define setpgrp(a, b) setpgid((pid_t)(a), (pid_t)(b))
-#endif
-
-#ifndef FD_COPY
-#define FD_COPY(f, t) memcpy((char *)t, (char *)f, sizeof(*(f)))
-#endif
-
-#ifdef NO_SNPRINTF
-int snprintf __P((char *str, size_t n, const char *fmt, ...));
-#endif
diff --git a/usr.sbin/lpr/common_source/displayq.c b/usr.sbin/lpr/common_source/displayq.c
index e0b6728..c3d5e53 100644
--- a/usr.sbin/lpr/common_source/displayq.c
+++ b/usr.sbin/lpr/common_source/displayq.c
@@ -61,11 +61,6 @@ static char sccsid[] = "@(#)displayq.c 8.4 (Berkeley) 4/28/95";
/*
* Stuff for handling job specifications
*/
-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 */
-
static int col; /* column on screen */
static char current[40]; /* current file being printed */
static char file[132]; /* print file name */
diff --git a/usr.sbin/lpr/common_source/lp.h b/usr.sbin/lpr/common_source/lp.h
index b8f956f..0c94372 100644
--- a/usr.sbin/lpr/common_source/lp.h
+++ b/usr.sbin/lpr/common_source/lp.h
@@ -84,6 +84,15 @@ extern char host[MAXHOSTNAMELEN];
extern char *from; /* client's machine name */
extern int remote; /* true if sending files to a remote host */
extern char *printcapdb[]; /* printcap database array */
+
+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 */
+extern char *person; /* name of person doing lprm */
+extern char *name;
+
+
/*
* Structure used for building a sorted list of control files.
*/
diff --git a/usr.sbin/lpr/common_source/printcap.c b/usr.sbin/lpr/common_source/printcap.c
deleted file mode 100644
index cbbaef1..0000000
--- a/usr.sbin/lpr/common_source/printcap.c
+++ /dev/null
@@ -1,551 +0,0 @@
-/*
- * Copyright (c) 1983, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * 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
-static char sccsid[] = "@(#)printcap.c 8.2 (Berkeley) 4/28/95";
-#endif /* not lint */
-
-#include <sys/param.h>
-
-#include <fcntl.h>
-#include <dirent.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <ctype.h>
-#include <string.h>
-#include "lp.h"
-#include "pathnames.h"
-
-#ifndef BUFSIZ
-#define BUFSIZ 1024
-#endif
-#define MAXHOP 32 /* max number of tc= indirections */
-
-/*
- * getcap-style interface for the old printcap routines.
- *
- * !!!USE THIS INTERFACE ONLY IF YOU DON'T HAVE THE REAL GETCAP!!!
- */
-
-static char *pbp; /* pointer into pbuf for pgetstr() */
-static char pbuf[BUFSIZ]; /* buffer for capability strings */
-extern char line[]; /* buffer for printcap entries */
-
-int
-cgetnext(bp, db_array)
- register char **bp;
- char **db_array;
-{
- int ret;
- char *strdup();
-
- pbp = pbuf;
- ret = getprent(line);
- *bp = strdup(line);
- return (ret);
-}
-
-int
-cgetent(bp, db_array, name)
- char **bp, **db_array, *name;
-{
- int i;
-
- *bp = line;
- pbp = pbuf;
- i = pgetent(*bp, name);
- if (i < 0)
- return (-2);
- else if (i == 0)
- return (-1);
- else
- return (0);
-}
-
-char *
-cgetcap(buf, cap, type)
- char *buf, *cap;
- int type;
-{
- return ((char *) pgetflag(cap));
-}
-
-int
-cgetstr(buf, cap, str)
- char *buf, *cap;
- char **str;
-{
- char *pgetstr __P((char *, char **));
-
- if (pbp >= pbuf+BUFSIZ) {
- write(2, "Capability string buffer overflow\n", 34);
- return (-1);
- }
- return ((*str = pgetstr(cap, &pbp)) == NULL ? -1 : 0);
-}
-
-int
-cgetnum(buf, cap, num)
- char *buf, *cap;
- long *num;
-{
- return ((*num = pgetnum(cap)) < 0 ? -1 : 0);
-}
-
-int
-cgetclose()
-{
- void endprent __P((void));
-
- endprent();
- return (0);
-}
-
-
-/*
- * termcap - routines for dealing with the terminal capability data base
- *
- * BUG: Should use a "last" pointer in tbuf, so that searching
- * for capabilities alphabetically would not be a n**2/2
- * process when large numbers of capabilities are given.
- * Note: If we add a last pointer now we will screw up the
- * tc capability. We really should compile termcap.
- *
- * Essentially all the work here is scanning and decoding escapes
- * in string capabilities. We don't use stdio because the editor
- * doesn't, and because living w/o it is not hard.
- */
-
-#define PRINTCAP
-
-#ifdef PRINTCAP
-#define tgetent pgetent
-#define tskip pskip
-#define tgetstr pgetstr
-#define tdecode pdecode
-#define tgetnum pgetnum
-#define tgetflag pgetflag
-#define tdecode pdecode
-#define tnchktc pnchktc
-#define tnamatch pnamatch
-#define V6
-#endif
-
-static FILE *pfp = NULL; /* printcap data base file pointer */
-static char *tbuf;
-static int hopcount; /* detect infinite loops in termcap, init 0 */
-static int tf;
-
-char *tgetstr __P((char *, char **));
-static char *tskip __P((char *));
-static char *tdecode __P((char *, char **));
-
-/*
- * Similar to tgetent except it returns the next enrty instead of
- * doing a lookup.
- */
-int
-getprent(bp)
- register char *bp;
-{
- register int c, skip = 0;
-
- if (pfp == NULL && (pfp = fopen(_PATH_PRINTCAP, "r")) == NULL)
- return(-1);
- tbuf = bp;
- for (;;) {
- switch (c = getc(pfp)) {
- case EOF:
- fclose(pfp);
- pfp = NULL;
- return(0);
- case '\n':
- if (bp == tbuf) {
- skip = 0;
- continue;
- }
- if (bp[-1] == '\\') {
- bp--;
- continue;
- }
- *bp = '\0';
- return(1);
- case '#':
- if (bp == tbuf)
- skip++;
- default:
- if (skip)
- continue;
- if (bp >= tbuf+BUFSIZ) {
- write(2, "Termcap entry too long\n", 23);
- *bp = '\0';
- return(1);
- }
- *bp++ = c;
- }
- }
-}
-
-void
-endprent()
-{
- if (pfp != NULL) {
- /*
- * Can't use fclose here because on POSIX-compliant
- * systems, fclose() causes the file pointer of the
- * underlying file descriptor (which is possibly shared
- * with a parent process) to be adjusted, and this
- * reeks havoc in the parent because it doesn't know
- * the file pointer has changed.
- */
- (void) close(fileno(pfp));
- pfp = NULL;
- }
-}
-
-/*
- * Get an entry for terminal name in buffer bp,
- * from the termcap file. Parse is very rudimentary;
- * we just notice escaped newlines.
- */
-int
-tgetent(bp, name)
- char *bp, *name;
-{
- register char *cp;
- register int c;
- register int i = 0, cnt = 0;
- char ibuf[BUFSIZ];
-
- tbuf = bp;
-#ifndef V6
- cp = getenv("TERMCAP");
- /*
- * TERMCAP can have one of two things in it. It can be the
- * name of a file to use instead of /etc/termcap. In this
- * case it better start with a "/". Or it can be an entry to
- * use so we don't have to read the file. In this case it
- * has to already have the newlines crunched out.
- */
- if (cp && *cp) {
- if (*cp!='/') {
- cp2 = getenv("TERM");
- if (cp2==(char *) 0 || strcmp(name,cp2)==0) {
- strcpy(bp,cp);
- return(tnchktc());
- } else {
- tf = open(_PATH_PRINTCAP, 0);
- }
- } else
- tf = open(cp, 0);
- }
-#endif
- if (tf==0)
- tf = open(_PATH_PRINTCAP, 0);
- if (tf < 0)
- return (-1);
- for (;;) {
- cp = bp;
- for (;;) {
- if (i == cnt) {
- cnt = read(tf, ibuf, BUFSIZ);
- if (cnt <= 0) {
- close(tf);
- tf = 0;
- return (0);
- }
- i = 0;
- }
- c = ibuf[i++];
- if (c == '\n') {
- if (cp > bp && cp[-1] == '\\'){
- cp--;
- continue;
- }
- break;
- }
- if (cp >= bp+BUFSIZ) {
- write(2,"Termcap entry too long\n", 23);
- break;
- } else
- *cp++ = c;
- }
- *cp = 0;
-
- /*
- * The real work for the match.
- */
- if (tnamatch(name)) {
- lseek(tf, 0L, 0);
- i = tnchktc();
- if (tf) {
- close(tf);
- tf = 0;
- }
- return(i);
- }
- }
-}
-
-/*
- * tnchktc: check the last entry, see if it's tc=xxx. If so,
- * recursively find xxx and append that entry (minus the names)
- * to take the place of the tc=xxx entry. This allows termcap
- * entries to say "like an HP2621 but doesn't turn on the labels".
- * Note that this works because of the left to right scan.
- */
-int
-tnchktc()
-{
- register char *p, *q;
- char tcname[16]; /* name of similar terminal */
- char tcbuf[BUFSIZ];
- char *holdtbuf = tbuf;
- int l;
-
- p = tbuf + strlen(tbuf) - 2; /* before the last colon */
- while (*--p != ':')
- if (p<tbuf) {
- write(2, "Bad termcap entry\n", 18);
- return (0);
- }
- p++;
- /* p now points to beginning of last field */
- if (p[0] != 't' || p[1] != 'c')
- return(1);
- strcpy(tcname,p+3);
- q = tcname;
- while (q && *q != ':')
- q++;
- *q = 0;
- if (++hopcount > MAXHOP) {
- write(2, "Infinite tc= loop\n", 18);
- return (0);
- }
- if (tgetent(tcbuf, tcname) != 1)
- return(0);
- for (q=tcbuf; *q != ':'; q++)
- ;
- l = p - holdtbuf + strlen(q);
- if (l > BUFSIZ) {
- write(2, "Termcap entry too long\n", 23);
- q[BUFSIZ - (p-tbuf)] = 0;
- }
- strcpy(p, q+1);
- tbuf = holdtbuf;
- return(1);
-}
-
-/*
- * Tnamatch deals with name matching. The first field of the termcap
- * entry is a sequence of names separated by |'s, so we compare
- * against each such name. The normal : terminator after the last
- * name (before the first field) stops us.
- */
-int
-tnamatch(np)
- char *np;
-{
- register char *Np, *Bp;
-
- Bp = tbuf;
- if (*Bp == '#')
- return(0);
- for (;;) {
- for (Np = np; *Np && *Bp == *Np; Bp++, Np++)
- continue;
- if (*Np == 0 && (*Bp == '|' || *Bp == ':' || *Bp == 0))
- return (1);
- while (*Bp && *Bp != ':' && *Bp != '|')
- Bp++;
- if (*Bp == 0 || *Bp == ':')
- return (0);
- Bp++;
- }
-}
-
-/*
- * Skip to the next field. Notice that this is very dumb, not
- * knowing about \: escapes or any such. If necessary, :'s can be put
- * into the termcap file in octal.
- */
-static char *
-tskip(bp)
- register char *bp;
-{
-
- while (*bp && *bp != ':')
- bp++;
- if (*bp == ':')
- bp++;
- return (bp);
-}
-
-/*
- * Return the (numeric) option id.
- * Numeric options look like
- * li#80
- * i.e. the option string is separated from the numeric value by
- * a # character. If the option is not found we return -1.
- * Note that we handle octal numbers beginning with 0.
- */
-int
-tgetnum(id)
- char *id;
-{
- register int i, base;
- register char *bp = tbuf;
-
- for (;;) {
- bp = tskip(bp);
- if (*bp == 0)
- return (-1);
- if (*bp++ != id[0] || *bp == 0 || *bp++ != id[1])
- continue;
- if (*bp == '@')
- return(-1);
- if (*bp != '#')
- continue;
- bp++;
- base = 10;
- if (*bp == '0')
- base = 8;
- i = 0;
- while (isdigit(*bp))
- i *= base, i += *bp++ - '0';
- return (i);
- }
-}
-
-/*
- * Handle a flag option.
- * Flag options are given "naked", i.e. followed by a : or the end
- * of the buffer. Return 1 if we find the option, or 0 if it is
- * not given.
- */
-int
-tgetflag(id)
- char *id;
-{
- register char *bp = tbuf;
-
- for (;;) {
- bp = tskip(bp);
- if (!*bp)
- return (0);
- if (*bp++ == id[0] && *bp != 0 && *bp++ == id[1]) {
- if (!*bp || *bp == ':')
- return (1);
- else if (*bp == '@')
- return(0);
- }
- }
-}
-
-/*
- * Get a string valued option.
- * These are given as
- * cl=^Z
- * Much decoding is done on the strings, and the strings are
- * placed in area, which is a ref parameter which is updated.
- * No checking on area overflow.
- */
-char *
-tgetstr(id, area)
- char *id, **area;
-{
- register char *bp = tbuf;
-
- for (;;) {
- bp = tskip(bp);
- if (!*bp)
- return (0);
- if (*bp++ != id[0] || *bp == 0 || *bp++ != id[1])
- continue;
- if (*bp == '@')
- return(0);
- if (*bp != '=')
- continue;
- bp++;
- return (tdecode(bp, area));
- }
-}
-
-/*
- * Tdecode does the grung work to decode the
- * string capability escapes.
- */
-static char *
-tdecode(str, area)
- register char *str;
- char **area;
-{
- register char *cp;
- register int c;
- register char *dp;
- int i;
-
- cp = *area;
- while ((c = *str++) && c != ':') {
- switch (c) {
-
- case '^':
- c = *str++ & 037;
- break;
-
- case '\\':
- dp = "E\033^^\\\\::n\nr\rt\tb\bf\f";
- c = *str++;
-nextc:
- if (*dp++ == c) {
- c = *dp++;
- break;
- }
- dp++;
- if (*dp)
- goto nextc;
- if (isdigit(c)) {
- c -= '0', i = 2;
- do
- c <<= 3, c |= *str++ - '0';
- while (--i && isdigit(*str));
- }
- break;
- }
- *cp++ = c;
- }
- *cp++ = 0;
- str = *area;
- *area = cp;
- return (str);
-}
diff --git a/usr.sbin/lpr/common_source/recvjob.c b/usr.sbin/lpr/common_source/recvjob.c
index 35f946f..fb307c5 100644
--- a/usr.sbin/lpr/common_source/recvjob.c
+++ b/usr.sbin/lpr/common_source/recvjob.c
@@ -342,7 +342,6 @@ frecverr(msg, va_alist)
va_dcl
#endif
{
- extern char fromb[];
va_list ap;
#if __STDC__
va_start(ap, msg);
diff --git a/usr.sbin/lpr/common_source/rmjob.c b/usr.sbin/lpr/common_source/rmjob.c
index bdfe853..5497ca2 100644
--- a/usr.sbin/lpr/common_source/rmjob.c
+++ b/usr.sbin/lpr/common_source/rmjob.c
@@ -56,12 +56,6 @@ static char sccsid[] = "@(#)rmjob.c 8.2 (Berkeley) 4/28/95";
/*
* Stuff for handling lprm 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 char *person; /* name of person doing lprm */
-
static char root[] = "root";
static int all = 0; /* eliminate all files (root only) */
static int cur_daemon; /* daemon's pid */
diff --git a/usr.sbin/lpr/common_source/startdaemon.c b/usr.sbin/lpr/common_source/startdaemon.c
index 237769e..807a976 100644
--- a/usr.sbin/lpr/common_source/startdaemon.c
+++ b/usr.sbin/lpr/common_source/startdaemon.c
@@ -102,7 +102,5 @@ static void
perr(msg)
char *msg;
{
- extern char *name;
-
(void)printf("%s: %s: %s\n", name, msg, strerror(errno));
}
OpenPOWER on IntegriCloud