Changeset f323dd1 in git for findexec/feResource.cc
- Timestamp:
- Feb 29, 2012, 5:18:58 PM (12 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- 8d8cd944663cf80b3fd163a42279526ce163a5fd
- Parents:
- d8b0f69f9828897dca663d5bb516369b1b0ac64a
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
findexec/feResource.cc
rd8b0f69 rf323dd1 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id$ */5 4 /* 6 5 * ABSTRACT: management of resources … … 10 9 #include <unistd.h> 11 10 #include <string.h> 12 #include < unistd.h>11 #include <stdio.h> 13 12 #include <sys/param.h> 14 13 … … 34 33 35 34 36 #include <reporter/reporter.h>35 //#include <reporter/reporter.h> 37 36 //char* feResource(const char id, int warn = -1); 38 37 //char* feResource(const char* key, int warn = -1); … … 41 40 // #define RESOURCE_DEBUG 42 41 43 #define SINGULAR_DEFAULT_DIR "/usr/local/Singular/" S_VERSION142 #define SINGULAR_DEFAULT_DIR "/usr/local/Singular/"PACKAGE_VERSION 44 43 45 44 /***************************************************************** … … 48 47 * 49 48 *****************************************************************/ 50 typedef enum {feResUndef = 0, feResBinary, feResDir, feResFile, feResUrl, feResPath} feResourceType;51 52 typedef struct feResourceConfig_s53 {54 const char* key; // key to identify resource55 const char id; // char id to identify resource56 feResourceType type; // type of Resource57 const char* env; // env variable to look for58 const char* fmt; // format string -- see below for epxlaination59 char* value; // what it was set to: may be changed60 } feResourceConfig_s;61 typedef feResourceConfig_s * feResourceConfig;62 63 49 // feSprintf transforms format strings as follows: 64 50 // 1.) substrings of the form %c (c being a letter) are replaced by respective resource value … … 68 54 // 1.) '/' characters are replaced by respective directory - separators 69 55 // 2.) ';' characters are replaced by respective path separators 70 staticfeResourceConfig_s feResourceConfigs[] =56 feResourceConfig_s feResourceConfigs[] = 71 57 { 72 58 {"SearchPath", 's', feResPath, NULL, … … 96 82 {"HtmlHelpFile",'C', feResFile, "SINGULAR_CHM_FILE", "%r/doc/Manual.chm", (char *)""}, 97 83 #endif 98 {"ManualUrl", 'u', feResUrl, "SINGULAR_URL", "http://www.singular.uni-kl.de/Manual/" S_VERSION1, (char *)""},84 {"ManualUrl", 'u', feResUrl, "SINGULAR_URL", "http://www.singular.uni-kl.de/Manual/"PACKAGE_VERSION, (char *)""}, 99 85 {"ExDir", 'm', feResDir, "SINGULAR_EXAMPLES_DIR","%r/examples", (char *)""}, 100 86 {"Path", 'p', feResPath, NULL, "%b;$PATH", (char *)""}, … … 130 116 static char* feInitResource(feResourceConfig config, int warn); 131 117 static char* feGetExpandedExecutable(); 132 static BOOLEANfeVerifyResourceValue(feResourceType type, char* value);118 static int feVerifyResourceValue(feResourceType type, char* value); 133 119 static char* feCleanResourceValue(feResourceType type, char* value); 134 120 static char* feCleanUpFile(char* fname); … … 278 264 static char* feInitResource(feResourceConfig config, int warn) 279 265 { 280 assume(config != NULL);266 /*assume(config != NULL);*/ 281 267 #ifdef RESOURCE_DEBUG 282 268 printf("feInitResource: entering for %s\n", config->key); … … 351 337 else if (config->fmt == NULL) 352 338 { 353 sprintf(value, "Wrong Resource Specification of %s", config->key); 354 dReportBug(value); 339 printf("Bug >>Wrong Resource Specification of %s<< at %s:%d\n",config->key,__FILE__,__LINE__); 355 340 return NULL; 356 341 } … … 388 373 if (warn > 0 || (warn < 0 && config->value != NULL)) 389 374 { 390 Warn("Could not get %s. ", config->key);391 Warn("Either set environment variable %s to %s,",375 printf("// ** Could not get %s. ", config->key); 376 printf("// ** Either set environment variable %s to %s,", 392 377 config->env, config->key); 393 378 feSprintf(value, config->fmt, warn); 394 Warn("or make sure that %s is at %s", config->key, value);379 printf("// ** or make sure that %s is at %s", config->key, value); 395 380 } 396 381 #ifdef RESOURCE_DEBUG … … 405 390 if (feArgv0 == NULL || *feArgv0 == '\0') 406 391 { 407 if (feArgv0 == NULL) dReportBug("feArgv0 == NULL"); 408 else dReportBug("feArgv0 == ''"); 392 if (feArgv0 == NULL) 393 printf("Bug >>feArgv0 == NULL<< at %s:%d\n",__FILE__,__LINE__); 394 else 395 printf("Bug >>feArgv0 == ''<< at %s:%d\n",__FILE__,__LINE__); 409 396 return NULL; 410 397 } … … 430 417 if (value == NULL) 431 418 { 432 char message[MAXRESOURCELEN]; 433 sprintf(message, "Could not get expanded executable from %s", feArgv0); 434 dReportBug(message); 419 printf("Bug >>Could not get expanded executable from %s<< at %s:%d\n",feArgv0,__FILE__,__LINE__); 435 420 return NULL; 436 421 } … … 439 424 440 425 441 static BOOLEANfeVerifyResourceValue(feResourceType type, char* value)426 static int feVerifyResourceValue(feResourceType type, char* value) 442 427 { 443 428 #ifdef RESOURCE_DEBUG … … 449 434 case feResUrl: 450 435 case feResPath: 451 return TRUE;436 return 1; 452 437 453 438 case feResFile: … … 459 444 460 445 default: 461 return FALSE;446 return 0; 462 447 } 463 448 } … … 663 648 static void mystrcpy(char* d, char* s) 664 649 { 665 assume(d != NULL && s != NULL);650 /*assume(d != NULL && s != NULL);*/ 666 651 while (*s != '\0') 667 652 { … … 727 712 } 728 713 729 void feStringAppendResources(int warn)730 {731 int i = 0;732 char* r;733 StringAppend("%-10s:\t%s\n", "argv[0]", feArgv0);734 while (feResourceConfigs[i].key != NULL)735 {736 r = feResource(feResourceConfigs[i].key, warn);737 StringAppend("%-10s:\t%s\n", feResourceConfigs[i].key,738 (r != NULL ? r : ""));739 i++;740 }741 }
Note: See TracChangeset
for help on using the changeset viewer.