#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 444 of file feResource.cc.
445{
446 if (value ==
NULL || *value ==
'\0')
return value;
447#ifdef RESOURCE_DEBUG
448 printf(
"Clean value:%s\n", value);
449#endif
450#ifdef __CYGWIN__
451#ifdef RESOURCE_DEBUG
452 printf(
"Clean WINNT value:%s\n", value);
453#endif
455 {
457 if (
l < 4 || (
strcmp(&value[
l-4],
".exe") != 0 &&
458 strcmp(&value[
l-4],
".EXE") != 0))
460 }
461#endif
466 return value;
467}
static char * feCleanUpFile(char *fname)
static char * feCleanUpPath(char *path)
◆ feCleanUpFile()
Definition at line 469 of file feResource.cc.
470{
472
473#ifdef RESOURCE_DEBUG
474 printf(
"feCleanUpFile: entering with =%s=\n",
fname);
475#endif
476
478 {
480 {
482 {
484 break;
485 }
487 {
490 }
491 else if (*(
fn+1) ==
'.')
492 {
493 if (*(
fn+2) ==
'.' && (*(
fn + 3) ==
'/' || *(
fn + 3) ==
'\0'))
494 {
495 #if 0
496
497
501 {
504 }
505 else
506 {
508 }
509 #endif
510 }
511 else if (*(
fn+2) ==
'/' || *(
fn+2) ==
'\0')
512 {
515 }
516 }
517 }
518 }
519
520#ifdef RESOURCE_DEBUG
521 printf(
"feCleanUpFile: leaving with =%s=\n",
fname);
522#endif
524}
const CanonicalForm int s
static void mystrcpy(char *d, char *s)
◆ feCleanUpPath()
Definition at line 527 of file feResource.cc.
528{
529#ifdef RESOURCE_DEBUG
530 printf(
"feCleanUpPath: entering with: =%s=\n",
path);
531#endif
533
537
539 {
541 else if (*
path ==
';')
542 {
545 }
546 }
547
552
554 {
555 while (1)
556 {
558 {
563 }
565 }
566 }
567
570#ifdef RESOURCE_DEBUG
571 printf(
"feCleanUpPath: after CleanUpName: ");
575#endif
576
578 {
579#ifdef RESOURCE_DEBUG
582#endif
584 {
585
587 {
589 {
590
591#ifdef RESOURCE_DEBUG
593#endif
595 break;
596 }
597 }
599 {
601 continue;
602 }
603 }
604
609 }
610
611
612
614 {
619 }
621 {
623 }
624 else
625 {
627 }
629#ifdef RESOURCE_DEBUG
630 printf(
"feCleanUpPath: leaving with path=%s=\n",
opath);
631#endif
633}
◆ feGetExpandedExecutable()
Definition at line 376 of file feResource.cc.
377{
379 {
382 else
385 }
386#ifdef __CYGWIN__
388 {
391 {
394 }
395 }
396#endif
397#ifdef RESOURCE_DEBUG
398 printf(
"feGetExpandedExecutable: calling find_exec with \"%s\"\n",
feArgv0);
399#endif
402#ifdef RESOURCE_DEBUG
404#endif
406 {
409 }
411}
char * omFindExec(const char *name, char *exec)
◆ feGetResource()
Definition at line 148 of file feResource.cc.
149{
151}
static feResourceConfig feGetResourceConfig(const char id)
static char * feResource(feResourceConfig config, int warn)
◆ feGetResourceConfig() [1/2]
Definition at line 224 of file feResource.cc.
225{
228 {
232 }
234}
VAR feResourceConfig_s feResourceConfigs[]
◆ feGetResourceConfig() [2/2]
◆ feInitResource()
Definition at line 251 of file feResource.cc.
252{
253
254#ifdef RESOURCE_DEBUG
255 printf(
"feInitResource(config->key: '%s', warn: '%d') : entering ...\n",
config->key,
warn);
256#endif
257
259
260
262 {
265 {
266#ifdef RESOURCE_DEBUG
267 printf(
"feInitResource(config,warn): Found value from env:%s\n",
evalue);
268#endif
271 ||
274 {
275#ifdef RESOURCE_DEBUG
276 printf(
"feInitResource(config,warn): Set value of config (with key: '%s') to '%s'\n",
config->key, value);
277#endif
280 }
281 }
282 }
283
284 *value = '\0';
285
287 {
290 {
291#ifdef RESOURCE_DEBUG
293#endif
295#ifdef RESOURCE_DEBUG
296 printf(
"value:%s\n", value);
297#endif
299 }
300 }
301
302 else if (
config->id ==
'b')
303 {
305#ifdef RESOURCE_DEBUG
307#endif
309 {
313 }
314 }
315
316#ifdef RESOURCE_DEBUG
317 printf(
"value:%s\n", value);
318#endif
319
321 {
323 }
325 {
327
329 }
330
331
334 {
335#ifdef RESOURCE_DEBUG
336 printf(
"feInitResource(config,warn): Set value of '%s' to \"%s\"\n",
config->key, value);
337#endif
340 }
342 {
343
346 {
349 {
351#ifdef RESOURCE_DEBUG
352 printf(
"feInitResource(config,warn): Set value of '%s' to \"%s\"\n",
config->key,
config->value);
353#endif
355 }
356 }
357 }
358
359
360
362 {
364 printf(
"// ** Either set environment variable '%s' to '%s',\n",
367 printf(
"// ** or make sure that '%s' is at \"%s\"\n",
config->key, value);
368 }
369#ifdef RESOURCE_DEBUG
370 printf(
"feInitResource(config,warn): Set value of '%s' to NULL",
config->key);
371#endif
374}
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 163 of file feResource.cc.
164{
166 {
167
171 }
172 else
174#ifdef RESOURCE_DEBUG
175 printf(
"feInitResources(argv0: '%s'): entering...\n",
feArgv0);
176#endif
177
180
183}
◆ feReInitResources()
void feReInitResources |
( |
| ) |
|
Definition at line 185 of file feResource.cc.
186{
189 {
192 {
195 }
197 }
198#ifdef RESOURCE_DEBUG
199 printf(
"feInitResources(): entering...\n");
200#endif
201
204
206}
◆ feResource() [1/3]
◆ feResource() [2/3]
◆ feResource() [3/3]
Definition at line 236 of file feResource.cc.
237{
241}
static char * feInitResource(feResourceConfig config, int warn)
◆ feResourceDefault() [1/3]
Definition at line 158 of file feResource.cc.
159{
161}
static char * feResourceDefault(feResourceConfig config)
◆ feResourceDefault() [2/3]
◆ feResourceDefault() [3/3]
◆ feSprintf()
Definition at line 653 of file feResource.cc.
654{
657
658 while (*fmt != '\0')
659 {
661
662 if (*fmt == '%' && *(fmt + 1) != '\0')
663 {
664 fmt++;
667 {
670 }
671 else
672 {
675 }
676 }
677 else if (*fmt == '$' && *(fmt + 1) != '\0')
678 {
679 fmt++;
681 while (*fmt == '_' ||
682 (*fmt >= 'A' && *fmt <= 'Z') ||
683 (*fmt >= 'a' && *fmt <= 'z'))
684 {
687 fmt++;
688 }
689 fmt--;
694 }
696 fmt++;
697 }
700}
const Variable & v
< [in] a sqrfree bivariate poly
◆ feVerifyResourceValue()
Definition at line 414 of file feResource.cc.
415{
416#ifdef RESOURCE_DEBUG
417 printf(
"feVerifyResourceValue(type: %d, value: \"%s\"): entering\n", (
int)type, value);
419#endif
420 switch(type)
421 {
424 return 1;
425
428
432
433 default:
434 return 0;
435 }
436}
◆ mystrcpy()
Definition at line 636 of file feResource.cc.
637{
638
640 {
642 d++;
644 }
645 *d = '\0';
646}
◆ 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/factory;"
50 "%r/share/factory;"
51 "%b/LIB;"
52 "%b/../LIB;"
53 "%b/../factory;"
54 "%b/../../factory;"
55
56 "%b/MOD;"
57 "%b/../MOD;"
58 "%r/lib/singular/MOD;"
59 "%r/libexec/singular/MOD;"
62 "%b;"
63 "%b/..",
64 (char *)""},
65 {
"Singular",
'S',
feResBinary,
"SINGULAR_EXECUTABLE",
"%d/Singular", (
char *)
""},
66 {
"BinDir",
'b',
feResDir,
"SINGULAR_BIN_DIR",
"", (
char *)
""},
67
68 {
"ProcDir",
'P',
feResPath,
"SINGULAR_PROCS_DIR",
69 "%b/MOD;"
70 "%b/../MOD;"
71 "%b/..;"
72 "%r/lib/singular/MOD;"
73 "%r/libexec/singular/MOD;"
76 {
"RootDir",
'r',
feResDir,
"SINGULAR_ROOT_DIR",
"%b/..", (
char *)
""},
77 {
"DataDir",
'D',
feResDir,
"SINGULAR_DATA_DIR",
"%b/../share/", (
char *)
""},
79 {
"InfoFile",
'i',
feResFile,
"SINGULAR_INFO_FILE",
"%D/info/singular.info.gz", (
char *)
""},
80 {
"IdxFile",
'x',
feResFile,
"SINGULAR_IDX_FILE",
"%D/singular/singular.idx", (
char *)
""},
82 {
"ManualUrl",
'u',
feResUrl,
"SINGULAR_URL",
"https://www.singular.uni-kl.de/Manual/", (
char *)
""},
83 {
"ExDir",
'm',
feResDir,
"SINGULAR_EXAMPLES_DIR",
"%r/examples", (
char *)
""},
85
86#ifdef __CYGWIN__
87 {
"emacs",
'E',
feResBinary,
"ESINGULAR_EMACS",
"%b/emacs.exe", (
char *)
""},
88 {
"xemacs",
'A',
feResBinary,
"ESINGULAR_EMACS",
"%b/xemacs.exe", (
char *)
""},
89 {
"SingularEmacs",
'M',
feResBinary,
"ESINGULAR_SINGULAR",
"%b/Singular.exe", (
char *)
""},
90#else
91 {
"emacs",
'E',
feResBinary,
"ESINGULAR_EMACS",
"%b/emacs", (
char *)
""},
92 {
"xemacs",
'A',
feResBinary,
"ESINGULAR_EMACS",
"%b/xemacs", (
char *)
""},
93 {
"SingularEmacs",
'M',
feResBinary,
"ESINGULAR_SINGULAR",
"%b/Singular", (
char *)
""},
94#endif
95 {
"EmacsLoad",
'l',
feResFile,
"ESINGULAR_EMACS_LOAD",
"%e/.emacs-singular", (
char *)
""},
96 {
"EmacsDir",
'e',
feResDir,
"ESINGULAR_EMACS_DIR",
"%D/singular/emacs", (
char *)
""},
97 {
"SingularXterm",
'M',
feResBinary,
"TSINGULAR_SINGULAR",
"%b/Singular", (
char *)
""},
98#ifdef __CYGWIN__
99 {
"rxvt",
'X',
feResBinary,
"RXVT",
"%b/rxvt", (
char *)
""},
100#else
101 {
"xterm",
'X',
feResBinary,
"XTERM",
"%b/xterm", (
char *)
""},
102#endif
103 {
"EmacsDir",
'e',
feResDir,
"SINGULAR_EMACS_DIR",
"%r/emacs", (
char *)
""},
105};
#define SINGULAR_DEFAULT_DIR