Index: trunk/psModules/src/config/pmConfigRecipes.c
===================================================================
--- trunk/psModules/src/config/pmConfigRecipes.c	(revision 17512)
+++ trunk/psModules/src/config/pmConfigRecipes.c	(revision 18908)
@@ -28,5 +28,6 @@
     if (!options) {
         options = psMetadataAlloc ();
-        success = psMetadataAddPtr (config->arguments, PS_LIST_TAIL, "OPTIONS",  PS_DATA_METADATA, "", options);
+        success = psMetadataAddPtr (config->arguments, PS_LIST_TAIL, "OPTIONS",  PS_DATA_METADATA, "",
+                                    options);
         assert (success); // type mismatch : OPTIONS already defined but wrong type
         psFree (options); // drop extra reference
@@ -47,5 +48,5 @@
 
 // this function may be called several times.  it attempts to load the recipe data from one of three
-// locations: config->complete, config->camera, and argv.  We cannot read the recipes from
+// locations: config->system, config->camera, and argv.  We cannot read the recipes from
 // config->camera until a camera has been read BUT, the argv recipes must override the camera and
 // system recipes.  This command strips the argv elements it uses from the argv list.
@@ -60,9 +61,9 @@
 
     // Read the recipe file names from the system configuration and camera configuration
-    // It is an error for config->complete:recipes not to exist.  all programs install their
+    // It is an error for config->system:recipes not to exist.  all programs install their
     // master recipe files in the system:recipe location when they are built.
-    psAssert (config->complete, "base config data defined");
+    psAssert(config->system, "base config data defined");
     if (source & PM_RECIPE_SOURCE_SYSTEM) {
-        if (!loadRecipeSystem(&status, config, config->complete)) {
+        if (!loadRecipeSystem(&status, config, config->system)) {
             psError(PS_ERR_IO, false, "Failed to read recipes from system config");
             return false;
@@ -75,5 +76,6 @@
     // for an identified camera (in pmConfigCameraFormatFromHeader).  the second
     // set should not override the first set
-    if (config->camera && (source & PM_RECIPE_SOURCE_CAMERA) && !(config->recipesRead & PM_RECIPE_SOURCE_CAMERA)) {
+    if (config->camera && (source & PM_RECIPE_SOURCE_CAMERA) &&
+        !(config->recipesRead & PM_RECIPE_SOURCE_CAMERA)) {
         if (!loadRecipeCamera(&status, config, config->camera)) {
             psError(PS_ERR_IO, false, "Failed to read recipes from camera config");
@@ -87,8 +89,9 @@
     }
 
-    // merge camera and sytem recipes, apply recipes loaded into config->arguments based on command-line arguments
+    // merge camera and sytem recipes, apply recipes loaded into config->arguments based on command-line
+    // arguments
     if (config->arguments && (source & PM_RECIPE_SOURCE_CL)) {
 
-	// update the system-level recipes with the symbolically-defined recipes 
+        // update the system-level recipes with the symbolically-defined recipes
         if (!loadRecipeSymbols(&status, config, PM_RECIPE_SOURCE_SYSTEM)) {
             psError(PS_ERR_IO, false, "Failed to read recipes from symbolic references");
@@ -101,12 +104,12 @@
         }
 
-	// merge the SYSTEM and CAMERA recipes
+        // merge the SYSTEM and CAMERA recipes
         if (!mergeRecipeCamera(&status, config)) {
             psError(PS_ERR_IO, false, "Failed to read recipes from symbolic references");
             return false;
         }
-	psLogMsg ("psModules.config", PS_LOG_DETAIL, "merged camera recipes with system recipes");
-
-	// load recipe-files specified on the command line
+        psLogMsg ("psModules.config", PS_LOG_DETAIL, "merged camera recipes with system recipes");
+
+        // load recipe-files specified on the command line
         if (!loadRecipeFromArguments(&status, config)) {
             psError(PS_ERR_IO, false, "Failed to read recipes from command-line arguments");
@@ -119,5 +122,5 @@
         }
 
-	// update the system-level recipes with the symbolically-defined recipes 
+        // update the system-level recipes with the symbolically-defined recipes
         if (!loadRecipeSymbols(&status, config, PM_RECIPE_SOURCE_CAMERA)) {
             psError(PS_ERR_IO, false, "Failed to read recipes from symbolic references");
@@ -130,5 +133,5 @@
         }
 
-	// override any specific values with values from the command line
+        // override any specific values with values from the command line
         if (!loadRecipeOptions(&status, config)) {
             psError(PS_ERR_IO, false, "Failed to read recipes from symbolic references");
@@ -155,5 +158,6 @@
     if (!options) {
         options = psMetadataAlloc();
-        success = psMetadataAddPtr(config->arguments, PS_LIST_TAIL, "OPTIONS",  PS_DATA_METADATA, "Command-line options specified with -D", options);
+        success = psMetadataAddPtr(config->arguments, PS_LIST_TAIL, "OPTIONS",  PS_DATA_METADATA,
+                                   "Command-line options specified with -D", options);
         assert (success); // type mismatch : OPTIONS already defined but wrong type
         psFree (options); // drop extra reference
@@ -178,5 +182,6 @@
             recipeName = config->defaultRecipe;
             if (!config->defaultRecipe) {
-                psError(PS_ERR_IO, true, "syntax error in parameter: no default recipe available; must specify recipe");
+                psError(PS_ERR_IO, true,
+                        "syntax error in parameter: no default recipe available; must specify recipe");
                 return false;
             }
@@ -242,5 +247,6 @@
     if (!recipes) {
         recipes = psMetadataAlloc();
-        success = psMetadataAddPtr (config->arguments, PS_LIST_TAIL, "RECIPES",  PS_DATA_METADATA, "", recipes);
+        success = psMetadataAddPtr (config->arguments, PS_LIST_TAIL, "RECIPES",  PS_DATA_METADATA, "",
+                                    recipes);
         assert (success);
         psFree (recipes);
@@ -298,5 +304,6 @@
         // Assume it's a symbolic reference to something that's not yet read in.
         // it will be loaded later by pmConfigReadRecipes with option CL
-        psMetadataAddStr(config->recipeSymbols, PS_LIST_TAIL, recipeName, PS_META_REPLACE, NULL, recipeSource);
+        psMetadataAddStr(config->recipeSymbols, PS_LIST_TAIL, recipeName, PS_META_REPLACE, NULL,
+                         recipeSource);
 
         psTrace ("psModules.config", 3, "read recipe %s from %s", recipeName, recipeSource);
@@ -319,5 +326,6 @@
 
     if (!source) {
-        psError(PS_ERR_IO, true, "The system configuration has not been read --- cannot read recipes from this location.\n");
+        psError(PS_ERR_IO, true,
+                "The system configuration has not been read --- cannot read recipes from this location.\n");
         config->recipesRead &= ~PM_RECIPE_SOURCE_SYSTEM;
         return false;
@@ -334,24 +342,16 @@
     // If it's not of the correct type, we can tell the user which file it's in, so they can find it easier.
     psMetadataIterator *recipesIter = psMetadataIteratorAlloc(recipes, PS_LIST_HEAD, NULL); // Iterator
-    psMetadataItem *fileItem = NULL;    // MD item containing the filename, from recipe iteration
-    while ((fileItem = psMetadataGetAndIncrement(recipesIter))) {
-        char *recipeName = fileItem->name;
-        char *recipeFile = fileItem->data.str;
-
-        // type mismatch is a serious error
-        if (fileItem->type != PS_DATA_STRING) {
-            psAbort("%s in system configuration RECIPES is not of type STR", recipeName);
-        }
-
-        // Read the recipe file. if we fail on a file, give a warning, but continue
-        psMetadata *recipe = NULL;
-        if (!pmConfigFileRead(&recipe, recipeFile, "recipe")) {
-            psError(PS_ERR_IO, false, "Failed to read recipe file %s listed in system configuration\n", recipeFile);
-            return false;
-        }
-
-        // and the contents of this recipe file to config->recipes
-        psMetadataAdd(config->recipes, PS_LIST_TAIL, fileItem->name, PS_DATA_METADATA | PS_META_REPLACE, fileItem->comment, recipe);
-        psFree(recipe);  // Drop reference
+    psMetadataItem *item = NULL;        // MD item containing the filename, from recipe iteration
+    while ((item = psMetadataGetAndIncrement(recipesIter))) {
+        if (!pmConfigFileIngest(item, "recipe")) {
+            psError(PS_ERR_IO, false, "Failed to read recipe %s listed in system configuration",
+                    item->name);
+            psFree(recipesIter);
+            return false;
+        }
+
+        // add the contents of this recipe file to config->recipes
+        psMetadataAdd(config->recipes, PS_LIST_TAIL, item->name, PS_DATA_METADATA | PS_META_REPLACE,
+                      item->comment, item->data.md);
     }
     psFree(recipesIter);
@@ -375,5 +375,6 @@
 
     if (!source) {
-        psError(PS_ERR_IO, true, "The camera configuration has not been read --- cannot read recipes from this location.\n");
+        psError(PS_ERR_IO, true,
+                "The camera configuration has not been read --- cannot read recipes from this location.\n");
         config->recipesRead &= ~PM_RECIPE_SOURCE_CAMERA;
         return false;
@@ -392,22 +393,13 @@
     // If it's not of the correct type, we can tell the user which file it's in, so they can find it easier.
     psMetadataIterator *recipesIter = psMetadataIteratorAlloc(recipes, PS_LIST_HEAD, NULL); // Iterator
-    psMetadataItem *fileItem = NULL;    // MD item containing the filename, from recipe iteration
-    while ((fileItem = psMetadataGetAndIncrement(recipesIter))) {
-        char *recipeName = fileItem->name;
-        char *recipeFile = fileItem->data.str;
-
-        psTrace("psModules.config", 3, "loading %s from %s within camera configuration.\n", recipeName, recipeFile);
-
-        // type mismatch is a serious error
-        if (fileItem->type != PS_DATA_STRING) {
-            psAbort("%s in camera configuration RECIPES is not of type STR", recipeName);
-        }
-
-        // Read the recipe file. if we fail on a file, give a warning, but continue
-        psMetadata *recipe = NULL;
-        if (!pmConfigFileRead(&recipe, recipeFile, "recipe")) {
-            psError(PS_ERR_IO, false, "Failed to read recipe file %s listed in camera configuration\n", recipeFile);
-            return false;
-        }
+    psMetadataItem *item = NULL;    // MD item containing the filename, from recipe iteration
+    while ((item = psMetadataGetAndIncrement(recipesIter))) {
+        if (!pmConfigFileIngest(item, "recipe")) {
+            psError(PS_ERR_IO, false, "Failed to read recipe %s listed in camera configuration",
+                    item->name);
+            return false;
+        }
+        const char *recipeName = item->name; // Name of the recipe
+        psMetadata *recipe = item->data.md; // The recipe
 
         // the named recipe must exist at the system level
@@ -415,11 +407,10 @@
         if (!current) {
             psError(PS_ERR_IO, false, "Failed to find recipe for %s in master recipe list", recipeName);
-            psFree(recipe);  // Drop reference
             return false;
         }
 
         // add the contents of this recipe file to config->recipesCamera
-        psMetadataAdd(config->recipesCamera, PS_LIST_TAIL, recipeName, PS_DATA_METADATA | PS_META_REPLACE, fileItem->comment, recipe);
-        psFree(recipe);  // Drop reference
+        psMetadataAdd(config->recipesCamera, PS_LIST_TAIL, recipeName, PS_DATA_METADATA | PS_META_REPLACE,
+                      item->comment, recipe);
     }
     psFree(recipesIter);
@@ -441,5 +432,5 @@
     // We could use psMetadataCopy for this, but it's better to check that everything's of the correct type.
     // If it's not of the correct type, we can tell the user which file it's in, so they can find it easier.
-    psMetadataIterator *recipesIter = psMetadataIteratorAlloc(config->recipesCamera, PS_LIST_HEAD, NULL); // Iterator
+    psMetadataIterator *recipesIter = psMetadataIteratorAlloc(config->recipesCamera, PS_LIST_HEAD, NULL);
     psMetadataItem *folderItem = NULL;    // MD item containing the filename, from recipe iteration
     while ((folderItem = psMetadataGetAndIncrement(recipesIter))) {
@@ -459,8 +450,8 @@
 
         // update the contents of this recipe from the one on config->recipesCamera
-	if (!psMetadataUpdate(current, recipe)) {
-	    psError(PS_ERR_IO, false, "Failed to update recipe for %s from camera recipe", recipeName);
-	    return false;
-	}
+        if (!psMetadataUpdate(current, recipe)) {
+            psError(PS_ERR_IO, false, "Failed to update recipe for %s from camera recipe", recipeName);
+            return false;
+        }
     }
     psFree(recipesIter);
@@ -552,23 +543,23 @@
 
         // search for sourceName in config->recipes (folder name is targetName)
-	psMetadata *folder = psMetadataLookupMetadata(&found, config->recipes, targetName);
-	psMetadata *sourceMD = psMetadataLookupMetadata(&found, folder, sourceName);
-
-	// if we find the desired symbolic name at this level, set the item comment to say "FOUND"
+        psMetadata *folder = psMetadataLookupMetadata(&found, config->recipes, targetName);
+        psMetadata *sourceMD = psMetadataLookupMetadata(&found, folder, sourceName);
+
+        // if we find the desired symbolic name at this level, set the item comment to say "FOUND"
         if (sourceMD) {
-	  if (!psMetadataUpdate(targetMD, sourceMD)) {
+          if (!psMetadataUpdate(targetMD, sourceMD)) {
             psError(PS_ERR_IO, false, "Failed to update recipe for %s from camera recipe", targetName);
             return false;
-	  }
-	  psStringAppend (&item->comment, "(FOUND)");
-	}	  
-
-	// if we have not found it by the camera level, we have a problem
-	if (source == PM_RECIPE_SOURCE_CAMERA) {
-	  if (strstr (item->comment, "(FOUND)") == NULL) {
-	    psError(PS_ERR_IO, false, "Selected symbolic name %s does not exist in recipes", sourceName);
-	    return false;
-	  }
-	}
+          }
+          psStringAppend (&item->comment, "(FOUND)");
+        }
+
+        // if we have not found it by the camera level, we have a problem
+        if (source == PM_RECIPE_SOURCE_CAMERA) {
+          if (strstr (item->comment, "(FOUND)") == NULL) {
+            psError(PS_ERR_IO, false, "Selected symbolic name %s does not exist in recipes", sourceName);
+            return false;
+          }
+        }
     }
     psFree(iter);
@@ -594,5 +585,5 @@
     }
 
-    psMetadata *recipes = psMetadataLookupMetadata(&found, config->arguments, "OPTIONS"); // The list of recipes
+    psMetadata *recipes = psMetadataLookupMetadata(&found, config->arguments, "OPTIONS"); // List of recipes
     if (!recipes) {
         psTrace("psModules.config", 4, "no OPTIONS in config->arguments, nothing to read here");
