Index: /branches/eam_branch_20080219/psModules/src/camera/pmFPAfileDefine.c
===================================================================
--- /branches/eam_branch_20080219/psModules/src/camera/pmFPAfileDefine.c	(revision 16577)
+++ /branches/eam_branch_20080219/psModules/src/camera/pmFPAfileDefine.c	(revision 16578)
@@ -155,5 +155,5 @@
     } else {
         bool mdok;                      // Status of MD lookup
-        psMetadata *cameras = psMetadataLookupMetadata(&mdok, config->xxSystem, "CAMERAS"); // Known cameras
+        psMetadata *cameras = psMetadataLookupMetadata(&mdok, config->complete, "CAMERAS"); // Known cameras
         if (!mdok || !cameras) {
             psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find CAMERAS in the system configuration.\n");
Index: /branches/eam_branch_20080219/psModules/src/config/pmConfig.c
===================================================================
--- /branches/eam_branch_20080219/psModules/src/config/pmConfig.c	(revision 16577)
+++ /branches/eam_branch_20080219/psModules/src/config/pmConfig.c	(revision 16578)
@@ -52,7 +52,8 @@
 static void configFree(pmConfig *config)
 {
-    psFree(config->xxUser);
-    psFree(config->xxSite);
-    psFree(config->xxSystem);
+    psFree(config->user);
+    psFree(config->site);
+    psFree(config->system);
+    psFree(config->complete);
     psFree(config->files);
     psFree(config->camera);
@@ -82,7 +83,8 @@
 
     // Initialise
-    config->xxUser = NULL;
-    config->xxSite = NULL;
-    config->xxSystem = NULL;
+    config->user = NULL;
+    config->site = NULL;
+    config->system = NULL;
+    config->complete = NULL;
     config->camera = NULL;
     config->cameraName = NULL;
@@ -426,10 +428,9 @@
     }
 
-
     // We have the configuration filename; now we read and parse the config
-    // file and store in psMetadata struct xxUser.
+    // file and store in psMetadata struct user.
     // XXX move this section to pmConfigReadUser.c ?
 
-    if (!pmConfigFileRead(&config->xxUser, configFile, "user")) {
+    if (!pmConfigFileRead(&config->user, configFile, "user")) {
         psFree(config);
         return NULL;
@@ -441,5 +442,5 @@
 
         // Set logging level
-        int logLevel = psMetadataLookupS32(&mdok, config->xxUser, "LOGLEVEL");
+        int logLevel = psMetadataLookupS32(&mdok, config->user, "LOGLEVEL");
         if (mdok && logLevel >= 0)
         {
@@ -450,5 +451,5 @@
 
         // Set logging format
-        psString logFormat = psMetadataLookupStr(&mdok, config->xxUser, "LOGFORMAT");
+        psString logFormat = psMetadataLookupStr(&mdok, config->user, "LOGFORMAT");
         if (mdok && logFormat)
         {
@@ -471,5 +472,5 @@
         }
         if (!logDest) {
-            logDest = psMemIncrRefCounter(psMetadataLookupStr(&mdok, config->xxUser, "LOGDEST"));
+            logDest = psMemIncrRefCounter(psMetadataLookupStr(&mdok, config->user, "LOGDEST"));
         }
         if (logDest) {
@@ -491,5 +492,5 @@
 
         // Set trace levels
-        psMetadata *trace = psMetadataLookupMetadata(&mdok, config->xxUser, "TRACE");
+        psMetadata *trace = psMetadataLookupMetadata(&mdok, config->user, "TRACE");
         if (mdok && trace) {
             psMetadataIterator *traceIter = psMetadataIteratorAlloc(trace, PS_LIST_HEAD, NULL); // Iterator
@@ -509,5 +510,5 @@
 
         // Set trace formats
-        psString traceFormat = psMetadataLookupStr(&mdok, config->xxUser, "TRACEFORMAT");
+        psString traceFormat = psMetadataLookupStr(&mdok, config->user, "TRACEFORMAT");
         if (mdok && traceFormat) {
             psTrace("psModules.config", 7, "Setting trace format to %s\n", traceFormat);
@@ -529,5 +530,5 @@
         }
         if (!traceDest) {
-            traceDest = psMemIncrRefCounter(psMetadataLookupStr(&mdok, config->xxUser, "TRACEDEST"));
+            traceDest = psMemIncrRefCounter(psMetadataLookupStr(&mdok, config->user, "TRACEDEST"));
         }
         if (traceDest) {
@@ -562,10 +563,10 @@
 
     // define the config-file search path (configPath).  
-    psString path = psMetadataLookupStr(NULL, config->xxUser, "PATH");
+    psString path = psMetadataLookupStr(NULL, config->user, "PATH");
     pmConfigSet (path);
 
-    // load the SITE file
-    psString siteFile = psMetadataLookupStr(NULL, config->xxUser, "SITE");
-    if (!pmConfigFileRead(&config->xxSite, siteFile, "site")) {
+    // read the SITE file
+    psString siteFile = psMetadataLookupStr(NULL, config->user, "SITE");
+    if (!pmConfigFileRead(&config->site, siteFile, "site")) {
         psFree(config);
         return NULL;
@@ -573,9 +574,14 @@
 
     // load the SYSTEM file
-    psString systemFile = psMetadataLookupStr(NULL, config->xxUser, "SYSTEM");
-    if (!pmConfigFileRead(&config->xxSystem, systemFile, "system")) {
+    psString systemFile = psMetadataLookupStr(NULL, config->user, "SYSTEM");
+    if (!pmConfigFileRead(&config->system, systemFile, "system")) {
         psFree(config);
         return NULL;
     }
+
+    // interpolate USER, SITE and SYSTEM into the config->complete metadata
+    config->complete = psMetadataCopy (NULL,             config->user);
+    config->complete = psMetadataCopy (config->complete, config->site);
+    config->complete = psMetadataCopy (config->complete, config->system);
 
     // XXX read TIME from SITE (or system?)
@@ -585,5 +591,5 @@
         // Initialise the psLib time handling
 	// XXX is this still needed / desired?
-        psString timeName = psMetadataLookupStr(&mdok, config->xxSite, "TIME");
+        psString timeName = psMetadataLookupStr(&mdok, config->complete, "TIME");
         if (mdok && timeName)
         {
@@ -605,6 +611,6 @@
             char *cameraName = argv[argNum]; // symbolic name of the camera
 
-            // look for the CAMERAS list in config->xxSystem
-            psMetadata *cameras = psMetadataLookupMetadata(&mdok, config->xxSystem, "CAMERAS");
+            // look for the CAMERAS list in config->complete
+            psMetadata *cameras = psMetadataLookupMetadata(&mdok, config->complete, "CAMERAS");
             if (!cameras) {
                 psError(PS_ERR_IO, false, "Unable to find CAMERAS in site configuration.\n");
@@ -652,5 +658,5 @@
                                   "Camera specified on command line", config->camera);
 
-            if (!pmConfigCameraSkycellVersion(config->xxSystem, cameraName)) {
+            if (!pmConfigCameraSkycellVersion(config->complete, cameraName)) {
                 psError(PS_ERR_UNKNOWN, false,
                         "Unable to generate skycell versions of specified camera %s.\n",
@@ -660,5 +666,5 @@
             }
 
-            if (!pmConfigCameraMosaickedVersions(config->xxSystem, cameraName)) {
+            if (!pmConfigCameraMosaickedVersions(config->complete, cameraName)) {
                 psError(PS_ERR_UNKNOWN, false,
                         "Unable to generate mosaicked versions of specified camera %s.\n",
@@ -673,5 +679,5 @@
     if (!config->camera && readCameraConfig) {
         bool mdok;                      // Status of MD lookup
-        psMetadata *cameras = psMetadataLookupMetadata(&mdok, config->xxSystem, "CAMERAS"); // List of cameras
+        psMetadata *cameras = psMetadataLookupMetadata(&mdok, config->complete, "CAMERAS"); // List of cameras
         if (!mdok || !cameras) {
             psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find CAMERAS in the system configuration.\n");
@@ -707,10 +713,10 @@
         psFree(iter);
 
-        if (!pmConfigCameraSkycellVersionsAll(config->xxSystem)) {
+        if (!pmConfigCameraSkycellVersionsAll(config->complete)) {
             psError(PS_ERR_UNKNOWN, false, "Unable to generate skycell versions of cameras.\n");
             psFree(config);
             return NULL;
         }
-        if (!pmConfigCameraMosaickedVersionsAll(config->xxSystem)) {
+        if (!pmConfigCameraMosaickedVersionsAll(config->complete)) {
             psError(PS_ERR_UNKNOWN, false, "Unable to generate mosaicked versions of cameras.\n");
             psFree(config);
@@ -751,5 +757,5 @@
         psArgumentRemove(argNum, argc, argv);
 
-        psMetadata *cameras = psMetadataLookupMetadata(NULL, config->xxSystem, "CAMERAS"); // List of cameras
+        psMetadata *cameras = psMetadataLookupMetadata(NULL, config->complete, "CAMERAS"); // List of cameras
         if (!cameras) {
             psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find CAMERAS in the site configuration.\n");
@@ -799,5 +805,5 @@
         } else {
             char *dbserver = argv[argNum]; // The camera configuration file to read
-            if (!psMetadataAddStr(config->xxSite, PS_LIST_TAIL, "DBSERVER", PS_META_REPLACE, NULL, dbserver)) {
+            if (!psMetadataAddStr(config->complete, PS_LIST_TAIL, "DBSERVER", PS_META_REPLACE, NULL, dbserver)) {
                 psWarning("Failed to overwrite .ipprc DBSERVER value");
             }
@@ -814,5 +820,5 @@
         } else {
             char *dbname = argv[argNum]; // The camera configuration file to read
-            if (!psMetadataAddStr(config->xxSite, PS_LIST_TAIL, "DBNAME", PS_META_REPLACE, NULL, dbname)) {
+            if (!psMetadataAddStr(config->complete, PS_LIST_TAIL, "DBNAME", PS_META_REPLACE, NULL, dbname)) {
                 psWarning("Failed to overwrite .ipprc DBNAME value");
             }
@@ -829,5 +835,5 @@
         } else {
             char *dbuser = argv[argNum]; // The camera configuration file to read
-            if (!psMetadataAddStr(config->xxSite, PS_LIST_TAIL, "DBUSER", PS_META_REPLACE, NULL, dbuser)) {
+            if (!psMetadataAddStr(config->complete, PS_LIST_TAIL, "DBUSER", PS_META_REPLACE, NULL, dbuser)) {
                 psWarning("Failed to overwrite .ipprc DBUSER value");
             }
@@ -844,5 +850,5 @@
         } else {
             char *dbpassword = argv[argNum]; // The camera configuration file to read
-            if (!psMetadataAddStr(config->xxSite, PS_LIST_TAIL, "DBPASSWORD", PS_META_REPLACE,
+            if (!psMetadataAddStr(config->complete, PS_LIST_TAIL, "DBPASSWORD", PS_META_REPLACE,
                                   NULL, dbpassword)) {
                 psWarning("Failed to overwrite .ipprc DBPASSWORD value");
@@ -860,5 +866,5 @@
         } else {
             char *dbport = argv[argNum]; // The camera configuration file to read
-            if (!psMetadataAddS32(config->xxSite, PS_LIST_TAIL, "DBPORT", PS_META_REPLACE, NULL,
+            if (!psMetadataAddS32(config->complete, PS_LIST_TAIL, "DBPORT", PS_META_REPLACE, NULL,
                                   (psS32)atoi(dbport))) {
                 psWarning("Failed to overwrite .ipprc DBPORT value");
@@ -1032,5 +1038,5 @@
     if (! config->camera) {
         bool mdok;                      // Metadata lookup status
-        psMetadata *cameras = psMetadataLookupMetadata(&mdok, config->xxSystem, "CAMERAS");
+        psMetadata *cameras = psMetadataLookupMetadata(&mdok, config->complete, "CAMERAS");
         if (! mdok || !cameras) {
             psError(PS_ERR_IO, true, "Unable to find CAMERAS in the configuration.");
@@ -1119,5 +1125,5 @@
     PS_ASSERT_STRING_NON_EMPTY(cameraName, NULL);
 
-    psMetadata *cameras = psMetadataLookupMetadata(NULL, config->xxSystem, "CAMERAS");
+    psMetadata *cameras = psMetadataLookupMetadata(NULL, config->complete, "CAMERAS");
     if (!cameras) {
         psError(PS_ERR_IO, true, "Unable to find CAMERAS in the configuration.");
@@ -1145,5 +1151,5 @@
 {
     PS_ASSERT_PTR_NON_NULL(config, NULL);
-    PS_ASSERT_PTR_NON_NULL(config->xxSite, NULL);
+    PS_ASSERT_PTR_NON_NULL(config->complete, NULL);
 
     #ifndef HAVE_PSDB
@@ -1162,9 +1168,9 @@
 
     // XXX leaky strings
-    psString dbServer = psMetadataLookupStr(&mdStatus01, config->xxSite, "DBSERVER");
-    psString dbUsername = psMetadataLookupStr(&mdStatus02, config->xxSite, "DBUSER");
-    psString dbPassword = psMetadataLookupStr(&mdStatus03, config->xxSite, "DBPASSWORD");
-    psString dbName = psMetadataLookupStr(&mdStatus04, config->xxSite, "DBNAME");
-    psS32 dbPort = psMetadataLookupS32(&mdStatus05, config->xxSite, "DBPORT");
+    psString dbServer = psMetadataLookupStr(&mdStatus01, config->complete, "DBSERVER");
+    psString dbUsername = psMetadataLookupStr(&mdStatus02, config->complete, "DBUSER");
+    psString dbPassword = psMetadataLookupStr(&mdStatus03, config->complete, "DBPASSWORD");
+    psString dbName = psMetadataLookupStr(&mdStatus04, config->complete, "DBNAME");
+    psS32 dbPort = psMetadataLookupS32(&mdStatus05, config->complete, "DBPORT");
     if (!mdStatus05) {
         dbPort = 0;
@@ -1357,11 +1363,11 @@
     // replace path://PATH with matched datapath
     if (!strncasecmp(filename, "path://", strlen("path://"))) {
-        PS_ASSERT_METADATA_NON_NULL(config->xxSite, NULL);
+        PS_ASSERT_METADATA_NON_NULL(config->complete, NULL);
 
         psString newName = psStringCopy(filename);
 
         // filename should be of the form: path://PATH/rest/of/file
-        // replace PATH with matching name from config->xxSite:DATAPATH
-        psMetadata *datapath = psMetadataLookupPtr (NULL, config->xxSite, "DATAPATH");
+        // replace PATH with matching name from config->complete:DATAPATH
+        psMetadata *datapath = psMetadataLookupPtr (NULL, config->complete, "DATAPATH");
         if (datapath == NULL) {
             psError(PS_ERR_UNKNOWN, true, "DATAPATH is not defined in config.site");
@@ -1415,5 +1421,5 @@
         // if env isn't set, check the config system
         if (!neb_server) {
-            neb_server = psMetadataLookupStr(&status, config->xxSite, "NEB_SERVER");
+            neb_server = psMetadataLookupStr(&status, config->complete, "NEB_SERVER");
             if (!status) {
                 psError(PM_ERR_CONFIG, true, "failed to lookup config value for NEB_SERVER.");
Index: /branches/eam_branch_20080219/psModules/src/config/pmConfig.h
===================================================================
--- /branches/eam_branch_20080219/psModules/src/config/pmConfig.h	(revision 16577)
+++ /branches/eam_branch_20080219/psModules/src/config/pmConfig.h	(revision 16578)
@@ -5,6 +5,6 @@
  *  @author Eugene Magnier, IfA
  *
- *  @version $Revision: 1.32.6.1 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2008-02-19 20:09:09 $
+ *  @version $Revision: 1.32.6.2 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2008-02-22 01:17:15 $
  *  Copyright 2005-2006 Institute for Astronomy, University of Hawaii
  */
@@ -37,7 +37,8 @@
 /// command-line arguments, the pmFPAfiles used, and the database handle.
 typedef struct {
-    psMetadata *xxUser;                 ///< User configuration
-    psMetadata *xxSite;                 ///< Site configuration
-    psMetadata *xxSystem;               ///< System configuration
+    psMetadata *user;                 	///< User configuration
+    psMetadata *site;                 	///< Site configuration
+    psMetadata *system;               	///< System configuration
+    psMetadata *complete;               ///< Full merged configuration
     psMetadata *camera;                 ///< Camera specification
     psString cameraName;                ///< Camera name
Index: /branches/eam_branch_20080219/psModules/src/config/pmConfigCommand.c
===================================================================
--- /branches/eam_branch_20080219/psModules/src/config/pmConfigCommand.c	(revision 16577)
+++ /branches/eam_branch_20080219/psModules/src/config/pmConfigCommand.c	(revision 16578)
@@ -13,23 +13,23 @@
     PS_ASSERT_PTR_NON_NULL(command, false);
     PS_ASSERT_PTR_NON_NULL(config, false);
-    PS_ASSERT_PTR_NON_NULL(config->xxSite, false);
+    PS_ASSERT_PTR_NON_NULL(config->complete, false);
 
     bool mdok;                          // Status of MD lookup
-    const char *dbserver = psMetadataLookupStr(&mdok, config->xxSite, "DBSERVER"); // Database server
+    const char *dbserver = psMetadataLookupStr(&mdok, config->complete, "DBSERVER"); // Database server
     if (!mdok || strlen(dbserver) == 0) {
         psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find DBSERVER in site configuration.\n");
         return false;
     }
-    const char *dbname = psMetadataLookupStr(&mdok, config->xxSite, "DBNAME"); // Database name
+    const char *dbname = psMetadataLookupStr(&mdok, config->complete, "DBNAME"); // Database name
     if (!mdok || strlen(dbname) == 0) {
         psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find DBNAME in site configuration.\n");
         return false;
     }
-    const char *dbuser = psMetadataLookupStr(&mdok, config->xxSite, "DBUSER"); // Database user
+    const char *dbuser = psMetadataLookupStr(&mdok, config->complete, "DBUSER"); // Database user
     if (!mdok || strlen(dbuser) == 0) {
         psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find DBUSER in site configuration.\n");
         return false;
     }
-    const char *dbpassword = psMetadataLookupStr(&mdok, config->xxSite, "DBPASSWORD"); // Database password
+    const char *dbpassword = psMetadataLookupStr(&mdok, config->complete, "DBPASSWORD"); // Database password
     if (!mdok || strlen(dbpassword) == 0) {
         psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find DBPASSWORD in site configuration.\n");
Index: /branches/eam_branch_20080219/psModules/src/config/pmConfigRecipes.c
===================================================================
--- /branches/eam_branch_20080219/psModules/src/config/pmConfigRecipes.c	(revision 16577)
+++ /branches/eam_branch_20080219/psModules/src/config/pmConfigRecipes.c	(revision 16578)
@@ -46,5 +46,5 @@
 
 // this function may be called several times.  it attempts to load the recipe data from one of
-// three locations: config->xxSystem, config->camera, and argv.  We cannot read the recipes
+// three locations: config->complete, 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.
@@ -59,8 +59,8 @@
 
     // Read the recipe file names from the system configuration and camera configuration
-    // It is an error for config->xxSystem:recipes not to exist.  all programs install their
+    // It is an error for config->complete:recipes not to exist.  all programs install their
     // master recipe files in the system:recipe location when they are built.
-    if (config->xxSystem && (source & PM_RECIPE_SOURCE_SYSTEM)) {
-        if (!loadRecipeSystem(&status, config, config->xxSystem)) {
+    if (config->complete && (source & PM_RECIPE_SOURCE_SYSTEM)) {
+        if (!loadRecipeSystem(&status, config, config->complete)) {
             psError(PS_ERR_IO, false, "Failed to read recipes from system config");
             return false;
