# include "../hdr/defines.h"
static char Sccsid
[] = "@(#)help.c 4.2 %G%";
Program to locate helpful info in an ascii file.
The program accepts a variable number of arguments.
The file to be searched is determined from the argument. If the
argument does not contain numerics, the search
will be attempted on '/usr/local/lib/help/cmds', with the search key
being the whole argument.
If the argument begins with non-numerics but contains
numerics (e.g, zz32) the search will be attempted on
'/usr/local/lib/help/<non-numeric prefix>', (e.g,/usr/lib/help/zz),
with the search key being <remainder of arg>, (e.g., 32).
If the argument is all numeric, or if the file as
determined above does not exist, the search will be attempted on
'/usr/local/lib/sccs.hf', which is the old help file, with the
search key being the entire argument.
In no case will more than one search per argument be performed.
File is formatted as follows:
The "str?" that matches the key is found and
the following text lines are printed.
If the argument is omitted, the program requests it.
char oldfile
[] = "/usr/local/lib/sccs.hf";
char helpdir
[] = "/usr/local/lib/help/";
Tell 'fatal' to issue messages, clean up, and return to its caller.
Fflags
= FTLMSG
| FTLCLN
| FTLJMP
;
findprt(ask()); /* ask user for argument */
for (i
= 1; i
< argc
; i
++)
if (setjmp(Fjmp
)) /* set up to return here from */
return; /* 'fatal' and return to 'main' */
fatal("argument too long (he2)");
while (*q
&& !numeric(*q
))
if (*q
== '\0') { /* all alphabetics */
cat(hfile
,helpdir
,"cmds",0);
if (q
== p
) { /* first char numeric */
else { /* first char alpha, then numeric */
copy(p
,key
); /* key used as temporary */
cat(hfile
,helpdir
,key
,0);
Now read file, looking for key.
while ((q
= fgets(line
,512,iop
)) != NULL
) {
repl(line
,'\n','\0'); /* replace newline char */
if (line
[0] == '-' && equal(&line
[1],key
))
if (q
== NULL
) { /* endfile? */
fatal(sprintf(Error
,"%s not found (he1)",p
));
while (fgets(line
,512,iop
) != NULL
&& line
[0] == '-')
} while (fgets(line
,512,iop
) != NULL
&& line
[0] != '-');
printf("msg number or comd name? ");
return(repl(resp
,'\n','\0'));