Changeset 18605 for trunk/psModules/src/config/pmConfigMask.c
- Timestamp:
- Jul 17, 2008, 2:34:16 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/config/pmConfigMask.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/config/pmConfigMask.c
r18604 r18605 64 64 65 65 bool status = false; 66 char namekey[80]; 67 char valuekey[80]; 68 69 psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, "MASKS"); // The recipe 70 if (!recipe) { 71 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find MASKS recipe."); 72 return false; 66 67 psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, "MASKS"); // The recipe 68 if (!recipe) { 69 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find MASKS recipe."); 70 return false; 71 } 72 73 // MASK.VALUE and MARK.VALUE aren't usually set in the recipe, but may be set in the header: create fake 74 // versions so that it won't complain later 75 if (!psMetadataLookup(recipe, "MASK.VALUE")) { 76 psMetadataAddU8(recipe, PS_LIST_TAIL, "MASK.VALUE", 0, "Bits to mask", 0); 77 } 78 if (!psMetadataLookup(recipe, "MARK.VALUE")) { 79 psMetadataAddU8(recipe, PS_LIST_TAIL, "MARK.VALUE", 0, "Bits for marking", 0); 73 80 } 74 81 … … 79 86 } 80 87 88 char namekey[80]; // Keyword name for symbolic name of mask entry 89 char valuekey[80]; // Keyword name for value of mask entry 81 90 for (int i = 0; i < nMask; i++) { 82 83 91 snprintf(namekey, 64, "MSKNAM%02d", i); 84 92 snprintf(valuekey, 64, "MSKVAL%02d", i); 85 93 86 94 char *name = psMetadataLookupStr(&status, header, namekey); 95 if (!status || !name) { 96 psWarning("Unable to find header keyword %s when parsing mask", namekey); 97 continue; 98 } 87 99 psU8 bit = psMetadataLookupU8(&status, header, valuekey); 100 if (!status) { 101 psWarning("Unable to find header keyword %s when parsing mask", namekey); 102 continue; 103 } 88 104 89 105 // XXX validate that bit is a 2^n value? 90 106 91 psMetadataItem *item = psMetadataLookup(recipe, name); 107 psString nameAlready = NULL; // Name of key with ".ALREADY" added 108 psStringAppend(&nameAlready, "%s.ALREADY", name); 109 bool already = psMetadataLookupBool(&status, recipe, nameAlready); // Already read this one? 110 111 psMetadataItem *item = psMetadataLookup(recipe, name); // Item in recipe with current value 112 if (item->type != PS_TYPE_MASK) { 113 psWarning("Mask recipe entry is not of a mask type (%x)", item->type); 114 item->type = PS_TYPE_MASK; 115 } 116 117 if (already) { 118 if (item && item->data.U8 != bit) { 119 psWarning("New mask recipe entry doesn't match previously loaded entry: %x vs %x", 120 bit, item->data.U8); 121 } 122 } else { 123 psMetadataAddBool(recipe, PS_LIST_TAIL, nameAlready, 0, "Already read this mask value", true); 124 } 125 92 126 if (!item) { 93 psWarning(" mask recipe entry %s not in recipe\n", name);94 psMetadataAddU8 (recipe, PS_LIST_TAIL, name, 0, "Bitmask bit value", bit);127 psWarning("Mask recipe entry %s not in recipe\n", name); 128 psMetadataAddU8(recipe, PS_LIST_TAIL, name, 0, "Bitmask bit value", bit); 95 129 } else { 96 130 item->data.U8 = bit; 97 131 } 98 } 132 133 psFree(nameAlready); 134 } 135 99 136 100 137 return true;
Note:
See TracChangeset
for help on using the changeset viewer.
