static char sccsid
[] = "@(#)lpq.c 4.5 (Berkeley) 7/17/83";
* Spool Queue examination program
* lpq [+[n]] [-Pprinter] [user...] [job...]
* + means continually scan queue until empty
* -P used to identify printer as per lpr/lprm
char *user
[MAXUSERS
]; /* users to process */
int users
; /* # of users in user array */
int requ
[MAXREQUESTS
]; /* job number of spool entries */
int requests
; /* # of spool requests */
static int repeat
; /* + flag indicator */
static int slptime
= 30; /* pause between screen refereshes */
static int lflag
; /* long output option */
* Termcap stuff for fancy display
static int dumb
; /* whether to use capabilities */
static char PC
; /* pad character for output */
static char *UP
; /* up one line */
static char *BC
; /* backspace character, other than \b */
static char *CM
; /* cursor motion */
static char *CL
; /* clear display */
static char *TI
; /* terminal init for CM */
static char *TE
; /* terminal clear for CM */
static char *SO
; /* stand out start */
static char *SE
; /* stand out end */
int putch(); /* for tputs' */
gethostname(host
, sizeof(host
));
if ((arg
= *++argv
)[0] == '+') {
if ((n
= atoi(&arg
[1])) > 0)
} else if (arg
[0] == '-')
case 'P': /* printer name */
case 'l': /* long output */
if (requests
>= MAXREQUESTS
)
fatal("too many requests");
requ
[requests
++] = atoi(arg
);
if (printer
== NULL
&& (printer
= getenv("PRINTER")) == NULL
)
tputs(tgoto(CM
, 0, 0), 0, putch
);
if ((n
= displayq(lflag
)) > 0)
standout(stdout
, "Hit return to continue");
while (getchar() != '\n');
printf("usage: lpq [-Pprinter] [-l] [+[n]] [user...] [job...]\n");
* If we have the capability, print this in standout mode
"bc", "cl", "cm", "so", "se", "ti", "te", "up",
&BC
, &CL
, &CM
, &SO
, &SE
, &TI
, &TE
, &UP
,
* All we need from termcap is to clear screen and
* position cursor at the top; if these aren't available
* we say the terminal is dumb and let things scroll
char *term
, tbuf
[BUFSIZ
];
static char buf
[BUFSIZ
/2];
register char **p
, ***q
, *cp
;
ioctl(0, TIOCGETP
, (char *)&sbuf
);
if ((term
= getenv("TERM")) != NULL
&& tgetent(tbuf
, term
) > 0) {
for (p
= capstrings
, q
= caps
; *p
!= NULL
; p
++, q
++)
if ((cp
= tgetstr("pc", &bp
)) != NULL
)
return(CL
== NULL
|| CM
== NULL
);
* Putchar writearound for tputs