Index: /trunk/psModules/configure.ac
===================================================================
--- /trunk/psModules/configure.ac	(revision 11291)
+++ /trunk/psModules/configure.ac	(revision 11292)
@@ -323,4 +323,13 @@
 PSMODULES_CFLAGS="${PSMODULES_CFLAGS=} ${PSLIB_CFLAGS}"
 PSMODULES_LIBS="${PSMODULES_LIBS=} ${PSLIB_LIBS}"
+
+dnl nebclient -----------------------------------------------------------------
+
+PKG_CHECK_MODULES([NEBCLIENT], [nebclient >= 0.0.2],
+    [AC_DEFINE([HAVE_NEBCLIENT], 1, [Define to 1 if libnebclient is avaiable])],    [AC_MSG_RESULT([no])]
+)
+
+PSMODULES_CFLAGS="${PSMODULES_CFLAGS=} ${NEBCLIENT_CFLAGS}"
+PSMODULES_LIBS="${PSMODULES_LIBS=} ${NEBCLIENT_LIBS}"
 
 echo "PSMODULES_CFLAGS: $PSMODULES_CFLAGS"
Index: /trunk/psModules/src/camera/pmFPA_JPEG.c
===================================================================
--- /trunk/psModules/src/camera/pmFPA_JPEG.c	(revision 11291)
+++ /trunk/psModules/src/camera/pmFPA_JPEG.c	(revision 11292)
@@ -5,6 +5,6 @@
  *  @author EAM, IfA
  *
- *  @version $Revision: 1.16 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-01-03 03:18:21 $
+ *  @version $Revision: 1.17 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2007-01-26 00:05:17 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -207,5 +207,6 @@
 
     psString name = pmFPAfileNameFromRule (file->filerule, file, view);
-    psString newName = pmConfigConvertFilename (name, config);
+    bool create = file->mode == PM_FPA_MODE_WRITE ? true : false;
+    psString newName = pmConfigConvertFilename(name, config, create);
 
     psImageJpegColormap *map = psImageJpegColormapSet (NULL, colormapName);
Index: /trunk/psModules/src/camera/pmFPA_MANAPLOT.c
===================================================================
--- /trunk/psModules/src/camera/pmFPA_MANAPLOT.c	(revision 11291)
+++ /trunk/psModules/src/camera/pmFPA_MANAPLOT.c	(revision 11292)
@@ -5,6 +5,6 @@
  *  @author EAM, IfA
  *
- *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-12-03 18:48:10 $
+ *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2007-01-26 00:05:17 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -136,15 +136,17 @@
     // output : filerule
 
+    bool create = file->mode == PM_FPA_MODE_WRITE ? true : false;
+
     psString tmpName;
     tmpName = pmFPAfileNameFromRule (file->filextra, file, view);
-    psString input = pmConfigConvertFilename (tmpName, config);
+    psString input = pmConfigConvertFilename (tmpName, config, create);
     psFree (tmpName);
 
     tmpName = pmFPAfileNameFromRule (file->filerule, file, view);
-    psString output = pmConfigConvertFilename (tmpName, config);
+    psString output = pmConfigConvertFilename (tmpName, config, create);
     psFree (tmpName);
 
     tmpName = pmFPAfileNameFromRule (file->extname, file, view);
-    psString script = pmConfigConvertFilename (tmpName, config);
+    psString script = pmConfigConvertFilename (tmpName, config, create);
     psFree (tmpName);
 
Index: /trunk/psModules/src/camera/pmFPAfileDefine.c
===================================================================
--- /trunk/psModules/src/camera/pmFPAfileDefine.c	(revision 11291)
+++ /trunk/psModules/src/camera/pmFPAfileDefine.c	(revision 11292)
@@ -286,5 +286,6 @@
     }
 
