Changeset 10481 for trunk/psModules/src/config/pmConfigRecipes.c
- Timestamp:
- Dec 5, 2006, 11:47:33 AM (20 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/config/pmConfigRecipes.c (modified) (16 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/config/pmConfigRecipes.c
r10470 r10481 64 64 if (config->site && (source & PM_RECIPE_SOURCE_SITE)) { 65 65 if (!loadRecipeFiles(config, config->site, PM_RECIPE_SOURCE_SITE, "site configuration")) { 66 psLogMsg ("psModules. pmConfig", PS_LOG_WARN, "Failed to read recipes from site config");67 } else { 68 psTrace ("psModules. pmConfig", 3, "read recipes from site config");66 psLogMsg ("psModules.config", PS_LOG_WARN, "Failed to read recipes from site config"); 67 } else { 68 psTrace ("psModules.config", 3, "read recipes from site config"); 69 69 } 70 70 } … … 76 76 if (config->camera && (source & PM_RECIPE_SOURCE_CAMERA) && !(config->recipesRead & PM_RECIPE_SOURCE_CAMERA)) { 77 77 if (!loadRecipeFiles(config, config->camera, PM_RECIPE_SOURCE_CAMERA, "camera configuration")) { 78 psLogMsg ("psModules. pmConfig", PS_LOG_DETAIL, "no recipe supplied by camera config");79 } else { 80 psTrace ("psModules. pmConfig", 3, "read recipes from camera config");78 psLogMsg ("psModules.config", PS_LOG_DETAIL, "no recipe supplied by camera config"); 79 } else { 80 psTrace ("psModules.config", 3, "read recipes from camera config"); 81 81 } 82 82 } … … 85 85 if (config->arguments && (source & PM_RECIPE_SOURCE_CL)) { 86 86 if (!loadRecipeFromArguments(config)) { 87 psLogMsg ("psModules. pmConfig", PS_LOG_DETAIL, "no recipe supplied on command-line arguments");88 } else { 89 psTrace ("psModules. pmConfig", 3, "read recipes from command-line arguments");87 psLogMsg ("psModules.config", PS_LOG_DETAIL, "no recipe supplied on command-line arguments"); 88 } else { 89 psTrace ("psModules.config", 3, "read recipes from command-line arguments"); 90 90 } 91 91 if (!loadRecipeSymbols(config)) { 92 psLogMsg ("psModules. pmConfig", PS_LOG_DETAIL, "no recipe supplied on command-line arguments");93 } else { 94 psTrace ("psModules. pmConfig", 3, "read recipes from command-line arguments");92 psLogMsg ("psModules.config", PS_LOG_DETAIL, "no recipe supplied on command-line arguments"); 93 } else { 94 psTrace ("psModules.config", 3, "read recipes from command-line arguments"); 95 95 } 96 96 if (!loadRecipeOptions(config)) { 97 psLogMsg ("psModules. pmConfig", PS_LOG_DETAIL, "no recipe supplied on command-line arguments");98 } else { 99 psTrace ("psModules. pmConfig", 3, "read recipes from command-line arguments");97 psLogMsg ("psModules.config", PS_LOG_DETAIL, "no recipe supplied on command-line arguments"); 98 } else { 99 psTrace ("psModules.config", 3, "read recipes from command-line arguments"); 100 100 } 101 101 } … … 117 117 // save the recipes onto config->arguments:RECIPES 118 118 // increment so we can free below (is a NOP is options is NULL) 119 psMetadata *options = psMemIncrRefCounter (psMetadataLookupMetadata(NULL, config->arguments, "OPTIONS")); 120 if (!options) { 121 options = psMetadataAlloc (); 122 psMetadataAddPtr (config->arguments, PS_LIST_TAIL, "OPTIONS", PS_DATA_METADATA, "", options); 119 psMetadata *options; // OPTIONS on the arguments 120 psMetadataItem *optionsItem = psMetadataLookup(config->arguments, "OPTIONS"); 121 if (optionsItem) { 122 if (optionsItem->type != PS_DATA_METADATA) { 123 psAbort(__func__, "OPTIONS is not of type METADATA."); 124 } 125 options = psMemIncrRefCounter(optionsItem->data.V); 126 } else { 127 options = psMetadataAlloc(); 128 psMetadataAddPtr(config->arguments, PS_LIST_TAIL, "OPTIONS", PS_DATA_METADATA, 129 "Command-line options specified with -D", options); 123 130 } 124 131 … … 200 207 bool pmConfigLoadRecipeArguments (pmConfig *config) 201 208 { 209 psMetadata *recipes; // Recipes in the arguments list 210 psMetadataItem *recipesItem = psMetadataLookup(config->arguments, "RECIPES"); 211 if (recipesItem) { 212 if (recipesItem->type != PS_DATA_METADATA) { 213 psAbort(__func__, "RECIPES is not of type METADATA."); 214 } 215 recipes = psMemIncrRefCounter(recipesItem->data.V); 216 } else { 217 recipes = psMetadataAlloc(); 218 psMetadataAddPtr (config->arguments, PS_LIST_TAIL, "RECIPES", PS_DATA_METADATA, "", recipes); 219 } 220 202 221 203 222 // Go through the command-line arguments … … 218 237 // The source is a file: load onto config->arguments 219 238 // save the recipes onto config->arguments:RECIPES 220 psMetadata *recipes = psMemIncrRefCounter (psMetadataLookupMetadata(NULL, config->arguments, "RECIPES"));221 if (!recipes) {222 recipes = psMetadataAlloc ();223 psMetadataAddPtr (config->arguments, PS_LIST_TAIL, "RECIPES", PS_DATA_METADATA, "", recipes);224 }225 239 226 240 psMetadata *recipe = NULL; // Recipe from file … … 228 242 psString comment = psStringCopy("Recipe added at command line from "); 229 243 psStringAppend(&comment, "%s", recipeSource); 230 psMetadataAdd(recipes, PS_LIST_TAIL, recipeName, PS_DATA_METADATA | PS_META_REPLACE, comment, recipe); 244 psMetadataAdd(recipes, PS_LIST_TAIL, recipeName, PS_DATA_METADATA | PS_META_REPLACE, 245 comment, recipe); 231 246 psFree(comment); 232 247 psFree(recipe); // Drop reference … … 234 249 psAbort ("pmConfig.c", "error reading config file %s\n", recipeSource); 235 250 } 236 psFree (recipes);237 251 } else { 238 252 // Assume it's a symbolic reference to something that's not yet read in. 239 253 // it will be loaded later by pmConfigReadRecipes with option CL 240 psMetadataAddStr(config->recipeSymbols, PS_LIST_TAIL, recipeName, PS_META_REPLACE, "", recipeSource); 241 } 242 psTrace ("psModules.pmConfig", 3, "read recipe %s from %s", recipeName, recipeSource); 254 psMetadataAddStr(config->recipeSymbols, PS_LIST_TAIL, recipeName, PS_META_REPLACE, "", 255 recipeSource); 256 } 257 psTrace ("psModules.config", 3, "read recipe %s from %s", recipeName, recipeSource); 243 258 psFree(recipeName); 244 259 psFree(recipeSource); 245 260 } // Iterating through the command-line arguments 246 261 262 psFree(recipes); // Drop reference 247 263 return true; 248 264 } … … 262 278 } 263 279 if (!source) { 264 psTrace("psModules. pmConfig", 4, "The %s has not been read --- cannot read recipes from this "280 psTrace("psModules.config", 4, "The %s has not been read --- cannot read recipes from this " 265 281 "location.\n", sourceName); 266 282 config->recipesRead &= ~sourceType; … … 270 286 psMetadata *recipes = psMetadataLookupMetadata(NULL, source, "RECIPES"); // The list of recipes 271 287 if (!recipes) { 272 psLogMsg("psModules. pmConfig", PS_LOG_WARN, "RECIPES not found in the %s\n", sourceName);288 psLogMsg("psModules.config", PS_LOG_WARN, "RECIPES not found in the %s\n", sourceName); 273 289 config->recipesRead &= ~sourceType; 274 290 return false; … … 289 305 psString comment = NULL; 290 306 psStringAppend(&comment, "Recipe added at %s from %s", sourceName, (char*)fileItem->data.V); 291 psTrace ("psModules.pmConfig", 3, comment); 292 psMetadataAddS32(config->recipesSource, PS_LIST_TAIL, fileItem->name, PS_META_REPLACE, comment, sourceType); 307 psTrace ("psModules.config", 3, comment); 308 psMetadataAddS32(config->recipesSource, PS_LIST_TAIL, fileItem->name, PS_META_REPLACE, 309 comment, sourceType); 293 310 psFree(comment); 294 311 #endif … … 304 321 305 322 // if this named recipe exists, supplement it 306 psMetadata *current = psMemIncrRefCounter(psMetadataLookupMetadata(NULL, config->recipes, 307 fileItem->name)); 308 current = psMetadataCopy (current, recipe); 323 psMetadata *current = NULL; // Current, extant recipe of the same name, to be supplemented 324 psMetadataItem *currentItem = psMetadataLookup(config->recipes, fileItem->name); 325 if (currentItem) { 326 if (currentItem->type != PS_DATA_METADATA) { 327 psAbort(__func__, "Item from recipes is not of type METADATA."); 328 } 329 current = psMemIncrRefCounter(currentItem->data.V); 330 psTrace("psModules.config", 3, "Supplementing %s from %s within %s.\n", currentItem->name, 331 fileItem->name, sourceName); 332 } 333 current = psMetadataCopy(current, recipe); 309 334 psFree(recipe); // Drop reference 310 335 psMetadataAdd(config->recipes, PS_LIST_TAIL, fileItem->name, PS_DATA_METADATA | PS_META_REPLACE, … … 325 350 assert(config); 326 351 if (!config->arguments) { 327 psTrace("psModules. pmConfig", 4, "no config->arguments metadata, nothing to read here");352 psTrace("psModules.config", 4, "no config->arguments metadata, nothing to read here"); 328 353 return false; 329 354 } … … 331 356 psMetadata *recipes = psMetadataLookupMetadata(NULL, config->arguments, "RECIPES"); // The list of recipes 332 357 if (!recipes) { 333 psTrace("psModules. pmConfig", 4, "no RECIPES in config->arguments, nothing to read here");358 psTrace("psModules.config", 4, "no RECIPES in config->arguments, nothing to read here"); 334 359 return false; 335 360 } … … 415 440 assert(config); 416 441 if (!config->arguments) { 417 psTrace("psModules. pmConfig", 4, "no config->arguments metadata, nothing to read here");442 psTrace("psModules.config", 4, "no config->arguments metadata, nothing to read here"); 418 443 return false; 419 444 } … … 421 446 psMetadata *recipes = psMetadataLookupMetadata(NULL, config->arguments, "OPTIONS"); // The list of recipes 422 447 if (!recipes) { 423 psTrace("psModules. pmConfig", 4, "no OPTIONS in config->arguments, nothing to read here");448 psTrace("psModules.config", 4, "no OPTIONS in config->arguments, nothing to read here"); 424 449 return false; 425 450 }
Note:
See TracChangeset
for help on using the changeset viewer.
