Loading...
Searching...
No Matches
fehelp.h File Reference

Go to the source code of this file.

## Functions

void | feHelp (char *str=NULL)
const char * | feHelpBrowser (char *browser=NULL, int warn=-1)
void | feStringAppendBrowsers (int warn=-1)

## Function Documentation

## feHelp()

void feHelp | ( | char * | str = NULL | ) |

Definition at line 90 of file fehelp.cc.

{
str = strclean(str);
if (str == NULL) {heBrowserHelp(NULL); return;}
if (strlen(str) > MAX_HE_ENTRY_LENGTH - 2) // need room for extra **
str[MAX_HE_ENTRY_LENGTH - 3] = '\0';
BOOLEAN key_is_regexp = (strchr(str, '*') != NULL);
heEntry_s hentry;
memset(&hentry,0,sizeof(hentry));
char* idxfile = feResource('x' /*"IdxFile"*/);
// Try exact match of help string with key in index
if (!key_is_regexp && (idxfile != NULL) && heKey2Entry(idxfile, str, &hentry))
{
heBrowserHelp(&hentry);
return;
}
// Try to match approximately with key in index file
if (idxfile != NULL)
{
if (heCurrentHelpBrowser == NULL) feHelpBrowser(NULL, 0);
assume(heCurrentHelpBrowser != NULL);
StringSetS("");
int found = heReKey2Entry(idxfile, str, &hentry);
if (found == 0)
{
// try proc help and library help
if (! key_is_regexp && heOnlineHelp(str)) return;
// Try to match with str*
char mkey[MAX_HE_ENTRY_LENGTH];
strcpy(mkey, str);
strcat(mkey, "*");
found = heReKey2Entry(idxfile, mkey, &hentry);
// Try to match with *str*
if (found == 0)
{
mkey[0] = '*';
strcpy(mkey + 1, str);
strcat(mkey, "*");
found = heReKey2Entry(idxfile, mkey, &hentry);
}
// Print warning and return if nothing found
if (found == 0)
{
Warn("No help for topic '%s' (not even for '*%s*')", str, str);
WarnS("Try '?;' for general help");
WarnS("or '?Index;' for all available help topics.");
return;
}
}
// do help if unique match was found
if (found == 1)
{
heBrowserHelp(&hentry);
return;
}
// Print warning about multiple matches and return
if (key_is_regexp)
Warn("No unique help for '%s'", str);
else
Warn("No help for topic '%s'", str);
WarnS("Try one of");
char *matches=StringEndS();
PrintS(matches);
omFree(matches);
PrintLn();
return;
}
// no idx file, let Browsers deal with it, if they can
strcpy(hentry.key, str);
*hentry.node = '\0';
*hentry.url = '\0';
hentry.chksum = 0;
heBrowserHelp(&hentry);
}
BOOLEAN
int BOOLEAN
Definition auxiliary.h:88
Warn
#define Warn
Definition emacs.cc:77
WarnS
#define WarnS
Definition emacs.cc:78
found
bool found
Definition facFactorize.cc:55
feResource
static char * feResource(feResourceConfig config, int warn)
Definition feResource.cc:233
heEntry_s::url
char url[MAX_HE_ENTRY_LENGTH]
Definition fehelp.cc:34
strclean
static char * strclean(char *str)
Definition fehelp.cc:364
heBrowserHelp
static void heBrowserHelp(heEntry hentry)
Definition fehelp.cc:769
heReKey2Entry
static int heReKey2Entry(char *filename, char *key, heEntry hentry)
Definition fehelp.cc:568
heEntry_s::node
char node[MAX_HE_ENTRY_LENGTH]
Definition fehelp.cc:33
heCurrentHelpBrowser
STATIC_VAR heBrowser heCurrentHelpBrowser
Definition fehelp.cc:71
MAX_HE_ENTRY_LENGTH
#define MAX_HE_ENTRY_LENGTH
Definition fehelp.cc:29
heEntry_s::key
char key[MAX_HE_ENTRY_LENGTH]
Definition fehelp.cc:32
heKey2Entry
static BOOLEAN heKey2Entry(char *filename, char *key, heEntry hentry)
Definition fehelp.cc:388
heEntry_s::chksum
long chksum
Definition fehelp.cc:35
feHelpBrowser
const char * feHelpBrowser(char *which, int warn)
Definition fehelp.cc:249
heOnlineHelp
static BOOLEAN heOnlineHelp(char *s)
Definition fehelp.cc:621
heEntry_s
Definition fehelp.cc:31
assume
#define assume(x)
Definition mod2.h:389
LibThread::str
char * str(leftv arg)
Definition shared.cc:699
omFree
#define omFree(addr)
Definition omAllocDecl.h:261
NULL
#define NULL
Definition omList.c:12
StringSetS
void StringSetS(const char *st)
Definition reporter.cc:128
PrintS
void PrintS(const char *s)
Definition reporter.cc:288
StringEndS
char * StringEndS()
Definition reporter.cc:151
PrintLn
void PrintLn()
Definition reporter.cc:314

