IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 4, 2007, 10:15:48 AM (19 years ago)
Author:
Paul Price
Message:

Gene pointed out that the file rules are also read in pmConfig (when the '-F' switch is used on the command-line), and the new ability to read file rules from a separate file wasn't implemented there. I've moved the function that gets a file rule from pmFPAfileDefine.c to pmConfig.c (now named pmConfigFileRule), and now both the pmConfig and pmFPAfileDefine functions use this.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/camera/pmFPAfileDefine.c

    r15183 r15217  
    2020#include "pmFPAConstruct.h"
    2121
    22 
    23 // Get the file rule of interest
    24 // Look up the name of the set of file rules to use, get that set from the site configuration, and return the
    25 // appropriate rule from the set.
    26 static psMetadata *getFileRule(const pmConfig *config, // Configuration
    27                                const psMetadata *camera, // Camera configuration of interest
    28                                const char *name // Name of rule to read
    29     )
    30 {
    31     assert(config);
    32     assert(config->site);
    33 
    34     psMetadataItem *item = psMetadataLookup(camera, "FILERULES"); // Item with the file rule of interest
    35     if (!item) {
    36         psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find FILERULES in the camera configuration.");
    37         return NULL;
    38     }
    39 
    40     psMetadata *filerules = NULL;       // File rules from the site configuration
    41     switch (item->type) {
    42       case PS_DATA_METADATA:
    43         // It's what we're after
    44         filerules = item->data.md;
    45         break;
    46       case PS_DATA_STRING: {
    47           // It's the name of a file --- read the file, and store it for future use
    48           if (!pmConfigFileRead(&filerules, item->data.str, "filerules")) {
    49               psError(PM_ERR_CONFIG, false, "Trouble reading reading file rules from %s  --- "
    50                       "ignored.\n", item->data.str);
    51               psFree(filerules);
    52               return NULL;
    53           }
    54 
    55           // Muck around under the hood to replace the filename with the metadata; don't try this at home,
    56           // kids
    57           item->type = PS_DATA_METADATA;
    58           psFree(item->data.str);
    59           item->data.md = filerules;
    60           break;
    61       }
    62       default:
    63         psError(PS_ERR_BAD_PARAMETER_TYPE, true,
    64                 "Unexpected type for %s (%x) in FILERULES in SITE configuration.",
    65                 name, item->type);
    66         return NULL;
    67     }
    68 
    69     // select the name from the FILERULES
    70     // check for alias name (type == STR, name is aliased name)
    71     bool mdok;                          // Status of MD lookup
    72     const char *realname = psMetadataLookupStr(&mdok, filerules, name); // Name of file rule to look up
    73     if (!realname || strlen(realname) == 0) {
    74         realname = name;
    75     }
    76 
    77     return psMetadataLookupMetadata(NULL, filerules, realname);
    78 }
    79 
    8022// Parse an option from a metadata, returning the appropriate integer value
    8123static int parseOptionInt(const psMetadata *md, // Metadata containing the option
     
    10749
    10850    const psMetadata *camera = (fpa ? fpa->camera : config->camera); // Camera configuration for this file
    109     psMetadata *data = getFileRule(config, camera, name); // File rule
     51    psMetadata *data = pmConfigFileRule(config, camera, name); // File rule
    11052    if (!data) {
    11153        psError(PS_ERR_IO, true, "Can't find file rule %s!", name);
     
    198140    }
    199141
    200     psMetadata *data = getFileRule(config, camera, name); // File rule
     142    psMetadata *data = pmConfigFileRule(config, camera, name); // File rule
    201143    if (!data) {
    202144        psError(PS_ERR_IO, true, "Can't find file rule %s!", name);
Note: See TracChangeset for help on using the changeset viewer.