Index: trunk/psModules/src/config/pmConfig.c
===================================================================
--- trunk/psModules/src/config/pmConfig.c	(revision 9539)
+++ trunk/psModules/src/config/pmConfig.c	(revision 9579)
@@ -1,8 +1,9 @@
 /** @file  pmConfig.h
  *
- *  @author PAP, IfA
+ *  @author PAP (IfA)
+ *  @author EAM (IfA)
  *
- *  @version $Revision: 1.47 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-10-13 21:15:45 $
+ *  @version $Revision: 1.48 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-10-14 03:54:51 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -28,5 +29,5 @@
 #define PS_DEFAULT_SITE ".ipprc"  // Default site config file
 
-static psArray *configPath = NULL;
+static psArray *configPath = NULL;      // Search path for configuration files
 
 static void configFree(pmConfig *config)
@@ -79,19 +80,9 @@
 }
 
-
-/** readConfig
- *
- * This function attempts to open the file specified in the parameter list
- * parse it into metadata, then return it as a psMetaData table.
- *
- */
-bool readConfig(
-    psMetadata **config,                // Config to output
-    const char *name,                   // Name of file
-    const char *description)            // Description of file
-{
-    assert(config);
-    assert(name && strlen(name) > 0);
-    assert(description && strlen(description) > 0);
+bool pmConfigFileRead(psMetadata **config, const char *name, const char *description)
+{
+    PS_ASSERT_METADATA_NON_NULL(*config, false);
+    PS_ASSERT_STRING_NON_EMPTY(name, false);
+    PS_ASSERT_STRING_NON_EMPTY(description, false);
 
     char *realName = NULL;
@@ -167,17 +158,5 @@
 
 
-/******************************************************************************
-pmConfigRead(**site, **camera, **recipe, *argc, **argv, char *recipeName)
- 
-XXX: The log/trace command line options (as processed by psArgumentVerbosity)
-must take precedence override the values set here.  This must be, somehow,
-coded.
- 
-XXX: Must load camera and recipe configuration if specified in the command
- line.
- *****************************************************************************/
-pmConfig *pmConfigRead(
-    int *argc,
-    char **argv)
+pmConfig *pmConfigRead(int *argc, char **argv)
 {
     PS_ASSERT_PTR_NON_NULL(argc, NULL);
@@ -236,5 +215,5 @@
     //
 
-    if (!readConfig(&config->site, siteName, "site")) {
+    if (!pmConfigFileRead(&config->site, siteName, "site")) {
         psFree(config);
         return NULL;
@@ -289,5 +268,5 @@
             }
 
-            readConfig(&config->camera, cameraFile, "camera");
+            pmConfigFileRead(&config->camera, cameraFile, "camera");
             psArgumentRemove(argNum, config->argc, config->argv);
         }
@@ -387,5 +366,6 @@
                 continue;
             }
-            psTrace("psModules.config", 7, "Setting trace level for %s to %d\n", traceItem->name, traceItem->data.S32);
+            psTrace("psModules.config", 7, "Setting trace level for %s to %d\n", traceItem->name,
+                    traceItem->data.S32);
             psTraceSetLevel(traceItem->name, traceItem->data.S32);
         }
@@ -437,7 +417,5 @@
 
 
-bool pmConfigValidateCameraFormat(
-    const psMetadata *cameraFormat,
-    const psMetadata *header)
+bool pmConfigValidateCameraFormat(const psMetadata *cameraFormat, const psMetadata *header)
 {
     PS_ASSERT_PTR_NON_NULL(cameraFormat, false);
@@ -478,4 +456,5 @@
 
 
+// Given a camera and a header, see if any of the camera formats match the header
 static bool formatFromHeader(psMetadata **format, // Format to return
                              psMetadata *camera, // Camera configuration
@@ -510,5 +489,5 @@
         psTrace("psModules.config", 5, "Reading camera format for %s...\n", formatsItem->name);
         psMetadata *testFormat = NULL;  // Format to test against what we've got
-        if (!readConfig(&testFormat, formatsItem->data.V, formatsItem->name)) {
+        if (!pmConfigFileRead(&testFormat, formatsItem->data.V, formatsItem->name)) {
             psLogMsg(__func__, PS_LOG_WARN, "Trouble reading reading camera format %s --- ignored.\n",
                      formatsItem->name);
@@ -535,10 +514,6 @@
 }
 
-// Work out what camera we have, based on the FITS header and a set of rules specified in the IPP
-// configuration; return the camera configuration and format
-psMetadata *pmConfigCameraFormatFromHeader(
-    pmConfig *config,                   // The configuration
-    const psMetadata *header            // The FITS header
-)
+
+psMetadata *pmConfigCameraFormatFromHeader(pmConfig *config, const psMetadata *header)
 {
     PS_ASSERT_PTR_NON_NULL(config, NULL);
@@ -561,5 +536,6 @@
         while ((camerasItem = psMetadataGetAndIncrement(camerasIter))) {
             // Open the camera information
-            psTrace("psModules.config", 3, "Inspecting camera %s (%s)\n", camerasItem->name, camerasItem->comment);
+            psTrace("psModules.config", 3, "Inspecting camera %s (%s)\n", camerasItem->name,
+                    camerasItem->comment);
             if (camerasItem->type != PS_DATA_STRING) {
                 psLogMsg(__func__, PS_LOG_WARN, "Camera configuration for %s in CAMERAS is not of type STR "
@@ -571,5 +547,5 @@
             psMetadata *testCamera = NULL; // Camera to test against what we've got:
 
-            if (!readConfig(&testCamera, camerasItem->data.V, camerasItem->name)) {
+            if (!pmConfigFileRead(&testCamera, camerasItem->data.V, camerasItem->name)) {
                 psLogMsg(__func__, PS_LOG_WARN, "Trouble reading reading camera configuration %s --- "
                          "ignored.\n", camerasItem->name);
@@ -607,11 +583,8 @@
 
 // Return the requested camera configuration
-psMetadata *pmConfigCameraByName(
-    pmConfig *config,                   // The configuration
-    const char *cameraName   // The camera name header
-)
-{
-    PS_ASSERT_PTR_NON_NULL(cameraName, NULL);
+psMetadata *pmConfigCameraByName(pmConfig *config, const char *cameraName)
+{
     PS_ASSERT_PTR_NON_NULL(config, NULL);
+    PS_ASSERT_STRING_NON_EMPTY(cameraName, NULL);
 
     psMetadata *cameras = psMetadataLookupMetadata(NULL, config->site, "CAMERAS");
@@ -629,5 +602,5 @@
     psMetadata *camera = NULL; // Camera to test against what we've got:
 
-    if (!readConfig(&camera, cameraPath, cameraName)) {
+    if (!pmConfigFileRead(&camera, cameraPath, cameraName)) {
         psLogMsg(__func__, PS_LOG_WARN, "Trouble reading reading camera configuration %s", cameraName);
         psFree(camera);
@@ -695,5 +668,5 @@
             // Read the recipe
             psMetadata *recipe = NULL;      // Recipe from file
-            if (readConfig(&recipe, fileItem->data.V, "recipe")) {
+            if (pmConfigFileRead(&recipe, fileItem->data.V, "recipe")) {
                 psMetadataAdd(config->recipes, PS_LIST_TAIL, fileItem->name,
                               PS_DATA_METADATA | PS_META_REPLACE, fileItem->comment, recipe);
@@ -738,6 +711,5 @@
 
 
-bool pmConfigReadRecipes(pmConfig *config
-                        )
+bool pmConfigReadRecipes(pmConfig *config)
 {
     PS_ASSERT_PTR_NON_NULL(config, false);
@@ -794,5 +766,6 @@
 
             // Is the source a symbolic reference?
-            psMetadata *extant = psMetadataLookupMetadata(&mdok, config->recipes, recipeSource); // Does it exist?
+            psMetadata *extant = psMetadataLookupMetadata(&mdok, config->recipes,
+                                 recipeSource); // Does it exist?
             if (mdok && extant) {
                 psString comment = psStringCopy("Recipe added from command line as symbolic link to ");
@@ -808,5 +781,5 @@
                 // The source is a file
                 psMetadata *recipe = NULL;      // Recipe from file
-                if (readConfig(&recipe, recipeSource, "recipe")) {
+                if (pmConfigFileRead(&recipe, recipeSource, "recipe")) {
                     psString comment = psStringCopy("Recipe added at command line from ");
                     psStringAppend(&comment, "%s", recipeSource);
@@ -837,15 +810,6 @@
 }
 
-/******************************************************************************
-pmConfigDB(*site)
- 
-XXX: this should allow the option of having NO database server, if chosen by config
-XXX: What should we use for the Database namespace in the call to psDBInit()?
-This is currently NULL.
- *****************************************************************************/
-
-psDB *pmConfigDB(
-    pmConfig *config                    // Configuration
-)
+
+psDB *pmConfigDB(pmConfig *config)
 {
     PS_ASSERT_PTR_NON_NULL(config, NULL);
@@ -869,19 +833,19 @@
     psString dbName = psMetadataLookupStr(&mdStatus04, config->site, "DBNAME");
     psS32 dbPort = psMetadataLookupS32(&mdStatus05, config->site, "DBPORT");
-    if (!mdStatus05)
+    if (!mdStatus05) {
         dbPort = 0;
-    if (!(mdStatus01 & mdStatus02 & mdStatus03 & mdStatus04)) {
-        psLogMsg(__func__, PS_LOG_WARN, "Could not determine database server name, userID, and password from site metadata.\n");
-        return(NULL);
-    }
-
-    return(psDBInit(dbServer, dbUsername, dbPassword, dbName, dbPort));
+    }
+    if (!(mdStatus01 && mdStatus02 && mdStatus03 && mdStatus04)) {
+        psLogMsg(__func__, PS_LOG_WARN,
+                 "Could not determine database server, name, user, and password from site metadata.\n");
+        return NULL;
+    }
+
+    return psDBInit(dbServer, dbUsername, dbPassword, dbName, dbPort);
     #endif
 }
 
 
-bool pmConfigConformHeader(psMetadata *header, // Header to conform
-                           const psMetadata *format // Camera format
-                          )
+bool pmConfigConformHeader(psMetadata *header, const psMetadata *format)
 {
     PS_ASSERT_PTR_NON_NULL(header, false);
@@ -907,7 +871,5 @@
 }
 
-// given the 'file' and 'list' words, find the arguments associated with these words
-// and interpret them as lists of files.  return an array of the resulting filenames.
-psArray *pmConfigFileSets(pmConfig *config, char *file, char *list)
+psArray *pmConfigFileSets(pmConfig *config, const char *file, const char *list)
 {
     PS_ASSERT_PTR_NON_NULL(config, NULL);
@@ -915,8 +877,6 @@
     PS_ASSERT_INT_NONNEGATIVE(*config->argc, NULL);
     PS_ASSERT_PTR_NON_NULL(config->argv, NULL);
-    PS_ASSERT_PTR_NON_NULL(file, NULL);
-    PS_ASSERT_INT_POSITIVE(strlen(file), NULL);
-    PS_ASSERT_PTR_NON_NULL(list, NULL);
-    PS_ASSERT_INT_POSITIVE(strlen(list), NULL);
+    PS_ASSERT_STRING_NON_EMPTY(file, NULL);
+    PS_ASSERT_STRING_NON_EMPTY(list, NULL);
 
     int Narg;
@@ -990,14 +950,12 @@
 }
 
-bool pmConfigFileSetsMD (psMetadata *metadata, pmConfig *config, char *name, char *file, char *list)
+bool pmConfigFileSetsMD(psMetadata *metadata, pmConfig *config, const char *name,
+                        const char *file, const char *list)
 {
     PS_ASSERT_PTR_NON_NULL(metadata, false);
     PS_ASSERT_PTR_NON_NULL(config, false);
-    PS_ASSERT_PTR_NON_NULL(name, false);
-    PS_ASSERT_INT_POSITIVE(strlen(name), false);
-    PS_ASSERT_PTR_NON_NULL(file, false);
-    PS_ASSERT_INT_POSITIVE(strlen(file), false);
-    PS_ASSERT_PTR_NON_NULL(list, false);
-    PS_ASSERT_INT_POSITIVE(strlen(list), false);
+    PS_ASSERT_STRING_NON_EMPTY(name, NULL);
+    PS_ASSERT_STRING_NON_EMPTY(file, NULL);
+    PS_ASSERT_STRING_NON_EMPTY(list, NULL);
 
     psErrorClear();   // pmConfigFileSets may or may not call psError, so