-    psString realName = pmConfigConvertFilename (infiles->data[0], config);
+    bool create = file->mode == PM_FPA_MODE_WRITE ? true : false;
+    psString realName = pmConfigConvertFilename (infiles->data[0], config, create);
     if (!realName) {
         psError(PS_ERR_IO, false, "Failed to convert file name %s\n", (char *) infiles->data[0]);
@@ -366,5 +367,6 @@
     for (int i = 0; i < infiles->n; i++) {
         if (i > 0) {
-            psString realName = pmConfigConvertFilename (infiles->data[i], config);
+            bool create = file->mode == PM_FPA_MODE_WRITE ? true : false;
+            psString realName = pmConfigConvertFilename (infiles->data[i], config, create);
             if (!realName) {
                 psError(PS_ERR_IO, false, "Failed to convert file name %s", (char *) infiles->data[i]);
@@ -490,5 +492,6 @@
     // save the association on file->names
     for (int i = 0; i < infiles->n; i++) {
-        psString realName = pmConfigConvertFilename (infiles->data[i], config);
+        bool create = file->mode == PM_FPA_MODE_WRITE ? true : false;
+        psString realName = pmConfigConvertFilename (infiles->data[i], config, create);
         if (!realName) {
             psError(PS_ERR_IO, false, "Failed to convert file name %s", (char *) infiles->data[i]);
@@ -724,5 +727,6 @@
 
     // Prepend the global path to the file rule
-    psString tmpName = pmConfigConvertFilename (file->filerule, config);
+    bool create = file->mode == PM_FPA_MODE_WRITE ? true : false;
+    psString tmpName = pmConfigConvertFilename (file->filerule, config, create);
     psFree (file->filerule);
     file->filerule = tmpName;
Index: /trunk/psModules/src/camera/pmFPAfileIO.c
===================================================================
--- /trunk/psModules/src/camera/pmFPAfileIO.c	(revision 11291)
+++ /trunk/psModules/src/camera/pmFPAfileIO.c	(revision 11292)
@@ -239,5 +239,6 @@
 
     // apply filename mangling rules (file://, path://, neb://)
-    psString tmpName = pmConfigConvertFilename (file->filename, config);
+    bool create = file->mode == PM_FPA_MODE_WRITE ? true : false;
+    psString tmpName = pmConfigConvertFilename (file->filename, config, create);
     psFree (file->filename);
     file->filename = tmpName;
Index: /trunk/psModules/src/config/pmConfig.c
===================================================================
--- /trunk/psModules/src/config/pmConfig.c	(revision 11291)
+++ /trunk/psModules/src/config/pmConfig.c	(revision 11292)
@@ -4,6 +4,6 @@
  *  @author EAM (IfA)
  *
- *  @version $Revision: 1.73 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-01-23 03:19:35 $
+ *  @version $Revision: 1.74 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2007-01-26 00:05:18 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -24,7 +24,13 @@
 #include <glob.h>
 #include <pslib.h>
+
 #include "pmConfig.h"
+#include "pmErrorCodes.h"
 #include "pmConfigRecipes.h"
 #include "pmConfigCamera.h"
+
+#ifdef HAVE_NEBCLIENT
+#include <nebclient.h>
+#endif // ifdef HAVE_NEBCLIENT
 
 #define PS_SITE "PS_SITE"         // Name of the environment variable containing the site config file
@@ -1047,13 +1053,13 @@
 
 // convert the supplied name, create a new output psString
-psString pmConfigConvertFilename(const char *filename, const pmConfig *config)
+psString pmConfigConvertFilename(const char *filename, const pmConfig *config, bool create)
 {
     PS_ASSERT_STRING_NON_EMPTY(filename, NULL);
     PS_ASSERT_PTR_NON_NULL(config, NULL);
 
-    psString newName = psStringCopy (filename);
-
     // strip file:// from front of name
-    if (!strncasecmp (newName, "file:", strlen("file:"))) {
+    if (!strncasecmp(filename, "file:", strlen("file:"))) {
+        psString newName = psStringCopy(filename);
+
         char *point = newName + strlen("file:");
         while (*point == '/')
@@ -1063,9 +1069,13 @@
         psFree (newName);
         newName = tmpName;
+
+        return newName;
     }
 
     // replace path://PATH with matched datapath
-    if (!strncasecmp (newName, "path://", strlen("path://"))) {
+    if (!strncasecmp(filename, "path://", strlen("path://"))) {
         PS_ASSERT_METADATA_NON_NULL(config->site, NULL);
+
+        psString newName = psStringCopy(filename);
 
         // filename should be of the form: path://PATH/rest/of/file
@@ -1102,8 +1112,55 @@
         psFree(newName);
         newName = tmpName;
+
+        return newName;
     }
 
     // substitute neb://name with matched nebulous name
-
-    return newName;
-}
+    if (!strncasecmp(filename, "neb://", strlen("neb://"))) {
+        #ifdef HAVE_NEBCLIENT
+
+        bool status = false;
+        psString nebulous_server = psMetadataLookupStr(&status, config->site, "NEBULOUS_SERVER");
+        if (!status) {
+            psError(PM_ERR_CONFIG, true, "failed to lookup config value for NEBULOUS_SERVER.");
+            return NULL;
+        }
+        if (!nebulous_server) {
+            psError(PM_ERR_CONFIG, true, "Could not determine nebulous server URI.");
+            return NULL;
+        }
+
+        nebServer *server = nebServerAlloc(nebulous_server);
+        if (!server) {
+            psError(PM_ERR_SYS, true, "failed to create a nebServer object.");
+            nebServerFree(server);
+            return NULL;
+        }
+
+        psString newName = psStringCopy(filename);
+
+        // for for the nebulous key
+        char *foo = nebFind(server, newName);
+        // if it doesn't exist, create it
+        if (!foo) {
+            foo = nebCreate(server, newName, 0, NULL, NULL, NULL);
+        }
+
+        psFree(newName);
+        psString newFoo = psStringCopy(foo);
+        psFree(foo);
+        nebServerFree(server);
+
+        return newFoo;
+
+        #else // ifdef HAVE_NEBCLIENT
+
+        psError(PM_ERR_PROG, true, "psModules was compiled without nebulous support.");
+        return NULL;
+        #endif // ifdef HAVE_NEBCLIENT
+
+    }
+
+    // if we go this far, do nothing
+    return psStringCopy(filename);
+}
Index: /trunk/psModules/src/config/pmConfig.h
===================================================================
--- /trunk/psModules/src/config/pmConfig.h	(revision 11291)
+++ /trunk/psModules/src/config/pmConfig.h	(revision 11292)
@@ -5,6 +5,6 @@
  *  @author Eugene Magnier, IfA
  * 
- *  @version $Revision: 1.26 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-01-24 01:05:41 $
+ *  @version $Revision: 1.27 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2007-01-26 00:05:18 $
  *  Copyright 2005-2006 Institute for Astronomy, University of Hawaii
  */
@@ -155,5 +155,9 @@
 
 /// Convert the supplied name, create a new output psString
-psString pmConfigConvertFilename(const char *filename, const pmConfig *config);
+psString pmConfigConvertFilename(
+    const char *filename,               ///< file path/URI
+    const pmConfig *config,             ///< configuration
+    bool create                         ///< create the file if it doesn't exist
+);
 
 /// Set whether all config parameters are read on startup
Index: /trunk/psModules/src/objects/pmPSF_IO.c
===================================================================
--- /trunk/psModules/src/objects/pmPSF_IO.c	(revision 11291)
+++ /trunk/psModules/src/objects/pmPSF_IO.c	(revision 11292)
@@ -6,6 +6,6 @@
  *  @author EAM, IfA
  *
- *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-12-03 18:48:10 $
+ *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2007-01-26 00:05:18 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -204,5 +204,6 @@
     case PM_FPA_FILE_PSF:
         filename = pmFPAfileNameFromRule (file->filerule, file, view);
-        realname = pmConfigConvertFilename (filename, config);
+        bool create = file->mode == PM_FPA_MODE_WRITE ? true : false;
+        realname = pmConfigConvertFilename (filename, config, create);
 
         psMetadata *psfData = pmPSFtoMetadata (NULL, psf);
@@ -308,5 +309,6 @@
     case PM_FPA_FILE_PSF:
         filename = pmFPAfileNameFromRule (file->filerule, file, view);
-        realname = pmConfigConvertFilename (filename, config);
+        bool create = file->mode == PM_FPA_MODE_WRITE ? true : false;
+        realname = pmConfigConvertFilename (filename, config, create);
 
         psMetadata *psfData = psMetadataConfigRead(NULL, &Nfail, realname, FALSE);
Index: /trunk/psModules/src/objects/pmSourceIO.c
===================================================================
--- /trunk/psModules/src/objects/pmSourceIO.c	(revision 11291)
+++ /trunk/psModules/src/objects/pmSourceIO.c	(revision 11292)
@@ -3,6 +3,6 @@
  *  @author EAM, IfA
  *
- *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-01-23 03:20:13 $
+ *  @version $Revision: 1.19 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2007-01-26 00:05:18 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -182,8 +182,10 @@
         return false;
 
+    bool create = file->mode == PM_FPA_MODE_WRITE ? true : false;
+
     switch (file->type) {
     case PM_FPA_FILE_RAW:
         filename = pmFPAfileNameFromRule (file->filerule, file, view);
-        realname = pmConfigConvertFilename (filename, config);
+        realname = pmConfigConvertFilename (filename, config, create);
         pmSourcesWriteRAW (sources, realname);
         psFree (realname);
@@ -193,5 +195,5 @@
     case PM_FPA_FILE_OBJ:
         filename = pmFPAfileNameFromRule (file->filerule, file, view);
-        realname = pmConfigConvertFilename (filename, config);
+        realname = pmConfigConvertFilename (filename, config, create);
         pmSourcesWriteOBJ (sources, realname);
         psFree (realname);
@@ -201,5 +203,5 @@
     case PM_FPA_FILE_SX:
         filename = pmFPAfileNameFromRule (file->filerule, file, view);
-        realname = pmConfigConvertFilename (filename, config);
+        realname = pmConfigConvertFilename (filename, config, create);
         pmSourcesWriteSX (sources, realname);
         psFree (realname);
@@ -211,5 +213,5 @@
         hdu = pmFPAviewThisHDU (view, file->fpa);
         filename = pmFPAfileNameFromRule (file->filerule, file, view);
-        realname = pmConfigConvertFilename (filename, config);
+        realname = pmConfigConvertFilename (filename, config, create);
 
         // copy the header to an output header, add the output header data
@@ -452,5 +454,6 @@
         }
 
-        psString realname = pmConfigConvertFilename (file->filename, config);
+        bool create = file->mode == PM_FPA_MODE_WRITE ? true : false;
+        psString realname = pmConfigConvertFilename (file->filename, config, create);
 
         file->fits = psFitsOpen (realname, "r");
