Changeset 15217 for trunk/psModules/src/camera/pmFPAfileDefine.c
- Timestamp:
- Oct 4, 2007, 10:15:48 AM (19 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/camera/pmFPAfileDefine.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/camera/pmFPAfileDefine.c
r15183 r15217 20 20 #include "pmFPAConstruct.h" 21 21 22 23 // Get the file rule of interest24 // Look up the name of the set of file rules to use, get that set from the site configuration, and return the25 // appropriate rule from the set.26 static psMetadata *getFileRule(const pmConfig *config, // Configuration27 const psMetadata *camera, // Camera configuration of interest28 const char *name // Name of rule to read29 )30 {31 assert(config);32 assert(config->site);33 34 psMetadataItem *item = psMetadataLookup(camera, "FILERULES"); // Item with the file rule of interest35 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 configuration41 switch (item->type) {42 case PS_DATA_METADATA:43 // It's what we're after44 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 use48 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 // kids57 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 FILERULES70 // check for alias name (type == STR, name is aliased name)71 bool mdok; // Status of MD lookup72 const char *realname = psMetadataLookupStr(&mdok, filerules, name); // Name of file rule to look up73 if (!realname || strlen(realname) == 0) {74 realname = name;75 }76 77 return psMetadataLookupMetadata(NULL, filerules, realname);78 }79 80 22 // Parse an option from a metadata, returning the appropriate integer value 81 23 static int parseOptionInt(const psMetadata *md, // Metadata containing the option … … 107 49 108 50 const psMetadata *camera = (fpa ? fpa->camera : config->camera); // Camera configuration for this file 109 psMetadata *data = getFileRule(config, camera, name); // File rule51 psMetadata *data = pmConfigFileRule(config, camera, name); // File rule 110 52 if (!data) { 111 53 psError(PS_ERR_IO, true, "Can't find file rule %s!", name); … … 198 140 } 199 141 200 psMetadata *data = getFileRule(config, camera, name); // File rule142 psMetadata *data = pmConfigFileRule(config, camera, name); // File rule 201 143 if (!data) { 202 144 psError(PS_ERR_IO, true, "Can't find file rule %s!", name);
Note:
See TracChangeset
for help on using the changeset viewer.
