Index: trunk/psModules/src/objects/pmSourceIO.c
===================================================================
--- trunk/psModules/src/objects/pmSourceIO.c	(revision 15562)
+++ trunk/psModules/src/objects/pmSourceIO.c	(revision 16819)
@@ -3,6 +3,6 @@
  *  @author EAM, IfA
  *
- *  @version $Revision: 1.53 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-11-10 01:09:20 $
+ *  @version $Revision: 1.54 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2008-03-05 01:08:08 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -254,4 +254,5 @@
     char *dataname = NULL;
     char *xsrcname = NULL;
+    char *xfitname = NULL;
     char *headname = NULL;
 
@@ -319,4 +320,5 @@
 	// if this is not TRUE, the output files only contain the psf measurements.
 	bool XSRC_OUTPUT = psMetadataLookupBool(&status, recipe, "SAVE.XSRC");
+	bool XFIT_OUTPUT = psMetadataLookupBool(&status, recipe, "SAVE.XFIT");
 
         // define the EXTNAME values for the different data segments:
@@ -356,4 +358,13 @@
 	      }
 	      xsrcname = pmFPAfileNameFromRule (rule, file, view);
+	    }
+	    if (XFIT_OUTPUT) {
+	      // EXTNAME for extended source data table
+	      rule = psMetadataLookupStr(&status, menu, "CMF.XFIT");
+	      if (!rule) {
+                psError(PS_ERR_UNKNOWN, true, "missing entry for CMF.XFIT in EXTNAME.RULES in camera.config");
+                return false;
+	      }
+	      xfitname = pmFPAfileNameFromRule (rule, file, view);
 	    }
         }
@@ -405,4 +416,12 @@
             psFree (exttype);
 
+	    // if we request XSRC output, add the XSRC name to this header
+	    if (xsrcname) {
+	      psMetadataAddStr (outhead, PS_LIST_TAIL, "XSRCNAME", PS_META_REPLACE, "name of XSRC table extension", xsrcname);
+	    }
+	    if (xfitname) {
+	      psMetadataAddStr (outhead, PS_LIST_TAIL, "XFITNAME", PS_META_REPLACE, "name of XFIT table extension", xfitname);
+	    }
+
             // XXX these are case-sensitive since the EXTYPE is case-sensitive
             status = false;
@@ -416,4 +435,14 @@
                 status = pmSourcesWrite_PS1_DEV_1 (file->fits, sources, file->header, outhead, dataname, xsrcname);
             }
+	    if (xsrcname) {
+	      if (!strcmp (exttype, "PS1_DEV_1")) {
+                status = pmSourcesWrite_PS1_DEV_1_XSRC (file->fits, sources, xsrcname);
+	      }
+	    }
+	    if (xfitname) {
+	      if (!strcmp (exttype, "PS1_DEV_1")) {
+                status = pmSourcesWrite_PS1_DEV_1_XFIT (file->fits, sources, xfitname);
+	      }
+	    }
             if (!status) {
                 psError(PS_ERR_IO, false, "writing CMF data to %s with format %s\n", file->filename, exttype);
