static char sccsid
[] = "@(#)lpc.c 4.4 (Berkeley) 7/17/83";
* lpc -- line printer control program
if (c
== (struct cmd
*)-1) {
printf("?Ambiguous command\n");
printf("?Invalid command\n");
if (c
->c_priv
&& getuid()) {
printf("?Privileged command\n");
(*c
->c_handler
)(argc
, argv
);
fromatty
= isatty(fileno(stdin
));
top
= setjmp(toplevel
) == 0;
extern struct cmd cmdtab
[];
if (c
== (struct cmd
*)-1) {
printf("?Ambiguous command\n");
printf("?Invalid command\n");
if (c
->c_priv
&& getuid()) {
printf("?Privileged command\n");
(*c
->c_handler
)(margc
, margv
);
register struct cmd
*c
, *found
;
register int nmatches
, longest
;
for (c
= cmdtab
; p
= c
->c_name
; c
++) {
for (q
= name
; *q
== *p
++; q
++)
if (*q
== 0) /* exact match? */
if (!*q
) { /* the name was a prefix */
if (q
- name
> longest
) {
} else if (q
- name
== longest
)
return((struct cmd
*)-1);
* Slice a string up into argc/argv.
register char **argp
= margv
;
for (cp
= cmdline
; *cp
;) {
while (*cp
!= '\0' && !isspace(*cp
))
#define HELPINDENT (sizeof ("directory"))
int columns
, width
= 0, lines
;
printf("Commands may be abbreviated. Commands are:\n\n");
for (c
= cmdtab
; c
< &cmdtab
[NCMDS
]; c
++) {
int len
= strlen(c
->c_name
);
width
= (width
+ 8) &~ 7;
lines
= (NCMDS
+ columns
- 1) / columns
;
for (i
= 0; i
< lines
; i
++) {
for (j
= 0; j
< columns
; j
++) {
c
= cmdtab
+ j
* lines
+ i
;
if (c
+ lines
>= &cmdtab
[NCMDS
]) {
if (c
== (struct cmd
*)-1)
printf("?Ambiguous help command %s\n", arg
);
else if (c
== (struct cmd
*)0)
printf("?Invalid help command %s\n", arg
);
printf("%-*s\t%s\n", HELPINDENT
,