- Timestamp:
- May 3, 2010, 8:50:52 AM (16 years ago)
- Location:
- branches/simtest_nebulous_branches
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/simtest_nebulous_branches
- Property svn:mergeinfo changed
-
branches/simtest_nebulous_branches/psModules
-
Property svn:mergeinfo
set to (toggle deleted branches)
/trunk/psModules merged eligible /branches/eam_branches/stackphot.20100406/psModules 27623-27653 /branches/pap_delete/psModules 27530-27595
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
branches/simtest_nebulous_branches/psModules/src/config/pmConfig.c
r24496 r27840 43 43 #define DEFAULT_TRACE STDERR_FILENO // Default file descriptor for trace messages 44 44 45 #define CHECK_FILE_RETRY 5 // Number of retries when checking a file 46 #define CHECK_FILE_WAIT 250000 // Wait between retries (usec) when checking a file 47 45 48 static bool readCameraConfig = true; // Read the camera config on startup (with pmConfigRead)? 46 49 static psArray *configPath = NULL; // Search path for configuration files 47 50 48 51 static bool checkPath(const char *filename, bool create, bool trunc); 52 static psString resolveConfigFile(const char *name); 49 53 50 54 bool pmConfigReadParamsSet(bool newReadCameraConfig) … … 174 178 char *envName = envStart + 1; // Start of the environment variable name 175 179 if (envName[0] == '\0') { 176 psError(P S_ERR_BAD_PARAMETER_VALUE, true, "Path %s contains a bad environment variable.\n", dir);180 psError(PM_ERR_CONFIG, true, "Path %s contains a bad environment variable.\n", dir); 177 181 return NULL; 178 182 } … … 180 184 envName++; 181 185 if (envName[0] == '\0') { 182 psError(P S_ERR_BAD_PARAMETER_VALUE, true,186 psError(PM_ERR_CONFIG, true, 183 187 "Path %s contains a bad environment variable.\n", dir); 184 188 return NULL; … … 272 276 273 277 if (configPath == NULL) { 274 psError(P S_ERR_IO, true, "Cannot find %s configuration file (%s) in path\n", description, name);278 psError(PM_ERR_CONFIG, true, "Cannot find %s configuration file (%s) in path\n", description, name); 275 279 return false; 276 280 } … … 296 300 } 297 301 298 psError(P S_ERR_IO, true, "Cannot find %s configuration file %s in path\n", description, name);302 psError(PM_ERR_CONFIG, true, "Cannot find %s configuration file %s in path\n", description, name); 299 303 return false; 300 304 … … 302 306 *config = psMetadataConfigRead(NULL, &numBadLines, realName, true); 303 307 if (numBadLines > 0) { 304 psError(P S_ERR_IO, false, "%d bad lines in %s configuration file (%s)",308 psError(PM_ERR_CONFIG, false, "%d bad lines in %s configuration file (%s)", 305 309 numBadLines, description, realName); 306 310 psFree (realName); … … 309 313 } 310 314 if (!*config) { 311 psError(P S_ERR_IO, true, "Unable to read %s configuration from %s",315 psError(PM_ERR_CONFIG, true, "Unable to read %s configuration from %s", 312 316 description, realName); 313 317 psFree (realName); … … 328 332 } 329 333 if (item->type != PS_DATA_STRING) { 330 ps Trace("config", 2, "Element %s in %s metadata is not of type STR.\n",334 psError(PM_ERR_CONFIG, true, "Element %s in %s metadata is not of type STR.\n", 331 335 item->name, description); 332 336 return false; … … 336 340 psMetadata *new = NULL; // New metadata 337 341 if (!pmConfigFileRead(&new, item->data.str, item->name)) { 338 psError( PM_ERR_CONFIG, false, "Trouble reading reading %s %s.\n",342 psError(psErrorCodeLast(), false, "Trouble reading reading %s %s.\n", 339 343 description, item->name); 340 344 psFree(new); … … 361 365 while ((item = psMetadataGetAndIncrement(iter))) { 362 366 if (!pmConfigFileIngest(item, description)) { 363 psError( PM_ERR_CONFIG, false, "Unable to read %s %s.", description, item->name);367 psError(psErrorCodeLast(), false, "Unable to read %s %s.", description, item->name); 364 368 psFree(iter); 365 369 return false; … … 382 386 psMetadata *formats = psMetadataLookupMetadata(&mdok, camera, "FORMATS"); // Formats 383 387 if (!mdok || !formats) { 384 psError(P S_ERR_UNEXPECTED_NULL, true, "Unable to find FORMATS in camera configuration %s.\n", name);388 psError(PM_ERR_CONFIG, true, "Unable to find FORMATS in camera configuration %s.\n", name); 385 389 return false; 386 390 } 387 391 if (!metadataReadFiles(formats, "camera format")) { 388 psError( PS_ERR_UNKNOWN, false, "Unable to read formats within camera configuration %s.\n", name);392 psError(psErrorCodeLast(), false, "Unable to read formats within camera configuration %s.\n", name); 389 393 return false; 390 394 } … … 447 451 psWarning("-ipprc command-line switch provided without the required filename --- ignored.\n"); 448 452 } else { 449 configFile = psStringCopy(argv[argNum]);453 configFile = resolveConfigFile(argv[argNum]); 450 454 psArgumentRemove(argNum, argc, argv); 451 455 } … … 486 490 psMetadataItem *siteItem = psMetadataLookup(config->user, "SITE"); 487 491 if (!siteItem) { 488 psError(P S_ERR_BAD_PARAMETER_VALUE, true, "Unable to find SITE in user configuration.");492 psError(PM_ERR_CONFIG, true, "Unable to find SITE in user configuration."); 489 493 psFree(config); 490 494 return NULL; 491 495 } 492 496 if (!pmConfigFileIngest(siteItem, "site configuration")) { 493 psError( PS_ERR_UNKNOWN, false, "Unable to read site configuration");497 psError(psErrorCodeLast(), false, "Unable to read site configuration"); 494 498 psFree(config); 495 499 return NULL; … … 500 504 psMetadataItem *systemItem = psMetadataLookup(config->user, "SYSTEM"); 501 505 if (!systemItem) { 502 psError(P S_ERR_BAD_PARAMETER_VALUE, true, "Unable to find SYSTEM in user configuration.");506 psError(PM_ERR_CONFIG, true, "Unable to find SYSTEM in user configuration."); 503 507 psFree(config); 504 508 return NULL; 505 509 } 506 510 if (!pmConfigFileIngest(systemItem, "system configuration")) { 507 psError( PS_ERR_UNKNOWN, false, "Unable to read system configuration");511 psError(psErrorCodeLast(), false, "Unable to read system configuration"); 508 512 psFree(config); 509 513 return NULL; … … 551 555 psString resolved = pmConfigConvertFilename(logDest, config, true, false); // Resolved filename 552 556 if (!resolved || strlen(resolved) == 0) { 553 psWarning("Unable to resolve log destination: %s --- ignored", logDest); 554 } else { 555 pmConfigRunFilenameAddWrite(config, "LOG", logDest); 556 config->logFD = psMessageDestination(resolved); 557 } 557 psError(psErrorCodeLast(), false, "Unable to resolve log destination: %s", logDest); 558 psFree(logDest); 559 return NULL; 560 } 561 pmConfigRunFilenameAddWrite(config, "LOG", logDest); 562 config->logFD = psMessageDestination(resolved); 558 563 psFree(resolved); 559 564 psFree(logDest); … … 610 615 psString resolved = pmConfigConvertFilename(traceDest, config, true, false); // Resolved filename 611 616 if (!resolved || strlen(resolved) == 0) { 612 psWarning("Unable to resolve trace destination: %s --- ignored", traceDest); 613 } else { 614 pmConfigRunFilenameAddWrite(config, "TRACE", traceDest); 615 config->traceFD = psMessageDestination(resolved); 616 } 617 psError(psErrorCodeLast(), false, "Unable to resolve trace destination: %s", traceDest); 618 psFree(traceDest); 619 return NULL; 620 } 621 pmConfigRunFilenameAddWrite(config, "TRACE", traceDest); 622 config->traceFD = psMessageDestination(resolved); 617 623 psFree(resolved); 618 624 psFree(traceDest); … … 659 665 seed = strtoll(argv[argNum], &end, 0); 660 666 if (strlen(end) > 0) { 661 psError(PS_ERR_IO, true, "Unable to read random number generator seed: %s", argv[argNum]); 667 psError(PM_ERR_CONFIG, true, "Unable to read random number generator seed: %s", 668 argv[argNum]); 662 669 psFree(config); 663 670 return NULL; … … 684 691 psMetadata *cameras = psMetadataLookupMetadata(&mdok, config->system, "CAMERAS"); 685 692 if (!cameras) { 686 psError(P S_ERR_IO, false, "Unable to find CAMERAS in site configuration.\n");693 psError(PM_ERR_CONFIG, false, "Unable to find CAMERAS in site configuration.\n"); 687 694 psFree(config); 688 695 return NULL; … … 692 699 char *cameraFile = psMetadataLookupStr(&mdok, cameras, cameraName); // The filename 693 700 if (!cameraFile) { 694 psError(P S_ERR_IO, false, "%s is not listed in the site CAMERAS list\n", cameraName);701 psError(PM_ERR_CONFIG, false, "%s is not listed in the site CAMERAS list\n", cameraName); 695 702 psFree(config); 696 703 return NULL; … … 699 706 // load this camera's configuration informatoin 700 707 if (!pmConfigFileRead(&config->camera, cameraFile, "camera")) { 701 psError( PM_ERR_CONFIG, false, "Problem reading %s", cameraName);708 psError(psErrorCodeLast(), false, "Problem reading %s", cameraName); 702 709 psFree(config); 703 710 return NULL; … … 710 717 // Read in the formats 711 718 if (!cameraReadFormats(config->camera, cameraFile)) { 712 psError( PS_ERR_UNKNOWN, false, "Unable to read formats within camera configuration %s.\n",719 psError(psErrorCodeLast(), false, "Unable to read formats within camera configuration %s.\n", 713 720 cameraFile); 714 721 psFree(config); … … 718 725 // Read in any camera-specific calibrations 719 726 if (!cameraReadCalibrations(config->camera, cameraName)) { 720 psError( PS_ERR_UNKNOWN, false,727 psError(psErrorCodeLast(), false, 721 728 "Unable to read calibrations within camera configuration %s.\n", 722 729 cameraName); … … 729 736 730 737 if (!pmConfigCameraSkycellVersion(config->system, cameraName)) { 731 psError( PS_ERR_UNKNOWN, false,738 psError(psErrorCodeLast(), false, 732 739 "Unable to generate skycell versions of specified camera %s.\n", 733 740 cameraName); … … 737 744 738 745 if (!pmConfigCameraMosaickedVersions(config->system, cameraName)) { 739 psError( PS_ERR_UNKNOWN, false,746 psError(psErrorCodeLast(), false, 740 747 "Unable to generate mosaicked versions of specified camera %s.\n", 741 748 cameraName); … … 751 758 psMetadata *cameras = psMetadataLookupMetadata(&mdok, config->system, "CAMERAS"); // List of cameras 752 759 if (!mdok || !cameras) { 753 psError(P S_ERR_UNEXPECTED_NULL, true, "Unable to find CAMERAS in the system configuration.\n");760 psError(PM_ERR_CONFIG, true, "Unable to find CAMERAS in the system configuration.\n"); 754 761 return false; 755 762 } 756 763 757 764 if (!metadataReadFiles(cameras, "camera configuration")) { 758 psError( PS_ERR_UNKNOWN, false, "Unable to read cameras within system configuration.\n");765 psError(psErrorCodeLast(), false, "Unable to read cameras within system configuration.\n"); 759 766 psFree(config); 760 767 return NULL; … … 784 791 785 792 if (!pmConfigCameraSkycellVersionsAll(config->system)) { 786 psError( PS_ERR_UNKNOWN, false, "Unable to generate skycell versions of cameras.\n");793 psError(psErrorCodeLast(), false, "Unable to generate skycell versions of cameras.\n"); 787 794 psFree(config); 788 795 return NULL; 789 796 } 790 797 if (!pmConfigCameraMosaickedVersionsAll(config->system)) { 791 psError( PS_ERR_UNKNOWN, false, "Unable to generate mosaicked versions of cameras.\n");798 psError(psErrorCodeLast(), false, "Unable to generate mosaicked versions of cameras.\n"); 792 799 psFree(config); 793 800 return NULL; … … 797 804 // Load the recipes from the camera file, if appropriate 798 805 if(!pmConfigReadRecipes(config, PM_RECIPE_SOURCE_SYSTEM | PM_RECIPE_SOURCE_CAMERA)) { 799 psError( PS_ERR_IO, false, "Failed to read recipes from camera file");806 psError(psErrorCodeLast(), false, "Failed to read recipes from camera file"); 800 807 psFree(config); 801 808 return NULL; … … 812 819 813 820 if (!pmConfigReadRecipes(config, PM_RECIPE_SOURCE_CL)) { 814 psError( PS_ERR_IO, false, "Failed to read recipes from command-line");821 psError(psErrorCodeLast(), false, "Failed to read recipes from command-line"); 815 822 psFree(config); 816 823 return NULL; … … 821 828 psArgumentRemove(argNum, argc, argv); 822 829 if (argNum + 1 >= *argc) { 823 psError(P S_ERR_BAD_PARAMETER_SIZE, true,830 psError(PM_ERR_CONFIG, true, 824 831 "Filerule switch (-F) provided without old and new filerule."); 825 832 psFree(config); … … 834 841 psMetadata *cameras = psMetadataLookupMetadata(NULL, config->system, "CAMERAS"); // List of cameras 835 842 if (!cameras) { 836 psError(P S_ERR_UNEXPECTED_NULL, false, "Unable to find CAMERAS in the site configuration.\n");843 psError(PM_ERR_CONFIG, false, "Unable to find CAMERAS in the site configuration.\n"); 837 844 return false; 838 845 } … … 995 1002 psMetadata *rule = psMetadataLookupMetadata(&mdStatus, cameraFormat, "RULE"); 996 1003 if (! mdStatus || ! rule) { 997 psError(P S_ERR_UNKNOWN, false, "Unable to read rule for camera.");1004 psError(PM_ERR_CONFIG, false, "Unable to read rule for camera."); 998 1005 *valid = false; 999 1006 return false; … … 1004 1011 psArray *keys = psListToArray (keyList); 1005 1012 if (! keys) { 1006 psError(P S_ERR_UNKNOWN, false, "Unable to read rule for camera.");1013 psError(PM_ERR_CONFIG, false, "Unable to read rule for camera."); 1007 1014 *valid = false; 1008 1015 return false; … … 1053 1060 } 1054 1061 1055 psError(P S_ERR_UNKNOWN, false, "Invalid type for RULE %s.", ruleItem->name);1062 psError(PM_ERR_CONFIG, false, "Invalid type for RULE %s.", ruleItem->name); 1056 1063 *valid = false; 1057 1064 psFree (keyList); … … 1088 1095 psMetadata *formats = psMetadataLookupMetadata(&mdok, camera, "FORMATS"); // List of formats 1089 1096 if (!mdok || !formats) { 1090 psError(P S_ERR_UNKNOWN, false, "Unable to find list of FORMATS in camera %s", cameraName);1097 psError(PM_ERR_CONFIG, false, "Unable to find list of FORMATS in camera %s", cameraName); 1091 1098 *status = false; 1092 1099 return false; … … 1094 1101 1095 1102 if (!metadataReadFiles(formats, "camera format")) { 1096 psError( PS_ERR_UNKNOWN, false, "Unable to read cameras formats within camera configuration.\n");1103 psError(psErrorCodeLast(), false, "Unable to read cameras formats within camera configuration.\n"); 1097 1104 *status = false; 1098 1105 return false; … … 1110 1117 bool valid = false; 1111 1118 if (!pmConfigValidateCameraFormat(&valid, testFormat, header)) { 1112 psError ( PS_ERR_UNKNOWN, false, "Error in config scripts for camera %s, format %s\n",1119 psError (psErrorCodeLast(), false, "Error in config scripts for camera %s, format %s\n", 1113 1120 cameraName, formatsItem->name); 1114 1121 *status = false; … … 1156 1163 psMetadata *cameras = psMetadataLookupMetadata(&mdok, config->system, "CAMERAS"); 1157 1164 if (! mdok || !cameras) { 1158 psError(P S_ERR_IO, true, "Unable to find CAMERAS in the configuration.");1165 psError(PM_ERR_CONFIG, true, "Unable to find CAMERAS in the configuration."); 1159 1166 return NULL; 1160 1167 } 1161 1168 1162 1169 if (!metadataReadFiles(cameras, "camera configuration")) { 1163 psError( PS_ERR_UNKNOWN, false, "Unable to read cameras within site configuration.\n");1170 psError(psErrorCodeLast(), false, "Unable to read cameras within site configuration.\n"); 1164 1171 return NULL; 1165 1172 } … … 1190 1197 } else { 1191 1198 if (!status) { 1192 psError(PS_ERR_IO, false, "Error reading camera config data for %s", camerasItem->name); 1199 psError(psErrorCodeLast(), false, "Error reading camera config data for %s", 1200 camerasItem->name); 1193 1201 return NULL; 1194 1202 } … … 1199 1207 // Done looking at all cameras 1200 1208 if (!config->camera) { 1201 psError(P S_ERR_IO, false, "Unable to find a camera that matches input FITS header!");1209 psError(PM_ERR_CONFIG, true, "Unable to find a camera that matches input FITS header!"); 1202 1210 return NULL; 1203 1211 } … … 1205 1213 // Now we have the camera, we can read the recipes 1206 1214 if (readRecipes && !pmConfigReadRecipes(config, PM_RECIPE_SOURCE_CAMERA | PM_RECIPE_SOURCE_CL)) { 1207 psError(PS_ERR_IO, false, "Error reading recipes from camera config for %s", config->cameraName); 1215 psError(psErrorCodeLast(), false, "Error reading recipes from camera config for %s", 1216 config->cameraName); 1208 1217 return NULL; 1209 1218 } … … 1281 1290 1282 1291 if (!found) { 1283 psError(PS_ERR_IO, true, "Unable to find a format with the specified camera (%s) that matches the " 1284 "given header.\n", baseName); 1292 psError(PM_ERR_CONFIG, true, 1293 "Unable to find a format with the specified camera (%s) that matches the given header.", 1294 baseName); 1285 1295 psFree (baseName); 1286 1296 return NULL; … … 1313 1323 psMetadata *cameras = psMetadataLookupMetadata(NULL, config->system, "CAMERAS"); 1314 1324 if (!cameras) { 1315 psError(P S_ERR_IO, true, "Unable to find CAMERAS in the configuration.");1325 psError(PM_ERR_CONFIG, true, "Unable to find CAMERAS in the configuration."); 1316 1326 return NULL; 1317 1327 } … … 1319 1329 psMetadataItem *item = psMetadataLookup(cameras, cameraName); // Item with camera of interest 1320 1330 if (!pmConfigFileIngest(item, "camera configuration")) { 1321 psError( PS_ERR_UNKNOWN, false, "Unable to ingest camera configuration.");1331 psError(psErrorCodeLast(), false, "Unable to ingest camera configuration."); 1322 1332 return NULL; 1323 1333 } … … 1335 1345 item = psMetadataLookup(config->site, name); 1336 1346 if (!item) { 1337 psError(P S_ERR_BAD_PARAMETER_VALUE, true,1347 psError(PM_ERR_CONFIG, true, 1338 1348 "Unable to find %s in user or site configuration", name); 1339 1349 return NULL; … … 1341 1351 } 1342 1352 if (item->type != type) { 1343 psError(P S_ERR_BAD_PARAMETER_TYPE, true,1353 psError(PM_ERR_CONFIG, true, 1344 1354 "Type of %s (%x) in user/site configuration does not match expected (%x)", 1345 1355 name, item->type, type); … … 1358 1368 #ifndef HAVE_PSDB 1359 1369 1360 psError(P S_ERR_UNKNOWN, false,1370 psError(PM_ERR_PROG, false, 1361 1371 "Cannot configure database: psModules was compiled without database support."); 1362 1372 return NULL; … … 1407 1417 psMetadata *rules = psMetadataLookupMetadata(&mdok, format, "RULE"); // How to identify this format 1408 1418 if (!mdok || !rules) { 1409 psError(P S_ERR_IO, true, "Unable to find RULE in camera format.\n");1419 psError(PM_ERR_CONFIG, true, "Unable to find RULE in camera format.\n"); 1410 1420 return false; 1411 1421 } … … 1415 1425 while ((rulesItem = psMetadataGetAndIncrement(rulesIter))) { 1416 1426 if (!PS_DATA_IS_PRIMITIVE(rulesItem->type) && rulesItem->type != PS_DATA_STRING) { 1417 psError(P S_ERR_UNKNOWN, false, "Invalid type for RULE %s.", rulesItem->name);1427 psError(PM_ERR_CONFIG, false, "Invalid type for RULE %s.", rulesItem->name); 1418 1428 return false; 1419 1429 } … … 1447 1457 case PS_METADATA_ITEM_COMPARE_OP_NE: 1448 1458 // It's not at all obvious what the value should be, so return an error. 1449 psError(P S_ERR_IO, true,1459 psError(PM_ERR_CONFIG, true, 1450 1460 "RULE %s (defined by an OPeration) is not present or not consistent in output header", 1451 1461 rulesItem->name); … … 1530 1540 default: 1531 1541 // rigid format, no comments allowed? 1532 psError(P S_ERR_BAD_PARAMETER_VALUE, true, "Unable to parse file list: spaces detected.");1542 psError(PM_ERR_CONFIG, true, "Unable to parse file list: spaces detected."); 1533 1543 psFree(input); 1534 1544 fclose(f); … … 1563 1573 if (!files) { 1564 1574 psAbort("error parsing argument list"); 1565 psError( PS_ERR_IO, false, "error parsing argument list");1575 psError(psErrorCodeLast(), false, "error parsing argument list"); 1566 1576 psFree (files); 1567 1577 return false; … … 1590 1600 1591 1601 char *point = newName + strlen("file:"); 1592 while (*point == '/') 1602 while (*point == '/') { 1593 1603 point ++; 1604 } 1594 1605 char *tmpName = NULL; 1595 1606 psStringAppend (&tmpName, "/%s", point); … … 1599 1610 if (!checkPath(newName, create, trunc)) { 1600 1611 // let checkPath()'s psError() call float up 1601 psError( PS_ERR_UNKNOWN, false, "error from checkPath for file:// (%s)", newName);1612 psError(psErrorCodeLast(), false, "error from checkPath for file:// (%s)", newName); 1602 1613 psFree (newName); 1603 1614 return NULL; … … 1617 1628 psMetadata *datapath = psMetadataLookupPtr (NULL, config->site, "DATAPATH"); 1618 1629 if (datapath == NULL) { 1619 psError(P S_ERR_UNKNOWN, true, "DATAPATH is not defined in config.site");1630 psError(PM_ERR_CONFIG, true, "DATAPATH is not defined in config.site"); 1620 1631 psFree (newName); 1621 1632 return NULL; … … 1625 1636 char *mark = strchr (point, '/'); 1626 1637 if (mark == NULL) { 1627 psError(P S_ERR_UNKNOWN, true, "syntax error in PATH-style name %s", newName);1638 psError(PM_ERR_CONFIG, true, "syntax error in PATH-style name %s", newName); 1628 1639 psFree (newName); 1629 1640 return false; … … 1633 1644 char *realpath = psMetadataLookupStr (NULL, datapath, path); 1634 1645 if (realpath == NULL) { 1635 psError(P S_ERR_UNKNOWN, true,1646 psError(PM_ERR_CONFIG, true, 1636 1647 "path (%s) not defined in config.site:DATAPATH for PATH-style name %s", 1637 1648 path, newName); … … 1649 1660 if (!checkPath(newName, create, trunc)) { 1650 1661 // let checkPath()'s psError() call float up 1651 psError( PS_ERR_UNKNOWN, false, "error from checkPath for path:// (%s)", newName);1662 psError(psErrorCodeLast(), false, "error from checkPath for path:// (%s)", newName); 1652 1663 psFree (newName); 1653 1664 return NULL; … … 1711 1722 nebServerFree(server); 1712 1723 1713 if (trunc) { 1714 if(truncate(path, 0) != 0) { 1715 psError(PS_ERR_IO, true, "Failed to truncate Nebulous file %s (real name %s)\n", 1716 filename, path); 1717 return NULL; 1718 } 1724 // Check to ensure it's there. Will create the file if Nebulous failed to do so. 1725 if (!checkPath(path, create, trunc)) { 1726 psError(psErrorCodeLast(), false, "Cannot find file %s", path); 1727 psFree(path); 1728 return NULL; 1719 1729 } 1720 1730 … … 1741 1751 psMetadataItem *item = psMetadataLookup(camera, "FILERULES"); // Item with the file rule of interest 1742 1752 if (!item) { 1743 psError(P S_ERR_UNEXPECTED_NULL, false, "Unable to find FILERULES in the camera configuration.");1753 psError(PM_ERR_CONFIG, false, "Unable to find FILERULES in the camera configuration."); 1744 1754 return NULL; 1745 1755 } … … 1774 1784 psMetadataItem *item = psMetadataLookup(camera, "FITSTYPES"); // Item with the file rule of interest 1775 1785 if (!item) { 1776 psError(P S_ERR_UNEXPECTED_NULL, false, "Unable to find FITSTYPES in the camera configuration.");1786 psError(PM_ERR_CONFIG, false, "Unable to find FITSTYPES in the camera configuration."); 1777 1787 return NULL; 1778 1788 } … … 1801 1811 1802 1812 // re-try access up to 5 times (1.25sec) to reduce NFS lurches 1803 for (int i = 0; i < 5; i++) {1813 for (int i = 0; i < CHECK_FILE_RETRY; i++) { 1804 1814 if (access(filename, R_OK) == 0) { 1805 1815 // file already exists … … 1826 1836 return true; 1827 1837 } 1828 usleep (250000);1838 usleep(CHECK_FILE_WAIT); 1829 1839 } 1830 1840 … … 1834 1844 return false; 1835 1845 } 1846 1847 static psString resolveConfigFile(const char *nameArg) 1848 { 1849 // if config file name is nebulous path resolve it 1850 // otherwise just return a copy of the argument 1851 if (strncasecmp(nameArg, "neb://", strlen("neb://"))) { 1852 return psStringCopy(nameArg); 1853 } 1854 1855 #ifdef HAVE_NEBCLIENT 1856 char *neb_server = getenv("NEB_SERVER"); 1857 1858 // if env isn't set, check the config system 1859 if (!neb_server) { 1860 psError(PM_ERR_CONFIG, true, "NEB_SERVER environment variable must be set in order to resolve config file."); 1861 return NULL; 1862 } 1863 1864 nebServer *server = nebServerAlloc(neb_server); 1865 if (!server) { 1866 psError(PM_ERR_SYS, true, "failed to create a nebServer object."); 1867 return NULL; 1868 } 1869 1870 char *nebfile = nebFind(server, nameArg); 1871 nebServerFree(server); 1872 if (!nebfile) { 1873 // object does not exist 1874 psError(PM_ERR_SYS, true, "failed to resolve nebulous path: %s.", nameArg); 1875 return NULL; 1876 } 1877 // XXX: do I need to free nebfile? 1878 1879 return psStringCopy(nebfile); 1880 #else 1881 psError(PM_ERR_PROG, true, "psModules was compiled without nebulous support."); 1882 return NULL; 1883 #endif // ifdef HAVE_NEBCLIENT 1884 }
Note:
See TracChangeset
for help on using the changeset viewer.
