Changeset 18908
- Timestamp:
- Aug 4, 2008, 5:45:56 PM (18 years ago)
- Location:
- trunk/psModules/src
- Files:
-
- 6 edited
-
camera/pmFPAfileDefine.c (modified) (15 diffs)
-
config/pmConfig.c (modified) (29 diffs)
-
config/pmConfig.h (modified) (3 diffs)
-
config/pmConfigCommand.c (modified) (1 diff)
-
config/pmConfigDump.c (modified) (2 diffs)
-
config/pmConfigRecipes.c (modified) (21 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/camera/pmFPAfileDefine.c
r18567 r18908 24 24 25 25 # define FPA_TEST_ASSERT(A){ \ 26 assert(A->format == NULL); \27 assert(A->formatName == NULL); \28 assert(A->filerule == NULL); \29 assert(A->filesrc == NULL); }26 assert(A->format == NULL); \ 27 assert(A->formatName == NULL); \ 28 assert(A->filerule == NULL); \ 29 assert(A->filesrc == NULL); } 30 30 31 31 // Parse an option from a metadata, returning the appropriate integer value … … 164 164 } else { 165 165 bool mdok; // Status of MD lookup 166 psMetadata *cameras = psMetadataLookupMetadata(&mdok, config-> complete, "CAMERAS"); // Known cameras166 psMetadata *cameras = psMetadataLookupMetadata(&mdok, config->system, "CAMERAS"); // Known cameras 167 167 if (!mdok || !cameras) { 168 168 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find CAMERAS in the system configuration.\n"); … … 486 486 psError(PS_ERR_IO, false, "Failed to read CCD format from %s\n", realName); 487 487 psFree(phu); 488 psFree(camera);489 psFree(formatName);488 psFree(camera); 489 psFree(formatName); 490 490 psFree(realName); 491 491 return NULL; … … 498 498 psError(PS_ERR_IO, false, "Failed to construct FPA from %s", realName); 499 499 psFree(phu); 500 psFree(camera);501 psFree(formatName);500 psFree(camera); 501 psFree(formatName); 502 502 psFree(realName); 503 503 psFree(format); … … 513 513 psError(PS_ERR_IO, false, "file %s not defined\n", filename); 514 514 psFree(phu); 515 psFree(formatName);515 psFree(formatName); 516 516 psFree(format); 517 517 psFree(fpa); 518 518 return NULL; 519 519 } 520 psFree (file->filerule); // this is set in pmFPAfileDefineInput 520 psFree (file->filerule); // this is set in pmFPAfileDefineInput 521 521 file->format = format; 522 522 file->formatName = formatName; … … 534 534 535 535 if (file->type == PM_FPA_FILE_MASK) { 536 if (!pmConfigMaskReadHeader (config, phu)) {537 psError(PS_ERR_IO, false, "error in mask bits");538 return NULL;539 }536 if (!pmConfigMaskReadHeader (config, phu)) { 537 psError(PS_ERR_IO, false, "error in mask bits"); 538 return NULL; 539 } 540 540 } 541 541 … … 549 549 if (!realName) { 550 550 psError(PS_ERR_IO, false, "Failed to convert file name %s", (char *) infiles->data[i]); 551 psFree(phu);552 psFree(fpa);551 psFree(phu); 552 psFree(fpa); 553 553 return NULL; 554 554 } … … 558 558 psError(PS_ERR_IO, false, "Failed to open file %s\n", realName); 559 559 psFree(realName); 560 psFree(phu);561 psFree(fpa);560 psFree(phu); 561 psFree(fpa); 562 562 return NULL; 563 563 } … … 567 567 psFree(realName); 568 568 psFitsClose(fits); 569 psFree(phu);570 psFree(fpa);569 psFree(phu); 570 psFree(fpa); 571 571 return NULL; 572 572 } … … 576 576 psFree(realName); 577 577 psFitsClose(fits); 578 psFree(phu);579 psFree(fpa);578 psFree(phu); 579 psFree(fpa); 580 580 return NULL; 581 581 } … … 584 584 psFree(realName); 585 585 psFitsClose(fits); 586 psFree(phu);587 psFree(fpa);586 psFree(phu); 587 psFree(fpa); 588 588 return NULL; 589 589 } … … 744 744 psMetadataAddStr (file->names, PS_LIST_TAIL, name, 0, "", infiles->data[i]); 745 745 746 if ((i == 0) && (file->type == PM_FPA_FILE_MASK)) {747 if (!pmConfigMaskReadHeader (config, phu)) {748 psError(PS_ERR_IO, false, "error in mask bits");749 return NULL;750 }751 }746 if ((i == 0) && (file->type == PM_FPA_FILE_MASK)) { 747 if (!pmConfigMaskReadHeader (config, phu)) { 748 psError(PS_ERR_IO, false, "error in mask bits"); 749 return NULL; 750 } 751 } 752 752 753 753 psFree(view); … … 819 819 psError(PS_ERR_IO, false, "Failed to read CCD format from %s\n", (char *)infiles->data[0]); 820 820 psFree(phu); 821 psFree(camera);822 psFree(formatName);821 psFree(camera); 822 psFree(formatName); 823 823 return NULL; 824 824 } … … 829 829 psError(PS_ERR_IO, false, "Failed to construct FPA from %s", (char *)infiles->data[0]); 830 830 psFree(phu); 831 psFree(camera);832 psFree(formatName);831 psFree(camera); 832 psFree(formatName); 833 833 psFree(format); 834 834 return NULL; … … 863 863 864 864 if (file->type == PM_FPA_FILE_MASK) { 865 if (!pmConfigMaskReadHeader (config, phu)) {866 psError(PS_ERR_IO, false, "error in mask bits");867 return NULL;868 }865 if (!pmConfigMaskReadHeader (config, phu)) { 866 psError(PS_ERR_IO, false, "error in mask bits"); 867 return NULL; 868 } 869 869 } 870 870 -
trunk/psModules/src/config/pmConfig.c
r18905 r18908 57 57 psFree(config->site); 58 58 psFree(config->system); 59 psFree(config->complete);60 59 psFree(config->files); 61 60 psFree(config->camera); … … 139 138 config->site = NULL; 140 139 config->system = NULL; 141 config->complete = NULL;142 140 config->camera = NULL; 143 141 config->cameraName = NULL; … … 232 230 bool pmConfigFileRead(psMetadata **config, const char *name, const char *description) 233 231 { 234 PS_ASSERT_PTR_NON_NULL(config, false);235 PS_ASSERT_STRING_NON_EMPTY(name, false);236 PS_ASSERT_STRING_NON_EMPTY(description, false);232 assert(config); 233 assert(name); 234 assert(description); 237 235 238 236 char *realName = NULL; … … 313 311 } 314 312 315 // Read a file into a metadataItem, if required 316 static bool metadataItemReadFile(psMetadataItem *item, // Item into which to read file 317 const char *description // Description, for error messages 318 ) 319 { 320 assert(item); 321 assert(description); 313 bool pmConfigFileIngest(psMetadataItem *item, const char *description) 314 { 315 PS_ASSERT_METADATA_ITEM_NON_NULL(item, false); 316 PS_ASSERT_STRING_NON_EMPTY(description, false); 322 317 323 318 if (item->type == PS_DATA_METADATA) { … … 357 352 psMetadataItem *item; // Item from iteration 358 353 while ((item = psMetadataGetAndIncrement(iter))) { 359 if (! metadataItemReadFile(item, description)) {354 if (!pmConfigFileIngest(item, description)) { 360 355 psError(PM_ERR_CONFIG, false, "Unable to read %s %s.", description, item->name); 361 356 psFree(iter); … … 400 395 psMetadataItem *darkNorm = psMetadataLookup(camera, "DARK.NORM"); // The dark normalisation calibration 401 396 if (darkNorm) { 402 if (darkNorm->type == PS_DATA_STRING) { 403 const char *darkNormName = darkNorm->data.str; // The file name 404 psTrace("config", 2, "Reading %s dark normalisation: %s\n", cameraName, darkNormName); 405 psMetadata *new = NULL; // New metadata 406 if (!pmConfigFileRead(&new, darkNormName, "Dark normalisation")) { 407 psError(PM_ERR_CONFIG, false, "Trouble reading reading %s dark normalisation %s --- " 408 "ignored.\n", cameraName, darkNormName); 409 psFree(new); 410 return false; 411 } 412 413 // Muck around under the hood to replace the filename with the metadata; 414 // don't try this at home, kids 415 darkNorm->type = PS_DATA_METADATA; 416 psFree(darkNorm->data.str); 417 darkNorm->data.md = new; 418 } else if (darkNorm->type != PS_DATA_METADATA) { 419 psWarning("DARK.NORM in camera %s is not of type STR or METADATA (%x)", 420 cameraName, darkNorm->type); 397 if (!pmConfigFileIngest(darkNorm, "dark normalisation")) { 398 psWarning("Unable to ingest DARK.NORM in camera %s", cameraName); 421 399 } 422 400 } else { … … 505 483 506 484 // read the SITE file 507 psString siteFile = psMetadataLookupStr(NULL, config->user, "SITE"); 508 if (!pmConfigFileRead(&config->site, siteFile, "site")) { 485 psMetadataItem *siteItem = psMetadataLookup(config->user, "SITE"); 486 if (!siteItem) { 487 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Unable to find SITE in user configuration."); 509 488 psFree(config); 510 489 return NULL; 511 490 } 512 513 // load the SYSTEM file 514 psString systemFile = psMetadataLookupStr(NULL, config->user, "SYSTEM"); 515 if (!pmConfigFileRead(&config->system, systemFile, "system")) { 491 if (!pmConfigFileIngest(siteItem, "site configuration")) { 492 psError(PS_ERR_UNKNOWN, false, "Unable to read site configuration"); 516 493 psFree(config); 517 494 return NULL; 518 495 } 519 520 // interpolate USER, SITE and SYSTEM into the config->complete metadata 521 config->complete = psMetadataCopy (NULL, config->user); 522 config->complete = psMetadataCopy (config->complete, config->site); 523 config->complete = psMetadataCopy (config->complete, config->system); 496 config->site = psMemIncrRefCounter(siteItem->data.md); 497 498 // load the SYSTEM file 499 psMetadataItem *systemItem = psMetadataLookup(config->user, "SYSTEM"); 500 if (!systemItem) { 501 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Unable to find SYSTEM in user configuration."); 502 psFree(config); 503 return NULL; 504 } 505 if (!pmConfigFileIngest(systemItem, "system configuration")) { 506 psError(PS_ERR_UNKNOWN, false, "Unable to read system configuration"); 507 psFree(config); 508 return NULL; 509 } 510 config->system = psMemIncrRefCounter(systemItem->data.md); 524 511 525 512 // Set LOG and TRACE options based on the user configuration. These must be set AFTER … … 651 638 // Initialise the psLib time handling 652 639 // XXX is this still needed / desired? 653 psString timeName = psMetadataLookupStr(&mdok, config->complete, "TIME"); 654 if (mdok && timeName) 655 { 640 psString timeName = psMetadataLookupStr(&mdok, config->system, "TIME"); 641 if (mdok && timeName) { 656 642 psTrace("psModules.config", 7, "Initialising psTime with file %s\n", timeName); 657 643 psTimeInit(timeName); … … 671 657 char *cameraName = argv[argNum]; // symbolic name of the camera 672 658 673 // look for the CAMERAS list in config-> complete674 psMetadata *cameras = psMetadataLookupMetadata(&mdok, config-> complete, "CAMERAS");659 // look for the CAMERAS list in config->system 660 psMetadata *cameras = psMetadataLookupMetadata(&mdok, config->system, "CAMERAS"); 675 661 if (!cameras) { 676 662 psError(PS_ERR_IO, false, "Unable to find CAMERAS in site configuration.\n"); … … 718 704 "Camera specified on command line", config->camera); 719 705 720 if (!pmConfigCameraSkycellVersion(config-> complete, cameraName)) {706 if (!pmConfigCameraSkycellVersion(config->system, cameraName)) { 721 707 psError(PS_ERR_UNKNOWN, false, 722 708 "Unable to generate skycell versions of specified camera %s.\n", … … 726 712 } 727 713 728 if (!pmConfigCameraMosaickedVersions(config-> complete, cameraName)) {714 if (!pmConfigCameraMosaickedVersions(config->system, cameraName)) { 729 715 psError(PS_ERR_UNKNOWN, false, 730 716 "Unable to generate mosaicked versions of specified camera %s.\n", … … 739 725 if (!config->camera && readCameraConfig) { 740 726 bool mdok; // Status of MD lookup 741 psMetadata *cameras = psMetadataLookupMetadata(&mdok, config-> complete, "CAMERAS"); // List of cameras727 psMetadata *cameras = psMetadataLookupMetadata(&mdok, config->system, "CAMERAS"); // List of cameras 742 728 if (!mdok || !cameras) { 743 729 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find CAMERAS in the system configuration.\n"); … … 773 759 psFree(iter); 774 760 775 if (!pmConfigCameraSkycellVersionsAll(config-> complete)) {761 if (!pmConfigCameraSkycellVersionsAll(config->system)) { 776 762 psError(PS_ERR_UNKNOWN, false, "Unable to generate skycell versions of cameras.\n"); 777 763 psFree(config); 778 764 return NULL; 779 765 } 780 if (!pmConfigCameraMosaickedVersionsAll(config-> complete)) {766 if (!pmConfigCameraMosaickedVersionsAll(config->system)) { 781 767 psError(PS_ERR_UNKNOWN, false, "Unable to generate mosaicked versions of cameras.\n"); 782 768 psFree(config); … … 817 803 psArgumentRemove(argNum, argc, argv); 818 804 819 psMetadata *cameras = psMetadataLookupMetadata(NULL, config-> complete, "CAMERAS"); // List of cameras805 psMetadata *cameras = psMetadataLookupMetadata(NULL, config->system, "CAMERAS"); // List of cameras 820 806 if (!cameras) { 821 807 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find CAMERAS in the site configuration.\n"); … … 865 851 } else { 866 852 char *dbserver = argv[argNum]; // The camera configuration file to read 867 if (!psMetadataAddStr(config-> complete, PS_LIST_TAIL, "DBSERVER", PS_META_REPLACE,853 if (!psMetadataAddStr(config->user, PS_LIST_TAIL, "DBSERVER", PS_META_REPLACE, 868 854 NULL, dbserver)) { 869 855 psWarning("Failed to overwrite .ipprc DBSERVER value"); … … 881 867 } else { 882 868 char *dbname = argv[argNum]; // The camera configuration file to read 883 if (!psMetadataAddStr(config-> complete, PS_LIST_TAIL, "DBNAME", PS_META_REPLACE, NULL, dbname)) {869 if (!psMetadataAddStr(config->user, PS_LIST_TAIL, "DBNAME", PS_META_REPLACE, NULL, dbname)) { 884 870 psWarning("Failed to overwrite .ipprc DBNAME value"); 885 871 } … … 896 882 } else { 897 883 char *dbuser = argv[argNum]; // The camera configuration file to read 898 if (!psMetadataAddStr(config-> complete, PS_LIST_TAIL, "DBUSER", PS_META_REPLACE, NULL, dbuser)) {884 if (!psMetadataAddStr(config->user, PS_LIST_TAIL, "DBUSER", PS_META_REPLACE, NULL, dbuser)) { 899 885 psWarning("Failed to overwrite .ipprc DBUSER value"); 900 886 } … … 911 897 } else { 912 898 char *dbpassword = argv[argNum]; // The camera configuration file to read 913 if (!psMetadataAddStr(config-> complete, PS_LIST_TAIL, "DBPASSWORD", PS_META_REPLACE,899 if (!psMetadataAddStr(config->user, PS_LIST_TAIL, "DBPASSWORD", PS_META_REPLACE, 914 900 NULL, dbpassword)) { 915 901 psWarning("Failed to overwrite .ipprc DBPASSWORD value"); … … 927 913 } else { 928 914 char *dbport = argv[argNum]; // The camera configuration file to read 929 if (!psMetadataAddS32(config-> complete, PS_LIST_TAIL, "DBPORT", PS_META_REPLACE, NULL,915 if (!psMetadataAddS32(config->user, PS_LIST_TAIL, "DBPORT", PS_META_REPLACE, NULL, 930 916 (psS32)atoi(dbport))) { 931 917 psWarning("Failed to overwrite .ipprc DBPORT value"); … … 1113 1099 1114 1100 bool mdok; // Metadata lookup status 1115 psMetadata *cameras = psMetadataLookupMetadata(&mdok, config-> complete, "CAMERAS");1101 psMetadata *cameras = psMetadataLookupMetadata(&mdok, config->system, "CAMERAS"); 1116 1102 if (! mdok || !cameras) { 1117 1103 psError(PS_ERR_IO, true, "Unable to find CAMERAS in the configuration."); … … 1183 1169 char *testName = NULL; 1184 1170 1185 psMetadata *cameras = psMetadataLookupMetadata (NULL, config-> complete, "CAMERAS");1171 psMetadata *cameras = psMetadataLookupMetadata (NULL, config->system, "CAMERAS"); 1186 1172 psAssert (cameras, "missing CAMERAS in complete metadata"); 1187 1173 … … 1263 1249 PS_ASSERT_STRING_NON_EMPTY(cameraName, NULL); 1264 1250 1265 psMetadata *cameras = psMetadataLookupMetadata(NULL, config-> complete, "CAMERAS");1251 psMetadata *cameras = psMetadataLookupMetadata(NULL, config->system, "CAMERAS"); 1266 1252 if (!cameras) { 1267 1253 psError(PS_ERR_IO, true, "Unable to find CAMERAS in the configuration."); … … 1269 1255 } 1270 1256 1271 char *cameraPath = psMetadataLookupStr(NULL, cameras, cameraName);1272 if (! cameraPath) {1273 psError(PS_ERR_ IO, true, "Unable to find requested CAMERA in theconfiguration.");1257 psMetadataItem *item = psMetadataLookup(cameras, cameraName); // Item with camera of interest 1258 if (!pmConfigFileIngest(item, "camera configuration")) { 1259 psError(PS_ERR_UNKNOWN, false, "Unable to ingest camera configuration."); 1274 1260 return NULL; 1275 1261 } 1276 1262 1277 psMetadata *camera = NULL; // Camera to test against what we've got: 1278 1279 if (!pmConfigFileRead(&camera, cameraPath, cameraName)) { 1280 psWarning("Trouble reading reading camera configuration %s", cameraName); 1281 psFree(camera); 1282 return NULL; 1283 } 1284 1285 return camera; 1263 return psMemIncrRefCounter(item->data.md); 1286 1264 } 1287 1265 … … 1289 1267 { 1290 1268 PS_ASSERT_PTR_NON_NULL(config, NULL); 1291 PS_ASSERT_PTR_NON_NULL(config-> complete, NULL);1269 PS_ASSERT_PTR_NON_NULL(config->user, NULL); 1292 1270 1293 1271 #ifndef HAVE_PSDB … … 1310 1288 1311 1289 // XXX leaky strings 1312 psString dbServer = psMetadataLookupStr(&mdStatus01, config-> complete, "DBSERVER");1313 psString dbUsername = psMetadataLookupStr(&mdStatus02, config-> complete, "DBUSER");1314 psString dbPassword = psMetadataLookupStr(&mdStatus03, config-> complete, "DBPASSWORD");1315 psString dbName = psMetadataLookupStr(&mdStatus04, config-> complete, "DBNAME");1316 psS32 dbPort = psMetadataLookupS32(&mdStatus05, config-> complete, "DBPORT");1290 psString dbServer = psMetadataLookupStr(&mdStatus01, config->user, "DBSERVER"); 1291 psString dbUsername = psMetadataLookupStr(&mdStatus02, config->user, "DBUSER"); 1292 psString dbPassword = psMetadataLookupStr(&mdStatus03, config->user, "DBPASSWORD"); 1293 psString dbName = psMetadataLookupStr(&mdStatus04, config->user, "DBNAME"); 1294 psS32 dbPort = psMetadataLookupS32(&mdStatus05, config->user, "DBPORT"); 1317 1295 if (!mdStatus05) { 1318 1296 dbPort = 0; … … 1527 1505 // replace path://PATH with matched datapath 1528 1506 if (!strncasecmp(filename, "path://", strlen("path://"))) { 1529 PS_ASSERT_METADATA_NON_NULL(config-> complete, NULL);1507 PS_ASSERT_METADATA_NON_NULL(config->site, NULL); 1530 1508 1531 1509 psString newName = psStringCopy(filename); 1532 1510 1533 1511 // filename should be of the form: path://PATH/rest/of/file 1534 // replace PATH with matching name from config-> complete:DATAPATH1535 psMetadata *datapath = psMetadataLookupPtr (NULL, config-> complete, "DATAPATH");1512 // replace PATH with matching name from config->site:DATAPATH 1513 psMetadata *datapath = psMetadataLookupPtr (NULL, config->site, "DATAPATH"); 1536 1514 if (datapath == NULL) { 1537 1515 psError(PS_ERR_UNKNOWN, true, "DATAPATH is not defined in config.site"); … … 1586 1564 // if env isn't set, check the config system 1587 1565 if (!neb_server) { 1588 neb_server = psMetadataLookupStr(&status, config-> complete, "NEB_SERVER");1566 neb_server = psMetadataLookupStr(&status, config->site, "NEB_SERVER"); 1589 1567 if (!status) { 1590 1568 psError(PM_ERR_CONFIG, true, "failed to lookup config value for NEB_SERVER."); … … 1662 1640 } 1663 1641 1664 if (! metadataItemReadFile(item, "file rules ")) {1642 if (!pmConfigFileIngest(item, "file rules ")) { 1665 1643 psError(PM_ERR_CONFIG, false, "Unable to read file rules for camera."); 1666 1644 return NULL; … … 1695 1673 } 1696 1674 1697 if (! metadataItemReadFile(item, "FITS Types")) {1675 if (!pmConfigFileIngest(item, "FITS Types")) { 1698 1676 psError(PM_ERR_CONFIG, false, "Unable to read fits types for camera."); 1699 1677 return NULL; -
trunk/psModules/src/config/pmConfig.h
r18905 r18908 5 5 * @author Eugene Magnier, IfA 6 6 * 7 * @version $Revision: 1. 39$ $Name: not supported by cvs2svn $8 * @date $Date: 2008-08-05 0 2:16:06 $7 * @version $Revision: 1.40 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2008-08-05 03:45:56 $ 9 9 * Copyright 2005-2006 Institute for Astronomy, University of Hawaii 10 10 */ … … 40 40 psMetadata *site; ///< Site configuration 41 41 psMetadata *system; ///< System configuration 42 psMetadata *complete; ///< Full merged configuration43 42 psMetadata *camera; ///< Camera specification 44 43 psString cameraName; ///< Camera name … … 86 85 /// Read a configuration file 87 86 /// 88 /// Read a metadata configuration file into the supplied metadata. Produce an error and return false if89 /// there's a problem.87 /// Read a metadata configuration file into the supplied metadata. Produce an error and 88 /// return false if there's a problem. 90 89 bool pmConfigFileRead(psMetadata **config, ///< Config to output 91 90 const char *name, ///< Name of file 92 91 const char *description ///< Description of file 93 ); 92 ); 93 94 /// Ingest a configuration file 95 /// 96 /// Ingest a metadata configuration file into the supplied metadata item, if required. Produce an error and 97 /// return false if there's a problem. 98 bool pmConfigFileIngest(psMetadataItem *item, // Item into which to read file 99 const char *description // Description, for error messages 100 ); 94 101 95 102 /// Validate a header against the camera format -
trunk/psModules/src/config/pmConfigCommand.c
r16611 r18908 13 13 PS_ASSERT_PTR_NON_NULL(command, false); 14 14 PS_ASSERT_PTR_NON_NULL(config, false); 15 PS_ASSERT_PTR_NON_NULL(config-> complete, false);15 PS_ASSERT_PTR_NON_NULL(config->user, false); 16 16 17 17 bool mdok; // Status of MD lookup 18 const char *dbserver = psMetadataLookupStr(&mdok, config-> complete, "DBSERVER"); // Database server18 const char *dbserver = psMetadataLookupStr(&mdok, config->user, "DBSERVER"); // Database server 19 19 if (!mdok || strlen(dbserver) == 0) { 20 20 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find DBSERVER in site configuration.\n"); 21 21 return false; 22 22 } 23 const char *dbname = psMetadataLookupStr(&mdok, config-> complete, "DBNAME"); // Database name23 const char *dbname = psMetadataLookupStr(&mdok, config->user, "DBNAME"); // Database name 24 24 if (!mdok || strlen(dbname) == 0) { 25 25 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find DBNAME in site configuration.\n"); 26 26 return false; 27 27 } 28 const char *dbuser = psMetadataLookupStr(&mdok, config-> complete, "DBUSER"); // Database user28 const char *dbuser = psMetadataLookupStr(&mdok, config->user, "DBUSER"); // Database user 29 29 if (!mdok || strlen(dbuser) == 0) { 30 30 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find DBUSER in site configuration.\n"); 31 31 return false; 32 32 } 33 const char *dbpassword = psMetadataLookupStr(&mdok, config-> complete, "DBPASSWORD"); // Database password33 const char *dbpassword = psMetadataLookupStr(&mdok, config->user, "DBPASSWORD"); // Database password 34 34 if (!mdok || strlen(dbpassword) == 0) { 35 35 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find DBPASSWORD in site configuration.\n"); -
trunk/psModules/src/config/pmConfigDump.c
r18905 r18908 64 64 PS_ASSERT_PTR_NON_NULL(config, false); 65 65 66 psMetadata *cameras = psMetadataLookupMetadata(NULL, config-> complete, "CAMERAS"); // Known cameras66 psMetadata *cameras = psMetadataLookupMetadata(NULL, config->system, "CAMERAS"); // Known cameras 67 67 if (!cameras) { 68 68 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find CAMERAS in the system configuration.\n"); … … 146 146 } 147 147 148 if (!psMetadataConfigWrite(config-> complete, filename)) {148 if (!psMetadataConfigWrite(config->user, filename)) { 149 149 psError(PS_ERR_IO, false, "Unable to dump configuration to %s", filename); 150 150 psFree(filename); -
trunk/psModules/src/config/pmConfigRecipes.c
r17512 r18908 28 28 if (!options) { 29 29 options = psMetadataAlloc (); 30 success = psMetadataAddPtr (config->arguments, PS_LIST_TAIL, "OPTIONS", PS_DATA_METADATA, "", options); 30 success = psMetadataAddPtr (config->arguments, PS_LIST_TAIL, "OPTIONS", PS_DATA_METADATA, "", 31 options); 31 32 assert (success); // type mismatch : OPTIONS already defined but wrong type 32 33 psFree (options); // drop extra reference … … 47 48 48 49 // this function may be called several times. it attempts to load the recipe data from one of three 49 // locations: config-> complete, config->camera, and argv. We cannot read the recipes from50 // locations: config->system, config->camera, and argv. We cannot read the recipes from 50 51 // config->camera until a camera has been read BUT, the argv recipes must override the camera and 51 52 // system recipes. This command strips the argv elements it uses from the argv list. … … 60 61 61 62 // Read the recipe file names from the system configuration and camera configuration 62 // It is an error for config-> complete:recipes not to exist. all programs install their63 // It is an error for config->system:recipes not to exist. all programs install their 63 64 // master recipe files in the system:recipe location when they are built. 64 psAssert (config->complete, "base config data defined");65 psAssert(config->system, "base config data defined"); 65 66 if (source & PM_RECIPE_SOURCE_SYSTEM) { 66 if (!loadRecipeSystem(&status, config, config-> complete)) {67 if (!loadRecipeSystem(&status, config, config->system)) { 67 68 psError(PS_ERR_IO, false, "Failed to read recipes from system config"); 68 69 return false; … … 75 76 // for an identified camera (in pmConfigCameraFormatFromHeader). the second 76 77 // set should not override the first set 77 if (config->camera && (source & PM_RECIPE_SOURCE_CAMERA) && !(config->recipesRead & PM_RECIPE_SOURCE_CAMERA)) { 78 if (config->camera && (source & PM_RECIPE_SOURCE_CAMERA) && 79 !(config->recipesRead & PM_RECIPE_SOURCE_CAMERA)) { 78 80 if (!loadRecipeCamera(&status, config, config->camera)) { 79 81 psError(PS_ERR_IO, false, "Failed to read recipes from camera config"); … … 87 89 } 88 90 89 // merge camera and sytem recipes, apply recipes loaded into config->arguments based on command-line arguments 91 // merge camera and sytem recipes, apply recipes loaded into config->arguments based on command-line 92 // arguments 90 93 if (config->arguments && (source & PM_RECIPE_SOURCE_CL)) { 91 94 92 // update the system-level recipes with the symbolically-defined recipes 95 // update the system-level recipes with the symbolically-defined recipes 93 96 if (!loadRecipeSymbols(&status, config, PM_RECIPE_SOURCE_SYSTEM)) { 94 97 psError(PS_ERR_IO, false, "Failed to read recipes from symbolic references"); … … 101 104 } 102 105 103 // merge the SYSTEM and CAMERA recipes106 // merge the SYSTEM and CAMERA recipes 104 107 if (!mergeRecipeCamera(&status, config)) { 105 108 psError(PS_ERR_IO, false, "Failed to read recipes from symbolic references"); 106 109 return false; 107 110 } 108 psLogMsg ("psModules.config", PS_LOG_DETAIL, "merged camera recipes with system recipes");109 110 // load recipe-files specified on the command line111 psLogMsg ("psModules.config", PS_LOG_DETAIL, "merged camera recipes with system recipes"); 112 113 // load recipe-files specified on the command line 111 114 if (!loadRecipeFromArguments(&status, config)) { 112 115 psError(PS_ERR_IO, false, "Failed to read recipes from command-line arguments"); … … 119 122 } 120 123 121 // update the system-level recipes with the symbolically-defined recipes 124 // update the system-level recipes with the symbolically-defined recipes 122 125 if (!loadRecipeSymbols(&status, config, PM_RECIPE_SOURCE_CAMERA)) { 123 126 psError(PS_ERR_IO, false, "Failed to read recipes from symbolic references"); … … 130 133 } 131 134 132 // override any specific values with values from the command line135 // override any specific values with values from the command line 133 136 if (!loadRecipeOptions(&status, config)) { 134 137 psError(PS_ERR_IO, false, "Failed to read recipes from symbolic references"); … … 155 158 if (!options) { 156 159 options = psMetadataAlloc(); 157 success = psMetadataAddPtr(config->arguments, PS_LIST_TAIL, "OPTIONS", PS_DATA_METADATA, "Command-line options specified with -D", options); 160 success = psMetadataAddPtr(config->arguments, PS_LIST_TAIL, "OPTIONS", PS_DATA_METADATA, 161 "Command-line options specified with -D", options); 158 162 assert (success); // type mismatch : OPTIONS already defined but wrong type 159 163 psFree (options); // drop extra reference … … 178 182 recipeName = config->defaultRecipe; 179 183 if (!config->defaultRecipe) { 180 psError(PS_ERR_IO, true, "syntax error in parameter: no default recipe available; must specify recipe"); 184 psError(PS_ERR_IO, true, 185 "syntax error in parameter: no default recipe available; must specify recipe"); 181 186 return false; 182 187 } … … 242 247 if (!recipes) { 243 248 recipes = psMetadataAlloc(); 244 success = psMetadataAddPtr (config->arguments, PS_LIST_TAIL, "RECIPES", PS_DATA_METADATA, "", recipes); 249 success = psMetadataAddPtr (config->arguments, PS_LIST_TAIL, "RECIPES", PS_DATA_METADATA, "", 250 recipes); 245 251 assert (success); 246 252 psFree (recipes); … … 298 304 // Assume it's a symbolic reference to something that's not yet read in. 299 305 // it will be loaded later by pmConfigReadRecipes with option CL 300 psMetadataAddStr(config->recipeSymbols, PS_LIST_TAIL, recipeName, PS_META_REPLACE, NULL, recipeSource); 306 psMetadataAddStr(config->recipeSymbols, PS_LIST_TAIL, recipeName, PS_META_REPLACE, NULL, 307 recipeSource); 301 308 302 309 psTrace ("psModules.config", 3, "read recipe %s from %s", recipeName, recipeSource); … … 319 326 320 327 if (!source) { 321 psError(PS_ERR_IO, true, "The system configuration has not been read --- cannot read recipes from this location.\n"); 328 psError(PS_ERR_IO, true, 329 "The system configuration has not been read --- cannot read recipes from this location.\n"); 322 330 config->recipesRead &= ~PM_RECIPE_SOURCE_SYSTEM; 323 331 return false; … … 334 342 // If it's not of the correct type, we can tell the user which file it's in, so they can find it easier. 335 343 psMetadataIterator *recipesIter = psMetadataIteratorAlloc(recipes, PS_LIST_HEAD, NULL); // Iterator 336 psMetadataItem *fileItem = NULL; // MD item containing the filename, from recipe iteration 337 while ((fileItem = psMetadataGetAndIncrement(recipesIter))) { 338 char *recipeName = fileItem->name; 339 char *recipeFile = fileItem->data.str; 340 341 // type mismatch is a serious error 342 if (fileItem->type != PS_DATA_STRING) { 343 psAbort("%s in system configuration RECIPES is not of type STR", recipeName); 344 } 345 346 // Read the recipe file. if we fail on a file, give a warning, but continue 347 psMetadata *recipe = NULL; 348 if (!pmConfigFileRead(&recipe, recipeFile, "recipe")) { 349 psError(PS_ERR_IO, false, "Failed to read recipe file %s listed in system configuration\n", recipeFile); 350 return false; 351 } 352 353 // and the contents of this recipe file to config->recipes 354 psMetadataAdd(config->recipes, PS_LIST_TAIL, fileItem->name, PS_DATA_METADATA | PS_META_REPLACE, fileItem->comment, recipe); 355 psFree(recipe); // Drop reference 344 psMetadataItem *item = NULL; // MD item containing the filename, from recipe iteration 345 while ((item = psMetadataGetAndIncrement(recipesIter))) { 346 if (!pmConfigFileIngest(item, "recipe")) { 347 psError(PS_ERR_IO, false, "Failed to read recipe %s listed in system configuration", 348 item->name); 349 psFree(recipesIter); 350 return false; 351 } 352 353 // add the contents of this recipe file to config->recipes 354 psMetadataAdd(config->recipes, PS_LIST_TAIL, item->name, PS_DATA_METADATA | PS_META_REPLACE, 355 item->comment, item->data.md); 356 356 } 357 357 psFree(recipesIter); … … 375 375 376 376 if (!source) { 377 psError(PS_ERR_IO, true, "The camera configuration has not been read --- cannot read recipes from this location.\n"); 377 psError(PS_ERR_IO, true, 378 "The camera configuration has not been read --- cannot read recipes from this location.\n"); 378 379 config->recipesRead &= ~PM_RECIPE_SOURCE_CAMERA; 379 380 return false; … … 392 393 // If it's not of the correct type, we can tell the user which file it's in, so they can find it easier. 393 394 psMetadataIterator *recipesIter = psMetadataIteratorAlloc(recipes, PS_LIST_HEAD, NULL); // Iterator 394 psMetadataItem *fileItem = NULL; // MD item containing the filename, from recipe iteration 395 while ((fileItem = psMetadataGetAndIncrement(recipesIter))) { 396 char *recipeName = fileItem->name; 397 char *recipeFile = fileItem->data.str; 398 399 psTrace("psModules.config", 3, "loading %s from %s within camera configuration.\n", recipeName, recipeFile); 400 401 // type mismatch is a serious error 402 if (fileItem->type != PS_DATA_STRING) { 403 psAbort("%s in camera configuration RECIPES is not of type STR", recipeName); 404 } 405 406 // Read the recipe file. if we fail on a file, give a warning, but continue 407 psMetadata *recipe = NULL; 408 if (!pmConfigFileRead(&recipe, recipeFile, "recipe")) { 409 psError(PS_ERR_IO, false, "Failed to read recipe file %s listed in camera configuration\n", recipeFile); 410 return false; 411 } 395 psMetadataItem *item = NULL; // MD item containing the filename, from recipe iteration 396 while ((item = psMetadataGetAndIncrement(recipesIter))) { 397 if (!pmConfigFileIngest(item, "recipe")) { 398 psError(PS_ERR_IO, false, "Failed to read recipe %s listed in camera configuration", 399 item->name); 400 return false; 401 } 402 const char *recipeName = item->name; // Name of the recipe 403 psMetadata *recipe = item->data.md; // The recipe 412 404 413 405 // the named recipe must exist at the system level … … 415 407 if (!current) { 416 408 psError(PS_ERR_IO, false, "Failed to find recipe for %s in master recipe list", recipeName); 417 psFree(recipe); // Drop reference418 409 return false; 419 410 } 420 411 421 412 // add the contents of this recipe file to config->recipesCamera 422 psMetadataAdd(config->recipesCamera, PS_LIST_TAIL, recipeName, PS_DATA_METADATA | PS_META_REPLACE, fileItem->comment, recipe);423 psFree(recipe); // Drop reference413 psMetadataAdd(config->recipesCamera, PS_LIST_TAIL, recipeName, PS_DATA_METADATA | PS_META_REPLACE, 414 item->comment, recipe); 424 415 } 425 416 psFree(recipesIter); … … 441 432 // We could use psMetadataCopy for this, but it's better to check that everything's of the correct type. 442 433 // If it's not of the correct type, we can tell the user which file it's in, so they can find it easier. 443 psMetadataIterator *recipesIter = psMetadataIteratorAlloc(config->recipesCamera, PS_LIST_HEAD, NULL); // Iterator434 psMetadataIterator *recipesIter = psMetadataIteratorAlloc(config->recipesCamera, PS_LIST_HEAD, NULL); 444 435 psMetadataItem *folderItem = NULL; // MD item containing the filename, from recipe iteration 445 436 while ((folderItem = psMetadataGetAndIncrement(recipesIter))) { … … 459 450 460 451 // update the contents of this recipe from the one on config->recipesCamera 461 if (!psMetadataUpdate(current, recipe)) {462 psError(PS_ERR_IO, false, "Failed to update recipe for %s from camera recipe", recipeName);463 return false;464 }452 if (!psMetadataUpdate(current, recipe)) { 453 psError(PS_ERR_IO, false, "Failed to update recipe for %s from camera recipe", recipeName); 454 return false; 455 } 465 456 } 466 457 psFree(recipesIter); … … 552 543 553 544 // search for sourceName in config->recipes (folder name is targetName) 554 psMetadata *folder = psMetadataLookupMetadata(&found, config->recipes, targetName);555 psMetadata *sourceMD = psMetadataLookupMetadata(&found, folder, sourceName);556 557 // if we find the desired symbolic name at this level, set the item comment to say "FOUND"545 psMetadata *folder = psMetadataLookupMetadata(&found, config->recipes, targetName); 546 psMetadata *sourceMD = psMetadataLookupMetadata(&found, folder, sourceName); 547 548 // if we find the desired symbolic name at this level, set the item comment to say "FOUND" 558 549 if (sourceMD) { 559 if (!psMetadataUpdate(targetMD, sourceMD)) {550 if (!psMetadataUpdate(targetMD, sourceMD)) { 560 551 psError(PS_ERR_IO, false, "Failed to update recipe for %s from camera recipe", targetName); 561 552 return false; 562 }563 psStringAppend (&item->comment, "(FOUND)");564 } 565 566 // if we have not found it by the camera level, we have a problem567 if (source == PM_RECIPE_SOURCE_CAMERA) {568 if (strstr (item->comment, "(FOUND)") == NULL) {569 psError(PS_ERR_IO, false, "Selected symbolic name %s does not exist in recipes", sourceName);570 return false;571 }572 }553 } 554 psStringAppend (&item->comment, "(FOUND)"); 555 } 556 557 // if we have not found it by the camera level, we have a problem 558 if (source == PM_RECIPE_SOURCE_CAMERA) { 559 if (strstr (item->comment, "(FOUND)") == NULL) { 560 psError(PS_ERR_IO, false, "Selected symbolic name %s does not exist in recipes", sourceName); 561 return false; 562 } 563 } 573 564 } 574 565 psFree(iter); … … 594 585 } 595 586 596 psMetadata *recipes = psMetadataLookupMetadata(&found, config->arguments, "OPTIONS"); // The list of recipes587 psMetadata *recipes = psMetadataLookupMetadata(&found, config->arguments, "OPTIONS"); // List of recipes 597 588 if (!recipes) { 598 589 psTrace("psModules.config", 4, "no OPTIONS in config->arguments, nothing to read here");
Note:
See TracChangeset
for help on using the changeset viewer.
