My Project  UNKNOWN_GIT_VERSION
Functions
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 89 of file fehelp.cc.

90  : public function
91  *
92  *****************************************************************/
93 void feHelp(char *str)
94 {
95  str = strclean(str);
96  if (str == NULL) {heBrowserHelp(NULL); return;}
97 
98  if (strlen(str) > MAX_HE_ENTRY_LENGTH - 2) // need room for extra **
99  str[MAX_HE_ENTRY_LENGTH - 3] = '\0';
100 
101  BOOLEAN key_is_regexp = (strchr(str, '*') != NULL);
102 
103 
104  heEntry_s hentry;
105  memset(&hentry,0,sizeof(hentry));
106  char* idxfile = feResource('x' /*"IdxFile"*/);
107 
108  // Try exact match of help string with key in index
109  if (!key_is_regexp && (idxfile != NULL) && heKey2Entry(idxfile, str, &hentry))
110  {
111  heBrowserHelp(&hentry);
112  return;
113  }
114 
115  // Try to match approximately with key in index file
116  if (idxfile != NULL)
117  {
120 
121  StringSetS("");
122  int found = heReKey2Entry(idxfile, str, &hentry);
123 
124 
125  if (found == 0)
126  {
127  // try proc help and library help
128  if (! key_is_regexp && heOnlineHelp(str)) return;
129 
130  // Try to match with str*
131  char mkey[MAX_HE_ENTRY_LENGTH];
132  strcpy(mkey, str);
133  strcat(mkey, "*");
134  found = heReKey2Entry(idxfile, mkey, &hentry);
135  // Try to match with *str*
136  if (found == 0)
137  {
138  mkey[0] = '*';
139  strcpy(mkey + 1, str);
140  strcat(mkey, "*");
141  found = heReKey2Entry(idxfile, mkey, &hentry);
142  }
143 
144  // Print warning and return if nothing found
145  if (found == 0)
146  {
147  Warn("No help for topic '%s' (not even for '*%s*')", str, str);
148  WarnS("Try '?;' for general help");
149  WarnS("or '?Index;' for all available help topics.");
150  return;
151  }
152  }
153 
154  // do help if unique match was found
155  if (found == 1)
156  {
157  heBrowserHelp(&hentry);
158  return;
159  }
160  // Print warning about multiple matches and return
161  if (key_is_regexp)
162  Warn("No unique help for '%s'", str);
163  else
164  Warn("No help for topic '%s'", str);
165  WarnS("Try one of");
166  char *matches=StringEndS();
167  PrintS(matches);
168  omFree(matches);
169  PrintLn();
170  return;
171  }
172 
173  // no idx file, let Browsers deal with it, if they can
174  strcpy(hentry.key, str);
175  *hentry.node = '\0';

◆ feHelpBrowser()

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

Definition at line 248 of file fehelp.cc.

253 {
254  int i = 0;
255 
256  // if no argument, choose first available help browser
258  if (which == NULL || *which == '\0')
259  {
260  // return, if already set
261  if (heCurrentHelpBrowser != NULL)
263 
264  // First, try emacs, if emacs-option is set
265  if (feOptValue(FE_OPT_EMACS) != NULL)
266  {
267  while (heHelpBrowsers[i].browser != NULL)
268  {
269  if (strcmp(heHelpBrowsers[i].browser, "emacs") == 0 &&
270  (heHelpBrowsers[i].init_proc(0,i)))
271  {
274  goto Finish;
275  }
276  i++;
277  }
278  i=0;
279  }
280  while (heHelpBrowsers[i].browser != NULL)
281  {
282  if (heHelpBrowsers[i].init_proc(0,i))
283  {
286  goto Finish;
287  }
288  i++;
289  }
290  // should never get here
291  dReportBug("should never get here");
292  }
293 
294  // with argument, find matching help browser
295  while (heHelpBrowsers[i].browser != NULL &&
296  strcmp(heHelpBrowsers[i].browser, which) != 0)
297  {i++;}
298 
299  if (heHelpBrowsers[i].browser == NULL)
300  {
301  if (warn) Warn("No help browser '%s' available.", which);
302  }
303  else
304  {
305  // see whether we can init it
306  if (heHelpBrowsers[i].init_proc(warn,i))
307  {
310  goto Finish;
311  }
312  }
313 
314  // something went wrong
315  if (heCurrentHelpBrowser == NULL)
316  {
317  feHelpBrowser();
319  if (warn)
320  Warn("Setting help browser to '%s'.", heCurrentHelpBrowser->browser);
322  }
323  else
324  {
325  // or, leave as is
326  if (warn)
327  Warn("Help browser stays at '%s'.", heCurrentHelpBrowser->browser);
329  }
330 
331  Finish:
332  // update value of Browser Option
333  if (feOptSpec[FE_OPT_BROWSER].value == NULL ||
334  strcmp((char*) feOptSpec[FE_OPT_BROWSER].value,
336  {
337  omfree(feOptSpec[FE_OPT_BROWSER].value);
338  feOptSpec[FE_OPT_BROWSER].value

◆ feStringAppendBrowsers()

void feStringAppendBrowsers ( int  warn = -1)

Definition at line 340 of file fehelp.cc.

345 {
346  int i;
347  StringAppendS("Available HelpBrowsers: ");
348 
349  i = 0;
351  while (heHelpBrowsers[i].browser != NULL)
352  {
353  if (heHelpBrowsers[i].init_proc(warn,i))
354  StringAppend("%s, ", heHelpBrowsers[i].browser);
StringAppendS
void StringAppendS(const char *st)
Definition: reporter.cc:106
omFree
#define omFree(addr)
Definition: omAllocDecl.h:259
heReKey2Entry
static int heReKey2Entry(char *filename, char *key, heEntry hentry)
Definition: fehelp.cc:566
feBrowserFile
static void feBrowserFile()
Definition: fehelp.cc:176
feHelp
void feHelp(char *str)
Definition: fehelp.cc:89
heOnlineHelp
static BOOLEAN heOnlineHelp(char *s)
Definition: fehelp.cc:619
heEntry_s::key
char key[MAX_HE_ENTRY_LENGTH]
Definition: fehelp.cc:35
StringEndS
char * StringEndS()
Definition: reporter.cc:150
MAX_HE_ENTRY_LENGTH
#define MAX_HE_ENTRY_LENGTH
Definition: fehelp.cc:32
found
bool found
Definition: facFactorize.cc:56
heBrowser_s::browser
const char * browser
Definition: fehelp.cc:47
i
int i
Definition: cfEzgcd.cc:125
PrintS
void PrintS(const char *s)
Definition: reporter.cc:283
BOOLEAN
int BOOLEAN
Definition: auxiliary.h:85
heEntry_s
Definition: fehelp.cc:33
dReportBug
#define dReportBug(s)
Definition: reporter.h:111
heBrowserHelp
static void heBrowserHelp(heEntry hentry)
Definition: fehelp.cc:766
heCurrentHelpBrowser
static heBrowser heCurrentHelpBrowser
Definition: fehelp.cc:73
heCurrentHelpBrowserIndex
static int heCurrentHelpBrowserIndex
Definition: fehelp.cc:74
heKey2Entry
static BOOLEAN heKey2Entry(char *filename, char *key, heEntry hentry)
Definition: fehelp.cc:386
heEntry_s::node
char node[MAX_HE_ENTRY_LENGTH]
Definition: fehelp.cc:36
feOptSpec
struct fe_option feOptSpec[]
feResource
static char * feResource(feResourceConfig config, int warn)
Definition: feResource.cc:254
StringSetS
void StringSetS(const char *st)
Definition: reporter.cc:127
WarnS
#define WarnS
Definition: emacs.cc:77
assume
#define assume(x)
Definition: mod2.h:384
NULL
#define NULL
Definition: omList.c:9
heHelpBrowsers
static heBrowser_s * heHelpBrowsers
Definition: fehelp.cc:83
fe_option::value
void * value
Definition: fegetopt.h:93
Warn
#define Warn
Definition: emacs.cc:76
StringAppend
#define StringAppend
Definition: emacs.cc:78
feOptValue
static void * feOptValue(feOptIndex opt)
Definition: feOpt.h:39
PrintLn
void PrintLn()
Definition: reporter.cc:309
strclean
static char * strclean(char *str)
Definition: fehelp.cc:362
feHelpBrowser
const char * feHelpBrowser(char *which, int warn)
Definition: fehelp.cc:248
omfree
#define omfree(addr)
Definition: omAllocDecl.h:235