Changeset 19870 for trunk/psModules/src/config/pmConfigMask.c
- Timestamp:
- Oct 2, 2008, 12:49:16 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/config/pmConfigMask.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/config/pmConfigMask.c
r19442 r19870 12 12 // Private functions 13 13 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// 14 15 static psMaskType maskGet(const psMetadata *source, // Source of masks16 const char *masks // Mask values to get17 )18 {19 psMaskType mask = 0; // Mask value, to return20 21 psArray *names = psStringSplitArray(masks, " ,;", false); // Array of symbolic names22 for (int i = 0; i < names->n; i++) {23 const char *name = names->data[i]; // Symbolic name of interest24 bool mdok; // Status of MD lookup25 psMaskType value = psMetadataLookupU8(&mdok, source, name);26 if (!mdok) {27 psError(PS_ERR_BAD_PARAMETER_VALUE, false, "Unable to find mask value for %s", name);28 psFree(names);29 return 0;30 }31 mask |= value;32 }33 psFree(names);34 35 return mask;36 }37 14 38 15 // maskSetValues examine named mask values and set the bits for maskValue and markValue. … … 152 129 } 153 130 131 // Get a mask value by name(s) 132 static psMaskType maskGet(psMetadata *source, // Source of masks 133 const char *masks // Mask values to get 134 ) 135 { 136 psMaskType mask = 0; // Mask value, to return 137 138 psArray *names = psStringSplitArray(masks, " ,;", false); // Array of symbolic names 139 for (int i = 0; i < names->n; i++) { 140 const char *name = names->data[i]; // Symbolic name of interest 141 bool mdok; // Status of MD lookup 142 psMaskType value = psMetadataLookupU8(&mdok, source, name); 143 if (!mdok) { 144 // Try and generate the value if we can 145 if (strcmp(name, "MASK.VALUE") == 0 || strcmp(name, "MARK.VALUE") == 0) { 146 if (!maskSetValues(NULL, NULL, source)) { 147 psError(PS_ERR_UNKNOWN, false, "Unable to set mask bits."); 148 return 0; 149 } 150 value = psMetadataLookupU8(&mdok, source, name); 151 psAssert(mdok, "Should have generated mask value"); 152 } else { 153 psError(PS_ERR_BAD_PARAMETER_VALUE, false, "Unable to find mask value for %s", name); 154 psFree(names); 155 return 0; 156 } 157 } 158 mask |= value; 159 } 160 psFree(names); 161 162 return mask; 163 } 164 154 165 // Remove from the header keywords starting with the provided string 155 166 static int maskRemoveHeader(psMetadata *header, // Header from which to remove keywords … … 327 338 PS_ASSERT_STRING_NON_EMPTY(masks, 0); 328 339 329 psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, "MASKS"); // The recipe 340 bool mdok; // Status of MD lookup 341 psMetadata *recipe = psMetadataLookupMetadata(&mdok, config->recipes, "MASKS"); // The recipe 330 342 if (!recipe) { 331 343 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find MASKS recipe.");
Note:
See TracChangeset
for help on using the changeset viewer.
