Index: trunk/ippTools/src/warptool.c
===================================================================
--- trunk/ippTools/src/warptool.c	(revision 11723)
+++ trunk/ippTools/src/warptool.c	(revision 11731)
@@ -32,4 +32,5 @@
 
 static bool definerunMode(pxConfig *config);
+static bool updaterunMode(pxConfig *config);
 static bool addinputexpMode(pxConfig *config);
 static bool toscfileMode(pxConfig *config);
@@ -43,4 +44,7 @@
 static bool diffimfileMode(pxConfig *config);
 
+static bool setp4RunState(pxConfig *config, const char *p4_id, const char *state);
+static bool isValidMode(pxConfig *config, const char *mode);
+
 # define MODECASE(caseName, func) \
     case caseName: \
@@ -58,4 +62,5 @@
     switch (config->mode) {
         MODECASE(P4TOOL_MODE_DEFINERUN,         definerunMode);
+        MODECASE(P4TOOL_MODE_UPDATERUN,         updaterunMode);
         MODECASE(P4TOOL_MODE_ADDINPUTEXP,       addinputexpMode);
         MODECASE(P4TOOL_MODE_TOSCFILE,          toscfileMode);
@@ -88,4 +93,5 @@
 }
 
+
 static bool definerunMode(pxConfig *config)
 {
@@ -101,4 +107,9 @@
     if (!mode) {
         psError(PS_ERR_UNKNOWN, true, "-mode is required");
+        return false;
+    }
+    // check mode
+    if (mode && !isValidMode(config, mode)) {
+        psError(PS_ERR_UNKNOWN, false, "invalud mode");
         return false;
     }
@@ -168,4 +179,39 @@
     return true;
 }
+
+
+static bool updaterunMode(pxConfig *config)
+{
+    PS_ASSERT_PTR_NON_NULL(config, false);
+
+    bool status = false;
+    psString p4_id = psMetadataLookupStr(&status, config->args, "-p4_id");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -p4t_id");
+        return false;
+    }
+    if (!p4_id) {
+        psError(PS_ERR_UNKNOWN, true, "-p4_id is required");
+        return false;
+    }
+
+    psString state = psMetadataLookupStr(&status, config->args, "-state");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -state");
+        return false;
+    }
+    if (!state) {
+        psError(PS_ERR_UNKNOWN, true, "-state is required");
+        return false;
+    }
+
+    if (state) {
+        // set detRun.state to state
+        return setp4RunState(config, p4_id, state);
+    }
+
+    return true;
+}
+
 
 static bool addinputexpMode(pxConfig *config)
@@ -857,2 +903,48 @@
     return true;
 }
+
+static bool setp4RunState(pxConfig *config, const char *p4_id, const char *state)
+{
+    PS_ASSERT_PTR_NON_NULL(p4_id, false);
+    PS_ASSERT_PTR_NON_NULL(state, false);
+
+    // check that state is a valid string value
+    if (!(
+            (strncmp(state, "run", 4) == 0)
+            || (strncmp(state, "stop", 5) == 0)
+            || (strncmp(state, "reg", 4) == 0)
+        )
+    ) {
+        psError(PS_ERR_UNKNOWN, false,
+                "invalid p4Run state: %s", state);
+        return false;
+    }
+
+    char *query = "UPDATE p4Run SET state = '%s' WHERE det_id = '%s'";
+    if (!p_psDBRunQuery(config->dbh, query, state, p4_id)) {
+        psError(PS_ERR_UNKNOWN, false,
+                "failed to change state for det_id %s", p4_id);
+        return false;
+    }
+
+    return true;
+}
+
+static bool isValidMode(pxConfig *config, const char *mode)
+{
+    PS_ASSERT_PTR_NON_NULL(config, false);
+    PS_ASSERT_PTR_NON_NULL(mode, false);
+
+    // check that state is a valid string value
+    if (!(
+            (strncmp(mode, "master", 7) == 0)
+            || (strncmp(mode, "verify", 7) == 0)
+        )
+    ) {
+        psError(PS_ERR_UNKNOWN, false,
+                "invalid detRun mode: %s", mode);
+        return false;
+    }
+
+    return true;
+}
