#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
#define SINGULAR_DEFAULT_DIR PREFIX |
◆ feCleanResourceValue()
static char * feCleanResourceValue |
( |
feResourceType |
type, |
|
|
char * |
value |
|
) |
| |
|
static |
Definition at line 444 of file feResource.cc.
446 if (value ==
NULL || *value ==
'\0')
return value;
447 #ifdef RESOURCE_DEBUG
448 printf(
"Clean value:%s\n", value);
451 #ifdef RESOURCE_DEBUG
452 printf(
"Clean WINNT value:%s\n", value);
456 int l = strlen(value);
457 if (
l < 4 || (strcmp(&value[
l-4],
".exe") != 0 &&
458 strcmp(&value[
l-4],
".EXE") != 0))
459 strcat(value,
".exe");
static char * feCleanUpFile(char *fname)
static char * feCleanUpPath(char *path)
◆ feCleanUpFile()
static char * feCleanUpFile |
( |
char * |
fname | ) |
|
|
static |
Definition at line 469 of file feResource.cc.
473 #ifdef RESOURCE_DEBUG
474 printf(
"feCleanUpFile: entering with =%s=\n", fname);
477 for (fn = fname; *fn !=
'\0'; fn++)
483 if (fname != fn) *fn =
'\0';
486 if (*(fn + 1) ==
'/' && (fname != fn))
491 else if (*(fn+1) ==
'.')
493 if (*(fn+2) ==
'.' && (*(fn + 3) ==
'/' || *(fn + 3) ==
'\0'))
499 s = strrchr(fname,
'/');
502 mystrcpy(
s+1, fn + (*(fn + 3) !=
'\0' ? 4 : 3));
511 else if (*(fn+2) ==
'/' || *(fn+2) ==
'\0')
520 #ifdef RESOURCE_DEBUG
521 printf(
"feCleanUpFile: leaving with =%s=\n", fname);
const CanonicalForm int s
static void mystrcpy(char *d, char *s)
◆ feCleanUpPath()
static char * feCleanUpPath |
( |
char * |
path | ) |
|
|
static |
Definition at line 527 of file feResource.cc.
529 #ifdef RESOURCE_DEBUG
530 printf(
"feCleanUpPath: entering with: =%s=\n", path);
532 if (path ==
NULL)
return path;
534 int n_comps = 1,
i,
j;
538 for (; *path !=
'\0'; path++)
541 else if (*path ==
';')
548 path_comps = (
char**)
malloc(n_comps*
sizeof(
char*));
560 path_comps[
i] = path+1;
562 if (
i == n_comps)
break;
568 for (
i=0;
i<n_comps;
i++)
570 #ifdef RESOURCE_DEBUG
571 printf(
"feCleanUpPath: after CleanUpName: ");
572 for (
i=0;
i<n_comps;
i++)
573 printf(
"%s:", path_comps[
i]);
577 for (
i=0;
i<n_comps;)
579 #ifdef RESOURCE_DEBUG
580 if (access(path_comps[
i], X_OK | R_OK))
581 printf(
"feCleanUpPath: remove %d:%s -- can not access\n",
i, path_comps[
i]);
583 if ( ! access(path_comps[
i], X_OK | R_OK))
588 if (strcmp(path_comps[
j], path_comps[
i]) == 0)
591 #ifdef RESOURCE_DEBUG
592 printf(
"feCleanUpPath: remove %d:%s -- equal to %d:%s\n",
j, path_comps[
j],
i, path_comps[
i]);
605 path_comps[
i] =
NULL;
606 for (
j=
i+1;
j<n_comps;
j++)
607 path_comps[
j-1] = path_comps[
j];
613 for (path=opath,
i=0;
i<n_comps-1;
i++)
616 path += strlen(path);
629 #ifdef RESOURCE_DEBUG
630 printf(
"feCleanUpPath: leaving with path=%s=\n", opath);
void * malloc(size_t size)
◆ feGetExpandedExecutable()
static char * feGetExpandedExecutable |
( |
| ) |
|
|
static |
Definition at line 376 of file feResource.cc.
381 printf(
"Bug >>feArgv0 == NULL<< at %s:%d\n",__FILE__,__LINE__);
383 printf(
"Bug >>feArgv0 == ''<< at %s:%d\n",__FILE__,__LINE__);
397 #ifdef RESOURCE_DEBUG
398 printf(
"feGetExpandedExecutable: calling find_exec with \"%s\"\n",
feArgv0);
402 #ifdef RESOURCE_DEBUG
403 printf(
"feGetExpandedExecutable: find_exec exited with \"%s\": %d\n", executable, access(executable, X_OK));
407 printf(
"Bug >>Could not get expanded executable from \"%s\"<< at %s:%d\n",
feArgv0,__FILE__,__LINE__);
char * omFindExec(const char *name, char *exec)
◆ feGetResource()
char* feGetResource |
( |
const char |
id, |
|
|
int |
warn |
|
) |
| |
Definition at line 148 of file feResource.cc.
static feResourceConfig feGetResourceConfig(const char id)
static char * feResource(feResourceConfig config, int warn)
◆ feGetResourceConfig() [1/2]
Definition at line 224 of file feResource.cc.
VAR feResourceConfig_s feResourceConfigs[]
◆ feGetResourceConfig() [2/2]
◆ feInitResource()
Definition at line 251 of file feResource.cc.
254 #ifdef RESOURCE_DEBUG
255 printf(
"feInitResource(config->key: '%s', warn: '%d') : entering ...\n",
config->key, warn);
266 #ifdef RESOURCE_DEBUG
267 printf(
"feInitResource(config,warn): Found value from env:%s\n", evalue);
269 strcpy(value, evalue);
275 #ifdef RESOURCE_DEBUG
276 printf(
"feInitResource(config,warn): Set value of config (with key: '%s') to '%s'\n",
config->key, value);
289 if (executable !=
NULL)
291 #ifdef RESOURCE_DEBUG
292 printf(
"exec:%s\n", executable);
294 strcpy(value, executable);
295 #ifdef RESOURCE_DEBUG
296 printf(
"value:%s\n", value);
302 else if (
config->id ==
'b')
305 #ifdef RESOURCE_DEBUG
306 printf(
"feInitResource(config,warn): Get '%s' from \"%s\"\n",
config->key, executable);
308 if (executable !=
NULL)
310 strcpy(value, executable);
311 executable = strrchr(value,
DIR_SEP);
312 if (executable !=
NULL) *executable =
'\0';
316 #ifdef RESOURCE_DEBUG
317 printf(
"value:%s\n", value);
326 printf(
"Bug >>Wrong Resource Specification of '%s'<< at \"%s:%d\"\n",
config->key,__FILE__,__LINE__);
335 #ifdef RESOURCE_DEBUG
336 printf(
"feInitResource(config,warn): Set value of '%s' to \"%s\"\n",
config->key, value);
345 if (executable !=
NULL)
351 #ifdef RESOURCE_DEBUG
352 printf(
"feInitResource(config,warn): Set value of '%s' to \"%s\"\n",
config->key,
config->value);
361 if (warn > 0 || (warn < 0 && config->value !=
NULL))
363 printf(
"// ** Could not get '%s'.\n",
config->key);
364 printf(
"// ** Either set environment variable '%s' to '%s',\n",
367 printf(
"// ** or make sure that '%s' is at \"%s\"\n",
config->key, value);
369 #ifdef RESOURCE_DEBUG
370 printf(
"feInitResource(config,warn): Set value of '%s' to NULL",
config->key);
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()
void feInitResources |
( |
const char * |
argv0 | ) |
|
Definition at line 163 of file feResource.cc.
174 #ifdef RESOURCE_DEBUG
175 printf(
"feInitResources(argv0: '%s'): entering...\n",
feArgv0);
◆ feReInitResources()
void feReInitResources |
( |
| ) |
|
Definition at line 185 of file feResource.cc.
198 #ifdef RESOURCE_DEBUG
199 printf(
"feInitResources(): entering...\n");
◆ feResource() [1/3]
char* feResource |
( |
const char * |
key, |
|
|
int |
warn |
|
) |
| |
◆ feResource() [2/3]
char* feResource |
( |
const char |
id, |
|
|
int |
warn |
|
) |
| |
◆ feResource() [3/3]
Definition at line 236 of file feResource.cc.
static char * feInitResource(feResourceConfig config, int warn)
◆ feResourceDefault() [1/3]
char* feResourceDefault |
( |
const char * |
key | ) |
|
Definition at line 158 of file feResource.cc.
static char * feResourceDefault(feResourceConfig config)
◆ feResourceDefault() [2/3]
char* feResourceDefault |
( |
const char |
id | ) |
|
◆ feResourceDefault() [3/3]
◆ feSprintf()
static char * feSprintf |
( |
char * |
s, |
|
|
const char * |
fmt, |
|
|
int |
warn = -1 |
|
) |
| |
|
static |
Definition at line 653 of file feResource.cc.
662 if (*fmt ==
'%' && *(fmt + 1) !=
'\0')
677 else if (*fmt ==
'$' && *(fmt + 1) !=
'\0')
681 while (*fmt ==
'_' ||
682 (*fmt >=
'A' && *fmt <=
'Z') ||
683 (*fmt >=
'a' && *fmt <=
'z'))
const Variable & v
< [in] a sqrfree bivariate poly
◆ feVerifyResourceValue()
static int feVerifyResourceValue |
( |
feResourceType |
type, |
|
|
char * |
value |
|
) |
| |
|
static |
Definition at line 414 of file feResource.cc.
416 #ifdef RESOURCE_DEBUG
417 printf(
"feVerifyResourceValue(type: %d, value: \"%s\"): entering\n", (
int)type, value);
418 printf(
"Access: ROK: %d, XOK: %d\n", access(value, R_OK), access(value, X_OK));
427 return ! access(value, R_OK);
431 return ! access(value, X_OK);
◆ mystrcpy()
static void mystrcpy |
( |
char * |
d, |
|
|
char * |
s |
|
) |
| |
|
static |
◆ feArgv0
◆ feResourceConfigs