Changeset 23286 for trunk/psModules/src/config/pmConfigRecipes.c
- Timestamp:
- Mar 11, 2009, 4:51:19 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/config/pmConfigRecipes.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/config/pmConfigRecipes.c
r21387 r23286 11 11 #include "pmConfigRecipes.h" 12 12 13 static bool loadRecipeSystem(bool *status, pmConfig *config , psMetadata *source);13 static bool loadRecipeSystem(bool *status, pmConfig *config); 14 14 static bool loadRecipeCamera(bool *status, pmConfig *config, psMetadata *source); 15 15 static bool loadRecipeSymbols(bool *status, pmConfig *config, pmRecipeSource source); … … 56 56 PS_ASSERT_PTR_NON_NULL(config, false); 57 57 58 if (!config->recipes) {59 config->recipes = psMetadataAlloc();60 }61 62 58 // Read the recipe file names from the system configuration and camera configuration 63 59 // It is an error for config->system:recipes not to exist. all programs install their 64 60 // master recipe files in the system:recipe location when they are built. 65 61 psAssert(config->system, "base config data defined"); 66 if ( source & PM_RECIPE_SOURCE_SYSTEM) {67 if (!loadRecipeSystem(&status, config , config->system)) {62 if (!config->recipes || (source & PM_RECIPE_SOURCE_SYSTEM)) { 63 if (!loadRecipeSystem(&status, config)) { 68 64 psError(PS_ERR_IO, false, "Failed to read recipes from system config"); 69 65 return false; … … 321 317 // Load the recipe files for SYSTEM : REQUIRED 322 318 static bool loadRecipeSystem(bool *status, 323 pmConfig *config, // The configuration into which to read the recipes 324 psMetadata *source // The source configuration, from which to read the filenames 319 pmConfig *config // The configuration into which to read the recipes 325 320 ) 326 321 { … … 329 324 *status = false; 330 325 331 if (! source) {326 if (!config->system) { 332 327 psError(PS_ERR_IO, true, 333 328 "The system configuration has not been read --- cannot read recipes from this location.\n"); … … 336 331 } 337 332 338 psMetadata *recipes = psMetadataLookupMetadata(NULL, source, "RECIPES"); // The list of recipes339 if (!recipes) {340 psError(PS_ERR_IO, false, "RECIPES not found in the system configuration\n");341 return false;342 }343 344 // Copy contents of the filenames to config->recipes from the "RECIPES" metadata in the source.345 // We could use psMetadataCopy for this, but it's better to check that everything's of the correct type. 346 // If it's not of the correct type, we can tell the user which file it's in, so they can find it easier.347 psMetadataIterator *recipesIter = psMetadataIteratorAlloc( recipes, PS_LIST_HEAD, NULL); // Iterator333 if (!config->recipes) { 334 config->recipes = psMemIncrRefCounter(psMetadataLookupMetadata(NULL, config->system, "RECIPES")); // The list of recipes 335 if (!config->recipes) { 336 psError(PS_ERR_IO, false, "RECIPES not found in the system configuration\n"); 337 return false; 338 } 339 } 340 341 // Read in the component recipes 342 psMetadataIterator *recipesIter = psMetadataIteratorAlloc(config->recipes, PS_LIST_HEAD, NULL); // Iterator 348 343 psMetadataItem *item = NULL; // MD item containing the filename, from recipe iteration 349 344 while ((item = psMetadataGetAndIncrement(recipesIter))) { … … 353 348 psFree(recipesIter); 354 349 return false; 355 } 356 357 // add the contents of this recipe file to config->recipes 358 psMetadataAdd(config->recipes, PS_LIST_TAIL, item->name, PS_DATA_METADATA | PS_META_REPLACE, 359 item->comment, item->data.md); 350 } 360 351 } 361 352 psFree(recipesIter);
Note:
See TracChangeset
for help on using the changeset viewer.
