Index: trunk/psModules/src/config/pmConfig.c
===================================================================
--- trunk/psModules/src/config/pmConfig.c	(revision 7278)
+++ trunk/psModules/src/config/pmConfig.c	(revision 7311)
@@ -3,6 +3,6 @@
  *  @author PAP, IfA
  *
- *  @version $Revision: 1.19 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-06-02 00:55:22 $
+ *  @version $Revision: 1.20 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-06-03 01:02:08 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -12,4 +12,5 @@
 #include <string.h>
 #include <unistd.h>
+#include <libgen.h>
 #include <assert.h>
 #include <sys/types.h>
@@ -52,7 +53,17 @@
 }
 
+void pmConfigSet(const char *path)
+{
+    pmConfigDone();
+
+    psList *list = psStringSplit(path, ":", false);
+    configPath = psListToArray(list);
+    psFree(list);
+}
+
 void pmConfigDone(void)
 {
     psFree(configPath);
+    configPath = NULL;
 }
 
@@ -100,5 +111,5 @@
 
     if (configPath == NULL) {
-        psError(PS_ERR_IO, false, "Cannot find %s configuration file (%s) in path\n", description, name);
+        psError(PS_ERR_IO, true, "Cannot find %s configuration file (%s) in path\n", description, name);
         return false;
     }
@@ -121,5 +132,5 @@
     }
 
-    psError(PS_ERR_IO, false, "Cannot find %s configuration file %s in path\n", description, name);
+    psError(PS_ERR_IO, true, "Cannot find %s configuration file %s in path\n", description, name);
     return false;
 
@@ -127,9 +138,12 @@
     *config = psMetadataConfigParse(NULL, &numBadLines, realName, true);
     if (numBadLines > 0) {
-        psLogMsg(__func__, PS_LOG_WARN, "%d bad lines in %s configuration file (%s)\n",
-                 description, realName);
+        psError(PS_ERR_IO, false, "%d bad lines in %s configuration file (%s)",
+                numBadLines, description, realName);
+        psFree (realName);
+
+        return false;
     }
     if (!*config) {
-        psError(PS_ERR_IO, false, "Unable to read %s configuration from %s\n",
+        psError(PS_ERR_IO, true, "Unable to read %s configuration from %s",
                 description, realName);
         psFree (realName);
@@ -214,17 +228,23 @@
         return NULL;
     }
+
+    // define the config-file search path (configPath).  Ensure that
+    // it contains the directory where we found the config file in
+    // the first place
+    if (configPath) {
+        pmConfigDone();
+    }
+
+    psString siteNameDir = psStringCopy(dirname(siteName));
     psFree(siteName);
 
-    // define the config-file search path (configPath)
-    if (configPath) {
-        psFree(configPath);
-        configPath = NULL;
-    }
-    char *path = psMetadataLookupStr(NULL, config->site, "PATH");
+    psString path = psMetadataLookupStr(NULL, config->site, "PATH");
     if (path) {
-        psList *list = psStringSplit(path, ":", false);
-        configPath = psListToArray(list);
-        psFree(list);
-    }
+        psStringAppend(&path, ":%s", siteNameDir);
+    } else {
+        path = psMemIncrRefCounter(siteNameDir);
+    }
+    pmConfigSet(path);
+    psFree(siteNameDir);
 
     // Next, we do a similar thing for the camera configuration file.  The
@@ -349,4 +369,6 @@
     }
 
+    psErrorClear();   // we may have failed to find some items in the metadata
+
     return config;
 }
@@ -468,5 +490,5 @@
         psMetadata *cameras = psMetadataLookupMD(&mdok, config->site, "CAMERAS");
         if (! mdok) {
-            psError(PS_ERR_IO, false, "Unable to find CAMERAS in the configuration.\n");
+            psError(PS_ERR_IO, true, "Unable to find CAMERAS in the configuration.");
             return false;
         }
@@ -502,5 +524,5 @@
 
         if (! config->camera) {
-            psError(PS_ERR_IO, true, "Unable to find a camera that matches input FITS header!\n");
+            psError(PS_ERR_IO, false, "Unable to find a camera that matches input FITS header!");
             return NULL;
         }
@@ -611,5 +633,5 @@
     psMetadata *rules = psMetadataLookupMD(&mdok, format, "RULE"); // How to identify this format
     if (!mdok || !rules) {
-        psError(PS_ERR_IO, false, "Unable to find RULE in camera format.\n");
+        psError(PS_ERR_IO, true, "Unable to find RULE in camera format.\n");
         return false;
     }
@@ -651,4 +673,10 @@
         globList.gl_offs = 0;
         glob (argv[Narg], 0, NULL, &globList);
+
+        if (globList.gl_pathc == 0) {
+            psError(PS_ERR_IO, true, "No match for %s", argv[Narg]);
+            return input;
+        }
+
         for (int i = 0; i < globList.gl_pathc; i++) {
             char *filename = psStringCopy (globList.gl_pathv[i]);
@@ -706,6 +734,9 @@
     PS_ASSERT_INT_POSITIVE(strlen(list), NULL);
 
+    psErrorClear();   // pmConfigFileSets may or may not call psError, so
+    // if files->n == 0 we'll want to call psError(..., false, ...)
     psArray *files = pmConfigFileSets (argc, argv, file, list);
     if (files->n == 0) {
+        psError(PS_ERR_IO, false, "pmConfigFileSets failed to find desired files in metadata");
         psFree (files);
         return false;
Index: trunk/psModules/src/config/pmConfig.h
===================================================================
--- trunk/psModules/src/config/pmConfig.h	(revision 7278)
+++ trunk/psModules/src/config/pmConfig.h	(revision 7311)
@@ -3,6 +3,6 @@
  *  @author PAP, IfA
  *
- *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-05-02 00:47:01 $
+ *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-06-03 01:02:08 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -28,4 +28,6 @@
 
 pmConfig *pmConfigAlloc(void);
+
+void pmConfigSet(const char *path); // set the configPath
 
 // Free static variables
