Fix about 90-100 warnings one gets when trying to compile lpr&friends
with BDECFLAGS on, mainly by adding 'const' to parameters in a number of routine declarations. While I'm at it, ANSI-fy all of the routine declarations. The resulting object code is exactly the same after this update as before it, with the exception of one unavoidable change to lpd.o on freebsd/alpha. Also added $FreeBSD$ line to lpc/extern.h lpc/lpc.h lptest/lptest.c Reviewed by: /sbin/md5, and no feedback from freebsd-audit
This commit is contained in:
parent
0d1b691ed7
commit
ba7a1ad76a
@ -64,11 +64,11 @@ static const char rcsid[] =
|
|||||||
* Routines and data common to all the line printer functions.
|
* Routines and data common to all the line printer functions.
|
||||||
*/
|
*/
|
||||||
char line[BUFSIZ];
|
char line[BUFSIZ];
|
||||||
char *name; /* program name */
|
const char *name; /* program name */
|
||||||
|
|
||||||
extern uid_t uid, euid;
|
extern uid_t uid, euid;
|
||||||
|
|
||||||
static int compar __P((const void *, const void *));
|
static int compar(const void *_p1, const void *_p2);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Getline reads a line from the control file cfp, removes tabs, converts
|
* Getline reads a line from the control file cfp, removes tabs, converts
|
||||||
@ -76,8 +76,7 @@ static int compar __P((const void *, const void *));
|
|||||||
* Returns 0 at EOF or the number of characters read.
|
* Returns 0 at EOF or the number of characters read.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
getline(cfp)
|
getline(FILE *cfp)
|
||||||
FILE *cfp;
|
|
||||||
{
|
{
|
||||||
register int linel = 0;
|
register int linel = 0;
|
||||||
register char *lp = line;
|
register char *lp = line;
|
||||||
@ -106,9 +105,7 @@ getline(cfp)
|
|||||||
* Return the number of entries and a pointer to the list.
|
* Return the number of entries and a pointer to the list.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
getq(pp, namelist)
|
getq(const struct printer *pp, struct jobqueue *(*namelist[]))
|
||||||
const struct printer *pp;
|
|
||||||
struct jobqueue *(*namelist[]);
|
|
||||||
{
|
{
|
||||||
register struct dirent *d;
|
register struct dirent *d;
|
||||||
register struct jobqueue *q, **queue;
|
register struct jobqueue *q, **queue;
|
||||||
@ -179,8 +176,7 @@ errdone:
|
|||||||
* Compare modification times.
|
* Compare modification times.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
compar(p1, p2)
|
compar(const void *p1, const void *p2)
|
||||||
const void *p1, *p2;
|
|
||||||
{
|
{
|
||||||
const struct jobqueue *qe1, *qe2;
|
const struct jobqueue *qe1, *qe2;
|
||||||
|
|
||||||
@ -207,24 +203,20 @@ compar(p1, p2)
|
|||||||
|
|
||||||
/* sleep n milliseconds */
|
/* sleep n milliseconds */
|
||||||
void
|
void
|
||||||
delay(n)
|
delay(int millisec)
|
||||||
int n;
|
|
||||||
{
|
{
|
||||||
struct timeval tdelay;
|
struct timeval tdelay;
|
||||||
|
|
||||||
if (n <= 0 || n > 10000)
|
if (millisec <= 0 || millisec > 10000)
|
||||||
fatal((struct printer *)0, /* fatal() knows how to deal */
|
fatal((struct printer *)0, /* fatal() knows how to deal */
|
||||||
"unreasonable delay period (%d)", n);
|
"unreasonable delay period (%d)", millisec);
|
||||||
tdelay.tv_sec = n / 1000;
|
tdelay.tv_sec = millisec / 1000;
|
||||||
tdelay.tv_usec = n * 1000 % 1000000;
|
tdelay.tv_usec = millisec * 1000 % 1000000;
|
||||||
(void) select(0, (fd_set *)0, (fd_set *)0, (fd_set *)0, &tdelay);
|
(void) select(0, (fd_set *)0, (fd_set *)0, (fd_set *)0, &tdelay);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
lock_file_name(pp, buf, len)
|
lock_file_name(const struct printer *pp, char *buf, size_t len)
|
||||||
const struct printer *pp;
|
|
||||||
char *buf;
|
|
||||||
size_t len;
|
|
||||||
{
|
{
|
||||||
static char staticbuf[MAXPATHLEN];
|
static char staticbuf[MAXPATHLEN];
|
||||||
|
|
||||||
@ -243,10 +235,7 @@ lock_file_name(pp, buf, len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
status_file_name(pp, buf, len)
|
status_file_name(const struct printer *pp, char *buf, size_t len)
|
||||||
const struct printer *pp;
|
|
||||||
char *buf;
|
|
||||||
size_t len;
|
|
||||||
{
|
{
|
||||||
static char staticbuf[MAXPATHLEN];
|
static char staticbuf[MAXPATHLEN];
|
||||||
|
|
||||||
@ -266,10 +255,7 @@ status_file_name(pp, buf, len)
|
|||||||
|
|
||||||
/* routine to get a current timestamp, optionally in a standard-fmt string */
|
/* routine to get a current timestamp, optionally in a standard-fmt string */
|
||||||
void
|
void
|
||||||
lpd_gettime(tsp, strp, strsize)
|
lpd_gettime(struct timespec *tsp, char *strp, int strsize)
|
||||||
struct timespec *tsp;
|
|
||||||
char *strp;
|
|
||||||
int strsize;
|
|
||||||
{
|
{
|
||||||
struct timespec local_ts;
|
struct timespec local_ts;
|
||||||
struct timeval btime;
|
struct timeval btime;
|
||||||
@ -331,10 +317,7 @@ lpd_gettime(tsp, strp, strsize)
|
|||||||
|
|
||||||
/* routines for writing transfer-statistic records */
|
/* routines for writing transfer-statistic records */
|
||||||
void
|
void
|
||||||
trstat_init(pp, fname, filenum)
|
trstat_init(struct printer *pp, const char *fname, int filenum)
|
||||||
struct printer *pp;
|
|
||||||
const char *fname;
|
|
||||||
int filenum;
|
|
||||||
{
|
{
|
||||||
register const char *srcp;
|
register const char *srcp;
|
||||||
register char *destp, *endp;
|
register char *destp, *endp;
|
||||||
@ -369,13 +352,8 @@ trstat_init(pp, fname, filenum)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
trstat_write(pp, sendrecv, bytecnt, userid, otherhost, orighost)
|
trstat_write(struct printer *pp, tr_sendrecv sendrecv, size_t bytecnt,
|
||||||
struct printer *pp;
|
const char *userid, const char *otherhost, const char *orighost)
|
||||||
tr_sendrecv sendrecv;
|
|
||||||
size_t bytecnt;
|
|
||||||
const char *userid;
|
|
||||||
const char *otherhost;
|
|
||||||
const char *orighost;
|
|
||||||
{
|
{
|
||||||
#define STATLINE_SIZE 1024
|
#define STATLINE_SIZE 1024
|
||||||
double trtime;
|
double trtime;
|
||||||
@ -594,8 +572,7 @@ fatal(pp, msg, va_alist)
|
|||||||
* be better to close the first N fds, for some small value of N.
|
* be better to close the first N fds, for some small value of N.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
closeallfds(start)
|
closeallfds(int start)
|
||||||
int start;
|
|
||||||
{
|
{
|
||||||
int stop = getdtablesize();
|
int stop = getdtablesize();
|
||||||
for (; start < stop; start++)
|
for (; start < stop; start++)
|
||||||
|
@ -81,19 +81,17 @@ static int lflag; /* long output option */
|
|||||||
static int rank; /* order to be printed (-1=none, 0=active) */
|
static int rank; /* order to be printed (-1=none, 0=active) */
|
||||||
static long totsize; /* total print job size in bytes */
|
static long totsize; /* total print job size in bytes */
|
||||||
|
|
||||||
static char *head0 = "Rank Owner Job Files";
|
static const char *head0 = "Rank Owner Job Files";
|
||||||
static char *head1 = "Total Size\n";
|
static const char *head1 = "Total Size\n";
|
||||||
|
|
||||||
static void alarmhandler __P((int));
|
static void alarmhandler(int _signo);
|
||||||
static void warn __P((const struct printer *pp));
|
static void warn(const struct printer *_pp);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Display the current state of the queue. Format = 1 if long format.
|
* Display the current state of the queue. Format = 1 if long format.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
displayq(pp, format)
|
displayq(struct printer *pp, int format)
|
||||||
struct printer *pp;
|
|
||||||
int format;
|
|
||||||
{
|
{
|
||||||
register struct jobqueue *q;
|
register struct jobqueue *q;
|
||||||
register int i, nitems, fd, ret;
|
register int i, nitems, fd, ret;
|
||||||
@ -258,8 +256,7 @@ displayq(pp, format)
|
|||||||
* Print a warning message if there is no daemon present.
|
* Print a warning message if there is no daemon present.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
warn(pp)
|
warn(const struct printer *pp)
|
||||||
const struct printer *pp;
|
|
||||||
{
|
{
|
||||||
if (pp->remote)
|
if (pp->remote)
|
||||||
printf("%s: ", host);
|
printf("%s: ", host);
|
||||||
@ -271,7 +268,7 @@ warn(pp)
|
|||||||
* Print the header for the short listing format
|
* Print the header for the short listing format
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
header()
|
header(void)
|
||||||
{
|
{
|
||||||
printf(head0);
|
printf(head0);
|
||||||
col = strlen(head0)+1;
|
col = strlen(head0)+1;
|
||||||
@ -280,9 +277,7 @@ header()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
inform(pp, cf)
|
inform(const struct printer *pp, char *cf)
|
||||||
const struct printer *pp;
|
|
||||||
char *cf;
|
|
||||||
{
|
{
|
||||||
register int copycnt;
|
register int copycnt;
|
||||||
char savedname[MAXPATHLEN+1];
|
char savedname[MAXPATHLEN+1];
|
||||||
@ -382,8 +377,7 @@ inform(pp, cf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
inlist(name, file)
|
inlist(char *uname, char *cfile)
|
||||||
char *name, *file;
|
|
||||||
{
|
{
|
||||||
register int *r, n;
|
register int *r, n;
|
||||||
register char **u, *cp;
|
register char **u, *cp;
|
||||||
@ -394,12 +388,12 @@ inlist(name, file)
|
|||||||
* Check to see if it's in the user list
|
* Check to see if it's in the user list
|
||||||
*/
|
*/
|
||||||
for (u = user; u < &user[users]; u++)
|
for (u = user; u < &user[users]; u++)
|
||||||
if (!strcmp(*u, name))
|
if (!strcmp(*u, uname))
|
||||||
return(1);
|
return(1);
|
||||||
/*
|
/*
|
||||||
* Check the request list
|
* Check the request list
|
||||||
*/
|
*/
|
||||||
for (n = 0, cp = file+3; isdigit(*cp); )
|
for (n = 0, cp = cfile+3; isdigit(*cp); )
|
||||||
n = n * 10 + (*cp++ - '0');
|
n = n * 10 + (*cp++ - '0');
|
||||||
for (r = requ; r < &requ[requests]; r++)
|
for (r = requ; r < &requ[requests]; r++)
|
||||||
if (*r == n && !strcmp(cp, from))
|
if (*r == n && !strcmp(cp, from))
|
||||||
@ -408,26 +402,23 @@ inlist(name, file)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
show(nfile, file, copies)
|
show(const char *nfile, const char *datafile, int copies)
|
||||||
register char *nfile, *file;
|
|
||||||
int copies;
|
|
||||||
{
|
{
|
||||||
if (strcmp(nfile, " ") == 0)
|
if (strcmp(nfile, " ") == 0)
|
||||||
nfile = "(standard input)";
|
nfile = "(standard input)";
|
||||||
if (lflag)
|
if (lflag)
|
||||||
ldump(nfile, file, copies);
|
ldump(nfile, datafile, copies);
|
||||||
else
|
else
|
||||||
dump(nfile, file, copies);
|
dump(nfile, datafile, copies);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Fill the line with blanks to the specified column
|
* Fill the line with blanks to the specified column
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
blankfill(n)
|
blankfill(int tocol)
|
||||||
register int n;
|
|
||||||
{
|
{
|
||||||
while (col++ < n)
|
while (col++ < tocol)
|
||||||
putchar(' ');
|
putchar(' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -435,9 +426,7 @@ blankfill(n)
|
|||||||
* Give the abbreviated dump of the file names
|
* Give the abbreviated dump of the file names
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
dump(nfile, file, copies)
|
dump(const char *nfile, const char *datafile, int copies)
|
||||||
char *nfile, *file;
|
|
||||||
int copies;
|
|
||||||
{
|
{
|
||||||
struct stat lbuf;
|
struct stat lbuf;
|
||||||
const char etctmpl[] = ", ...";
|
const char etctmpl[] = ", ...";
|
||||||
@ -488,7 +477,7 @@ dump(nfile, file, copies)
|
|||||||
first = 0;
|
first = 0;
|
||||||
|
|
||||||
seteuid(euid);
|
seteuid(euid);
|
||||||
if (*file && !stat(file, &lbuf))
|
if (*datafile && !stat(datafile, &lbuf))
|
||||||
totsize += copies * lbuf.st_size;
|
totsize += copies * lbuf.st_size;
|
||||||
seteuid(uid);
|
seteuid(uid);
|
||||||
}
|
}
|
||||||
@ -497,9 +486,7 @@ dump(nfile, file, copies)
|
|||||||
* Print the long info about the file
|
* Print the long info about the file
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
ldump(nfile, file, copies)
|
ldump(const char *nfile, const char *datafile, int copies)
|
||||||
char *nfile, *file;
|
|
||||||
int copies;
|
|
||||||
{
|
{
|
||||||
struct stat lbuf;
|
struct stat lbuf;
|
||||||
|
|
||||||
@ -508,7 +495,7 @@ ldump(nfile, file, copies)
|
|||||||
printf("%-2d copies of %-19s", copies, nfile);
|
printf("%-2d copies of %-19s", copies, nfile);
|
||||||
else
|
else
|
||||||
printf("%-32s", nfile);
|
printf("%-32s", nfile);
|
||||||
if (*file && !stat(file, &lbuf))
|
if (*datafile && !stat(datafile, &lbuf))
|
||||||
printf(" %qd bytes", (long long) lbuf.st_size);
|
printf(" %qd bytes", (long long) lbuf.st_size);
|
||||||
else
|
else
|
||||||
printf(" ??? bytes");
|
printf(" ??? bytes");
|
||||||
@ -520,11 +507,10 @@ ldump(nfile, file, copies)
|
|||||||
* update col for screen management
|
* update col for screen management
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
prank(n)
|
prank(int n)
|
||||||
int n;
|
|
||||||
{
|
{
|
||||||
char rline[100];
|
char rline[100];
|
||||||
static char *r[] = {
|
static const char *r[] = {
|
||||||
"th", "st", "nd", "rd", "th", "th", "th", "th", "th", "th"
|
"th", "st", "nd", "rd", "th", "th", "th", "th", "th", "th"
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -542,8 +528,8 @@ prank(n)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
alarmhandler(signo)
|
alarmhandler(int signo __unused)
|
||||||
int signo;
|
|
||||||
{
|
{
|
||||||
/* ignored */
|
/* the signal is ignored */
|
||||||
|
/* (the '__unused' is just to avoid a compile-time warning) */
|
||||||
}
|
}
|
||||||
|
@ -153,7 +153,7 @@ struct request {
|
|||||||
* Global definitions for the line printer system.
|
* Global definitions for the line printer system.
|
||||||
*/
|
*/
|
||||||
extern char line[BUFSIZ];
|
extern char line[BUFSIZ];
|
||||||
extern char *name; /* program name */
|
extern const char *name; /* program name */
|
||||||
/* host machine name */
|
/* host machine name */
|
||||||
extern char host[MAXHOSTNAMELEN];
|
extern char host[MAXHOSTNAMELEN];
|
||||||
extern char *from; /* client's machine name */
|
extern char *from; /* client's machine name */
|
||||||
@ -221,48 +221,48 @@ typedef enum { TR_SENDING, TR_RECVING, TR_PRINTING } tr_sendrecv;
|
|||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
struct dirent;
|
struct dirent;
|
||||||
|
|
||||||
void blankfill __P((int));
|
void blankfill(int _tocol);
|
||||||
char *checkremote __P((struct printer *pp));
|
char *checkremote(struct printer *_pp);
|
||||||
int chk __P((char *));
|
int chk(char *_file);
|
||||||
void closeallfds __P((int start));
|
void closeallfds(int _start);
|
||||||
void delay __P((int));
|
void delay(int _millisec);
|
||||||
void displayq __P((struct printer *pp, int format));
|
void displayq(struct printer *_pp, int _format);
|
||||||
void dump __P((char *, char *, int));
|
void dump(const char *_nfile, const char *_datafile, int _copies);
|
||||||
void fatal __P((const struct printer *pp, const char *fmp, ...));
|
void fatal(const struct printer *_pp, const char *_msg, ...);
|
||||||
int firstprinter __P((struct printer *pp, int *status));
|
int firstprinter(struct printer *_pp, int *_error);
|
||||||
void free_printer __P((struct printer *pp));
|
void free_printer(struct printer *_pp);
|
||||||
void free_request __P((struct request *rp));
|
void free_request(struct request *_rp);
|
||||||
int getline __P((FILE *));
|
int getline(FILE *_cfp);
|
||||||
int getport __P((const struct printer *pp, const char *, int));
|
int getport(const struct printer *_pp, const char *_rhost, int _rport);
|
||||||
int getprintcap __P((const char *printer, struct printer *pp));
|
int getprintcap(const char *_printer, struct printer *_pp);
|
||||||
int getq __P((const struct printer *, struct jobqueue *(*[])));
|
int getq(const struct printer *_pp, struct jobqueue *(*_namelist[]));
|
||||||
void header __P((void));
|
void header(void);
|
||||||
void inform __P((const struct printer *pp, char *cf));
|
void inform(const struct printer *_pp, char *_cf);
|
||||||
void init_printer __P((struct printer *pp));
|
void init_printer(struct printer *_pp);
|
||||||
void init_request __P((struct request *rp));
|
void init_request(struct request *_rp);
|
||||||
int inlist __P((char *, char *));
|
int inlist(char *_uname, char *_cfile);
|
||||||
int iscf __P((struct dirent *));
|
int iscf(struct dirent *_d);
|
||||||
int isowner __P((char *, char *));
|
int isowner(char *_owner, char *_file);
|
||||||
void ldump __P((char *, char *, int));
|
void ldump(const char *_nfile, const char *_datafile, int _copies);
|
||||||
void lastprinter __P((void));
|
void lastprinter(void);
|
||||||
int lockchk __P((struct printer *pp, char *));
|
int lockchk(struct printer *_pp, char *_slockf);
|
||||||
char *lock_file_name __P((const struct printer *pp, char *buf, size_t len));
|
char *lock_file_name(const struct printer *_pp, char *_buf, size_t _len);
|
||||||
void lpd_gettime __P((struct timespec *_tsp, char *_strp, int _strsize));
|
void lpd_gettime(struct timespec *_tsp, char *_strp, int _strsize);
|
||||||
int nextprinter __P((struct printer *pp, int *status));
|
int nextprinter(struct printer *_pp, int *_error);
|
||||||
const
|
const
|
||||||
char *pcaperr __P((int error));
|
char *pcaperr(int _error);
|
||||||
void prank __P((int));
|
void prank(int _n);
|
||||||
void process __P((const struct printer *pp, char *));
|
void process(const struct printer *_pp, char *_file);
|
||||||
void rmjob __P((const char *printer));
|
void rmjob(const char *_printer);
|
||||||
void rmremote __P((const struct printer *pp));
|
void rmremote(const struct printer *_pp);
|
||||||
void setprintcap __P((char *newprintcap));
|
void setprintcap(char *_newfile);
|
||||||
void show __P((char *, char *, int));
|
void show(const char *_nfile, const char *_datafile, int _copies);
|
||||||
int startdaemon __P((const struct printer *pp));
|
int startdaemon(const struct printer *_pp);
|
||||||
char *status_file_name __P((const struct printer *pp, char *buf,
|
char *status_file_name(const struct printer *_pp, char *_buf,
|
||||||
size_t len));
|
size_t _len);
|
||||||
void trstat_init __P((struct printer *pp, const char *fname, int filenum));
|
void trstat_init(struct printer *_pp, const char *_fname, int _filenum);
|
||||||
void trstat_write __P((struct printer *pp, tr_sendrecv sendrecv,
|
void trstat_write(struct printer *_pp, tr_sendrecv _sendrecv,
|
||||||
size_t bytecnt, const char *userid,
|
size_t _bytecnt, const char *_userid, const char *_otherhost,
|
||||||
const char *otherhost, const char *orighost));
|
const char *_orighost);
|
||||||
ssize_t writel __P((int s, ...));
|
ssize_t writel(int _strm, ...);
|
||||||
__END_DECLS
|
__END_DECLS
|
||||||
|
@ -178,7 +178,7 @@ retry:
|
|||||||
char *
|
char *
|
||||||
checkremote(struct printer *pp)
|
checkremote(struct printer *pp)
|
||||||
{
|
{
|
||||||
char name[MAXHOSTNAMELEN];
|
char lclhost[MAXHOSTNAMELEN];
|
||||||
struct addrinfo hints, *local_res, *remote_res, *lr, *rr;
|
struct addrinfo hints, *local_res, *remote_res, *lr, *rr;
|
||||||
char *err;
|
char *err;
|
||||||
int ncommonaddrs, error;
|
int ncommonaddrs, error;
|
||||||
@ -194,17 +194,17 @@ checkremote(struct printer *pp)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* get the addresses of the local host */
|
/* get the addresses of the local host */
|
||||||
gethostname(name, sizeof(name));
|
gethostname(lclhost, sizeof(lclhost));
|
||||||
name[sizeof(name) - 1] = '\0';
|
lclhost[sizeof(lclhost) - 1] = '\0';
|
||||||
|
|
||||||
memset(&hints, 0, sizeof(hints));
|
memset(&hints, 0, sizeof(hints));
|
||||||
hints.ai_family = family;
|
hints.ai_family = family;
|
||||||
hints.ai_socktype = SOCK_STREAM;
|
hints.ai_socktype = SOCK_STREAM;
|
||||||
hints.ai_flags = AI_PASSIVE;
|
hints.ai_flags = AI_PASSIVE;
|
||||||
if ((error = getaddrinfo(name, NULL, &hints, &local_res)) != 0) {
|
if ((error = getaddrinfo(lclhost, NULL, &hints, &local_res)) != 0) {
|
||||||
asprintf(&err, "unable to get official name "
|
asprintf(&err, "unable to get official name "
|
||||||
"for local machine %s: %s",
|
"for local machine %s: %s",
|
||||||
name, gai_strerror(error));
|
lclhost, gai_strerror(error));
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -256,7 +256,7 @@ checkremote(struct printer *pp)
|
|||||||
* values are as for writev(2).
|
* values are as for writev(2).
|
||||||
*/
|
*/
|
||||||
ssize_t
|
ssize_t
|
||||||
writel(int s, ...)
|
writel(int strm, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
int i, n;
|
int i, n;
|
||||||
@ -266,7 +266,7 @@ writel(int s, ...)
|
|||||||
ssize_t retval;
|
ssize_t retval;
|
||||||
|
|
||||||
/* first count them */
|
/* first count them */
|
||||||
va_start(ap, s);
|
va_start(ap, strm);
|
||||||
n = 0;
|
n = 0;
|
||||||
do {
|
do {
|
||||||
cp = va_arg(ap, char *);
|
cp = va_arg(ap, char *);
|
||||||
@ -282,13 +282,13 @@ writel(int s, ...)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* now make up iovec and send */
|
/* now make up iovec and send */
|
||||||
va_start(ap, s);
|
va_start(ap, strm);
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
iovp[i].iov_base = va_arg(ap, char *);
|
iovp[i].iov_base = va_arg(ap, char *);
|
||||||
iovp[i].iov_len = strlen(iovp[i].iov_base);
|
iovp[i].iov_len = strlen(iovp[i].iov_base);
|
||||||
}
|
}
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
retval = writev(s, iovp, n);
|
retval = writev(strm, iovp, n);
|
||||||
if (iovp != iov)
|
if (iovp != iov)
|
||||||
free(iovp);
|
free(iovp);
|
||||||
return retval;
|
return retval;
|
||||||
|
@ -58,14 +58,16 @@ static const char rcsid[] =
|
|||||||
/*
|
/*
|
||||||
* Routines and data used in processing the printcap file.
|
* Routines and data used in processing the printcap file.
|
||||||
*/
|
*/
|
||||||
static char *printcapdb[2] = { _PATH_PRINTCAP, 0 }; /* list for cget* */
|
static char *printcapdb[2] = { _PATH_PRINTCAP, 0 }; /* list for cget* */
|
||||||
|
|
||||||
static char *capdb_canonical_name(const char *);
|
static char *capdb_canonical_name(const char *_bp);
|
||||||
static int capdb_getaltlog(char *, const char *, const char *);
|
static int capdb_getaltlog(char *_bp, const char *_shrt,
|
||||||
static int capdb_getaltnum(char *, const char *, const char *, long, long *);
|
const char *_lng);
|
||||||
static int capdb_getaltstr(char *, const char *, const char *, const char *,
|
static int capdb_getaltnum(char *_bp, const char *_shrt,
|
||||||
char **);
|
const char *_lng, long _dflt, long *_result);
|
||||||
static int getprintcap_int(char *bp, struct printer *pp);
|
static int capdb_getaltstr(char *_bp, const char *_shrt,
|
||||||
|
const char *lng, const char *_dflt, char **_result);
|
||||||
|
static int getprintcap_int(char *_bp, struct printer *_pp);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Change the name of the printcap file. Used by chkprintcap(8),
|
* Change the name of the printcap file. Used by chkprintcap(8),
|
||||||
@ -210,9 +212,7 @@ static const char *longfilters[] = {
|
|||||||
* and store a malloced copy of it in pp->printer.
|
* and store a malloced copy of it in pp->printer.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
getprintcap_int(bp, pp)
|
getprintcap_int(char *bp, struct printer *pp)
|
||||||
char *bp;
|
|
||||||
struct printer *pp;
|
|
||||||
{
|
{
|
||||||
enum lpd_filters filt;
|
enum lpd_filters filt;
|
||||||
char *rp_name;
|
char *rp_name;
|
||||||
@ -371,7 +371,7 @@ free_printer(struct printer *pp)
|
|||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
capdb_getaltstr(char *bp, const char *shrt, const char *lng,
|
capdb_getaltstr(char *bp, const char *shrt, const char *lng,
|
||||||
const char *dflt, char **result)
|
const char *dflt, char **result)
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
@ -395,7 +395,7 @@ capdb_getaltstr(char *bp, const char *shrt, const char *lng,
|
|||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
capdb_getaltnum(char *bp, const char *shrt, const char *lng, long dflt,
|
capdb_getaltnum(char *bp, const char *shrt, const char *lng, long dflt,
|
||||||
long *result)
|
long *result)
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
|
@ -73,12 +73,11 @@ static char current[7+MAXHOSTNAMELEN]; /* active control file name */
|
|||||||
|
|
||||||
extern uid_t uid, euid; /* real and effective user id's */
|
extern uid_t uid, euid; /* real and effective user id's */
|
||||||
|
|
||||||
static void alarmhandler __P((int));
|
static void alarmhandler(int _signo);
|
||||||
static void do_unlink __P((char *));
|
static void do_unlink(char *_file);
|
||||||
|
|
||||||
void
|
void
|
||||||
rmjob(printer)
|
rmjob(const char *printer)
|
||||||
const char *printer;
|
|
||||||
{
|
{
|
||||||
register int i, nitems;
|
register int i, nitems;
|
||||||
int assasinated = 0;
|
int assasinated = 0;
|
||||||
@ -154,17 +153,15 @@ rmjob(printer)
|
|||||||
* Return boolean indicating existence of a lock file.
|
* Return boolean indicating existence of a lock file.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
lockchk(pp, s)
|
lockchk(struct printer *pp, char *slockf)
|
||||||
struct printer *pp;
|
|
||||||
char *s;
|
|
||||||
{
|
{
|
||||||
register FILE *fp;
|
register FILE *fp;
|
||||||
register int i, n;
|
register int i, n;
|
||||||
|
|
||||||
seteuid(euid);
|
seteuid(euid);
|
||||||
if ((fp = fopen(s, "r")) == NULL) {
|
if ((fp = fopen(slockf, "r")) == NULL) {
|
||||||
if (errno == EACCES)
|
if (errno == EACCES)
|
||||||
fatal(pp, "%s: %s", s, strerror(errno));
|
fatal(pp, "%s: %s", slockf, strerror(errno));
|
||||||
else
|
else
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
@ -194,9 +191,7 @@ lockchk(pp, s)
|
|||||||
* Process a control file.
|
* Process a control file.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
process(pp, file)
|
process(const struct printer *pp, char *file)
|
||||||
const struct printer *pp;
|
|
||||||
char *file;
|
|
||||||
{
|
{
|
||||||
FILE *cfp;
|
FILE *cfp;
|
||||||
|
|
||||||
@ -219,8 +214,7 @@ process(pp, file)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
do_unlink(file)
|
do_unlink(char *file)
|
||||||
char *file;
|
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@ -236,8 +230,7 @@ do_unlink(file)
|
|||||||
* Do the dirty work in checking
|
* Do the dirty work in checking
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
chk(file)
|
chk(char *file)
|
||||||
char *file;
|
|
||||||
{
|
{
|
||||||
register int *r, n;
|
register int *r, n;
|
||||||
register char **u, *cp;
|
register char **u, *cp;
|
||||||
@ -293,13 +286,12 @@ chk(file)
|
|||||||
* Normal users can only remove the file from where it was sent.
|
* Normal users can only remove the file from where it was sent.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
isowner(owner, file)
|
isowner(char *owner, char *file)
|
||||||
char *owner, *file;
|
|
||||||
{
|
{
|
||||||
if (!strcmp(person, root) && (from == host || !strcmp(from, file+6)))
|
if (!strcmp(person, root) && (from == host || !strcmp(from, file+6)))
|
||||||
return(1);
|
return (1);
|
||||||
if (!strcmp(person, owner) && !strcmp(from, file+6))
|
if (!strcmp(person, owner) && !strcmp(from, file+6))
|
||||||
return(1);
|
return (1);
|
||||||
if (from != host)
|
if (from != host)
|
||||||
printf("%s: ", host);
|
printf("%s: ", host);
|
||||||
printf("%s: Permission denied\n", file);
|
printf("%s: Permission denied\n", file);
|
||||||
@ -311,8 +303,7 @@ isowner(owner, file)
|
|||||||
* then try removing files on the remote machine.
|
* then try removing files on the remote machine.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
rmremote(pp)
|
rmremote(const struct printer *pp)
|
||||||
const struct printer *pp;
|
|
||||||
{
|
{
|
||||||
int i, elem, firstreq, niov, rem, totlen;
|
int i, elem, firstreq, niov, rem, totlen;
|
||||||
char buf[BUFSIZ];
|
char buf[BUFSIZ];
|
||||||
@ -390,15 +381,14 @@ rmremote(pp)
|
|||||||
* Return 1 if the filename begins with 'cf'
|
* Return 1 if the filename begins with 'cf'
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
iscf(d)
|
iscf(struct dirent *d)
|
||||||
struct dirent *d;
|
|
||||||
{
|
{
|
||||||
return(d->d_name[0] == 'c' && d->d_name[1] == 'f');
|
return(d->d_name[0] == 'c' && d->d_name[1] == 'f');
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
alarmhandler(signo)
|
alarmhandler(int signo __unused)
|
||||||
int signo;
|
|
||||||
{
|
{
|
||||||
/* ignored */
|
/* the signal is ignored */
|
||||||
|
/* (the '__unused' is just to avoid a compile-time warning) */
|
||||||
}
|
}
|
||||||
|
@ -60,8 +60,7 @@ extern uid_t uid, euid;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
int
|
int
|
||||||
startdaemon(pp)
|
startdaemon(const struct printer *pp)
|
||||||
const struct printer *pp;
|
|
||||||
{
|
{
|
||||||
struct sockaddr_un un;
|
struct sockaddr_un un;
|
||||||
register int s, n;
|
register int s, n;
|
||||||
|
@ -72,9 +72,7 @@ char *host; /* user's machine name */
|
|||||||
char *acctfile; /* accounting information file */
|
char *acctfile; /* accounting information file */
|
||||||
|
|
||||||
int
|
int
|
||||||
main(argc, argv)
|
main(int argc, char *argv[])
|
||||||
int argc;
|
|
||||||
char *argv[];
|
|
||||||
{
|
{
|
||||||
register FILE *p = stdin, *o = stdout;
|
register FILE *p = stdin, *o = stdout;
|
||||||
register int i, col;
|
register int i, col;
|
||||||
|
@ -70,27 +70,24 @@ static const char rcsid[] =
|
|||||||
#include "extern.h"
|
#include "extern.h"
|
||||||
#include "pathnames.h"
|
#include "pathnames.h"
|
||||||
|
|
||||||
static void abortpr __P((struct printer *, int));
|
static void abortpr(struct printer *_pp, int _dis);
|
||||||
static int doarg __P((char *));
|
static int doarg(char *_job);
|
||||||
static int doselect __P((struct dirent *));
|
static int doselect(struct dirent *_d);
|
||||||
static void putmsg __P((struct printer *, int, char **));
|
static void putmsg(struct printer *_pp, int _argc, char **_argv);
|
||||||
static int sortq __P((const void *, const void *));
|
static int sortq(const void *_a, const void *_b);
|
||||||
static void startpr __P((struct printer *, int));
|
static void startpr(struct printer *_pp, int _chgenable);
|
||||||
static int touch __P((struct jobqueue *));
|
static int touch(struct jobqueue *_jq);
|
||||||
static void unlinkf __P((char *));
|
static void unlinkf(char *_name);
|
||||||
static void upstat __P((struct printer *, char *));
|
static void upstat(struct printer *_pp, const char *_msg);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* generic framework for commands which operate on all or a specified
|
* generic framework for commands which operate on all or a specified
|
||||||
* set of printers
|
* set of printers
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
generic(doit, argc, argv)
|
generic(void (*specificrtn)(struct printer *_pp), int argc, char *argv[])
|
||||||
void (*doit) __P((struct printer *));
|
|
||||||
int argc;
|
|
||||||
char *argv[];
|
|
||||||
{
|
{
|
||||||
int status, more;
|
int cmdstatus, more;
|
||||||
struct printer myprinter, *pp = &myprinter;
|
struct printer myprinter, *pp = &myprinter;
|
||||||
|
|
||||||
if (argc == 1) {
|
if (argc == 1) {
|
||||||
@ -98,15 +95,15 @@ generic(doit, argc, argv)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (argc == 2 && strcmp(argv[1], "all") == 0) {
|
if (argc == 2 && strcmp(argv[1], "all") == 0) {
|
||||||
more = firstprinter(pp, &status);
|
more = firstprinter(pp, &cmdstatus);
|
||||||
if (status)
|
if (cmdstatus)
|
||||||
goto looperr;
|
goto looperr;
|
||||||
while (more) {
|
while (more) {
|
||||||
(*doit)(pp);
|
(*specificrtn)(pp);
|
||||||
do {
|
do {
|
||||||
more = nextprinter(pp, &status);
|
more = nextprinter(pp, &cmdstatus);
|
||||||
looperr:
|
looperr:
|
||||||
switch (status) {
|
switch (cmdstatus) {
|
||||||
case PCAPERR_TCOPEN:
|
case PCAPERR_TCOPEN:
|
||||||
printf("warning: %s: unresolved "
|
printf("warning: %s: unresolved "
|
||||||
"tc= reference(s) ",
|
"tc= reference(s) ",
|
||||||
@ -114,19 +111,19 @@ looperr:
|
|||||||
case PCAPERR_SUCCESS:
|
case PCAPERR_SUCCESS:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fatal(pp, pcaperr(status));
|
fatal(pp, pcaperr(cmdstatus));
|
||||||
}
|
}
|
||||||
} while (more && status);
|
} while (more && cmdstatus);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
while (--argc) {
|
while (--argc) {
|
||||||
++argv;
|
++argv;
|
||||||
init_printer(pp);
|
init_printer(pp);
|
||||||
status = getprintcap(*argv, pp);
|
cmdstatus = getprintcap(*argv, pp);
|
||||||
switch(status) {
|
switch (cmdstatus) {
|
||||||
default:
|
default:
|
||||||
fatal(pp, pcaperr(status));
|
fatal(pp, pcaperr(cmdstatus));
|
||||||
case PCAPERR_NOTFOUND:
|
case PCAPERR_NOTFOUND:
|
||||||
printf("unknown printer %s\n", *argv);
|
printf("unknown printer %s\n", *argv);
|
||||||
continue;
|
continue;
|
||||||
@ -137,7 +134,7 @@ looperr:
|
|||||||
case PCAPERR_SUCCESS:
|
case PCAPERR_SUCCESS:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
(*doit)(pp);
|
(*specificrtn)(pp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,16 +142,13 @@ looperr:
|
|||||||
* kill an existing daemon and disable printing.
|
* kill an existing daemon and disable printing.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
doabort(pp)
|
doabort(struct printer *pp)
|
||||||
struct printer *pp;
|
|
||||||
{
|
{
|
||||||
abortpr(pp, 1);
|
abortpr(pp, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
abortpr(pp, dis)
|
abortpr(struct printer *pp, int dis)
|
||||||
struct printer *pp;
|
|
||||||
int dis;
|
|
||||||
{
|
{
|
||||||
register FILE *fp;
|
register FILE *fp;
|
||||||
struct stat stbuf;
|
struct stat stbuf;
|
||||||
@ -222,9 +216,7 @@ out:
|
|||||||
* Write a message into the status file.
|
* Write a message into the status file.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
upstat(pp, msg)
|
upstat(struct printer *pp, const char *msg)
|
||||||
struct printer *pp;
|
|
||||||
char *msg;
|
|
||||||
{
|
{
|
||||||
register int fd;
|
register int fd;
|
||||||
char statfile[MAXPATHLEN];
|
char statfile[MAXPATHLEN];
|
||||||
@ -245,8 +237,7 @@ upstat(pp, msg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
doselect(d)
|
doselect(struct dirent *d)
|
||||||
struct dirent *d;
|
|
||||||
{
|
{
|
||||||
int c = d->d_name[0];
|
int c = d->d_name[0];
|
||||||
|
|
||||||
@ -260,14 +251,13 @@ doselect(d)
|
|||||||
* by `cf', `tf', or `df', then by the sequence letter A-Z, a-z.
|
* by `cf', `tf', or `df', then by the sequence letter A-Z, a-z.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
sortq(a, b)
|
sortq(const void *a, const void *b)
|
||||||
const void *a, *b;
|
|
||||||
{
|
{
|
||||||
struct dirent **d1, **d2;
|
const struct dirent **d1, **d2;
|
||||||
int c1, c2;
|
int c1, c2;
|
||||||
|
|
||||||
d1 = (struct dirent **)a;
|
d1 = (const struct dirent **)a;
|
||||||
d2 = (struct dirent **)b;
|
d2 = (const struct dirent **)b;
|
||||||
if ((c1 = strcmp((*d1)->d_name + 3, (*d2)->d_name + 3)))
|
if ((c1 = strcmp((*d1)->d_name + 3, (*d2)->d_name + 3)))
|
||||||
return(c1);
|
return(c1);
|
||||||
c1 = (*d1)->d_name[0];
|
c1 = (*d1)->d_name[0];
|
||||||
@ -287,8 +277,7 @@ sortq(a, b)
|
|||||||
* Remove incomplete jobs from spooling area.
|
* Remove incomplete jobs from spooling area.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
clean(pp)
|
clean(struct printer *pp)
|
||||||
struct printer *pp;
|
|
||||||
{
|
{
|
||||||
register int i, n;
|
register int i, n;
|
||||||
register char *cp, *cp1, *lp;
|
register char *cp, *cp1, *lp;
|
||||||
@ -345,8 +334,7 @@ clean(pp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
unlinkf(name)
|
unlinkf(char *name)
|
||||||
char *name;
|
|
||||||
{
|
{
|
||||||
seteuid(euid);
|
seteuid(euid);
|
||||||
if (unlink(name) < 0)
|
if (unlink(name) < 0)
|
||||||
@ -360,8 +348,7 @@ unlinkf(name)
|
|||||||
* Enable queuing to the printer (allow lpr's).
|
* Enable queuing to the printer (allow lpr's).
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
enable(pp)
|
enable(struct printer *pp)
|
||||||
struct printer *pp;
|
|
||||||
{
|
{
|
||||||
struct stat stbuf;
|
struct stat stbuf;
|
||||||
char lf[MAXPATHLEN];
|
char lf[MAXPATHLEN];
|
||||||
@ -386,8 +373,7 @@ enable(pp)
|
|||||||
* Disable queuing.
|
* Disable queuing.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
disable(pp)
|
disable(struct printer *pp)
|
||||||
struct printer *pp;
|
|
||||||
{
|
{
|
||||||
register int fd;
|
register int fd;
|
||||||
struct stat stbuf;
|
struct stat stbuf;
|
||||||
@ -424,11 +410,9 @@ disable(pp)
|
|||||||
* (reason for being down).
|
* (reason for being down).
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
down(argc, argv)
|
down(int argc, char *argv[])
|
||||||
int argc;
|
|
||||||
char *argv[];
|
|
||||||
{
|
{
|
||||||
int status, more;
|
int cmdstatus, more;
|
||||||
struct printer myprinter, *pp = &myprinter;
|
struct printer myprinter, *pp = &myprinter;
|
||||||
|
|
||||||
if (argc == 1) {
|
if (argc == 1) {
|
||||||
@ -436,15 +420,15 @@ down(argc, argv)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!strcmp(argv[1], "all")) {
|
if (!strcmp(argv[1], "all")) {
|
||||||
more = firstprinter(pp, &status);
|
more = firstprinter(pp, &cmdstatus);
|
||||||
if (status)
|
if (cmdstatus)
|
||||||
goto looperr;
|
goto looperr;
|
||||||
while (more) {
|
while (more) {
|
||||||
putmsg(pp, argc - 2, argv + 2);
|
putmsg(pp, argc - 2, argv + 2);
|
||||||
do {
|
do {
|
||||||
more = nextprinter(pp, &status);
|
more = nextprinter(pp, &cmdstatus);
|
||||||
looperr:
|
looperr:
|
||||||
switch (status) {
|
switch (cmdstatus) {
|
||||||
case PCAPERR_TCOPEN:
|
case PCAPERR_TCOPEN:
|
||||||
printf("warning: %s: unresolved "
|
printf("warning: %s: unresolved "
|
||||||
"tc= reference(s) ",
|
"tc= reference(s) ",
|
||||||
@ -452,17 +436,17 @@ looperr:
|
|||||||
case PCAPERR_SUCCESS:
|
case PCAPERR_SUCCESS:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fatal(pp, pcaperr(status));
|
fatal(pp, pcaperr(cmdstatus));
|
||||||
}
|
}
|
||||||
} while (more && status);
|
} while (more && cmdstatus);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
init_printer(pp);
|
init_printer(pp);
|
||||||
status = getprintcap(argv[1], pp);
|
cmdstatus = getprintcap(argv[1], pp);
|
||||||
switch(status) {
|
switch (cmdstatus) {
|
||||||
default:
|
default:
|
||||||
fatal(pp, pcaperr(status));
|
fatal(pp, pcaperr(cmdstatus));
|
||||||
case PCAPERR_NOTFOUND:
|
case PCAPERR_NOTFOUND:
|
||||||
printf("unknown printer %s\n", argv[1]);
|
printf("unknown printer %s\n", argv[1]);
|
||||||
return;
|
return;
|
||||||
@ -476,10 +460,7 @@ looperr:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
putmsg(pp, argc, argv)
|
putmsg(struct printer *pp, int argc, char **argv)
|
||||||
struct printer *pp;
|
|
||||||
int argc;
|
|
||||||
char **argv;
|
|
||||||
{
|
{
|
||||||
register int fd;
|
register int fd;
|
||||||
register char *cp1, *cp2;
|
register char *cp1, *cp2;
|
||||||
@ -547,9 +528,7 @@ putmsg(pp, argc, argv)
|
|||||||
* Exit lpc
|
* Exit lpc
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
quit(argc, argv)
|
quit(int argc __unused, char *argv[] __unused)
|
||||||
int argc;
|
|
||||||
char *argv[];
|
|
||||||
{
|
{
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
@ -558,8 +537,7 @@ quit(argc, argv)
|
|||||||
* Kill and restart the daemon.
|
* Kill and restart the daemon.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
restart(pp)
|
restart(struct printer *pp)
|
||||||
struct printer *pp;
|
|
||||||
{
|
{
|
||||||
abortpr(pp, 0);
|
abortpr(pp, 0);
|
||||||
startpr(pp, 0);
|
startpr(pp, 0);
|
||||||
@ -569,16 +547,13 @@ restart(pp)
|
|||||||
* Enable printing on the specified printer and startup the daemon.
|
* Enable printing on the specified printer and startup the daemon.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
startcmd(pp)
|
startcmd(struct printer *pp)
|
||||||
struct printer *pp;
|
|
||||||
{
|
{
|
||||||
startpr(pp, 1);
|
startpr(pp, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
startpr(pp, enable)
|
startpr(struct printer *pp, int chgenable)
|
||||||
struct printer *pp;
|
|
||||||
int enable;
|
|
||||||
{
|
{
|
||||||
struct stat stbuf;
|
struct stat stbuf;
|
||||||
char lf[MAXPATHLEN];
|
char lf[MAXPATHLEN];
|
||||||
@ -587,13 +562,13 @@ startpr(pp, enable)
|
|||||||
printf("%s:\n", pp->printer);
|
printf("%s:\n", pp->printer);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* For enable==1 ('start'), turn off the LFM_PRINT_DIS bit of the
|
* For chgenable==1 ('start'), turn off the LFM_PRINT_DIS bit of the
|
||||||
* lock file to re-enable printing. For enable==2 ('up'), also
|
* lock file to re-enable printing. For chgenable==2 ('up'), also
|
||||||
* turn off the LFM_QUEUE_DIS bit to re-enable queueing.
|
* turn off the LFM_QUEUE_DIS bit to re-enable queueing.
|
||||||
*/
|
*/
|
||||||
seteuid(euid);
|
seteuid(euid);
|
||||||
if (enable && stat(lf, &stbuf) >= 0) {
|
if (chgenable && stat(lf, &stbuf) >= 0) {
|
||||||
mode_t bits = (enable == 2 ? 0 : LFM_QUEUE_DIS);
|
mode_t bits = (chgenable == 2 ? 0 : LFM_QUEUE_DIS);
|
||||||
if (chmod(lf, stbuf.st_mode & (LOCK_FILE_MODE | bits)) < 0)
|
if (chmod(lf, stbuf.st_mode & (LOCK_FILE_MODE | bits)) < 0)
|
||||||
printf("\tcannot enable printing\n");
|
printf("\tcannot enable printing\n");
|
||||||
else
|
else
|
||||||
@ -610,8 +585,7 @@ startpr(pp, enable)
|
|||||||
* Print the status of the printer queue.
|
* Print the status of the printer queue.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
status(pp)
|
status(struct printer *pp)
|
||||||
struct printer *pp;
|
|
||||||
{
|
{
|
||||||
struct stat stbuf;
|
struct stat stbuf;
|
||||||
register int fd, i;
|
register int fd, i;
|
||||||
@ -674,8 +648,7 @@ status(pp)
|
|||||||
* printing.
|
* printing.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
stop(pp)
|
stop(struct printer *pp)
|
||||||
struct printer *pp;
|
|
||||||
{
|
{
|
||||||
register int fd;
|
register int fd;
|
||||||
struct stat stbuf;
|
struct stat stbuf;
|
||||||
@ -719,13 +692,11 @@ time_t mtime;
|
|||||||
* Put the specified jobs at the top of printer queue.
|
* Put the specified jobs at the top of printer queue.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
topq(argc, argv)
|
topq(int argc, char *argv[])
|
||||||
int argc;
|
|
||||||
char *argv[];
|
|
||||||
{
|
{
|
||||||
register int i;
|
register int i;
|
||||||
struct stat stbuf;
|
struct stat stbuf;
|
||||||
int status, changed;
|
int cmdstatus, changed;
|
||||||
struct printer myprinter, *pp = &myprinter;
|
struct printer myprinter, *pp = &myprinter;
|
||||||
|
|
||||||
if (argc < 3) {
|
if (argc < 3) {
|
||||||
@ -736,10 +707,10 @@ topq(argc, argv)
|
|||||||
--argc;
|
--argc;
|
||||||
++argv;
|
++argv;
|
||||||
init_printer(pp);
|
init_printer(pp);
|
||||||
status = getprintcap(*argv, pp);
|
cmdstatus = getprintcap(*argv, pp);
|
||||||
switch(status) {
|
switch(cmdstatus) {
|
||||||
default:
|
default:
|
||||||
fatal(pp, pcaperr(status));
|
fatal(pp, pcaperr(cmdstatus));
|
||||||
case PCAPERR_NOTFOUND:
|
case PCAPERR_NOTFOUND:
|
||||||
printf("unknown printer %s\n", *argv);
|
printf("unknown printer %s\n", *argv);
|
||||||
return;
|
return;
|
||||||
@ -793,8 +764,7 @@ out:
|
|||||||
* the control file.
|
* the control file.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
touch(q)
|
touch(struct jobqueue *jq)
|
||||||
struct jobqueue *q;
|
|
||||||
{
|
{
|
||||||
struct timeval tvp[2];
|
struct timeval tvp[2];
|
||||||
int ret;
|
int ret;
|
||||||
@ -802,7 +772,7 @@ touch(q)
|
|||||||
tvp[0].tv_sec = tvp[1].tv_sec = --mtime;
|
tvp[0].tv_sec = tvp[1].tv_sec = --mtime;
|
||||||
tvp[0].tv_usec = tvp[1].tv_usec = 0;
|
tvp[0].tv_usec = tvp[1].tv_usec = 0;
|
||||||
seteuid(euid);
|
seteuid(euid);
|
||||||
ret = utimes(q->job_cfname, tvp);
|
ret = utimes(jq->job_cfname, tvp);
|
||||||
seteuid(uid);
|
seteuid(uid);
|
||||||
return (ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
@ -812,8 +782,7 @@ touch(q)
|
|||||||
* Returns: negative (-1) if argument name is not in the queue.
|
* Returns: negative (-1) if argument name is not in the queue.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
doarg(job)
|
doarg(char *job)
|
||||||
char *job;
|
|
||||||
{
|
{
|
||||||
register struct jobqueue **qq;
|
register struct jobqueue **qq;
|
||||||
register int jobnum, n;
|
register int jobnum, n;
|
||||||
@ -884,8 +853,7 @@ doarg(job)
|
|||||||
* Enable everything and start printer (undo `down').
|
* Enable everything and start printer (undo `down').
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
up(pp)
|
up(struct printer *pp)
|
||||||
struct printer *pp;
|
|
||||||
{
|
{
|
||||||
startpr(pp, 2);
|
startpr(pp, 2);
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,8 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* @(#)extern.h 8.1 (Berkeley) 6/6/93
|
* @(#)extern.h 8.1 (Berkeley) 6/6/93
|
||||||
|
*
|
||||||
|
* $FreeBSD$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@ -40,20 +42,21 @@
|
|||||||
|
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
void clean __P((struct printer *));
|
void clean(struct printer *_pp);
|
||||||
void disable __P((struct printer *));
|
void disable(struct printer *_pp);
|
||||||
void doabort __P((struct printer *));
|
void doabort(struct printer *_pp);
|
||||||
void down __P((int, char **));
|
void down(int _argc, char *_argv[]);
|
||||||
void enable __P((struct printer *));
|
void enable(struct printer *_pp);
|
||||||
void generic __P((void (*) __P((struct printer *)), int, char **));
|
void generic(void (*_specificrtn)(struct printer *_pp), int _argc,
|
||||||
void help __P((int, char **));
|
char *_argv[]);
|
||||||
void quit __P((int, char **));
|
void help(int _argc, char *_argv[]);
|
||||||
void restart __P((struct printer *));
|
void quit(int _argc, char *_argv[]);
|
||||||
void startcmd __P((struct printer *));
|
void restart(struct printer *_pp);
|
||||||
void status __P((struct printer *));
|
void startcmd(struct printer *_pp);
|
||||||
void stop __P((struct printer *));
|
void status(struct printer *_pp);
|
||||||
void topq __P((int, char **));
|
void stop(struct printer *_pp);
|
||||||
void up __P((struct printer *));
|
void topq(int _argc, char *_argv[]);
|
||||||
|
void up(struct printer *_pp);
|
||||||
__END_DECLS
|
__END_DECLS
|
||||||
|
|
||||||
extern int NCMDS;
|
extern int NCMDS;
|
||||||
|
@ -82,17 +82,15 @@ static int margc;
|
|||||||
static char *margv[MAX_MARGV];
|
static char *margv[MAX_MARGV];
|
||||||
uid_t uid, euid;
|
uid_t uid, euid;
|
||||||
|
|
||||||
int main __P((int, char *[]));
|
int main(int _argc, char *_argv[]);
|
||||||
static void cmdscanner __P((void));
|
static void cmdscanner(void);
|
||||||
static struct cmd *getcmd __P((char *));
|
static struct cmd *getcmd(const char *_name);
|
||||||
static void intr __P((int));
|
static void intr(int _signo);
|
||||||
static void makeargv __P((void));
|
static void makeargv(void);
|
||||||
static int ingroup __P((char *));
|
static int ingroup(const char *_grname);
|
||||||
|
|
||||||
int
|
int
|
||||||
main(argc, argv)
|
main(int argc, char *argv[])
|
||||||
int argc;
|
|
||||||
char *argv[];
|
|
||||||
{
|
{
|
||||||
register struct cmd *c;
|
register struct cmd *c;
|
||||||
|
|
||||||
@ -131,13 +129,13 @@ main(argc, argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
intr(signo)
|
intr(int signo __unused)
|
||||||
int signo;
|
|
||||||
{
|
{
|
||||||
|
/* (the '__unused' is just to avoid a compile-time warning) */
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static const char *
|
||||||
lpc_prompt(void)
|
lpc_prompt(void)
|
||||||
{
|
{
|
||||||
return ("lpc> ");
|
return ("lpc> ");
|
||||||
@ -147,7 +145,7 @@ lpc_prompt(void)
|
|||||||
* Command parser.
|
* Command parser.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
cmdscanner()
|
cmdscanner(void)
|
||||||
{
|
{
|
||||||
register struct cmd *c;
|
register struct cmd *c;
|
||||||
static EditLine *el = NULL;
|
static EditLine *el = NULL;
|
||||||
@ -210,10 +208,9 @@ cmdscanner()
|
|||||||
}
|
}
|
||||||
|
|
||||||
static struct cmd *
|
static struct cmd *
|
||||||
getcmd(name)
|
getcmd(const char *name)
|
||||||
register char *name;
|
|
||||||
{
|
{
|
||||||
register char *p, *q;
|
register const char *p, *q;
|
||||||
register struct cmd *c, *found;
|
register struct cmd *c, *found;
|
||||||
register int nmatches, longest;
|
register int nmatches, longest;
|
||||||
|
|
||||||
@ -242,7 +239,7 @@ getcmd(name)
|
|||||||
* Slice a string up into argc/argv.
|
* Slice a string up into argc/argv.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
makeargv()
|
makeargv(void)
|
||||||
{
|
{
|
||||||
register char *cp;
|
register char *cp;
|
||||||
register char **argp = margv;
|
register char **argp = margv;
|
||||||
@ -272,9 +269,7 @@ makeargv()
|
|||||||
* Help command.
|
* Help command.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
help(argc, argv)
|
help(int argc, char *argv[])
|
||||||
int argc;
|
|
||||||
char *argv[];
|
|
||||||
{
|
{
|
||||||
register struct cmd *c;
|
register struct cmd *c;
|
||||||
|
|
||||||
@ -330,8 +325,7 @@ help(argc, argv)
|
|||||||
* return non-zero if the user is a member of the given group
|
* return non-zero if the user is a member of the given group
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
ingroup(grname)
|
ingroup(const char *grname)
|
||||||
char *grname;
|
|
||||||
{
|
{
|
||||||
static struct group *gptr=NULL;
|
static struct group *gptr=NULL;
|
||||||
static int ngroups = 0;
|
static int ngroups = 0;
|
||||||
|
@ -31,6 +31,8 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* @(#)lpc.h 8.1 (Berkeley) 6/6/93
|
* @(#)lpc.h 8.1 (Berkeley) 6/6/93
|
||||||
|
*
|
||||||
|
* $FreeBSD$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -39,10 +41,10 @@
|
|||||||
struct printer;
|
struct printer;
|
||||||
|
|
||||||
struct cmd {
|
struct cmd {
|
||||||
char *c_name; /* command name */
|
const char *c_name; /* command name */
|
||||||
char *c_help; /* help message */
|
const char *c_help; /* help message */
|
||||||
/* routine to do the work */
|
/* routine to do the work */
|
||||||
void (*c_handler) __P((int, char *[]));
|
void (*c_handler)(int, char *[]);
|
||||||
int c_priv; /* privileged command */
|
int c_priv; /* privileged command */
|
||||||
void (*c_generic) __P((struct printer *)); /* generic command */
|
void (*c_generic)(struct printer *); /* generic command */
|
||||||
};
|
};
|
||||||
|
@ -44,8 +44,8 @@ struct printer;
|
|||||||
struct termios;
|
struct termios;
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
void printjob __P((struct printer *pp));
|
void printjob(struct printer *_pp);
|
||||||
void startprinting __P((const char *printer));
|
void startprinting(const char *_printer);
|
||||||
void recvjob __P((const char *printer));
|
void recvjob(const char *_printer);
|
||||||
int msearch __P((char *str, struct termios *ip));
|
int msearch(char *_str, struct termios *_ip);
|
||||||
__END_DECLS
|
__END_DECLS
|
||||||
|
@ -107,15 +107,15 @@ int lflag; /* log requests flag */
|
|||||||
int pflag; /* no incoming port flag */
|
int pflag; /* no incoming port flag */
|
||||||
int from_remote; /* from remote socket */
|
int from_remote; /* from remote socket */
|
||||||
|
|
||||||
int main __P((int, char **));
|
int main(int argc, char **_argv);
|
||||||
static void reapchild __P((int));
|
static void reapchild(int _signo);
|
||||||
static void mcleanup __P((int));
|
static void mcleanup(int _signo);
|
||||||
static void doit __P((void));
|
static void doit(void);
|
||||||
static void startup __P((void));
|
static void startup(void);
|
||||||
static void chkhost __P((struct sockaddr *));
|
static void chkhost(struct sockaddr *_f);
|
||||||
static int ckqueue __P((struct printer *));
|
static int ckqueue(struct printer *_pp);
|
||||||
static void usage __P((void));
|
static void usage(void);
|
||||||
static int *socksetup __P((int, int));
|
static int *socksetup(int _af, int _options);
|
||||||
|
|
||||||
/* XXX from libc/net/rcmd.c */
|
/* XXX from libc/net/rcmd.c */
|
||||||
extern int __ivaliduser_sa __P((FILE *, struct sockaddr *, socklen_t,
|
extern int __ivaliduser_sa __P((FILE *, struct sockaddr *, socklen_t,
|
||||||
@ -124,9 +124,7 @@ extern int __ivaliduser_sa __P((FILE *, struct sockaddr *, socklen_t,
|
|||||||
uid_t uid, euid;
|
uid_t uid, euid;
|
||||||
|
|
||||||
int
|
int
|
||||||
main(argc, argv)
|
main(int argc, char **argv)
|
||||||
int argc;
|
|
||||||
char **argv;
|
|
||||||
{
|
{
|
||||||
int errs, f, funix, *finet, fromlen, i, options, socket_debug;
|
int errs, f, funix, *finet, fromlen, i, options, socket_debug;
|
||||||
fd_set defreadfds;
|
fd_set defreadfds;
|
||||||
@ -382,8 +380,7 @@ main(argc, argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
reapchild(signo)
|
reapchild(int signo __unused)
|
||||||
int signo;
|
|
||||||
{
|
{
|
||||||
union wait status;
|
union wait status;
|
||||||
|
|
||||||
@ -392,8 +389,7 @@ reapchild(signo)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
mcleanup(signo)
|
mcleanup(int signo)
|
||||||
int signo;
|
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* XXX syslog(3) is not signal-safe.
|
* XXX syslog(3) is not signal-safe.
|
||||||
@ -419,7 +415,7 @@ char *person; /* name of person doing lprm */
|
|||||||
|
|
||||||
char fromb[MAXHOSTNAMELEN]; /* buffer for client's machine name */
|
char fromb[MAXHOSTNAMELEN]; /* buffer for client's machine name */
|
||||||
char cbuf[BUFSIZ]; /* command line buffer */
|
char cbuf[BUFSIZ]; /* command line buffer */
|
||||||
char *cmdnames[] = {
|
const char *cmdnames[] = {
|
||||||
"null",
|
"null",
|
||||||
"printjob",
|
"printjob",
|
||||||
"recvjob",
|
"recvjob",
|
||||||
@ -429,7 +425,7 @@ char *cmdnames[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
doit()
|
doit(void)
|
||||||
{
|
{
|
||||||
char *cp, *printer;
|
char *cp, *printer;
|
||||||
int n;
|
int n;
|
||||||
@ -543,7 +539,7 @@ doit()
|
|||||||
* files left from the last time the machine went down.
|
* files left from the last time the machine went down.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
startup()
|
startup(void)
|
||||||
{
|
{
|
||||||
int pid, status, more;
|
int pid, status, more;
|
||||||
struct printer myprinter, *pp = &myprinter;
|
struct printer myprinter, *pp = &myprinter;
|
||||||
@ -584,8 +580,7 @@ errloop:
|
|||||||
* Make sure there's some work to do before forking off a child
|
* Make sure there's some work to do before forking off a child
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
ckqueue(pp)
|
ckqueue(struct printer *pp)
|
||||||
struct printer *pp;
|
|
||||||
{
|
{
|
||||||
register struct dirent *d;
|
register struct dirent *d;
|
||||||
DIR *dirp;
|
DIR *dirp;
|
||||||
@ -610,8 +605,7 @@ ckqueue(pp)
|
|||||||
* Check to see if the from host has access to the line printer.
|
* Check to see if the from host has access to the line printer.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
chkhost(f)
|
chkhost(struct sockaddr *f)
|
||||||
struct sockaddr *f;
|
|
||||||
{
|
{
|
||||||
struct addrinfo hints, *res, *r;
|
struct addrinfo hints, *res, *r;
|
||||||
register FILE *hostf;
|
register FILE *hostf;
|
||||||
@ -706,8 +700,7 @@ again:
|
|||||||
/* if af is PF_UNSPEC more than one socket may be returned */
|
/* if af is PF_UNSPEC more than one socket may be returned */
|
||||||
/* the returned list is dynamically allocated, so caller needs to free it */
|
/* the returned list is dynamically allocated, so caller needs to free it */
|
||||||
static int *
|
static int *
|
||||||
socksetup(af, options)
|
socksetup(int af, int options)
|
||||||
int af, options;
|
|
||||||
{
|
{
|
||||||
struct addrinfo hints, *res, *r;
|
struct addrinfo hints, *res, *r;
|
||||||
int error, maxs, *s, *socks;
|
int error, maxs, *s, *socks;
|
||||||
@ -786,7 +779,7 @@ socksetup(af, options)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
usage()
|
usage(void)
|
||||||
{
|
{
|
||||||
#ifdef INET6
|
#ifdef INET6
|
||||||
fprintf(stderr, "usage: lpd [-dlp46] [port#]\n");
|
fprintf(stderr, "usage: lpd [-dlp46] [port#]\n");
|
||||||
|
@ -47,8 +47,8 @@ static const char rcsid[] =
|
|||||||
|
|
||||||
struct modes {
|
struct modes {
|
||||||
const char *name;
|
const char *name;
|
||||||
const long set;
|
const long set;
|
||||||
const long unset;
|
const long unset;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -202,9 +202,7 @@ struct modes omodes[] = {
|
|||||||
#define CHK(name, s) (*name == s[0] && !strcmp(name, s))
|
#define CHK(name, s) (*name == s[0] && !strcmp(name, s))
|
||||||
|
|
||||||
int
|
int
|
||||||
msearch(str, ip)
|
msearch(char *str, struct termios *ip)
|
||||||
char *str;
|
|
||||||
struct termios *ip;
|
|
||||||
{
|
{
|
||||||
struct modes *mp;
|
struct modes *mp;
|
||||||
|
|
||||||
|
@ -121,32 +121,31 @@ static char width[10] = "-w"; /* page width in static characters */
|
|||||||
#define TFILENAME "fltXXXXXX"
|
#define TFILENAME "fltXXXXXX"
|
||||||
static char tfile[] = TFILENAME; /* file name for filter output */
|
static char tfile[] = TFILENAME; /* file name for filter output */
|
||||||
|
|
||||||
static void abortpr __P((int));
|
static void abortpr(int _signo);
|
||||||
static void alarmhandler __P((int));
|
static void alarmhandler(int _signo);
|
||||||
static void banner __P((struct printer *pp, char *name1, char *name2));
|
static void banner(struct printer *_pp, char *_name1, char *_name2);
|
||||||
static int dofork __P((const struct printer *pp, int action));
|
static int dofork(const struct printer *_pp, int _action);
|
||||||
static int dropit __P((int));
|
static int dropit(int _c);
|
||||||
static void init __P((struct printer *pp));
|
static void init(struct printer *_pp);
|
||||||
static void openpr __P((const struct printer *pp));
|
static void openpr(const struct printer *_pp);
|
||||||
static void opennet __P((const struct printer *pp));
|
static void opennet(const struct printer *_pp);
|
||||||
static void opentty __P((const struct printer *pp));
|
static void opentty(const struct printer *_pp);
|
||||||
static void openrem __P((const struct printer *pp));
|
static void openrem(const struct printer *pp);
|
||||||
static int print __P((struct printer *pp, int format, char *file));
|
static int print(struct printer *_pp, int _format, char *_file);
|
||||||
static int printit __P((struct printer *pp, char *file));
|
static int printit(struct printer *_pp, char *_file);
|
||||||
static void pstatus __P((const struct printer *, const char *, ...));
|
static void pstatus(const struct printer *_pp, const char *_msg, ...);
|
||||||
static char response __P((const struct printer *pp));
|
static char response(const struct printer *_pp);
|
||||||
static void scan_out __P((struct printer *pp, int scfd, char *scsp,
|
static void scan_out(struct printer *_pp, int _scfd, char *_scsp,
|
||||||
int dlm));
|
int _dlm);
|
||||||
static char *scnline __P((int, char *, int));
|
static char *scnline(int _key, char *_p, int _c);
|
||||||
static int sendfile __P((struct printer *pp, int type, char *file,
|
static int sendfile(struct printer *_pp, int _type, char *_file,
|
||||||
int format));
|
char _format);
|
||||||
static int sendit __P((struct printer *pp, char *file));
|
static int sendit(struct printer *_pp, char *_file);
|
||||||
static void sendmail __P((struct printer *pp, char *user, int bombed));
|
static void sendmail(struct printer *_pp, char *_user, int _bombed);
|
||||||
static void setty __P((const struct printer *pp));
|
static void setty(const struct printer *_pp);
|
||||||
|
|
||||||
void
|
void
|
||||||
printjob(pp)
|
printjob(struct printer *pp)
|
||||||
struct printer *pp;
|
|
||||||
{
|
{
|
||||||
struct stat stb;
|
struct stat stb;
|
||||||
register struct jobqueue *q, **qp;
|
register struct jobqueue *q, **qp;
|
||||||
@ -349,9 +348,7 @@ char ifonts[4][40] = {
|
|||||||
* and performing the various actions.
|
* and performing the various actions.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
printit(pp, file)
|
printit(struct printer *pp, char *file)
|
||||||
struct printer *pp;
|
|
||||||
char *file;
|
|
||||||
{
|
{
|
||||||
register int i;
|
register int i;
|
||||||
char *cp;
|
char *cp;
|
||||||
@ -584,10 +581,7 @@ pass2:
|
|||||||
* stderr as the log file, and must not ignore SIGINT.
|
* stderr as the log file, and must not ignore SIGINT.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
print(pp, format, file)
|
print(struct printer *pp, int format, char *file)
|
||||||
struct printer *pp;
|
|
||||||
int format;
|
|
||||||
char *file;
|
|
||||||
{
|
{
|
||||||
register int n, i;
|
register int n, i;
|
||||||
register char *prog;
|
register char *prog;
|
||||||
@ -837,9 +831,7 @@ start:
|
|||||||
* 0 if all is well.
|
* 0 if all is well.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
sendit(pp, file)
|
sendit(struct printer *pp, char *file)
|
||||||
struct printer *pp;
|
|
||||||
char *file;
|
|
||||||
{
|
{
|
||||||
register int i, err = OK;
|
register int i, err = OK;
|
||||||
char *cp, last[BUFSIZ];
|
char *cp, last[BUFSIZ];
|
||||||
@ -946,11 +938,7 @@ sendit(pp, file)
|
|||||||
* Return positive if we should try resending.
|
* Return positive if we should try resending.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
sendfile(pp, type, file, format)
|
sendfile(struct printer *pp, int type, char *file, char format)
|
||||||
struct printer *pp;
|
|
||||||
int type;
|
|
||||||
char *file;
|
|
||||||
char format;
|
|
||||||
{
|
{
|
||||||
register int f, i, amt;
|
register int f, i, amt;
|
||||||
struct stat stb;
|
struct stat stb;
|
||||||
@ -1188,8 +1176,7 @@ sendfile(pp, type, file, format)
|
|||||||
* Return non-zero if the connection was lost.
|
* Return non-zero if the connection was lost.
|
||||||
*/
|
*/
|
||||||
static char
|
static char
|
||||||
response(pp)
|
response(const struct printer *pp)
|
||||||
const struct printer *pp;
|
|
||||||
{
|
{
|
||||||
char resp;
|
char resp;
|
||||||
|
|
||||||
@ -1204,9 +1191,7 @@ response(pp)
|
|||||||
* Banner printing stuff
|
* Banner printing stuff
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
banner(pp, name1, name2)
|
banner(struct printer *pp, char *name1, char *name2)
|
||||||
struct printer *pp;
|
|
||||||
char *name1, *name2;
|
|
||||||
{
|
{
|
||||||
time_t tvec;
|
time_t tvec;
|
||||||
|
|
||||||
@ -1245,10 +1230,7 @@ banner(pp, name1, name2)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
scnline(key, p, c)
|
scnline(int key, char *p, int c)
|
||||||
register int key;
|
|
||||||
register char *p;
|
|
||||||
int c;
|
|
||||||
{
|
{
|
||||||
register int scnwidth;
|
register int scnwidth;
|
||||||
|
|
||||||
@ -1262,10 +1244,7 @@ scnline(key, p, c)
|
|||||||
#define TRC(q) (((q)-' ')&0177)
|
#define TRC(q) (((q)-' ')&0177)
|
||||||
|
|
||||||
static void
|
static void
|
||||||
scan_out(pp, scfd, scsp, dlm)
|
scan_out(struct printer *pp, int scfd, char *scsp, int dlm)
|
||||||
struct printer *pp;
|
|
||||||
int scfd, dlm;
|
|
||||||
char *scsp;
|
|
||||||
{
|
{
|
||||||
register char *strp;
|
register char *strp;
|
||||||
register int nchrs, j;
|
register int nchrs, j;
|
||||||
@ -1297,8 +1276,7 @@ scan_out(pp, scfd, scsp, dlm)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
dropit(c)
|
dropit(int c)
|
||||||
int c;
|
|
||||||
{
|
{
|
||||||
switch(c) {
|
switch(c) {
|
||||||
|
|
||||||
@ -1322,14 +1300,11 @@ dropit(c)
|
|||||||
* tell people about job completion
|
* tell people about job completion
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
sendmail(pp, user, bombed)
|
sendmail(struct printer *pp, char *user, int bombed)
|
||||||
struct printer *pp;
|
|
||||||
char *user;
|
|
||||||
int bombed;
|
|
||||||
{
|
{
|
||||||
register int i;
|
register int i;
|
||||||
int p[2], s;
|
int p[2], s;
|
||||||
register char *cp;
|
register const char *cp;
|
||||||
struct stat stb;
|
struct stat stb;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
|
||||||
@ -1402,22 +1377,20 @@ sendmail(pp, user, bombed)
|
|||||||
* dofork - fork with retries on failure
|
* dofork - fork with retries on failure
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
dofork(pp, action)
|
dofork(const struct printer *pp, int action)
|
||||||
const struct printer *pp;
|
|
||||||
int action;
|
|
||||||
{
|
{
|
||||||
register int i, pid;
|
register int i, forkpid;
|
||||||
struct passwd *pwd;
|
struct passwd *pwd;
|
||||||
|
|
||||||
for (i = 0; i < 20; i++) {
|
for (i = 0; i < 20; i++) {
|
||||||
if ((pid = fork()) < 0) {
|
if ((forkpid = fork()) < 0) {
|
||||||
sleep((unsigned)(i*i));
|
sleep((unsigned)(i*i));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Child should run as daemon instead of root
|
* Child should run as daemon instead of root
|
||||||
*/
|
*/
|
||||||
if (pid == 0) {
|
if (forkpid == 0) {
|
||||||
if ((pwd = getpwuid(pp->daemon_user)) == NULL) {
|
if ((pwd = getpwuid(pp->daemon_user)) == NULL) {
|
||||||
syslog(LOG_ERR, "Can't lookup default daemon uid (%ld) in password file",
|
syslog(LOG_ERR, "Can't lookup default daemon uid (%ld) in password file",
|
||||||
pp->daemon_user);
|
pp->daemon_user);
|
||||||
@ -1427,7 +1400,7 @@ dofork(pp, action)
|
|||||||
setgid(pwd->pw_gid);
|
setgid(pwd->pw_gid);
|
||||||
setuid(pp->daemon_user);
|
setuid(pp->daemon_user);
|
||||||
}
|
}
|
||||||
return(pid);
|
return(forkpid);
|
||||||
}
|
}
|
||||||
syslog(LOG_ERR, "can't fork");
|
syslog(LOG_ERR, "can't fork");
|
||||||
|
|
||||||
@ -1447,8 +1420,7 @@ dofork(pp, action)
|
|||||||
* Kill child processes to abort current job.
|
* Kill child processes to abort current job.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
abortpr(signo)
|
abortpr(int signo __unused)
|
||||||
int signo;
|
|
||||||
{
|
{
|
||||||
|
|
||||||
(void) unlink(tempstderr);
|
(void) unlink(tempstderr);
|
||||||
@ -1463,8 +1435,7 @@ abortpr(signo)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
init(pp)
|
init(struct printer *pp)
|
||||||
struct printer *pp;
|
|
||||||
{
|
{
|
||||||
char *s;
|
char *s;
|
||||||
|
|
||||||
@ -1479,8 +1450,7 @@ init(pp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
startprinting(printer)
|
startprinting(const char *printer)
|
||||||
const char *printer;
|
|
||||||
{
|
{
|
||||||
struct printer myprinter, *pp = &myprinter;
|
struct printer myprinter, *pp = &myprinter;
|
||||||
int status;
|
int status;
|
||||||
@ -1506,8 +1476,7 @@ startprinting(printer)
|
|||||||
* Acquire line printer or remote connection.
|
* Acquire line printer or remote connection.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
openpr(pp)
|
openpr(const struct printer *pp)
|
||||||
const struct printer *pp;
|
|
||||||
{
|
{
|
||||||
int p[2];
|
int p[2];
|
||||||
char *cp;
|
char *cp;
|
||||||
@ -1562,8 +1531,7 @@ openpr(pp)
|
|||||||
* or to a terminal server on the net
|
* or to a terminal server on the net
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
opennet(pp)
|
opennet(const struct printer *pp)
|
||||||
const struct printer *pp;
|
|
||||||
{
|
{
|
||||||
register int i;
|
register int i;
|
||||||
int resp;
|
int resp;
|
||||||
@ -1615,8 +1583,7 @@ opennet(pp)
|
|||||||
* Printer is connected to an RS232 port on this host
|
* Printer is connected to an RS232 port on this host
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
opentty(pp)
|
opentty(const struct printer *pp)
|
||||||
const struct printer *pp;
|
|
||||||
{
|
{
|
||||||
register int i;
|
register int i;
|
||||||
|
|
||||||
@ -1645,8 +1612,7 @@ opentty(pp)
|
|||||||
* Printer is on a remote host
|
* Printer is on a remote host
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
openrem(pp)
|
openrem(const struct printer *pp)
|
||||||
const struct printer *pp;
|
|
||||||
{
|
{
|
||||||
register int i;
|
register int i;
|
||||||
int resp;
|
int resp;
|
||||||
@ -1687,8 +1653,7 @@ openrem(pp)
|
|||||||
* setup tty lines.
|
* setup tty lines.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
setty(pp)
|
setty(const struct printer *pp)
|
||||||
const struct printer *pp;
|
|
||||||
{
|
{
|
||||||
struct termios ttybuf;
|
struct termios ttybuf;
|
||||||
|
|
||||||
@ -1756,7 +1721,8 @@ pstatus(pp, msg, va_alist)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
alarmhandler(signo)
|
alarmhandler(int signo __unused)
|
||||||
{
|
{
|
||||||
/* ignored */
|
/* the signal is ignored */
|
||||||
|
/* (the '__unused' is just to avoid a compile-time warning) */
|
||||||
}
|
}
|
||||||
|
@ -71,21 +71,20 @@ static const char rcsid[] =
|
|||||||
|
|
||||||
static char dfname[NAME_MAX]; /* data files */
|
static char dfname[NAME_MAX]; /* data files */
|
||||||
static int minfree; /* keep at least minfree blocks available */
|
static int minfree; /* keep at least minfree blocks available */
|
||||||
static char *sp = "";
|
static const char *sp = "";
|
||||||
static char tfname[NAME_MAX]; /* tmp copy of cf before linking */
|
static char tfname[NAME_MAX]; /* tmp copy of cf before linking */
|
||||||
|
|
||||||
static int chksize __P((int));
|
static int chksize(int _size);
|
||||||
static void frecverr __P((const char *, ...));
|
static void frecverr(const char *_msg, ...);
|
||||||
static int noresponse __P((void));
|
static int noresponse(void);
|
||||||
static void rcleanup __P((int));
|
static void rcleanup(int _signo);
|
||||||
static int read_number __P((char *));
|
static int read_number(const char *_fn);
|
||||||
static int readfile __P((struct printer *pp, char *, int));
|
static int readfile(struct printer *_pp, char *_file, int _size);
|
||||||
static int readjob __P((struct printer *pp));
|
static int readjob(struct printer *_pp);
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
recvjob(printer)
|
recvjob(const char *printer)
|
||||||
const char *printer;
|
|
||||||
{
|
{
|
||||||
struct stat stb;
|
struct stat stb;
|
||||||
int status;
|
int status;
|
||||||
@ -138,8 +137,7 @@ recvjob(printer)
|
|||||||
* Return the number of jobs successfully transfered.
|
* Return the number of jobs successfully transfered.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
readjob(pp)
|
readjob(struct printer *pp)
|
||||||
struct printer *pp;
|
|
||||||
{
|
{
|
||||||
register int size;
|
register int size;
|
||||||
register char *cp;
|
register char *cp;
|
||||||
@ -246,10 +244,7 @@ readjob(pp)
|
|||||||
* Read files send by lpd and copy them to the spooling directory.
|
* Read files send by lpd and copy them to the spooling directory.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
readfile(pp, file, size)
|
readfile(struct printer *pp, char *file, int size)
|
||||||
struct printer *pp;
|
|
||||||
char *file;
|
|
||||||
int size;
|
|
||||||
{
|
{
|
||||||
register char *cp;
|
register char *cp;
|
||||||
char buf[BUFSIZ];
|
char buf[BUFSIZ];
|
||||||
@ -301,7 +296,7 @@ readfile(pp, file, size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
noresponse()
|
noresponse(void)
|
||||||
{
|
{
|
||||||
char resp;
|
char resp;
|
||||||
|
|
||||||
@ -319,8 +314,7 @@ noresponse()
|
|||||||
* 1 == OK, 0 == Not OK.
|
* 1 == OK, 0 == Not OK.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
chksize(size)
|
chksize(int size)
|
||||||
int size;
|
|
||||||
{
|
{
|
||||||
int spacefree;
|
int spacefree;
|
||||||
struct statfs sfb;
|
struct statfs sfb;
|
||||||
@ -337,8 +331,7 @@ chksize(size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
read_number(fn)
|
read_number(const char *fn)
|
||||||
char *fn;
|
|
||||||
{
|
{
|
||||||
char lin[80];
|
char lin[80];
|
||||||
register FILE *fp;
|
register FILE *fp;
|
||||||
@ -357,8 +350,7 @@ read_number(fn)
|
|||||||
* Remove all the files associated with the current job being transfered.
|
* Remove all the files associated with the current job being transfered.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
rcleanup(signo)
|
rcleanup(int signo __unused)
|
||||||
int signo;
|
|
||||||
{
|
{
|
||||||
if (tfname[0] && strchr(tfname, '/') == NULL)
|
if (tfname[0] && strchr(tfname, '/') == NULL)
|
||||||
(void) unlink(tfname);
|
(void) unlink(tfname);
|
||||||
|
@ -77,17 +77,15 @@ int users; /* # of users in user array */
|
|||||||
|
|
||||||
uid_t uid, euid;
|
uid_t uid, euid;
|
||||||
|
|
||||||
static int ckqueue __P((const struct printer *));
|
static int ckqueue(const struct printer *_pp);
|
||||||
static void usage __P((void));
|
static void usage(void);
|
||||||
int main __P((int, char **));
|
int main(int _argc, char **_argv);
|
||||||
|
|
||||||
int
|
int
|
||||||
main(argc, argv)
|
main(int argc, char **argv)
|
||||||
int argc;
|
|
||||||
char **argv;
|
|
||||||
{
|
{
|
||||||
int ch, aflag, lflag;
|
int ch, aflag, lflag;
|
||||||
char *printer;
|
const char *printer;
|
||||||
struct printer myprinter, *pp = &myprinter;
|
struct printer myprinter, *pp = &myprinter;
|
||||||
|
|
||||||
printer = NULL;
|
printer = NULL;
|
||||||
@ -172,8 +170,7 @@ looperr:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
ckqueue(pp)
|
ckqueue(const struct printer *pp)
|
||||||
const struct printer *pp;
|
|
||||||
{
|
{
|
||||||
register struct dirent *d;
|
register struct dirent *d;
|
||||||
DIR *dirp;
|
DIR *dirp;
|
||||||
@ -193,7 +190,7 @@ ckqueue(pp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
usage()
|
usage(void)
|
||||||
{
|
{
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"usage: lpq [-a] [-l] [-Pprinter] [user ...] [job ...]\n");
|
"usage: lpq [-a] [-l] [-Pprinter] [user ...] [job ...]\n");
|
||||||
|
@ -88,7 +88,7 @@ static int hdr = 1; /* print header or not (default is yes) */
|
|||||||
static int iflag; /* indentation wanted */
|
static int iflag; /* indentation wanted */
|
||||||
static int inchar; /* location to increment char in file names */
|
static int inchar; /* location to increment char in file names */
|
||||||
static int indent; /* amount to indent */
|
static int indent; /* amount to indent */
|
||||||
static char *jobname; /* job name on header page */
|
static const char *jobname; /* job name on header page */
|
||||||
static int mailflg; /* send mail */
|
static int mailflg; /* send mail */
|
||||||
static int nact; /* number of jobs to act on */
|
static int nact; /* number of jobs to act on */
|
||||||
static int ncopies = 1; /* # of copies to make */
|
static int ncopies = 1; /* # of copies to make */
|
||||||
@ -107,30 +107,30 @@ static char *Zflag; /* extra filter options for LPRng servers */
|
|||||||
|
|
||||||
static struct stat statb;
|
static struct stat statb;
|
||||||
|
|
||||||
static void card __P((int, char *));
|
static void card(int _c, const char *_p2);
|
||||||
static int checkwriteperm __P((char*, char *));
|
static int checkwriteperm(const char *_file, const char *_directory);
|
||||||
static void chkprinter __P((char *printer, struct printer *pp));
|
static void chkprinter(const char *_ptrname, struct printer *_pp);
|
||||||
static void cleanup __P((int));
|
static void cleanup(int _signo);
|
||||||
static void copy __P((const struct printer *, int, char []));
|
static void copy(const struct printer *_pp, int _f, const char _n[]);
|
||||||
static char *itoa __P((int));
|
static char *itoa(int _i);
|
||||||
static char *linked __P((char *));
|
static const char *linked(const char *_file);
|
||||||
int main __P((int, char **));
|
int main(int _argc, char *_argv[]);
|
||||||
static char *lmktemp __P((const struct printer *pp, char *, int, int));
|
static char *lmktemp(const struct printer *_pp, const char *_id,
|
||||||
static void mktemps __P((const struct printer *pp));
|
int _num, int len);
|
||||||
static int nfile __P((char *));
|
static void mktemps(const struct printer *_pp);
|
||||||
static int test __P((char *));
|
static int nfile(char *_n);
|
||||||
static void usage __P((void));
|
static int test(const char *_file);
|
||||||
|
static void usage(void);
|
||||||
|
|
||||||
uid_t uid, euid;
|
uid_t uid, euid;
|
||||||
|
|
||||||
int
|
int
|
||||||
main(argc, argv)
|
main(int argc, char *argv[])
|
||||||
int argc;
|
|
||||||
char *argv[];
|
|
||||||
{
|
{
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
struct group *gptr;
|
struct group *gptr;
|
||||||
char *arg, *cp, *printer, *p;
|
const char *arg, *cp, *printer;
|
||||||
|
char *p;
|
||||||
char buf[BUFSIZ];
|
char buf[BUFSIZ];
|
||||||
int c, i, f, errs;
|
int c, i, f, errs;
|
||||||
int ret, didlink;
|
int ret, didlink;
|
||||||
@ -528,10 +528,7 @@ main(argc, argv)
|
|||||||
* Create the file n and copy from file descriptor f.
|
* Create the file n and copy from file descriptor f.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
copy(pp, f, n)
|
copy(const struct printer *pp, int f, const char n[])
|
||||||
const struct printer *pp;
|
|
||||||
int f;
|
|
||||||
char n[];
|
|
||||||
{
|
{
|
||||||
register int fd, i, nr, nc;
|
register int fd, i, nr, nc;
|
||||||
char buf[BUFSIZ];
|
char buf[BUFSIZ];
|
||||||
@ -571,9 +568,8 @@ copy(pp, f, n)
|
|||||||
* Try and link the file to dfname. Return a pointer to the full
|
* Try and link the file to dfname. Return a pointer to the full
|
||||||
* path name if successful.
|
* path name if successful.
|
||||||
*/
|
*/
|
||||||
static char *
|
static const char *
|
||||||
linked(file)
|
linked(const char *file)
|
||||||
register char *file;
|
|
||||||
{
|
{
|
||||||
register char *cp;
|
register char *cp;
|
||||||
static char buf[MAXPATHLEN];
|
static char buf[MAXPATHLEN];
|
||||||
@ -611,9 +607,7 @@ linked(file)
|
|||||||
* Put a line into the control file.
|
* Put a line into the control file.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
card(c, p2)
|
card(int c, const char *p2)
|
||||||
register int c;
|
|
||||||
register char *p2;
|
|
||||||
{
|
{
|
||||||
char buf[BUFSIZ];
|
char buf[BUFSIZ];
|
||||||
register char *p1 = buf;
|
register char *p1 = buf;
|
||||||
@ -632,8 +626,7 @@ card(c, p2)
|
|||||||
* Create a new file in the spool directory.
|
* Create a new file in the spool directory.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
nfile(n)
|
nfile(char *n)
|
||||||
char *n;
|
|
||||||
{
|
{
|
||||||
register int f;
|
register int f;
|
||||||
int oldumask = umask(0); /* should block signals */
|
int oldumask = umask(0); /* should block signals */
|
||||||
@ -665,8 +658,7 @@ nfile(n)
|
|||||||
* Cleanup after interrupts and errors.
|
* Cleanup after interrupts and errors.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
cleanup(signo)
|
cleanup(int signo __unused)
|
||||||
int signo;
|
|
||||||
{
|
{
|
||||||
register int i;
|
register int i;
|
||||||
|
|
||||||
@ -700,8 +692,7 @@ cleanup(signo)
|
|||||||
* we should remove it after printing.
|
* we should remove it after printing.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
test(file)
|
test(const char *file)
|
||||||
char *file;
|
|
||||||
{
|
{
|
||||||
struct exec execb;
|
struct exec execb;
|
||||||
char *path;
|
char *path;
|
||||||
@ -765,8 +756,7 @@ error1:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
checkwriteperm(file, directory)
|
checkwriteperm(const char *file, const char *directory)
|
||||||
char *file, *directory;
|
|
||||||
{
|
{
|
||||||
struct stat stats;
|
struct stat stats;
|
||||||
if (access(directory, W_OK) == 0) {
|
if (access(directory, W_OK) == 0) {
|
||||||
@ -785,8 +775,7 @@ checkwriteperm(file, directory)
|
|||||||
* itoa - integer to string conversion
|
* itoa - integer to string conversion
|
||||||
*/
|
*/
|
||||||
static char *
|
static char *
|
||||||
itoa(i)
|
itoa(int i)
|
||||||
register int i;
|
|
||||||
{
|
{
|
||||||
static char b[10] = "########";
|
static char b[10] = "########";
|
||||||
register char *p;
|
register char *p;
|
||||||
@ -802,22 +791,20 @@ itoa(i)
|
|||||||
* Perform lookup for printer name or abbreviation --
|
* Perform lookup for printer name or abbreviation --
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
chkprinter(s, pp)
|
chkprinter(const char *ptrname, struct printer *pp)
|
||||||
char *s;
|
|
||||||
struct printer *pp;
|
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
init_printer(pp);
|
init_printer(pp);
|
||||||
status = getprintcap(s, pp);
|
status = getprintcap(ptrname, pp);
|
||||||
switch(status) {
|
switch(status) {
|
||||||
case PCAPERR_OSERR:
|
case PCAPERR_OSERR:
|
||||||
case PCAPERR_TCLOOP:
|
case PCAPERR_TCLOOP:
|
||||||
errx(1, "%s: %s", s, pcaperr(status));
|
errx(1, "%s: %s", ptrname, pcaperr(status));
|
||||||
case PCAPERR_NOTFOUND:
|
case PCAPERR_NOTFOUND:
|
||||||
errx(1, "%s: unknown printer", s);
|
errx(1, "%s: unknown printer", ptrname);
|
||||||
case PCAPERR_TCOPEN:
|
case PCAPERR_TCOPEN:
|
||||||
warnx("%s: unresolved tc= reference(s)", s);
|
warnx("%s: unresolved tc= reference(s)", ptrname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -825,7 +812,7 @@ chkprinter(s, pp)
|
|||||||
* Tell the user what we wanna get.
|
* Tell the user what we wanna get.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
usage()
|
usage(void)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s\n",
|
fprintf(stderr, "%s\n",
|
||||||
"usage: lpr [-Pprinter] [-#num] [-C class] [-J job] [-T title] [-U user]\n"
|
"usage: lpr [-Pprinter] [-#num] [-C class] [-J job] [-T title] [-U user]\n"
|
||||||
@ -839,8 +826,7 @@ usage()
|
|||||||
* Make the temp files.
|
* Make the temp files.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
mktemps(pp)
|
mktemps(const struct printer *pp)
|
||||||
const struct printer *pp;
|
|
||||||
{
|
{
|
||||||
register int len, fd, n;
|
register int len, fd, n;
|
||||||
register char *cp;
|
register char *cp;
|
||||||
@ -881,10 +867,7 @@ mktemps(pp)
|
|||||||
* Make a temp file name.
|
* Make a temp file name.
|
||||||
*/
|
*/
|
||||||
static char *
|
static char *
|
||||||
lmktemp(pp, id, num, len)
|
lmktemp(const struct printer *pp, const char *id, int num, int len)
|
||||||
const struct printer *pp;
|
|
||||||
char *id;
|
|
||||||
int num, len;
|
|
||||||
{
|
{
|
||||||
register char *s;
|
register char *s;
|
||||||
|
|
||||||
|
@ -82,15 +82,14 @@ uid_t uid, euid; /* real and effective user id's */
|
|||||||
|
|
||||||
static char luser[16]; /* buffer for person */
|
static char luser[16]; /* buffer for person */
|
||||||
|
|
||||||
int main __P((int, char *[]));
|
int main(int argc, char *_argv[]);
|
||||||
static void usage __P((void));
|
static void usage(void);
|
||||||
|
|
||||||
int
|
int
|
||||||
main(argc, argv)
|
main(int argc, char *argv[])
|
||||||
int argc;
|
|
||||||
char *argv[];
|
|
||||||
{
|
{
|
||||||
char *arg, *printer;
|
char *arg;
|
||||||
|
const char *printer;
|
||||||
struct passwd *p;
|
struct passwd *p;
|
||||||
static char root[] = "root";
|
static char root[] = "root";
|
||||||
|
|
||||||
@ -158,7 +157,7 @@ main(argc, argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
usage()
|
usage(void)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "usage: lprm [-] [-Pprinter] [[job #] [user] ...]\n");
|
fprintf(stderr, "usage: lprm [-] [-Pprinter] [[job #] [user] ...]\n");
|
||||||
exit(2);
|
exit(2);
|
||||||
|
@ -39,7 +39,11 @@ static char copyright[] =
|
|||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
|
#if 0
|
||||||
static char sccsid[] = "@(#)lptest.c 8.1 (Berkeley) 6/6/93";
|
static char sccsid[] = "@(#)lptest.c 8.1 (Berkeley) 6/6/93";
|
||||||
|
#endif
|
||||||
|
static const char rcsid[] =
|
||||||
|
"$FreeBSD$";
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -49,12 +53,10 @@ static char sccsid[] = "@(#)lptest.c 8.1 (Berkeley) 6/6/93";
|
|||||||
* lptest -- line printer test program (and other devices).
|
* lptest -- line printer test program (and other devices).
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
main(argc, argv)
|
main(int argc, char **argv)
|
||||||
int argc;
|
|
||||||
char **argv;
|
|
||||||
{
|
{
|
||||||
int len, count;
|
int len, count;
|
||||||
register i, j, fc, nc;
|
register int i, j, fc, nc;
|
||||||
char outbuf[BUFSIZ];
|
char outbuf[BUFSIZ];
|
||||||
|
|
||||||
setbuf(stdout, outbuf);
|
setbuf(stdout, outbuf);
|
||||||
|
@ -96,25 +96,23 @@ struct hent {
|
|||||||
|
|
||||||
static struct hent *hashtab[HSHSIZE]; /* Hash table proper */
|
static struct hent *hashtab[HSHSIZE]; /* Hash table proper */
|
||||||
|
|
||||||
int main __P((int, char **));
|
int main(int argc, char **_argv);
|
||||||
static void account __P((FILE *));
|
static void account(FILE *_acct);
|
||||||
static int any __P((int, char []));
|
static int any(int _ch, const char _str[]);
|
||||||
static int chkprinter __P((char *));
|
static int chkprinter(const char *_ptrname);
|
||||||
static void dumpit __P((void));
|
static void dumpit(void);
|
||||||
static int hash __P((char []));
|
static int hash(const char _name[]);
|
||||||
static struct hent *enter __P((char []));
|
static struct hent *enter(const char _name[]);
|
||||||
static struct hent *lookup __P((char []));
|
static struct hent *lookup(const char _name[]);
|
||||||
static int qucmp __P((const void *, const void *));
|
static int qucmp(const void *_a, const void *_b);
|
||||||
static void rewrite __P((void));
|
static void rewrite(void);
|
||||||
static void usage __P((void));
|
static void usage(void);
|
||||||
|
|
||||||
int
|
int
|
||||||
main(argc, argv)
|
main(int argc, char **argv)
|
||||||
int argc;
|
|
||||||
char **argv;
|
|
||||||
{
|
{
|
||||||
FILE *acct;
|
FILE *acct;
|
||||||
char *cp, *printer;
|
const char *cp, *printer;
|
||||||
|
|
||||||
printer = NULL;
|
printer = NULL;
|
||||||
euid = geteuid(); /* these aren't used in pac(1) */
|
euid = geteuid(); /* these aren't used in pac(1) */
|
||||||
@ -198,7 +196,7 @@ main(argc, argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
usage()
|
usage(void)
|
||||||
{
|
{
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"usage: pac [-Pprinter] [-pprice] [-s] [-c] [-r] [-m] [user ...]\n");
|
"usage: pac [-Pprinter] [-pprice] [-s] [-c] [-r] [-m] [user ...]\n");
|
||||||
@ -214,8 +212,7 @@ usage()
|
|||||||
* Host names are ignored if the -m flag is present.
|
* Host names are ignored if the -m flag is present.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
account(acct)
|
account(FILE *acct)
|
||||||
register FILE *acct;
|
|
||||||
{
|
{
|
||||||
char linebuf[BUFSIZ];
|
char linebuf[BUFSIZ];
|
||||||
double t;
|
double t;
|
||||||
@ -257,7 +254,7 @@ account(acct)
|
|||||||
* and print it all out.
|
* and print it all out.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
dumpit()
|
dumpit(void)
|
||||||
{
|
{
|
||||||
struct hent **base;
|
struct hent **base;
|
||||||
register struct hent *hp, **ap;
|
register struct hent *hp, **ap;
|
||||||
@ -295,7 +292,7 @@ dumpit()
|
|||||||
* Rewrite the summary file with the summary information we have accumulated.
|
* Rewrite the summary file with the summary information we have accumulated.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
rewrite()
|
rewrite(void)
|
||||||
{
|
{
|
||||||
register struct hent *hp;
|
register struct hent *hp;
|
||||||
register int i;
|
register int i;
|
||||||
@ -335,8 +332,7 @@ rewrite()
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
static struct hent *
|
static struct hent *
|
||||||
enter(name)
|
enter(const char name[])
|
||||||
char name[];
|
|
||||||
{
|
{
|
||||||
register struct hent *hp;
|
register struct hent *hp;
|
||||||
register int h;
|
register int h;
|
||||||
@ -361,8 +357,7 @@ enter(name)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
static struct hent *
|
static struct hent *
|
||||||
lookup(name)
|
lookup(const char name[])
|
||||||
char name[];
|
|
||||||
{
|
{
|
||||||
register int h;
|
register int h;
|
||||||
register struct hent *hp;
|
register struct hent *hp;
|
||||||
@ -379,11 +374,10 @@ lookup(name)
|
|||||||
* the hash table to begin the search.
|
* the hash table to begin the search.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
hash(name)
|
hash(const char name[])
|
||||||
char name[];
|
|
||||||
{
|
{
|
||||||
register int h;
|
register int h;
|
||||||
register char *cp;
|
register const char *cp;
|
||||||
|
|
||||||
for (cp = name, h = 0; *cp; h = (h << 2) + *cp++)
|
for (cp = name, h = 0; *cp; h = (h << 2) + *cp++)
|
||||||
;
|
;
|
||||||
@ -394,12 +388,10 @@ hash(name)
|
|||||||
* Other stuff
|
* Other stuff
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
any(ch, str)
|
any(int ch, const char str[])
|
||||||
int ch;
|
|
||||||
char str[];
|
|
||||||
{
|
{
|
||||||
register int c = ch;
|
register int c = ch;
|
||||||
register char *cp = str;
|
register const char *cp = str;
|
||||||
|
|
||||||
while (*cp)
|
while (*cp)
|
||||||
if (*cp++ == c)
|
if (*cp++ == c)
|
||||||
@ -413,14 +405,13 @@ any(ch, str)
|
|||||||
* or by feet of typesetter film, according to sort.
|
* or by feet of typesetter film, according to sort.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
qucmp(a, b)
|
qucmp(const void *a, const void *b)
|
||||||
const void *a, *b;
|
|
||||||
{
|
{
|
||||||
register struct hent *h1, *h2;
|
register const struct hent *h1, *h2;
|
||||||
register int r;
|
register int r;
|
||||||
|
|
||||||
h1 = *(struct hent **)a;
|
h1 = *(const struct hent **)a;
|
||||||
h2 = *(struct hent **)b;
|
h2 = *(const struct hent **)b;
|
||||||
if (sort)
|
if (sort)
|
||||||
r = h1->h_feetpages < h2->h_feetpages ?
|
r = h1->h_feetpages < h2->h_feetpages ?
|
||||||
-1 : h1->h_feetpages > h2->h_feetpages;
|
-1 : h1->h_feetpages > h2->h_feetpages;
|
||||||
@ -433,14 +424,13 @@ qucmp(a, b)
|
|||||||
* Perform lookup for printer name or abbreviation --
|
* Perform lookup for printer name or abbreviation --
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
chkprinter(s)
|
chkprinter(const char *ptrname)
|
||||||
register char *s;
|
|
||||||
{
|
{
|
||||||
int stat;
|
int stat;
|
||||||
struct printer myprinter, *pp = &myprinter;
|
struct printer myprinter, *pp = &myprinter;
|
||||||
|
|
||||||
init_printer(&myprinter);
|
init_printer(&myprinter);
|
||||||
stat = getprintcap(s, pp);
|
stat = getprintcap(ptrname, pp);
|
||||||
switch(stat) {
|
switch(stat) {
|
||||||
case PCAPERR_OSERR:
|
case PCAPERR_OSERR:
|
||||||
printf("pac: getprintcap: %s\n", pcaperr(stat));
|
printf("pac: getprintcap: %s\n", pcaperr(stat));
|
||||||
@ -451,7 +441,7 @@ chkprinter(s)
|
|||||||
fatal(pp, "%s", pcaperr(stat));
|
fatal(pp, "%s", pcaperr(stat));
|
||||||
}
|
}
|
||||||
if ((acctfile = pp->acct_file) == NULL)
|
if ((acctfile = pp->acct_file) == NULL)
|
||||||
errx(3, "accounting not enabled for printer %s", s);
|
errx(3, "accounting not enabled for printer %s", ptrname);
|
||||||
if (!pflag && pp->price100)
|
if (!pflag && pp->price100)
|
||||||
price = pp->price100/10000.0;
|
price = pp->price100/10000.0;
|
||||||
sumfile = (char *) calloc(sizeof(char), strlen(acctfile)+5);
|
sumfile = (char *) calloc(sizeof(char), strlen(acctfile)+5);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user