Changeset 18425
- Timestamp:
- Jul 6, 2008, 12:03:34 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branch_20080706/psModules/src/config/pmConfigMask.c
r16815 r18425 39 39 return mask; 40 40 } 41 42 // replace the named masks in the recipe with values in the header 43 void pmConfigMasksReadHeader (pmConfig *config, psMetadata *header) { 44 45 psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, "MASKS"); // The recipe 46 if (!recipe) { 47 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find MASKS recipe."); 48 return false; 49 } 50 51 int nMask = 0; 52 53 psMetadataIterator *iter = psMetadataIteratorAlloc(recipe, PS_LIST_HEAD, NULL); // Iterator 54 55 psMetadataItem *item; // Item from iteration 56 while ((item = psMetadataGetAndIncrement(iter))) { 57 58 if (item->type != PS_DATA_U8) { 59 psWarning("mask recipe entry %s is not a bit value\n", item->name); 60 continue; 61 } 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 } 70 71 psMetadataAddU8 (header, PS_LIST_TAIL, "MSKNUM", 0, "Bitmask bit count", nMask); 72 return true; 73 } 74 75 // write the named mask bits to the header 76 bool pmConfigMasksWriteHeader (pmConfig *config, psMetadata *header) { 77 78 psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, "MASKS"); // The recipe 79 if (!recipe) { 80 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find MASKS recipe."); 81 return false; 82 } 83 84 int nMask = 0; 85 86 psMetadataIterator *iter = psMetadataIteratorAlloc(recipe, PS_LIST_HEAD, NULL); // Iterator 87 88 psMetadataItem *item; // Item from iteration 89 while ((item = psMetadataGetAndIncrement(iter))) { 90 91 if (item->type != PS_DATA_U8) { 92 psWarning("mask recipe entry %s is not a bit value\n", item->name); 93 continue; 94 } 95 96 snprintf (namekey, 64, "MSKNAM%02d", nMask); 97 snprintf (valuekey, 64, "MSKVAL%02d", nMask); 98 99 psMetadataAddStr (header, PS_LIST_TAIL, namekey, 0, "Bitmask bit name", item->name); 100 psMetadataAddU8 (header, PS_LIST_TAIL, valuekey, 0, "Bitmask bit value", item->data.U8); 101 nMask ++; 102 } 103 104 psMetadataAddU8 (header, PS_LIST_TAIL, "MSKNUM", 0, "Bitmask bit count", nMask); 105 return true; 106 }
Note:
See TracChangeset
for help on using the changeset viewer.
