|
|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T h
Length: 1708 (0x6ac)
Types: TextFile
Names: »help.c«
└─⟦87ddcff64⟧ Bits:30001253 CPHDIST85 Tape, 1985 Autumn Conference Copenhagen
└─⟦this⟧ »cph85dist/rman/daemon/help.c«
#ifndef lint
static char *RCSid = "$Header: help.c,v 1.3 85/07/16 11:08:41 broome Exp $";
#endif
/*
* $Log: help.c,v $
* Revision 1.3 85/07/16 11:08:41 broome
* Fixed to print error message when can't open help file.
*
* Revision 1.2 85/07/06 16:55:53 broome
*
*
* Revision 1.1 85/06/25 11:23:35 broome
* Initial revision
*/
#include <stdio.h>
#include "response.h"
#ifndef HELPFILE
#define HELPFILE "/usr/lib/mand.hf"
#endif
static FILE *hp = (FILE *) NULL; /* help file pointer */
help (argc, argv)
int argc;
char *argv[];
{
char buf[80];
int slen, found = 0;
char *subj;
char *i, *index();
if (argc == 1) /* no args, use "mand" */
subj = "mand";
else
subj = argv[1];
slen = strlen (subj);
if (hp == (FILE *) NULL) /* haven't opened help file yet */
if ((hp = fopen (HELPFILE, "r")) == (FILE *) NULL) {
printf ("%d Cannot open help file (%s)\r\n", ERR_HLPFILE, HELPFILE);
(void) fflush (stdout);
return (ERR_HLPFILE);
}
fseek (hp, 0L, 0); /* go to top of file */
while (fgets (buf, 80, hp)) {
if (strncmp (buf, subj, slen)) /* subject doesn't match */
continue;
buf[strlen(buf)-1] = '\0'; /* zap the '\n' */
if (i = index (buf, '\t')) /* tabs separate name from info */
printf ("%d-%s\r\n", INFO_HELP, ++i);
found++;
}
if (found)
printf ("%d End of HELP info for \"%s\"\r\n", INFO_HELP, subj);
else
printf ("%d HELP topic \"%s\" unknown\r\n", ERR_NOHELP, subj);
fflush (stdout);
return (found != 0);
}