- Timestamp:
- Jul 6, 2008, 6:23:02 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branch_20080706/psModules/src/config/pmConfigMask.c
r18425 r18430 40 40 } 41 41 42 // replace the named masks in the recipe with values in the header 42 // replace the named masks in the recipe with values in the header: 43 // replace only the names in the header in the recipe 43 44 void pmConfigMasksReadHeader (pmConfig *config, psMetadata *header) { 44 45 … … 49 50 } 50 51 51 int nMask = 0; 52 int nMask = psMetadataLookupS32 (&status, header, "MSKNUM"); 53 if (!status) { 54 psError(PS_ERR_UNKNOWN, true, "Unable to find MSKNUM in header."); 55 return false; 56 } 52 57 53 psMetadataIterator *iter = psMetadataIteratorAlloc(recipe, PS_LIST_HEAD, NULL); // Iterator58 for (int i = 0; i < nMask; i++) { 54 59 55 psMetadataItem *item; // Item from iteration 56 while ((item = psMetadataGetAndIncrement(iter))) { 60 snprintf (namekey, 64, "MSKNAM%02d", i); 61 snprintf (valuekey, 64, "MSKVAL%02d", i); 57 62 58 if (item->type != PS_DATA_U8) { 59 psWarning("mask recipe entry %s is not a bit value\n", item->name); 60 continue; 63 char *name = psMetadataLookupStr (&status, header, namekey); 64 psU8 bit = psMetadataLookupU8 (&status, header, valuekey); 65 66 // XXX validate that bit is a 2^n value? 67 68 psMetadataItem *item = psMetadataLookup (header, name); 69 if (!item) { 70 psWarning("mask recipe entry %s not in recipe\n", name); 71 psMetadataAddU8 (recipe, PS_LIST_TAIL, name, 0, "Bitmask bit value", bit); 72 } else { 73 item->data.U8 = bit; 61 74 } 62 63 snprintf (namekey, 64, "MSKNAM%02d", nMask);64 snprintf (valuekey, 64, "MSKVAL%02d", nMask);65 66 psMetadataAddStr (header, PS_LIST_TAIL, namekey, 0, "Bitmask bit name", item->name);67 psMetadataAddU8 (header, PS_LIST_TAIL, valuekey, 0, "Bitmask bit value", item->data.U8);68 nMask ++;69 75 } 70 76 71 psMetadataAddU8 (header, PS_LIST_TAIL, "MSKNUM", 0, "Bitmask bit count", nMask);72 77 return true; 73 78 } … … 102 107 } 103 108 104 psMetadataAdd U8(header, PS_LIST_TAIL, "MSKNUM", 0, "Bitmask bit count", nMask);109 psMetadataAddS32 (header, PS_LIST_TAIL, "MSKNUM", 0, "Bitmask bit count", nMask); 105 110 return true; 106 111 }
Note:
See TracChangeset
for help on using the changeset viewer.
