MCPcopy Create free account
hub / github.com/Singular/Singular / feInitResource

Function feInitResource

resources/feResource.cc:251–374  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

249}
250
251static char* feInitResource(feResourceConfig config, int warn)
252{
253 /*assume(config != NULL);*/
254#ifdef RESOURCE_DEBUG
255 printf("feInitResource(config->key: '%s', warn: '%d') : entering ...\n", config->key, warn);
256#endif
257
258 char value[MAXRESOURCELEN];
259 // now we have to work
260 // First, check Environment variable
261 if (config->env != NULL)
262 {
263 char* evalue = getenv(config->env);
264 if (evalue != NULL)
265 {
266#ifdef RESOURCE_DEBUG
267 printf("feInitResource(config,warn): Found value from env:%s\n", evalue);
268#endif
269 strcpy(value, evalue);
270 if (config->type == feResBinary // do not verify binaries
271 ||
272 feVerifyResourceValue(config->type,
273 feCleanResourceValue(config->type, value)))
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
278 config->value = strdup(value);
279 return config->value;
280 }
281 }
282 }
283
284 *value = '\0';
285 // Special treatment of executable
286 if (config->id == 'S')
287 {
288 char* executable = feGetExpandedExecutable();
289 if (executable != NULL)
290 {
291#ifdef RESOURCE_DEBUG
292 printf("exec:%s\n", executable);
293#endif
294 strcpy(value, executable);
295#ifdef RESOURCE_DEBUG
296 printf("value:%s\n", value);
297#endif
298 free(executable);
299 }
300 }
301 // and bindir
302 else if (config->id == 'b')
303 {
304 char* executable = feResource('S');
305#ifdef RESOURCE_DEBUG
306 printf("feInitResource(config,warn): Get '%s' from \"%s\"\n", config->key, executable);
307#endif
308 if (executable != NULL)

Callers 1

feResourceFunction · 0.85

Calls 7

feVerifyResourceValueFunction · 0.85
feCleanResourceValueFunction · 0.85
feGetExpandedExecutableFunction · 0.85
freeFunction · 0.85
feResourceFunction · 0.85
feSprintfFunction · 0.85
omFindExecFunction · 0.85

Tested by

no test coverage detected