clean up that import. no rcsids yet.

This commit is contained in:
cgd 1994-05-18 01:25:21 +00:00
parent ec7c1628df
commit 2847add277
8 changed files with 323 additions and 239 deletions

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved.
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
* (c) UNIX System Laboratories, Inc.
* All or some portions of this file are derived from material licensed
* to the University of California by American Telephone and Telegraph
@ -37,69 +37,87 @@
*/
#ifndef lint
/*static char sccsid[] = "from: @(#)common.c 5.7 (Berkeley) 3/2/91";*/
static char rcsid[] = "$Id: common.c,v 1.4 1994/05/17 04:15:20 cgd Exp $";
static char sccsid[] = "@(#)common.c 8.2 (Berkeley) 1/21/94";
#endif /* not lint */
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <dirent.h>
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "lp.h"
#include "pathnames.h"
/*
* Routines and data common to all the line printer functions.
*/
#include "lp.h"
int DU; /* daeomon user-id */
int MX; /* maximum number of blocks to copy */
int MC; /* maximum number of copies allowed */
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 *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 *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 *RG; /* resricted group */
char *RM; /* remote machine name */
char *RP; /* remote printer name */
char *LO; /* lock file name */
char *ST; /* status file 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 */
char *AF; /* accounting file */
char *LF; /* log file for error messages */
char *OF; /* name of output filter (created once) */
char *IF; /* name of input filter (created per job) */
char *RF; /* name of fortran text filter (per job) */
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 *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 */
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 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 */
char host[32]; /* host machine 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 *));
/*
* Create a connection to the remote printer server.
* Most of this code comes from rcmd.c.
*/
int
getport(rhost)
char *rhost;
{
@ -155,6 +173,7 @@ retry:
* new-line to null and leaves it in line.
* Returns 0 at EOF or the number of characters read.
*/
int
getline(cfp)
FILE *cfp;
{
@ -184,6 +203,7 @@ getline(cfp)
* creation time.
* Return the number of entries and a pointer to the list.
*/
int
getq(namelist)
struct queue *(*namelist[]);
{
@ -193,7 +213,6 @@ getq(namelist)
struct stat stbuf;
DIR *dirp;
int arraysz;
static int compar();
if ((dirp = opendir(SD)) == NULL)
return(-1);
@ -246,13 +265,13 @@ errdone:
/*
* Compare modification times.
*/
static
static int
compar(p1, p2)
register struct queue **p1, **p2;
const void *p1, *p2;
{
if ((*p1)->q_time < (*p2)->q_time)
if ((*(struct queue **)p1)->q_time < (*(struct queue **)p2)->q_time)
return(-1);
if ((*p1)->q_time > (*p2)->q_time)
if ((*(struct queue **)p1)->q_time > (*(struct queue **)p2)->q_time)
return(1);
return(0);
}
@ -275,7 +294,7 @@ checkremote()
name[sizeof(name)-1] = '\0';
hp = gethostbyname(name);
if (hp == (struct hostent *) NULL) {
(void) sprintf(errbuf,
(void) snprintf(errbuf, sizeof(errbuf),
"unable to get official name for local machine %s",
name);
return errbuf;
@ -284,7 +303,7 @@ checkremote()
/* get the official name of RM */
hp = gethostbyname(RM);
if (hp == (struct hostent *) NULL) {
(void) sprintf(errbuf,
(void) snprintf(errbuf, sizeof(errbuf),
"unable to get official name for remote machine %s",
RM);
return errbuf;
@ -300,16 +319,34 @@ checkremote()
return (char *)0;
}
/*VARARGS1*/
fatal(msg, a1, a2, a3)
#if __STDC__
#include <stdarg.h>
#else
#include <varargs.h>
#endif
void
#if __STDC__
fatal(const char *msg, ...)
#else
fatal(msg, va_alist)
char *msg;
va_dcl
#endif
{
va_list ap;
#if __STDC__
va_start(ap, msg);
#else
va_start(ap);
#endif
if (from != host)
printf("%s: ", host);
printf("%s: ", name);
(void)printf("%s: ", host);
(void)printf("%s: ", name);
if (printer)
printf("%s: ", printer);
printf(msg, a1, a2, a3);
putchar('\n');
(void)printf("%s: ", printer);
(void)vprintf(msg, ap);
va_end(ap);
(void)putchar('\n');
exit(1);
}

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved.
* 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
@ -32,17 +32,27 @@
*/
#ifndef lint
/*static char sccsid[] = "from: @(#)displayq.c 5.13 (Berkeley) 6/1/90";*/
static char rcsid[] = "$Id: displayq.c,v 1.3 1994/03/27 09:15:15 cgd Exp $";
static char sccsid[] = "@(#)displayq.c 8.1 (Berkeley) 6/6/93";
#endif /* not lint */
#include <sys/param.h>
#include <sys/stat.h>
#include <signal.h>
#include <fcntl.h>
#include <dirent.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "lp.h"
#include "lp.local.h"
#include "pathnames.h"
/*
* Routines to display the state of the queue.
*/
#include "lp.h"
#include "pathnames.h"
#define JOBCOL 40 /* column for job # in -l format */
#define OWNCOL 7 /* start of Owner column in normal */
#define SIZCOL 62 /* start of Size column in normal */
@ -50,26 +60,27 @@ static char rcsid[] = "$Id: displayq.c,v 1.3 1994/03/27 09:15:15 cgd Exp $";
/*
* 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 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.
*/
void
displayq(format)
int format;
{
@ -79,27 +90,27 @@ displayq(format)
struct queue **queue;
struct stat statb;
FILE *fp;
char c;
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");
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;
if ((RP = pgetstr("rp", &bp)) == NULL)
if (cgetstr(bp, "rp", &RP) < 0)
RP = DEFLP;
if ((SD = pgetstr("sd", &bp)) == NULL)
if (cgetstr(bp, "sd", &SD) < 0)
SD = _PATH_DEFSPOOL;
if ((LO = pgetstr("lo", &bp)) == NULL)
if (cgetstr(bp,"lo", &LO) < 0)
LO = DEFLOCK;
if ((ST = pgetstr("st", &bp)) == NULL)
if (cgetstr(bp, "st", &ST) < 0)
ST = DEFSTAT;
RM = pgetstr("rm", &bp);
cgetstr(bp, "rm", &RM);
if (cp = checkremote())
printf("Warning: %s\n", cp);
@ -223,6 +234,7 @@ displayq(format)
/*
* Print a warning message if there is no daemon present.
*/
void
warn()
{
if (sendtorem)
@ -234,6 +246,7 @@ warn()
/*
* Print the header for the short listing format
*/
void
header()
{
printf(head0);
@ -242,11 +255,11 @@ header()
printf(head1);
}
void
inform(cf)
char *cf;
{
register int j, k;
register char *cp;
register int j;
FILE *cfp;
/*
@ -304,6 +317,7 @@ inform(cf)
}
}
int
inlist(name, file)
char *name, *file;
{
@ -329,8 +343,10 @@ inlist(name, file)
return(0);
}
void
show(nfile, file, copies)
register char *nfile, *file;
int copies;
{
if (strcmp(nfile, " ") == 0)
nfile = "(standard input)";
@ -343,6 +359,7 @@ show(nfile, file, copies)
/*
* Fill the line with blanks to the specified column
*/
void
blankfill(n)
register int n;
{
@ -353,8 +370,10 @@ blankfill(n)
/*
* Give the abbreviated dump of the file names
*/
void
dump(nfile, file, copies)
char *nfile, *file;
int copies;
{
register short n, fill;
struct stat lbuf;
@ -384,8 +403,10 @@ dump(nfile, file, copies)
/*
* Print the long info about the file
*/
void
ldump(nfile, file, copies)
char *nfile, *file;
int copies;
{
struct stat lbuf;
@ -405,9 +426,11 @@ ldump(nfile, file, copies)
* Print the job's rank in the queue,
* update col for screen management
*/
void
prank(n)
int n;
{
char line[100];
char rline[100];
static char *r[] = {
"th", "st", "nd", "rd", "th", "th", "th", "th", "th", "th"
};
@ -418,9 +441,9 @@ prank(n)
return;
}
if ((n/10)%10 == 1)
(void) sprintf(line, "%dth", n);
(void)snprintf(rline, sizeof(rline), "%dth", n);
else
(void) sprintf(line, "%d%s", n, r[n%10]);
col += strlen(line);
printf("%s", line);
(void)snprintf(rline, sizeof(rline), "%d%s", n, r[n%10]);
col += strlen(rline);
printf("%s", rline);
}

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved.
* 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
@ -30,83 +30,63 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)lp.h 5.5 (Berkeley) 6/1/90
* $Id: lp.h,v 1.4 1994/05/18 00:54:02 cgd Exp $
* @(#)lp.h 8.1 (Berkeley) 6/6/93
*/
/*
* Global definitions for the line printer system.
*/
#include <stdio.h>
#include <sys/param.h>
#include <sys/file.h>
#include <dirent.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <netinet/in.h>
#include <netdb.h>
#include <pwd.h>
#include <syslog.h>
#include <signal.h>
#include <sys/wait.h>
#include <sgtty.h>
#include <ctype.h>
#include <errno.h>
#include <unistd.h>
#include "lp.local.h"
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 *LF; /* log file for error messages */
extern char *OF; /* name of output filter (created once) */
extern char *IF; /* name of input filter (created per job) */
extern char *RF; /* name of fortran text 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 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 *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 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 *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 *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 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 */
extern char host[32]; /* host machine 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 int errno;
extern char *printcapdb[]; /* printcap database array */
/*
* Structure used for building a sorted list of control files.
*/
@ -115,9 +95,32 @@ struct queue {
char q_name[MAXNAMLEN+1]; /* control file name */
};
char *pgetstr();
char *malloc();
char *getenv();
char *index();
char *rindex();
char *checkremote();
#include <sys/cdefs.h>
__BEGIN_DECLS
struct dirent;
void blankfill __P((int));
char *checkremote __P((void));
int chk __P((char *));
void displayq __P((int));
void dump __P((char *, char *, int));
void fatal __P((const char *, ...));
int getline __P((FILE *));
int getport __P((char *));
int getq __P((struct queue *(*[])));
void header __P((void));
void inform __P((char *));
int inlist __P((char *, char *));
int iscf __P((struct dirent *));
int isowner __P((char *, char *));
void ldump __P((char *, char *, int));
int lockchk __P((char *));
void prank __P((int));
void process __P((char *));
void rmjob __P((void));
void rmremote __P((void));
void show __P((char *, char *, int));
int startdaemon __P((char *));
void warn __P((void));
__END_DECLS

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved.
* 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
@ -30,29 +30,13 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)lp.local.h 5.5 (Berkeley) 6/1/90
* $Id: lp.local.h,v 1.4 1993/08/01 17:59:08 mycroft Exp $
* @(#)lp.local.h 8.1 (Berkeley) 6/6/93
*/
/*
* Possibly, local parameters to the spooling system
*/
/*
* Magic number mapping for binary files, used by lpr to avoid
* printing objects files.
*/
#include <a.out.h>
#include <ar.h>
#ifndef A_MAGIC1 /* must be a VM/UNIX system */
#ifndef SARMAG
# undef ARMAG
# define ARMAG 0177545
#endif
#endif
/*
* Defaults for line printer capabilities data base
*/

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 1989 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 1989, 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
@ -30,8 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)pathnames.h 5.4 (Berkeley) 6/1/90
* $Id: pathnames.h,v 1.2 1993/08/01 17:59:06 mycroft Exp $
* @(#)pathnames.h 8.1 (Berkeley) 6/6/93
*/
#include <paths.h>

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved.
* 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
@ -32,12 +32,18 @@
*/
#ifndef lint
/*static char sccsid[] = "from: @(#)printcap.c 5.7 (Berkeley) 3/4/91";*/
static char rcsid[] = "$Id: printcap.c,v 1.3 1993/08/01 17:59:12 mycroft Exp $";
static char sccsid[] = "@(#)printcap.c 8.1 (Berkeley) 6/6/93";
#endif /* not lint */
#include <ctype.h>
#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
@ -77,15 +83,16 @@ static char rcsid[] = "$Id: printcap.c,v 1.3 1993/08/01 17:59:12 mycroft Exp $";
static FILE *pfp = NULL; /* printcap data base file pointer */
static char *tbuf;
static int hopcount; /* detect infinite loops in termcap, init 0 */
static char *tskip();
char *tgetstr();
static char *tdecode();
char *getenv();
static char *tskip __P((char *));
static char *tskip __P((char *bp));
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;
{
@ -127,6 +134,7 @@ getprent(bp)
}
}
void
endprent()
{
if (pfp != NULL)
@ -138,6 +146,7 @@ endprent()
* from the termcap file. Parse is very rudimentary;
* we just notice escaped newlines.
*/
int
tgetent(bp, name)
char *bp, *name;
{
@ -145,7 +154,6 @@ tgetent(bp, name)
register int c;
register int i = 0, cnt = 0;
char ibuf[BUFSIZ];
char *cp2;
int tf;
tbuf = bp;
@ -222,6 +230,7 @@ tgetent(bp, name)
* 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;
@ -269,6 +278,7 @@ tnchktc()
* against each such name. The normal : terminator after the last
* name (before the first field) stops us.
*/
int
tnamatch(np)
char *np;
{
@ -315,6 +325,7 @@ tskip(bp)
* 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;
{
@ -348,6 +359,7 @@ tgetnum(id)
* of the buffer. Return 1 if we find the option, or 0 if it is
* not given.
*/
int
tgetflag(id)
char *id;
{
@ -443,3 +455,4 @@ nextc:
*area = cp;
return (str);
}

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved.
* 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
@ -32,17 +32,27 @@
*/
#ifndef lint
/*static char sccsid[] = "from: @(#)rmjob.c 5.7 (Berkeley) 6/1/90";*/
static char rcsid[] = "$Id: rmjob.c,v 1.3 1993/12/08 00:47:04 jtc Exp $";
static char sccsid[] = "@(#)rmjob.c 8.1 (Berkeley) 6/6/93";
#endif /* not lint */
#include <sys/param.h>
#include <signal.h>
#include <errno.h>
#include <dirent.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include "lp.h"
#include "lp.local.h"
#include "pathnames.h"
/*
* rmjob - remove the specified jobs from the queue.
*/
#include "lp.h"
#include "pathnames.h"
/*
* Stuff for handling lprm specifications
*/
@ -52,13 +62,12 @@ extern int requ[]; /* job number of spool entries */
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 */
int iscf();
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()
{
register int i, nitems;
@ -66,19 +75,21 @@ rmjob()
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");
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;
if ((RP = pgetstr("rp", &bp)) == NULL)
if (cgetstr(bp, "rp", &RP) < 0)
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);
@ -137,6 +148,7 @@ rmjob()
* daemon and the file name of the active spool entry.
* Return boolean indicating existence of a lock file.
*/
int
lockchk(s)
char *s;
{
@ -172,6 +184,7 @@ lockchk(s)
/*
* Process a control file.
*/
void
process(file)
char *file;
{
@ -199,6 +212,7 @@ process(file)
/*
* Do the dirty work in checking
*/
int
chk(file)
char *file;
{
@ -253,6 +267,7 @@ chk(file)
* files sent from the remote machine to be removed.
* Normal users can only remove the file from where it was sent.
*/
int
isowner(owner, file)
char *owner, *file;
{
@ -270,6 +285,7 @@ isowner(owner, file)
* Check to see if we are sending files to a remote machine. If we are,
* then try removing files on the remote machine.
*/
void
rmremote()
{
register char *cp;
@ -285,7 +301,7 @@ rmremote()
*/
fflush(stdout);
sprintf(buf, "\5%s %s", RP, all ? "-all" : person);
(void)snprintf(buf, sizeof(buf), "\5%s %s", RP, all ? "-all" : person);
cp = buf;
for (i = 0; i < users; i++) {
cp += strlen(cp);
@ -315,6 +331,7 @@ rmremote()
/*
* Return 1 if the filename begins with 'cf'
*/
int
iscf(d)
struct dirent *d;
{

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved.
* Copyright (c) 1983, 1993, 1994
* 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
@ -32,38 +32,48 @@
*/
#ifndef lint
/*static char sccsid[] = "from: @(#)startdaemon.c 5.7 (Berkeley) 3/2/91";*/
static char rcsid[] = "$Id: startdaemon.c,v 1.3 1993/11/10 04:36:04 cgd Exp $";
static char sccsid[] = "@(#)startdaemon.c 8.2 (Berkeley) 4/17/94";
#endif /* not lint */
#include <sys/param.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <dirent.h>
#include <errno.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include "lp.h"
#include "pathnames.h"
static void perr __P((char *));
/*
* Tell the printer daemon that there are new files in the spool directory.
*/
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <stdio.h>
#include "lp.local.h"
#include "pathnames.h"
int
startdaemon(printer)
char *printer;
{
struct sockaddr_un sun;
struct sockaddr_un un;
register int s, n;
char buf[BUFSIZ];
static void perr();
s = socket(AF_UNIX, SOCK_STREAM, 0);
if (s < 0) {
perr("socket");
return(0);
}
bzero(&sun, sizeof(sun));
sun.sun_family = AF_UNIX;
strcpy(sun.sun_path, _PATH_SOCKETNAME);
if (connect(s, (struct sockaddr *)&sun, strlen(sun.sun_path) + 2) < 0) {
memset(&un, 0, sizeof(un));
un.sun_family = AF_UNIX;
strcpy(un.sun_path, _PATH_SOCKETNAME);
#ifndef SUN_LEN
#define SUN_LEN(unp) (strlen((unp)->sun_path) + 2)
#endif
if (connect(s, (struct sockaddr *)&un, SUN_LEN(&un)) < 0) {
perr("connect");
(void) close(s);
return(0);
@ -92,9 +102,7 @@ static void
perr(msg)
char *msg;
{
extern int errno;
extern char *name;
char *strerror();
(void)printf("%s: %s: %s\n", name, msg, strerror(errno));
}