#include "singular_resourcesconfig.h"
#include "feResource.h"
#include "omFindExec.h"
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include <sys/param.h>
Go to the source code of this file.
|
static feResourceConfig | feGetResourceConfig (const char id) |
|
static feResourceConfig | feGetResourceConfig (const char *key) |
|
static char * | feResource (feResourceConfig config, int warn) |
|
static char * | feResourceDefault (feResourceConfig config) |
|
static char * | feInitResource (feResourceConfig config, int warn) |
|
static char * | feGetExpandedExecutable () |
|
static int | feVerifyResourceValue (feResourceType type, char *value) |
|
static char * | feCleanResourceValue (feResourceType type, char *value) |
|
static char * | feCleanUpFile (char *fname) |
|
static char * | feCleanUpPath (char *path) |
|
static void | mystrcpy (char *d, char *s) |
|
static char * | feSprintf (char *s, const char *fmt, int warn=-1) |
|
char * | feResource (const char *key, int warn) |
|
char * | feResource (const char id, int warn) |
|
char * | feGetResource (const char id, int warn) |
|
char * | feResourceDefault (const char id) |
|
char * | feResourceDefault (const char *key) |
|
void | feInitResources (const char *argv0) |
|
void | feReInitResources () |
|
◆ MAXRESOURCELEN
◆ SINGULAR_DEFAULT_DIR
◆ feCleanResourceValue()
Definition at line 441 of file feResource.cc.
442{
443 if (value ==
NULL || *value ==
'\0')
return value;
444#ifdef RESOURCE_DEBUG
445 printf(
"Clean value:%s\n", value);
446#endif
447#ifdef __CYGWIN__
448#ifdef RESOURCE_DEBUG
449 printf(
"Clean WINNT value:%s\n", value);
450#endif
452 {
454 if (
l < 4 || (
strcmp(&value[
l-4],
".exe") != 0 &&
455 strcmp(&value[
l-4],
".EXE") != 0))
457 }
458#endif
463 return value;
464}
static char * feCleanUpFile(char *fname)
static char * feCleanUpPath(char *path)
◆ feCleanUpFile()
Definition at line 466 of file feResource.cc.
467{
469
470#ifdef RESOURCE_DEBUG
471 printf(
"feCleanUpFile: entering with =%s=\n",
fname);
472#endif
473
475 {
477 {
479 {
481 break;
482 }
484 {
487 }
488 else if (*(
fn+1) ==
'.')
489 {
490 if (*(
fn+2) ==
'.' && (*(
fn + 3) ==
'/' || *(
fn + 3) ==
'\0'))
491 {
492 #if 0
493
494
498 {
501 }
502 else
503 {
505 }
506 #endif
507 }
508 else if (*(
fn+2) ==
'/' || *(
fn+2) ==
'\0')
509 {
512 }
513 }
514 }
515 }
516
517#ifdef RESOURCE_DEBUG
518 printf(
"feCleanUpFile: leaving with =%s=\n",
fname);
519#endif
521}
const CanonicalForm int s
static void mystrcpy(char *d, char *s)
◆ feCleanUpPath()
Definition at line 524 of file feResource.cc.
525{
526#ifdef RESOURCE_DEBUG
527 printf(
"feCleanUpPath: entering with: =%s=\n",
path);
528#endif
530
534
536 {
538 else if (*
path ==
';')
539 {
542 }
543 }
544
549
551 {
552 while (1)
553 {
555 {
560 }
562 }
563 }
564
567#ifdef RESOURCE_DEBUG
568 printf(
"feCleanUpPath: after CleanUpName: ");
572#endif
573
575 {
576#ifdef RESOURCE_DEBUG
579#endif
581 {
582
584 {
586 {
587
588#ifdef RESOURCE_DEBUG
590#endif
592 break;
593 }
594 }
596 {
598 continue;
599 }
600 }
601
606 }
607
608
609
611 {
616 }
618 {
620 }
621 else
622 {
624 }
626#ifdef RESOURCE_DEBUG
627 printf(
"feCleanUpPath: leaving with path=%s=\n",
opath);
628#endif
630}
◆ feGetExpandedExecutable()
Definition at line 373 of file feResource.cc.
374{
376 {
379 else
382 }
383#ifdef __CYGWIN__
385 {
388 {
391 }
392 }
393#endif
394#ifdef RESOURCE_DEBUG
395 printf(
"feGetExpandedExecutable: calling find_exec with \"%s\"\n",
feArgv0);
396#endif
399#ifdef RESOURCE_DEBUG
401#endif
403 {
406 }
408}
char * omFindExec(const char *name, char *exec)
◆ feGetResource()
Definition at line 145 of file feResource.cc.
146{
148}
static feResourceConfig feGetResourceConfig(const char id)
static char * feResource(feResourceConfig config, int warn)
◆ feGetResourceConfig() [1/2]
Definition at line 221 of file feResource.cc.
222{
225 {
229 }
231}
VAR feResourceConfig_s feResourceConfigs[]
◆ feGetResourceConfig() [2/2]
◆ feInitResource()
Definition at line 248 of file feResource.cc.
249{
250
251#ifdef RESOURCE_DEBUG
252 printf(
"feInitResource(config->key: '%s', warn: '%d') : entering ...\n",
config->key,
warn);
253#endif
254
256
257
259 {
262 {
263#ifdef RESOURCE_DEBUG
264 printf(
"feInitResource(config,warn): Found value from env:%s\n",
evalue);
265#endif
268 ||
271 {
272#ifdef RESOURCE_DEBUG
273 printf(
"feInitResource(config,warn): Set value of config (with key: '%s') to '%s'\n",
config->key, value);
274#endif
277 }
278 }
279 }
280
281 *value = '\0';
282
284 {
287 {
288#ifdef RESOURCE_DEBUG
290#endif
292#ifdef RESOURCE_DEBUG
293 printf(
"value:%s\n", value);
294#endif
296 }
297 }
298
299 else if (
config->id ==
'b')
300 {
302#ifdef RESOURCE_DEBUG
304#endif
306 {
310 }
311 }
312
313#ifdef RESOURCE_DEBUG
314 printf(
"value:%s\n", value);
315#endif
316
318 {
320 }
322 {
324
326 }
327
328
331 {
332#ifdef RESOURCE_DEBUG
333 printf(
"feInitResource(config,warn): Set value of '%s' to \"%s\"\n",
config->key, value);
334#endif
337 }
339 {
340
343 {
346 {
348#ifdef RESOURCE_DEBUG
349 printf(
"feInitResource(config,warn): Set value of '%s' to \"%s\"\n",
config->key,
config->value);
350#endif
352 }
353 }
354 }
355
356
357
359 {
361 printf(
"// ** Either set environment variable '%s' to '%s',\n",
364 printf(
"// ** or make sure that '%s' is at \"%s\"\n",
config->key, value);
365 }
366#ifdef RESOURCE_DEBUG
367 printf(
"feInitResource(config,warn): Set value of '%s' to NULL",
config->key);
368#endif
371}
static char * feSprintf(char *s, const char *fmt, int warn=-1)
static char * feGetExpandedExecutable()
static char * feCleanResourceValue(feResourceType type, char *value)
static int feVerifyResourceValue(feResourceType type, char *value)
◆ feInitResources()
Definition at line 160 of file feResource.cc.
161{
163 {
164
168 }
169 else
171#ifdef RESOURCE_DEBUG
172 printf(
"feInitResources(argv0: '%s'): entering...\n",
feArgv0);
173#endif
174
177
180}
◆ feReInitResources()
void feReInitResources |
( |
| ) |
|
Definition at line 182 of file feResource.cc.
183{
186 {
189 {
192 }
194 }
195#ifdef RESOURCE_DEBUG
196 printf(
"feInitResources(): entering...\n");
197#endif
198
201
203}
◆ feResource() [1/3]
◆ feResource() [2/3]
◆ feResource() [3/3]
Definition at line 233 of file feResource.cc.
234{
238}
static char * feInitResource(feResourceConfig config, int warn)
◆ feResourceDefault() [1/3]
Definition at line 155 of file feResource.cc.
156{
158}
static char * feResourceDefault(feResourceConfig config)
◆ feResourceDefault() [2/3]
◆ feResourceDefault() [3/3]
◆ feSprintf()
Definition at line 650 of file feResource.cc.
651{
654
655 while (*fmt != '\0')
656 {
658
659 if (*fmt == '%' && *(fmt + 1) != '\0')
660 {
661 fmt++;
664 {
667 }
668 else
669 {
672 }
673 }
674 else if (*fmt == '$' && *(fmt + 1) != '\0')
675 {
676 fmt++;
678 while (*fmt == '_' ||
679 (*fmt >= 'A' && *fmt <= 'Z') ||
680 (*fmt >= 'a' && *fmt <= 'z'))
681 {
684 fmt++;
685 }
686 fmt--;
691 }
693 fmt++;
694 }
697}
const Variable & v
< [in] a sqrfree bivariate poly
◆ feVerifyResourceValue()
Definition at line 411 of file feResource.cc.
412{
413#ifdef RESOURCE_DEBUG
414 printf(
"feVerifyResourceValue(type: %d, value: \"%s\"): entering\n", (
int)type, value);
416#endif
417 switch(type)
418 {
421 return 1;
422
425
429
430 default:
431 return 0;
432 }
433}
◆ mystrcpy()
Definition at line 633 of file feResource.cc.
634{
635
637 {
639 d++;
641 }
642 *d = '\0';
643}
◆ feArgv0
◆ feResourceConfigs
Definition at line 41 of file feResource.cc.
42{
44 "$SINGULARPATH;"
45 "%D/singular/LIB;"
46 "%r/share/singular/LIB;"
47 "%b/../share/singular/LIB;"
48
49 "%D/singular/factory;"
50 "%r/share/singular/factory;"
51
52
53 "%b/../share/singular/factory;"
54
55
56
57
58 "%r/lib/singular/MOD;"
60 "%b;"
61
62 ,(char *)""},
63 {
"Singular",
'S',
feResBinary,
"SINGULAR_EXECUTABLE",
"%d/Singular", (
char *)
""},
64 {
"BinDir",
'b',
feResDir,
"SINGULAR_BIN_DIR",
"", (
char *)
""},
65
66 {
"ProcDir",
'P',
feResPath,
"SINGULAR_PROCS_DIR",
67 "%b/MOD;"
68
69
70 "%r/lib/singular/MOD;"
72 ,(char *)""},
73 {
"RootDir",
'r',
feResDir,
"SINGULAR_ROOT_DIR",
"%b/..", (
char *)
""},
74 {
"DataDir",
'D',
feResDir,
"SINGULAR_DATA_DIR",
"%b/../share/", (
char *)
""},
76 {
"InfoFile",
'i',
feResFile,
"SINGULAR_INFO_FILE",
"%D/info/singular.info", (
char *)
""},
77 {
"IdxFile",
'x',
feResFile,
"SINGULAR_IDX_FILE",
"%D/singular/singular.idx", (
char *)
""},
79 {
"ManualUrl",
'u',
feResUrl,
"SINGULAR_URL",
"https://www.singular.uni-kl.de/Manual/", (
char *)
""},
80 {
"ExDir",
'm',
feResDir,
"SINGULAR_EXAMPLES_DIR",
"%r/examples", (
char *)
""},
82
83#ifdef __CYGWIN__
84 {
"emacs",
'E',
feResBinary,
"ESINGULAR_EMACS",
"%b/emacs.exe", (
char *)
""},
85 {
"xemacs",
'A',
feResBinary,
"ESINGULAR_EMACS",
"%b/xemacs.exe", (
char *)
""},
86 {
"SingularEmacs",
'M',
feResBinary,
"ESINGULAR_SINGULAR",
"%b/Singular.exe", (
char *)
""},
87#else
88 {
"emacs",
'E',
feResBinary,
"ESINGULAR_EMACS",
"%b/emacs", (
char *)
""},
89 {
"xemacs",
'A',
feResBinary,
"ESINGULAR_EMACS",
"%b/xemacs", (
char *)
""},
90 {
"SingularEmacs",
'M',
feResBinary,
"ESINGULAR_SINGULAR",
"%b/Singular", (
char *)
""},
91#endif
92 {
"EmacsLoad",
'l',
feResFile,
"ESINGULAR_EMACS_LOAD",
"%e/.emacs-singular", (
char *)
""},
93 {
"EmacsDir",
'e',
feResDir,
"ESINGULAR_EMACS_DIR",
"%D/singular/emacs", (
char *)
""},
94 {
"SingularXterm",
'M',
feResBinary,
"TSINGULAR_SINGULAR",
"%b/Singular", (
char *)
""},
95#ifdef __CYGWIN__
96 {
"rxvt",
'X',
feResBinary,
"RXVT",
"%b/rxvt", (
char *)
""},
97#else
98 {
"xterm",
'X',
feResBinary,
"XTERM",
"%b/xterm", (
char *)
""},
99#endif
100 {
"EmacsDir",
'e',
feResDir,
"SINGULAR_EMACS_DIR",
"%r/emacs", (
char *)
""},
102};
#define SINGULAR_DEFAULT_DIR