43 #define MAX_HE_ENTRY_LENGTH 160 73 static int heReKey2Entry (
char* filename,
char* key, heEntry hentry);
111 BOOLEAN key_is_regexp = (strchr(str,
'*') !=
NULL);
117 memset(&hentry,0,
sizeof(hentry));
121 if (!key_is_regexp && (idxfile !=
NULL) &&
heKey2Entry(idxfile, str, &hentry))
147 strcpy(mkey + 1, str);
155 Warn(
"No help for topic '%s' (not even for '*%s*')", str, str);
156 WarnS(
"Try '?;' for general help");
157 WarnS(
"or '?Index;' for all available help topics.");
170 Warn(
"No unique help for '%s'", str);
172 Warn(
"No help for topic '%s'", str);
182 strcpy(hentry.
key, str);
195 while (fgets( buf,
sizeof(buf), f))
197 if ((buf[0]!=
'#') && (buf[0]>
' ')) br++;
203 while (fgets( buf,
sizeof(buf),
f))
205 if ((buf[0]!=
'#') && (buf[0]>
' '))
207 char *
name=strtok(buf,
"!");
208 char *req=strtok(
NULL,
"!");
209 char *cmd=strtok(
NULL,
"!");
212 while ((cmd[0]!=
'\0') && (cmd[strlen(cmd)-1]<=
' '))
213 cmd[strlen(cmd)-1]=
'\0';
224 Print(
"syntax error in help.cnf, at line starting with %s\n",buf);
235 heHelpBrowsers[br].
browser=
"builtin";
241 heHelpBrowsers[br].
browser=
"dummy";
247 heHelpBrowsers[br].
browser=
"emacs";
266 if (which ==
NULL || *which ==
'\0')
269 if (heCurrentHelpBrowser !=
NULL)
270 return heCurrentHelpBrowser->
browser;
275 while (heHelpBrowsers[i].browser !=
NULL)
277 if (strcmp(heHelpBrowsers[i].browser,
"emacs") == 0 &&
278 (heHelpBrowsers[i].init_proc(0,i)))
280 heCurrentHelpBrowser = &(heHelpBrowsers[
i]);
288 while (heHelpBrowsers[i].browser !=
NULL)
290 if (heHelpBrowsers[i].init_proc(0,i))
292 heCurrentHelpBrowser = &(heHelpBrowsers[
i]);
303 while (heHelpBrowsers[i].browser !=
NULL &&
304 strcmp(heHelpBrowsers[i].browser, which) != 0)
307 if (heHelpBrowsers[i].browser ==
NULL)
309 if (warn)
Warn(
"No help browser '%s' available.", which);
314 if (heHelpBrowsers[i].init_proc(warn,i))
316 heCurrentHelpBrowser = &(heHelpBrowsers[
i]);
323 if (heCurrentHelpBrowser ==
NULL)
328 Warn(
"Setting help browser to '%s'.", heCurrentHelpBrowser->
browser);
329 return heCurrentHelpBrowser->
browser;
335 Warn(
"Help browser stays at '%s'.", heCurrentHelpBrowser->
browser);
336 return heCurrentHelpBrowser->
browser;
342 strcmp((
char*)
feOptSpec[FE_OPT_BROWSER].value,
343 heCurrentHelpBrowser->
browser) != 0)
349 return heCurrentHelpBrowser->
browser;
359 while (heHelpBrowsers[i].browser !=
NULL)
361 if (heHelpBrowsers[i].init_proc(warn,i))
379 while ((*s <=
' ') && (*s !=
'\0')) s++;
380 if (*s ==
'\0')
return NULL;
382 while (*ss!=
'\0') ss++;
384 while ((*ss <=
' ') && (*ss !=
'\0'))
389 if (*ss ==
'\0')
return NULL;
404 *(hentry->
key) =
'\0';
405 *(hentry->
url) =
'\0';
406 *(hentry->
node) =
'\0';
409 fd = fopen(filename,
"r");
415 while ((c = getc(fd)) != EOF)
420 while (getc(fd) !=
'\n') {};
433 if (getc(fd) !=
'\t')
goto Failure;
436 if (hentry->
key != key) strcpy(hentry->
key, key);
439 while ((c = getc(fd)) !=
'\t' && c != EOF)
444 if (c == EOF)
goto Failure;
445 if (hentry->
node[0]==
'\0')
446 strcpy(hentry->
node,hentry->
key);
451 while ((c = getc(fd)) !=
'\t' && c != EOF)
456 if (c == EOF)
goto Failure;
459 hentry->
url[
i] =
'\0';
461 if (si_fscanf(fd,
"%ld\n", &(hentry->
chksum)) != 1)
493 if (s ==
NULL || *s ==
'\0')
494 return (re ==
NULL || *re ==
'\0' || strcmp(re,
"*") == 0);
495 if (re ==
NULL || *re ==
'\0')
return FALSE;
500 char *
l, *
r, *ll, *rr;
507 if (*s >=
'A' && *s <=
'Z') ls[
i] = *s + (
'a' -
'A');
511 }
while (*s !=
'\0');
519 if (*re >=
'A' && *re <=
'Z') rs[
i]= *re + (
'a' -
'A');
523 }
while (*re !=
'\0');
528 while (*r !=
'*' && *r !=
'\0' && *l !=
'\0')
530 if (*r != *l)
return FALSE;
536 if (*r ==
'\0')
return (*l ==
'\0');
537 if (*r ==
'*' && r[1] ==
'\0')
return TRUE;
538 if (*l ==
'\0')
return FALSE;
540 rr = &r[strlen(r) - 1];
541 ll = &l[strlen(l) - 1];
542 while (*rr !=
'*' && *rr !=
'\0' && *ll !=
'\0')
544 if (*rr != *ll)
return FALSE;
550 if (*rr ==
'\0')
return (*ll ==
'\0');
551 if (*rr ==
'*' && rr[-1] ==
'\0')
return TRUE;
552 if (*ll ==
'\0')
return FALSE;
560 while (*rr !=
'*' && *rr !=
'\0') rr++;
585 if (filename ==
NULL || key ==
NULL)
return 0;
586 fd = fopen(filename,
"r");
587 if (fd ==
NULL)
return 0;
589 while (si_fscanf(fd,
"%[^\t]\t%*[^\n]\n", index_key) == 1)
594 Werror(
"index file corrupt at line >>%s<<",index_key);
627 Print(
"`%s` not found in package %s\n",
id,pa);
637 if ((ss=strstr(s,
"::"))!=
NULL)
644 Print(
"help for %s from package %s\n",ss,s);
647 strcat(s_help,
"_help");
652 else Print(
"package %s not found\n",s);
662 if((lib!=
NULL)&&(*lib!=
'\0'))
664 Print(
"// proc %s from lib %s\n",s,lib);
687 if (strlen(s) >=4 && strcmp(&s[ls-3],
"lib") == 0)
689 if (s[ls - 4] ==
'.') str =
s;
704 if ((str[1]!=
'\0') &&
719 Warn(
"library %s has an old format. Please fix it for the next time",
721 if (str != s)
omFree(str);
723 while (fgets( buf,
sizeof(buf), fp))
725 if (strncmp(buf,
"//",2)==0)
727 if (found)
return TRUE;
729 else if ((strncmp(buf,
"proc ",5)==0)||(strncmp(buf,
"LIB ",4)==0))
731 if (!found)
WarnS(
"no help part in library found");
743 if (str != s)
omFree(str);
752 if (str != s)
omFree(str);
758 if (key ==
NULL || *key ==
'\0')
return 0;
763 if (pi !=
NULL)
return pi->
data.s.help_chksum;
779 int kchksum = (hentry !=
NULL && hentry->
chksum > 0 ?
788 Warn(
"Displaying help in browser '%s'.", heCurrentHelpBrowser->
browser);
794 Warn(
"Use 'system(\"--browser\", <browser>);' to change browser,");
798 while (heHelpBrowsers[i].browser !=
NULL)
800 if (heHelpBrowsers[i].init_proc(0,i))
805 if (browsers[strlen(browsers)-2] ==
',')
807 browsers[strlen(browsers)-2] =
'.';
808 browsers[strlen(browsers)-1] =
'\0';
818 #define MAX_SYSCMD_LEN MAXPATHLEN*2 821 if (heHelpBrowsers[br].required==
NULL)
return TRUE;
822 const char *
p=heHelpBrowsers[br].
required;
834 if (warn)
Warn(
"resource `%c` not found",*p);
841 if (warn)
WarnS(
"resource `D` not found");
854 while (((*p==
':')||(*p<=
' ')) && (*p!=
'\0')) p++;
855 while((i<127) && (*p>
' ') && (*p!=
':'))
857 name[
i]=*
p; p++; i++;
859 if (i==0)
return FALSE;
861 if ((op==
'O') && (strcmp(name,S_UNAME)!=0))
865 if (warn)
Warn(
"executable `%s` not found",name);
870 default:
Warn(
"unknown char %c",*p);
881 const char *
p=heHelpBrowsers[br].
action;
882 if (p==
NULL) {
PrintS(
"no action ?\n");
return;}
898 if ((*p==
'h')&&(htmldir!=
NULL))
899 strcat(sys,
"file://localhost");
900 else if ((*p==
'H')||(htmldir==
NULL))
903 if (hentry !=
NULL && *(hentry->
url) !=
'\0')
904 #ifdef HAVE_VSNPRINTF 907 snprintf(temp,256,
"%s/%d-%d-%d/%s", htmldir,
913 snprintf(temp,256,
"%s/%s", htmldir, hentry->
url);
918 snprintf(temp,256,
"%s/%d-%d-%d/index.htm", htmldir,
924 snprintf(temp,256,
"%s/index.htm", htmldir);
929 sprintf(temp,
"%s/%d-%d-%d/%s", htmldir,
935 sprintf(temp,
"%s/%d-%d-%d/%s", htmldir, hentry->
url);
939 sprintf(temp,
"%s/%d-%d-%d/index.htm", htmldir,
945 sprintf(temp,
"%s/index.htm", htmldir);
951 char *
pp=(
char *)strchr(sys,
'#');
965 if (i_res!=
NULL) strcat(sys,i_res);
968 WarnS(
"singular.hlp not found");
977 if ((hentry!=
NULL) && (*(hentry->
node) !=
'\0'))
978 sprintf(temp,
"%s",hentry->
node);
1007 Print(
"running `%s`\n",sys);
1017 Werror(
"No functioning help browser available.");
1026 WarnS(
"Your help command could not be executed. Use");
1028 (hentry !=
NULL && *(hentry->
node) !=
'\0' ? hentry->
node :
"Top"));
1029 Warn(
"to enter the Singular online help. For general");
1030 Warn(
"information on Singular running under Emacs, type C-h m.");
1036 hentry->
key :
"Top");
1047 #define FIN_INDEX '\037' 1048 #define HELP_NOT_OPEN 1 1049 #define HELP_NOT_FOUND 2 1052 #define MAX_LINES 21 1056 if ((
'A'<=p)&&(p<=
'Z'))
return p | 040;
1069 fseek(help, (
long)(offset+1), (
int)0);
1070 while( (!feof(help))
1071 && (*fgets(buffer,
BUF_LEN, help) != EOF)
1074 printf(
"%s", buffer);
1077 printf(
"\n Press <RETURN> to continue or x to exit help.\n");
1079 *close = (char)getchar();
1090 printf(
"\nEnd of part. Press <RETURN> to continue or x to exit help.\n");
1092 *close = (char)getchar();
1109 Print(
"HELP >>%s>>\n",str);
1118 for(p=str; *
p; p++) *p =
tolow(*p);
1123 while ((p != str) && (*p<=
' '));
1126 (void)sprintf(String,
" %s ", str);
1130 (void)sprintf(String,
" %s", str);
1134 && (fgets(buffer,
BUF_LEN, index) != (
char *)0)
1140 if (si_sscanf(buffer,
"Node:%[^\177]\177%ld\n", Index, &offset)!=2)
1144 for(p=Index; *
p; p++) *p =
tolow(*p);
1145 (void)strcat(Index,
" ");
1146 if( strstr(Index, String)!=
NULL)
1148 done++; (void)
show(offset, &close);
1151 else if( strcmp(Index, String)==0)
1153 done++; (void)
show(offset, &close);
1160 if (index !=
NULL) (void)fclose(index);
1163 Warn(
"`%s` not found",String);
const char * feHelpBrowser(char *which, int warn)
char url[MAX_HE_ENTRY_LENGTH]
const CanonicalForm int s
static void * feOptValue(feOptIndex opt)
int yylplex(const char *libname, const char *libfile, lib_style_types *lib_style, idhdl pl, BOOLEAN autoexport=FALSE, lp_modes=LOAD_LIB)
static int singular_manual(char *str, BOOLEAN isIndexEntry)
static BOOLEAN heOnlineHelp(char *s)
#define MAX_HE_ENTRY_LENGTH
static char * feResource(feResourceConfig config, int warn)
static BOOLEAN heEmacsInit(int, int)
static int show(unsigned long offset, char *close)
static void feBrowserFile()
static BOOLEAN feHelpCalled
heBrowserInitProc init_proc
char key[MAX_HE_ENTRY_LENGTH]
static int heReKey2Entry(char *filename, char *key, heEntry hentry)
static void heBrowserHelp(heEntry hentry)
static void heBuiltinHelp(heEntry hentry, int)
static int heCurrentHelpBrowserIndex
void feStringAppendBrowsers(int warn)
static BOOLEAN heDummyInit(int, int)
char node[MAX_HE_ENTRY_LENGTH]
void StringSetS(const char *st)
int status int void * buf
void StringAppendS(const char *st)
Print("running `%s`\n", sys)
static void heEmacsHelp(heEntry hentry, int)
struct fe_option feOptSpec[]
static BOOLEAN heKey2Entry(char *filename, char *key, heEntry hentry)
static void heDummyHelp(heEntry hentry, int)
FILE * feFopen(const char *path, const char *mode, char *where, short useWerror, short path_only)
static heBrowser heCurrentHelpBrowser
void PrintS(const char *s)
static void heGenHelp(heEntry hentry, int)
static void hePrintHelpStr(const idhdl hh, const char *id, const char *pa)
BOOLEAN iiLocateLib(const char *lib, char *where)
static int index(p_Length length, p_Ord ord)
static long heKeyChksum(char *key)
BOOLEAN(* heBrowserInitProc)(int warn, int br)
void(* heBrowserHelpProc)(heEntry hentry, int br)
char name(const Variable &v)
static heBrowser_s * heHelpBrowsers
static BOOLEAN heGenInit(int, int)
heBrowserHelpProc help_proc
static char * strclean(char *str)
char * iiGetLibName(procinfov pi)
char * omFindExec(const char *name, char *exec)
static char tolow(char p)
static BOOLEAN strmatch(char *s, char *re)
char * iiGetLibProcBuffer(procinfo *pi, int part)
void Werror(const char *fmt,...)
idhdl ggetid(const char *n, BOOLEAN, idhdl *packhdl)