Index: trunk/ippTools/src/chiptool.c
===================================================================
--- trunk/ippTools/src/chiptool.c	(revision 22751)
+++ trunk/ippTools/src/chiptool.c	(revision 23229)
@@ -52,9 +52,10 @@
 static bool runMode(pxConfig *config);
 static bool tocleanedimfileMode(pxConfig *config);
-static bool tocleanedimfile_from_scrubbedMode(pxConfig *config);
+// static bool tocleanedimfile_from_scrubbedMode(pxConfig *config);
 static bool tofullimfileMode(pxConfig *config);
 static bool topurgedimfileMode(pxConfig *config);
 static bool exportrunMode(pxConfig *config);
 static bool importrunMode(pxConfig *config);
+static bool change_imfile_data_state(pxConfig *config, psString data_state, psString run_state);
 
 # define MODECASE(caseName, func) \
@@ -92,5 +93,5 @@
         MODECASE(CHIPTOOL_MODE_RUN,                     runMode);
         MODECASE(CHIPTOOL_MODE_TOCLEANEDIMFILE,         tocleanedimfileMode);
-        MODECASE(CHIPTOOL_MODE_TOCLEANEDIMFILE_FROM_SCRUBBED, tocleanedimfile_from_scrubbedMode);
+        // MODECASE(CHIPTOOL_MODE_TOCLEANEDIMFILE_FROM_SCRUBBED, tocleanedimfile_from_scrubbedMode);
         MODECASE(CHIPTOOL_MODE_TOFULLIMFILE,            tofullimfileMode);
         MODECASE(CHIPTOOL_MODE_TOPURGEDIMFILE,          topurgedimfileMode);
@@ -651,13 +652,36 @@
     PXOPT_COPY_S64(config->args, where, "-chip_id", "chip_id", "==");
     PXOPT_COPY_STR(config->args, where, "-class_id", "class_id", "==");
-    PXOPT_LOOKUP_S16(code, config->args, "-code", true, false);
-
-    if (!pxSetFaultCode(config->dbh, "chipProcessedImfile", where, code)) {
+    PXOPT_LOOKUP_STR(state, config->args, "-set_state", false, false);
+    PXOPT_LOOKUP_S16(code, config->args, "-code", false, false);
+
+    if (state && code) {
+        psError(PS_ERR_UNKNOWN, true, "only one of -set_state and -code may be supplied");
+        return false;
+    }
+
+    if (state) {
+      // make sure that the state string is valid
+      if (!pxIsValidState(state)) {
+        psError(PXTOOLS_ERR_DATA, false, "%s is not a valid state", state);
+        return false;
+      }
+      if (!change_imfile_data_state(config, state, "unknown")) {
         psError(PS_ERR_UNKNOWN, false, "failed to set set fault flag");
         return false;
-    }
-    psFree(where);
-
-    return true;
+      }
+      return true;
+    }
+
+    if (code) {
+      if (!pxSetFaultCode(config->dbh, "chipProcessedImfile", where, code)) {
+        psError(PS_ERR_UNKNOWN, false, "failed to set set fault flag");
+        return false;
+      }
+      psFree(where);
+      return true;
+    }
+
+    psError(PS_ERR_UNKNOWN, true, "one of -set_state or -code must be supplied");
+    return false;
 }
 
@@ -1195,4 +1219,9 @@
 // shared code for the modes -tocleanedimfile -tofullimfile -topurgedimfile
 
+// XXX EAM : this function was enforcing only certain transitions with the SQL.  However,
+// this is getting fairly messy now that we have added a few additional target and
+// destination states.  I'm disabling these restrictions for now; is there are better way
+// to enforce the allowed state transitions?
+
 static bool change_imfile_data_state(pxConfig *config, psString data_state, psString run_state)
 {
@@ -1210,6 +1239,8 @@
     }
 
+    // XXX this feature is disabled (run_state is ignored)
     // note only updates if chipRun.state = run_state
-    if (!p_psDBRunQueryF(config->dbh, query, data_state, chip_id, class_id, run_state)) {
+
+    if (!p_psDBRunQueryF(config->dbh, query, data_state, chip_id, class_id)) {
         psError(PS_ERR_UNKNOWN, false, "database error");
         // rollback
@@ -1246,8 +1277,4 @@
 {
     return change_imfile_data_state(config, "cleaned", "goto_cleaned");
-}
-static bool tocleanedimfile_from_scrubbedMode(pxConfig *config)
-{
-    return change_imfile_data_state(config, "cleaned", "goto_scrubbed");
 }
 static bool tofullimfileMode(pxConfig *config)
