Deleted Added
sdiff udiff text old ( 50479 ) new ( 78146 )
full compact
1/*
2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 29 unchanged lines hidden (view full) ---

38 The Regents of the University of California. All rights reserved.\n";
39#endif /* not lint */
40
41#ifndef lint
42/*
43static char sccsid[] = "@(#)lpq.c 8.3 (Berkeley) 5/10/95";
44*/
45static const char rcsid[] =
46 "$FreeBSD: head/usr.sbin/lpr/lpq/lpq.c 78146 2001-06-12 16:38:20Z gad $";
47#endif /* not lint */
48
49/*
50 * Spool Queue examination program
51 *
52 * lpq [-a] [-l] [-Pprinter] [user...] [job...]
53 *
54 * -a show all non-null queues on the local machine

--- 17 unchanged lines hidden (view full) ---

72
73int requ[MAXREQUESTS]; /* job number of spool entries */
74int requests; /* # of spool requests */
75char *user[MAXUSERS]; /* users to process */
76int users; /* # of users in user array */
77
78uid_t uid, euid;
79
80static int ckqueue(const struct printer *_pp);
81static void usage(void);
82int main(int _argc, char **_argv);
83
84int
85main(int argc, char **argv)
86{
87 int ch, aflag, lflag;
88 const char *printer;
89 struct printer myprinter, *pp = &myprinter;
90
91 printer = NULL;
92 euid = geteuid();
93 uid = getuid();
94 seteuid(uid);
95 name = *argv;
96 if (gethostname(host, sizeof(host)))

--- 68 unchanged lines hidden (view full) ---

165 fatal(pp, pcaperr(status));
166
167 displayq(pp, lflag);
168 }
169 exit(0);
170}
171
172static int
173ckqueue(const struct printer *pp)
174{
175 register struct dirent *d;
176 DIR *dirp;
177 char *spooldir;
178
179 spooldir = pp->spool_dir;
180 if ((dirp = opendir(spooldir)) == NULL)
181 return (-1);
182 while ((d = readdir(dirp)) != NULL) {
183 if (d->d_name[0] != 'c' || d->d_name[1] != 'f')
184 continue; /* daemon control files only */
185 closedir(dirp);
186 return (1); /* found something */
187 }
188 closedir(dirp);
189 return (0);
190}
191
192static void
193usage(void)
194{
195 fprintf(stderr,
196 "usage: lpq [-a] [-l] [-Pprinter] [user ...] [job ...]\n");
197 exit(1);
198}