Changeset 7311 for trunk/psModules/src/config/pmConfig.c
- Timestamp:
- Jun 2, 2006, 3:02:08 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/config/pmConfig.c (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/config/pmConfig.c
r7278 r7311 3 3 * @author PAP, IfA 4 4 * 5 * @version $Revision: 1. 19$ $Name: not supported by cvs2svn $6 * @date $Date: 2006-06-0 2 00:55:22$5 * @version $Revision: 1.20 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2006-06-03 01:02:08 $ 7 7 * 8 8 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 12 12 #include <string.h> 13 13 #include <unistd.h> 14 #include <libgen.h> 14 15 #include <assert.h> 15 16 #include <sys/types.h> … … 52 53 } 53 54 55 void pmConfigSet(const char *path) 56 { 57 pmConfigDone(); 58 59 psList *list = psStringSplit(path, ":", false); 60 configPath = psListToArray(list); 61 psFree(list); 62 } 63 54 64 void pmConfigDone(void) 55 65 { 56 66 psFree(configPath); 67 configPath = NULL; 57 68 } 58 69 … … 100 111 101 112 if (configPath == NULL) { 102 psError(PS_ERR_IO, false, "Cannot find %s configuration file (%s) in path\n", description, name);113 psError(PS_ERR_IO, true, "Cannot find %s configuration file (%s) in path\n", description, name); 103 114 return false; 104 115 } … … 121 132 } 122 133 123 psError(PS_ERR_IO, false, "Cannot find %s configuration file %s in path\n", description, name);134 psError(PS_ERR_IO, true, "Cannot find %s configuration file %s in path\n", description, name); 124 135 return false; 125 136 … … 127 138 *config = psMetadataConfigParse(NULL, &numBadLines, realName, true); 128 139 if (numBadLines > 0) { 129 psLogMsg(__func__, PS_LOG_WARN, "%d bad lines in %s configuration file (%s)\n", 130 description, realName); 140 psError(PS_ERR_IO, false, "%d bad lines in %s configuration file (%s)", 141 numBadLines, description, realName); 142 psFree (realName); 143 144 return false; 131 145 } 132 146 if (!*config) { 133 psError(PS_ERR_IO, false, "Unable to read %s configuration from %s\n",147 psError(PS_ERR_IO, true, "Unable to read %s configuration from %s", 134 148 description, realName); 135 149 psFree (realName); … … 214 228 return NULL; 215 229 } 230 231 // define the config-file search path (configPath). Ensure that 232 // it contains the directory where we found the config file in 233 // the first place 234 if (configPath) { 235 pmConfigDone(); 236 } 237 238 psString siteNameDir = psStringCopy(dirname(siteName)); 216 239 psFree(siteName); 217 240 218 // define the config-file search path (configPath) 219 if (configPath) { 220 psFree(configPath); 221 configPath = NULL; 222 } 223 char *path = psMetadataLookupStr(NULL, config->site, "PATH"); 241 psString path = psMetadataLookupStr(NULL, config->site, "PATH"); 224 242 if (path) { 225 psList *list = psStringSplit(path, ":", false); 226 configPath = psListToArray(list); 227 psFree(list); 228 } 243 psStringAppend(&path, ":%s", siteNameDir); 244 } else { 245 path = psMemIncrRefCounter(siteNameDir); 246 } 247 pmConfigSet(path); 248 psFree(siteNameDir); 229 249 230 250 // Next, we do a similar thing for the camera configuration file. The … … 349 369 } 350 370 371 psErrorClear(); // we may have failed to find some items in the metadata 372 351 373 return config; 352 374 } … … 468 490 psMetadata *cameras = psMetadataLookupMD(&mdok, config->site, "CAMERAS"); 469 491 if (! mdok) { 470 psError(PS_ERR_IO, false, "Unable to find CAMERAS in the configuration.\n");492 psError(PS_ERR_IO, true, "Unable to find CAMERAS in the configuration."); 471 493 return false; 472 494 } … … 502 524 503 525 if (! config->camera) { 504 psError(PS_ERR_IO, true, "Unable to find a camera that matches input FITS header!\n");526 psError(PS_ERR_IO, false, "Unable to find a camera that matches input FITS header!"); 505 527 return NULL; 506 528 } … … 611 633 psMetadata *rules = psMetadataLookupMD(&mdok, format, "RULE"); // How to identify this format 612 634 if (!mdok || !rules) { 613 psError(PS_ERR_IO, false, "Unable to find RULE in camera format.\n");635 psError(PS_ERR_IO, true, "Unable to find RULE in camera format.\n"); 614 636 return false; 615 637 } … … 651 673 globList.gl_offs = 0; 652 674 glob (argv[Narg], 0, NULL, &globList); 675 676 if (globList.gl_pathc == 0) { 677 psError(PS_ERR_IO, true, "No match for %s", argv[Narg]); 678 return input; 679 } 680 653 681 for (int i = 0; i < globList.gl_pathc; i++) { 654 682 char *filename = psStringCopy (globList.gl_pathv[i]); … … 706 734 PS_ASSERT_INT_POSITIVE(strlen(list), NULL); 707 735 736 psErrorClear(); // pmConfigFileSets may or may not call psError, so 737 // if files->n == 0 we'll want to call psError(..., false, ...) 708 738 psArray *files = pmConfigFileSets (argc, argv, file, list); 709 739 if (files->n == 0) { 740 psError(PS_ERR_IO, false, "pmConfigFileSets failed to find desired files in metadata"); 710 741 psFree (files); 711 742 return false;
Note:
See TracChangeset
for help on using the changeset viewer.
