8#include "singular_resourcesconfig.h"
27#if defined(HPUX_10) || defined(HPUX_9)
29extern "C" int setenv(
const char *
name,
const char *value,
int overwrite);
40#define SINGULAR_DEFAULT_DIR PREFIX
59 "%r/share/singular/LIB;"
60 "%b/../share/singular/LIB;"
68 "%r/lib/singular/MOD;"
69 "%r/libexec/singular/MOD;"
70 LIB_DIR
"/singular/MOD;"
71 LIBEXEC_DIR
"/singular/MOD;"
74 {
"Singular",
'S',
feResBinary,
"SINGULAR_EXECUTABLE",
"%d/Singular", (
char *)
""},
75 {
"BinDir",
'b',
feResDir,
"SINGULAR_BIN_DIR",
"", (
char *)
""},
77 {
"ProcDir",
'P',
feResPath,
"SINGULAR_PROCS_DIR",
79 "%r/lib/singular/MOD;"
80 "%r/libexec/singular/MOD;"
81 LIB_DIR
"/singular/MOD;"
82 LIBEXEC_DIR
"/singular/MOD" , (
char *)
""},
83 {
"RootDir",
'r',
feResDir,
"SINGULAR_ROOT_DIR",
"%b/..", (
char *)
""},
84 {
"DataDir",
'D',
feResDir,
"SINGULAR_DATA_DIR",
"%b/../share/", (
char *)
""},
86 {
"InfoFile",
'i',
feResFile,
"SINGULAR_INFO_FILE",
"%D/info/singular.hlp.gz", (
char *)
""},
87 {
"IdxFile",
'x',
feResFile,
"SINGULAR_IDX_FILE",
"%D/singular/singular.idx", (
char *)
""},
88 {
"HtmlDir",
'h',
feResDir,
"SINGULAR_HTML_DIR",
"%D/singular/html", (
char *)
""},
89 {
"ManualUrl",
'u',
feResUrl,
"SINGULAR_URL",
"https://www.singular.uni-kl.de/Manual/", (
char *)
""},
90 {
"ExDir",
'm',
feResDir,
"SINGULAR_EXAMPLES_DIR",
"%r/examples", (
char *)
""},
94 {
"emacs",
'E',
feResBinary,
"ESINGULAR_EMACS",
"%b/emacs.exe", (
char *)
""},
95 {
"xemacs",
'A',
feResBinary,
"ESINGULAR_EMACS",
"%b/xemacs.exe", (
char *)
""},
96 {
"SingularEmacs",
'M',
feResBinary,
"ESINGULAR_SINGULAR",
"%b/Singular.exe", (
char *)
""},
98 {
"emacs",
'E',
feResBinary,
"ESINGULAR_EMACS",
"%b/emacs", (
char *)
""},
99 {
"xemacs",
'A',
feResBinary,
"ESINGULAR_EMACS",
"%b/xemacs", (
char *)
""},
100 {
"SingularEmacs",
'M',
feResBinary,
"ESINGULAR_SINGULAR",
"%b/Singular", (
char *)
""},
102 {
"EmacsLoad",
'l',
feResFile,
"ESINGULAR_EMACS_LOAD",
"%e/.emacs-singular", (
char *)
""},
103 {
"EmacsDir",
'e',
feResDir,
"ESINGULAR_EMACS_DIR",
"%D/singular/emacs", (
char *)
""},
104 {
"SingularXterm",
'M',
feResBinary,
"TSINGULAR_SINGULAR",
"%b/Singular", (
char *)
""},
106 {
"rxvt",
'X',
feResBinary,
"RXVT",
"%b/rxvt", (
char *)
""},
108 {
"xterm",
'X',
feResBinary,
"XTERM",
"%b/xterm", (
char *)
""},
110 {
"EmacsDir",
'e',
feResDir,
"SINGULAR_EMACS_DIR",
"%r/emacs", (
char *)
""},
121#define MAXRESOURCELEN 5*MAXPATHLEN
134static char*
feSprintf(
char*
s,
const char* fmt,
int warn = -1);
135#if defined(__CYGWIN__) && defined(__GNUC__)
137extern "C" int cygwin32_posix_path_list_p (
const char *path);
182 printf(
"feInitResources(argv0: '%s'): entering...\n",
feArgv0);
191#if defined(HAVE_SETENV) || defined(HAVE_PUTENV)
194 printf(
"feInitResources(argv0): setting path with '%s'\n", path);
197 if (path !=
NULL) {
char *
s=(
char *)
malloc(strlen(path)+6);
198 sprintf(
s,
"PATH=%s",path);
202 if (path !=
NULL) setenv(
"PATH", path, 1);
221 printf(
"feInitResources(): entering...\n");
277 printf(
"feInitResource(config->key: '%s', warn: '%d') : entering ...\n",
config->key, warn);
289 printf(
"feInitResource(config,warn): Found value from env:%s\n", evalue);
291 strcpy(value, evalue);
298 printf(
"feInitResource(config,warn): Set value of config (with key: '%s') to '%s'\n",
config->key, value);
311 if (executable !=
NULL)
314 printf(
"exec:%s\n", executable);
316 strcpy(value, executable);
318 printf(
"value:%s\n", value);
324 else if (
config->id ==
'b')
328 printf(
"feInitResource(config,warn): Get '%s' from \"%s\"\n",
config->key, executable);
330 if (executable !=
NULL)
332 strcpy(value, executable);
333 executable = strrchr(value,
DIR_SEP);
334 if (executable !=
NULL) *executable =
'\0';
339 printf(
"value:%s\n", value);
348 printf(
"Bug >>Wrong Resource Specification of '%s'<< at \"%s:%d\"\n",
config->key,__FILE__,__LINE__);
358 printf(
"feInitResource(config,warn): Set value of '%s' to \"%s\"\n",
config->key, value);
367 if (executable !=
NULL)
374 printf(
"feInitResource(config,warn): Set value of '%s' to \"%s\"\n",
config->key,
config->value);
383 if (warn > 0 || (warn < 0 && config->value !=
NULL))
385 printf(
"// ** Could not get '%s'.\n",
config->key);
386 printf(
"// ** Either set environment variable '%s' to '%s',\n",
389 printf(
"// ** or make sure that '%s' is at \"%s\"\n",
config->key, value);
392 printf(
"feInitResource(config,warn): Set value of '%s' to NULL",
config->key);
403 printf(
"Bug >>feArgv0 == NULL<< at %s:%d\n",__FILE__,__LINE__);
405 printf(
"Bug >>feArgv0 == ''<< at %s:%d\n",__FILE__,__LINE__);
420 printf(
"feGetExpandedExecutable: calling find_exec with \"%s\"\n",
feArgv0);
425 printf(
"feGetExpandedExecutable: find_exec exited with \"%s\": %d\n", executable, access(executable, X_OK));
429 printf(
"Bug >>Could not get expanded executable from \"%s\"<< at %s:%d\n",
feArgv0,__FILE__,__LINE__);
439 printf(
"feVerifyResourceValue(type: %d, value: \"%s\"): entering\n", (
int)type, value);
440 printf(
"Access: ROK: %d, XOK: %d\n", access(value, R_OK), access(value, X_OK));
449 return ! access(value, R_OK);
453 return ! access(value, X_OK);
468 if (value ==
NULL || *value ==
'\0')
return value;
470 printf(
"Clean value:%s\n", value);
474 printf(
"Clean WINNT value:%s\n", value);
478 int l = strlen(value);
479 if (
l < 4 || (strcmp(&value[
l-4],
".exe") != 0 &&
480 strcmp(&value[
l-4],
".EXE") != 0))
481 strcat(value,
".exe");
496 printf(
"feCleanUpFile: entering with =%s=\n", fname);
499 for (fn = fname; *fn !=
'\0'; fn++)
505 if (fname != fn) *fn =
'\0';
508 if (*(fn + 1) ==
'/' && (fname != fn))
513 else if (*(fn+1) ==
'.')
515 if (*(fn+2) ==
'.' && (*(fn + 3) ==
'/' || *(fn + 3) ==
'\0'))
521 s = strrchr(fname,
'/');
524 mystrcpy(
s+1, fn + (*(fn + 3) !=
'\0' ? 4 : 3));
533 else if (*(fn+2) ==
'/' || *(fn+2) ==
'\0')
543 printf(
"feCleanUpFile: leaving with =%s=\n", fname);
552 printf(
"feCleanUpPath: entering with: =%s=\n", path);
554 if (path ==
NULL)
return path;
556 int n_comps = 1,
i,
j;
560 for (; *path !=
'\0'; path++)
563 else if (*path ==
';')
570 path_comps = (
char**)
malloc(n_comps*
sizeof(
char*));
582 path_comps[
i] = path+1;
584 if (
i == n_comps)
break;
590 for (
i=0;
i<n_comps;
i++)
593 printf(
"feCleanUpPath: after CleanUpName: ");
594 for (
i=0;
i<n_comps;
i++)
595 printf(
"%s:", path_comps[
i]);
599 for (
i=0;
i<n_comps;)
602 if (access(path_comps[
i], X_OK | R_OK))
603 printf(
"feCleanUpPath: remove %d:%s -- can not access\n",
i, path_comps[
i]);
605 if ( ! access(path_comps[
i], X_OK | R_OK))
610 if (strcmp(path_comps[
j], path_comps[
i]) == 0)
614 printf(
"feCleanUpPath: remove %d:%s -- equal to %d:%s\n",
j, path_comps[
j],
i, path_comps[
i]);
627 path_comps[
i] =
NULL;
628 for (
j=
i+1;
j<n_comps;
j++)
629 path_comps[
j-1] = path_comps[
j];
635 for (path=opath,
i=0;
i<n_comps-1;
i++)
638 path += strlen(path);
652 printf(
"feCleanUpPath: leaving with path=%s=\n", opath);
684 if (*fmt ==
'%' && *(fmt + 1) !=
'\0')
699 else if (*fmt ==
'$' && *(fmt + 1) !=
'\0')
703 while (*fmt ==
'_' ||
704 (*fmt >=
'A' && *fmt <=
'Z') ||
705 (*fmt >=
'a' && *fmt <=
'z'))
const CanonicalForm int s
const Variable & v
< [in] a sqrfree bivariate poly
char name(const Variable &v)
static char * feCleanUpFile(char *fname)
static feResourceConfig feGetResourceConfig(const char id)
static char * feResourceDefault(feResourceConfig config)
static char * feSprintf(char *s, const char *fmt, int warn=-1)
VAR feResourceConfig_s feResourceConfigs[]
static char * feInitResource(feResourceConfig config, int warn)
static char * feCleanUpPath(char *path)
static char * feResource(feResourceConfig config, int warn)
void feInitResources(const char *argv0)
static char * feGetExpandedExecutable()
static char * feCleanResourceValue(feResourceType type, char *value)
static int feVerifyResourceValue(feResourceType type, char *value)
char * feGetResource(const char id, int warn)
#define SINGULAR_DEFAULT_DIR
static void mystrcpy(char *d, char *s)
char * omFindExec(const char *name, char *exec)
void * malloc(size_t size)