Index: /branches/eam_branch_20070817/psModules/src/camera/pmFPAfile.c
===================================================================
--- /branches/eam_branch_20070817/psModules/src/camera/pmFPAfile.c	(revision 14607)
+++ /branches/eam_branch_20070817/psModules/src/camera/pmFPAfile.c	(revision 14608)
@@ -32,4 +32,5 @@
     psFree (file->camera);
     psFree (file->format);
+    psFree (file->formatName);
     psFree (file->name);
 
@@ -73,4 +74,5 @@
     file->camera = NULL;
     file->format = NULL;
+    file->formatName = NULL;
     file->name = NULL;
 
Index: /branches/eam_branch_20070817/psModules/src/camera/pmFPAfile.h
===================================================================
--- /branches/eam_branch_20070817/psModules/src/camera/pmFPAfile.h	(revision 14607)
+++ /branches/eam_branch_20070817/psModules/src/camera/pmFPAfile.h	(revision 14608)
@@ -4,6 +4,6 @@
  * @author EAM, IfA
  *
- * @version $Revision: 1.19 $ $Name: not supported by cvs2svn $
- * @date $Date: 2007-07-14 03:17:44 $
+ * @version $Revision: 1.19.4.1 $ $Name: not supported by cvs2svn $
+ * @date $Date: 2007-08-23 00:49:43 $
  * Copyright 2004-2005 Institute for Astronomy, University of Hawaii
  */
@@ -91,4 +91,5 @@
     psMetadata *camera;                 // Camera configuration
     psMetadata *format;                 // Camera format
+    char *formatName;                   // name of the camera format
 }
 pmFPAfile;
Index: /branches/eam_branch_20070817/psModules/src/camera/pmFPAfileDefine.c
===================================================================
--- /branches/eam_branch_20070817/psModules/src/camera/pmFPAfileDefine.c	(revision 14607)
+++ /branches/eam_branch_20070817/psModules/src/camera/pmFPAfileDefine.c	(revision 14608)
@@ -203,4 +203,5 @@
     }
     file->format = psMemIncrRefCounter(format);
+    file->formatName = psStringCopy(formatName);
 
     if (fpa) {
@@ -351,4 +352,5 @@
     psFree (format);
     file->format = psMemIncrRefCounter(format);
+    file->formatName = psStringCopy(config->formatName);
 
     // adjust the rules to identify these files in the file->names data
@@ -440,5 +442,5 @@
 // save the pmFPAfile on config->files
 // return the pmFPAfile (a view to the one saved on config->files)
-pmFPAfile *pmFPAfileBindFromArgs (bool *success, pmFPAfile *input, const pmConfig *config, const char *filename, const char *argname)
+pmFPAfile *pmFPAfileBindFromArgs (bool *success, pmFPAfile *input, pmConfig *config, const char *filename, const char *argname)
 {
     PS_ASSERT_PTR_NON_NULL(input, NULL);
@@ -511,5 +513,5 @@
 
         if (!format) {
-            format = pmConfigCameraFormatFromHeader((pmConfig*)config, phu, true);
+            format = pmConfigCameraFormatFromHeader(config, phu, true);
             if (!format) {
                 psError(PS_ERR_IO, false, "Failed to read CCD format from %s\n", realName);
@@ -562,4 +564,5 @@
     psFree(file->format);
     file->format = format;
+    file->formatName = psStringCopy(config->formatName);
 
     if (success) *success = true;
@@ -639,4 +642,5 @@
     psFree (file->format);
     file->format = format;
+    file->formatName = psStringCopy(config->formatName);
 
     // adjust the rules to identify these files in the file->names data
@@ -925,5 +929,5 @@
     pmFPAfile *file = pmFPAfileDefineOutput (config, fpa, filename);
     if (!file) {
-        psErrorStackPrint(stderr, "file %s not defined\n", filename);
+        psError(PS_ERR_UNEXPECTED_NULL, false, "file %s not defined\n", filename);
         return NULL;
     }
@@ -944,9 +948,9 @@
     pmFPAfile *file = pmFPAfileDefineOutput (config, NULL, filename);
     if (!file) {
-        psErrorStackPrint(stderr, "file %s not defined\n", filename);
+        psError(PS_ERR_UNEXPECTED_NULL, false, "file %s not defined\n", filename);
         return NULL;
     }
     if (!file->camera) {
-        psErrorStackPrint(stderr, "file %s does not define a new camera\n", filename);
+        psError(PS_ERR_UNEXPECTED_NULL, false, "file %s does not define a new camera\n", filename);
         return NULL;
     }
@@ -987,5 +991,5 @@
     }
     if (!file) {
-        psErrorStackPrint(stderr, "file %s not defined\n", filename);
+        psError(PS_ERR_UNEXPECTED_NULL, false, "file %s not defined\n", filename);
         return NULL;
     }
@@ -1026,8 +1030,9 @@
         // Find the correct camera configuration
         file = pmFPAfileDefineOutputForFormat(config, NULL, filename, newCameraName, config->formatName);
+        psFree(newCameraName);
         psFree(cameraName);
     }
     if (!file) {
-        psErrorStackPrint(stderr, "file %s not defined\n", filename);
+        psError(PS_ERR_UNEXPECTED_NULL, false, "file %s not defined\n", filename);
         return NULL;
     }
@@ -1070,9 +1075,9 @@
         psFree(original);
 
-        file = pmFPAfileDefineOutputForFormat(config, NULL, filename, newCameraName, config->formatName);
+        file = pmFPAfileDefineOutputForFormat(config, NULL, filename, cameraName, config->formatName);
         psFree(cameraName);
     }
     if (!file) {
-        psErrorStackPrint(stderr, "file %s not defined\n", filename);
+        psError(PS_ERR_UNEXPECTED_NULL, false, "file %s not defined\n", filename);
         return NULL;
     }
