IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 14, 2011, 2:58:01 PM (15 years ago)
Author:
watersc1
Message:

merge from czw_branch of logflux code

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/psModules/src/config/pmConfig.c

    r29004 r30636  
    897897            psMetadataAddMetadata(filerules, PS_LIST_TAIL, old, PS_META_REPLACE,
    898898                                  "Original replaced by -F option", newRule);
     899        }
     900        psFree(camerasIter);
     901    }
     902
     903    // Look for command-line options for files to replace
     904    while ((argNum = psArgumentGet(*argc, argv, "-R")) > 0) {
     905        psArgumentRemove(argNum, argc, argv);
     906        if (argNum + 2 >= *argc) {
     907            psError(PM_ERR_CONFIG, true,
     908                    "Filerule element switch (-R) provided without filerule element and value.");
     909            psFree(config);
     910            return NULL;
     911        }
     912
     913        const char *rulename = argv[argNum]; // The filerule, to be modified
     914        psArgumentRemove(argNum, argc, argv);
     915        const char *element  = argv[argNum]; // The element, to be modified
     916        psArgumentRemove(argNum, argc, argv);
     917        const char *value    = argv[argNum]; // The value, to be set
     918        psArgumentRemove(argNum, argc, argv);
     919
     920        psMetadata *cameras = psMetadataLookupMetadata(NULL, config->system, "CAMERAS"); // List of cameras
     921        if (!cameras) {
     922            psError(PM_ERR_CONFIG, false, "Unable to find CAMERAS in the site configuration.\n");
     923            return false;
     924        }
     925
     926        psMetadataIterator *camerasIter = psMetadataIteratorAlloc(cameras, PS_LIST_HEAD, NULL); // Iterator
     927        psMetadataItem *cameraItem;     // Item from iteration
     928        while ((cameraItem = psMetadataGetAndIncrement(camerasIter))) {
     929            // Silently ignore problems --- they will be caught later, because if the user wants the nominated
     930            // file and it's not available for that camera, then they will know.
     931
     932            if (cameraItem->type != PS_DATA_METADATA) {
     933                psTrace("psModules.config", 2,
     934                        "Entry %s in CAMERAS is not of type METADATA --- ignored.", cameraItem->name);
     935                continue;
     936            }
     937            psMetadata *camera = cameraItem->data.md; // Camera configuration
     938
     939            psMetadata *newRule = pmConfigFileRule(config, camera, rulename); // The rule of interest
     940            if (!newRule) {
     941                psTrace("psModules.config", 2,
     942                        "Unable to find filerule %s in camera %s --- ignored.", rulename, cameraItem->name);
     943                continue;
     944            }
     945
     946            // By calling pmConfigFileRule, we've assured that the FILERULES is now a metadata
     947            psMetadata *filerules = psMetadataLookupMetadata(NULL, camera, "FILERULES"); // File rules
     948            if (!filerules) {
     949                psTrace("psModules.config", 2,
     950                        "Can't find FILERULES of type METADATA in camera %s --- ignored.", cameraItem->name);
     951                continue;
     952            }
     953
     954            // Convert newRule to have the element value requested.
     955            if (!psMetadataLookupStr(NULL,newRule,element)) {
     956              psTrace("psModules.config", 2,
     957                      "Unable to find filerule element %s in filerule %s in camera %s --- ignored.",
     958                      element,rulename,cameraItem->name);
     959              continue;
     960            }
     961            psMetadataAddStr(newRule, PS_LIST_TAIL, element, PS_META_REPLACE,
     962                             "Original replaced by -R option", value);
     963           
     964            psMetadataAddMetadata(filerules, PS_LIST_TAIL, rulename, PS_META_REPLACE,
     965                                  "Original replaced by -R option", newRule);
    899966        }
    900967        psFree(camerasIter);
Note: See TracChangeset for help on using the changeset viewer.