Index: trunk/ippTools/src/flatcorr.c
===================================================================
--- trunk/ippTools/src/flatcorr.c	(revision 23783)
+++ trunk/ippTools/src/flatcorr.c	(revision 23786)
@@ -117,5 +117,5 @@
     }
 
-    // require the camera to be defined: this analysis does not make sense
+    // require the camera to be defined: this analysis does not make sense 
     // across multiple cameras
     PXOPT_LOOKUP_STR(camera, config->args, "-inst", true, false);
@@ -169,12 +169,12 @@
 
     if (pretend) {
-        for (long i = 0; i < psArrayLength(output); i++) {
-            // negative simple so the default is true
-            if (!ippdbPrintMetadataRaw(stdout, output->data[i], !simple)) {
-                psError(PS_ERR_UNKNOWN, false, "failed to print array");
-                psFree(output);
-                return false;
-            }
-        }
+	for (long i = 0; i < psArrayLength(output); i++) {
+	    // negative simple so the default is true
+	    if (!ippdbPrintMetadataRaw(stdout, output->data[i], !simple)) {
+		psError(PS_ERR_UNKNOWN, false, "failed to print array");
+		psFree(output);
+		return false;
+	    }
+	}
         psFree(output);
         return true;
@@ -191,11 +191,11 @@
     // create a new flatcorrRun
     if (!flatcorrRunInsert(
-            config->dbh,
+	    config->dbh,
             0,      // corr_id
-            det_type,
+	    det_type,
             dvodb,
-            camera,
-            telescope,
-            NULL,
+	    camera,
+	    telescope,
+	    NULL,
             filter,
             "reg",  // state
@@ -203,7 +203,7 @@
             label,
             reduction,
-            region,
-            NULL,
-            0
+	    region,
+	    NULL,
+	    0
         )) {
         if (!psDBRollback(config->dbh)) {
@@ -304,18 +304,18 @@
     // create a new flatcorrRun
     flatcorrRunRow *row = flatcorrRunRowAlloc(
-        0,      // corr_id
-        det_type,
-        dvodb,
-        camera,
-        telescope,
-        NULL,
-        filter,
-        "reg",  // state
-        workdir,
-        label,
-        reduction,
-        region,
-        NULL, // hostname
-        0 // fault
+	0,      // corr_id
+	det_type,
+	dvodb,
+	camera,
+	telescope,
+	NULL,
+	filter,
+	"reg",  // state
+	workdir,
+	label,
+	reduction,
+	region,
+	NULL, // hostname
+	0 // fault
         );
 
@@ -328,5 +328,5 @@
         return false;
     }
-
+    
     // figure out the ID of the flatcorrRun we just created
     psS64 corr_id = psDBLastInsertID(config->dbh);
@@ -365,6 +365,6 @@
     psString query = pxDataGet("flatcorr_dropchip.sql");
     if (!query) {
-        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
-        return false;
+	psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
+	return false;
     }
 
@@ -390,13 +390,13 @@
     psString query = pxDataGet("flatcorr_chiprundone.sql");
     if (!query) {
-        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
-        return false;
+	psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
+	return false;
     }
 
     // treat limit == 0 as "no limit"
     if (limit) {
-        psString limitString = psDBGenerateLimitSQL(limit);
-        psStringAppend(&query, " %s", limitString);
-        psFree(limitString);
+	psString limitString = psDBGenerateLimitSQL(limit);
+	psStringAppend(&query, " %s", limitString);
+	psFree(limitString);
     }
 
@@ -459,13 +459,13 @@
         // queue the exp
         if (!pxcamQueueByChipID(
-                config,
-                row->chip_id,
-                row->workdir,
-                row->label,
-                row->reduction,
-                row->expgroup,
-                row->dvodb,
-                row->tess_id,
-                "camera")) {
+		config,
+		row->chip_id,
+		row->workdir,
+		row->label,
+		row->reduction,
+		row->expgroup,
+		row->dvodb,
+		row->tess_id,
+		"camera")) {
             if (!psDBRollback(config->dbh)) {
                 psError(PS_ERR_UNKNOWN, false, "database error");
@@ -478,8 +478,8 @@
         }
 
-        // figure out the ID of the flatcorrRun we just created
-        psS64 cam_id = psDBLastInsertID(config->dbh);
-
-        // add the camRun entry to the flatcorrCamLink table (include is TRUE)
+	// figure out the ID of the flatcorrRun we just created
+	psS64 cam_id = psDBLastInsertID(config->dbh);
+
+	// add the camRun entry to the flatcorrCamLink table (include is TRUE)
         if (!flatcorrCamLinkInsert(config->dbh, corr_id, row->chip_id, cam_id, 1)) {
             if (!psDBRollback(config->dbh)) {
@@ -489,5 +489,5 @@
             return false;
         }
-
+	
         psFree(row);
     }
@@ -513,6 +513,6 @@
     psString query = pxDataGet("flatcorr_dropcamera.sql");
     if (!query) {
-        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
-        return false;
+	psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
+	return false;
     }
 
@@ -537,13 +537,13 @@
     psString query = pxDataGet("flatcorr_pendingprocess.sql");
     if (!query) {
-        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
-        return false;
+	psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
+	return false;
     }
 
     // treat limit == 0 as "no limit"
     if (limit) {
-        psString limitString = psDBGenerateLimitSQL(limit);
-        psStringAppend(&query, " %s", limitString);
-        psFree(limitString);
+	psString limitString = psDBGenerateLimitSQL(limit);
+	psStringAppend(&query, " %s", limitString);
+	psFree(limitString);
     }
 
@@ -566,7 +566,7 @@
 
     if (!ippdbPrintMetadatas(stdout, output, "flatcorrPending", !simple)) {
-        psError(PS_ERR_UNKNOWN, false, "failed to print array");
-        psFree(output);
-        return false;
+	psError(PS_ERR_UNKNOWN, false, "failed to print array");
+	psFree(output);
+	return false;
     }
 
@@ -588,7 +588,7 @@
     // treat limit == 0 as "no limit"
     if (limit) {
-        psString limitString = psDBGenerateLimitSQL(limit);
-        psStringAppend(&query, " %s", limitString);
-        psFree(limitString);
+	psString limitString = psDBGenerateLimitSQL(limit);
+	psStringAppend(&query, " %s", limitString);
+	psFree(limitString);
     }
 
@@ -611,7 +611,7 @@
 
     if (!ippdbPrintMetadatas(stdout, output, "flatcorrPending", !simple)) {
-        psError(PS_ERR_UNKNOWN, false, "failed to print array");
-        psFree(output);
-        return false;
+	psError(PS_ERR_UNKNOWN, false, "failed to print array");
+	psFree(output);
+	return false;
     }
 
@@ -628,5 +628,5 @@
     PXOPT_LOOKUP_BOOL(simple,  config->args, "-simple",  false);
     PXOPT_LOOKUP_BOOL(limit,   config->args, "-limit",   false);
-
+    
     psMetadata *where = psMetadataAlloc();
     PXOPT_COPY_S64(config->args, where, "-chip_id", "chipProcessedImfile.chip_id", "==");
@@ -647,7 +647,7 @@
     // treat limit == 0 as "no limit"
     if (limit) {
-        psString limitString = psDBGenerateLimitSQL(limit);
-        psStringAppend(&query, " %s", limitString);
-        psFree(limitString);
+	psString limitString = psDBGenerateLimitSQL(limit);
+	psStringAppend(&query, " %s", limitString);
+	psFree(limitString);
     }
 
@@ -670,7 +670,7 @@
 
     if (!ippdbPrintMetadatas(stdout, output, "flatcorrPending", !simple)) {
-        psError(PS_ERR_UNKNOWN, false, "failed to print array");
-        psFree(output);
-        return false;
+	psError(PS_ERR_UNKNOWN, false, "failed to print array");
+	psFree(output);
+	return false;
     }
 
@@ -685,9 +685,9 @@
     PXOPT_LOOKUP_S64(corr_id, config->args, "-corr_id", true, false);
     PXOPT_LOOKUP_STR(hostname, config->args, "-hostname", false, false);
-    PXOPT_LOOKUP_S16(fault, config->args, "-fault", false, false);
+    PXOPT_LOOKUP_S16(code, config->args, "-code", false, false);
 
     char *query = "UPDATE flatcorrRun SET state = 'full', hostname = '%s', fault = '%hd' WHERE corr_id = %" PRId64;
 
-    if (!p_psDBRunQueryF(config->dbh, query, hostname, fault, corr_id)) {
+    if (!p_psDBRunQueryF(config->dbh, query, hostname, code, corr_id)) {
         psError(PS_ERR_UNKNOWN, false, "failed to change state for corr_id %" PRId64, corr_id);
         return false;
@@ -721,7 +721,7 @@
 
     // check that state is a valid string value
-    if (!strcmp(state, "reg") &&
-        !strcmp(state, "new") &&
-        !strcmp(state, "full"))
+    if (!strcmp(state, "reg") && 
+	!strcmp(state, "new") && 
+	!strcmp(state, "full"))
     {
         psError(PS_ERR_UNKNOWN, false, "invalid state: %s", state);
@@ -745,5 +745,5 @@
     char sqlFilename[80];
   } ExportTable;
-
+  
   int numExportTables = 3;
 
@@ -761,5 +761,5 @@
 
   psMetadata *where = psMetadataAlloc();
-  PXOPT_COPY_S64(config->args, where, "-coor_id", "corr_id", "==");
+  PXOPT_COPY_S64(config->args, where, "-corr_id", "corr_id", "==");
 
   ExportTable tables [] = {
@@ -825,11 +825,11 @@
   unsigned int nFail;
   psMetadataItem *item, *entry;
-
+  
   int numImportTables = 3;
-
+  
   char tables[3] [80] = {"flatcorrRun", "flatcorrCamLink", "flatcorrChipLink"};
 
   PS_ASSERT_PTR_NON_NULL(config, NULL);
-
+  
   PXOPT_LOOKUP_STR(infile, config->args, "-infile", true,  false);
 
@@ -843,9 +843,9 @@
     psAssert (item, "entry not in input?");
     psAssert (item->type == PS_DATA_METADATA_MULTI, "entry not multi?");
-
+    
     entry = psListGet (item->data.list, 0);
     assert (entry);
     assert (entry->type == PS_DATA_METADATA);
-
+  
     switch (i) {
       case 0:
@@ -857,5 +857,5 @@
         // psMetadataPrint (stderr, entry->data.md, 1);
         break;
-      }
+      } 
       case 1:
       {
