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