## feHelpBrowser()

const char * feHelpBrowser | ( | char * | browser = NULL,
|  | int | warn = -1 )

Definition at line 249 of file fehelp.cc.

{
int i = 0;
// if no argument, choose first available help browser
if (heHelpBrowsers==NULL) feBrowserFile();
if (which == NULL || *which == '\0')
{
// return, if already set
if (heCurrentHelpBrowser != NULL)
return heCurrentHelpBrowser->browser;
// First, try emacs, if emacs-option is set
if (feOptValue(FE_OPT_EMACS) != NULL)
{
while (heHelpBrowsers[i].browser != NULL)
{
if (strcmp(heHelpBrowsers[i].browser, "emacs") == 0 &&
(heHelpBrowsers[i].init_proc(0,i)))
{
heCurrentHelpBrowser = &(heHelpBrowsers[i]);
heCurrentHelpBrowserIndex=i;
goto Finish;
}
i++;
}
i=0;
}
while (heHelpBrowsers[i].browser != NULL)
{
if (heHelpBrowsers[i].init_proc(0,i))
{
heCurrentHelpBrowser = &(heHelpBrowsers[i]);
heCurrentHelpBrowserIndex=i;
goto Finish;
}
i++;
}
// should never get here
dReportBug("should never get here");
}
// with argument, find matching help browser
while (heHelpBrowsers[i].browser != NULL &&
strcmp(heHelpBrowsers[i].browser, which) != 0)
{i++;}
if (heHelpBrowsers[i].browser == NULL)
{
if (warn) Warn("No help browser '%s' available.", which);
}
else
{
// see whether we can init it
if (heHelpBrowsers[i].init_proc(warn,i))
{
heCurrentHelpBrowser = &(heHelpBrowsers[i]);
heCurrentHelpBrowserIndex=i;
goto Finish;
}
}
// something went wrong
if (heCurrentHelpBrowser == NULL)
{
feHelpBrowser();
assume(heCurrentHelpBrowser != NULL);
if (warn)
Warn("Setting help browser to '%s'.", heCurrentHelpBrowser->browser);
return heCurrentHelpBrowser->browser;
}
else
{
// or, leave as is
if (warn)
Warn("Help browser stays at '%s'.", heCurrentHelpBrowser->browser);
return heCurrentHelpBrowser->browser;
}
Finish:
// update value of Browser Option
if (feOptSpec[FE_OPT_BROWSER].value == NULL ||
strcmp((char*) feOptSpec[FE_OPT_BROWSER].value,
heCurrentHelpBrowser->browser) != 0)
{
omfree(feOptSpec[FE_OPT_BROWSER].value);
feOptSpec[FE_OPT_BROWSER].value
= (void*) omStrDup(heCurrentHelpBrowser->browser);
}
return heCurrentHelpBrowser->browser;
}
i
int i
Definition cfEzgcd.cc:132
feOptValue
static void * feOptValue(feOptIndex opt)
Definition feOpt.h:40
feOptSpec
EXTERN_VAR struct fe_option feOptSpec[]
Definition feOpt.h:17
feBrowserFile
static void feBrowserFile()
Definition fehelp.cc:177
heHelpBrowsers
STATIC_VAR heBrowser_s * heHelpBrowsers
Definition fehelp.cc:82
heCurrentHelpBrowserIndex
STATIC_VAR int heCurrentHelpBrowserIndex
Definition fehelp.cc:72
omStrDup
#define omStrDup(s)
Definition omAllocDecl.h:263
omfree
#define omfree(addr)
Definition omAllocDecl.h:237
dReportBug
#define dReportBug(s)
Definition reporter.h:113

## feStringAppendBrowsers()

void feStringAppendBrowsers | ( | int | warn = -1 | ) |

Definition at line 341 of file fehelp.cc.

{
int i;
StringAppendS("Available HelpBrowsers: ");
i = 0;
if (heHelpBrowsers==NULL) feBrowserFile();
while (heHelpBrowsers[i].browser != NULL)
{
if (heHelpBrowsers[i].init_proc(warn,i))
StringAppend("%s, ", heHelpBrowsers[i].browser);
i++;
}
StringAppend("\nCurrent HelpBrowser: %s ", feHelpBrowser());
}
StringAppend
#define StringAppend
Definition emacs.cc:79
StringAppendS
void StringAppendS(const char *st)
Definition reporter.cc:107