1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
|
/* Copyright (c) 1996--1999 Geoff Pike. */
/* All rights reserved. */
/* Floater is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */
/* This software is provided "as is" and comes with absolutely no */
/* warranties. Geoff Pike is not liable for damages under any */
/* circumstances. Support is not provided. Use at your own risk. */
/* Personal, non-commercial use is allowed. Attempting to make money */
/* from Floater or products or code derived from Floater is not allowed */
/* without prior written consent from Geoff Pike. Anything that remotely */
/* involves commercialism, including (but not limited to) systems that */
/* show advertisements while being used and systems that collect */
/* information on users that is later sold or traded require prior */
/* written consent from Geoff Pike. */
#include "floater.h"
#include "tickler.h"
#include "floatcmd.h"
extern char *helpdescriptions;
extern char *helpcommands;
/* find the text in helpdescriptions that starts with a tab character followed
by the given string, and ends with a tab character */
static void lookuphelp(char *s)
{
char *t = helpdescriptions;
int len = strlen(s);
for (;;) {
while (*t != '\0' && *t != '\t') t++;
if (*t == '\0') {
helpmsg3("No help available for `", s, "'");
return;
}
t++; /* advance over tab */
if (strncasecmp(s, t, len) == 0) {
/* found it */
s = t = TEMPCOPY(t);
while (*t != '\n') t++;
*t = '\0';
helpmsg3("`", s, "'");
s = t = t + 1;
while (*t != '\0') {
if (*t == '\t') {
*t = '\0';
goto done;
}
if (*t == '\n') {
*t = ' ';
}
t++;
}
done:
helpmsg(s);
return;
}
}
}
static void dumphelpable(void)
{
/*
helpmsg("What follows is a list of commands for which hand written descriptions are available. For a complete list of commands, use `commands.'");
*/
helpmsg("What follows is a list of commands for which hand written descriptions are available. For example, for help on the claim command, do `help claim.' See the Floater WWW page for more information.");
talkmsg(helpcommands);
}
/* a request for help on s */
void help(char *s)
{
if (*s == '\0' || strcaseeq(s, "help")) {
/* no arguments: just print out all commands for which we have help */
dumphelpable();
return;
}
if ((s = helpstring_to_command(s)) == NULL) return;
lookuphelp(s);
}
|