Index: trunk/ippTools/src/camtool.c
===================================================================
--- trunk/ippTools/src/camtool.c	(revision 9392)
+++ trunk/ippTools/src/camtool.c	(revision 9790)
@@ -30,4 +30,7 @@
 static bool pendingimfileMode(pxConfig *config);
 static bool addprocessedexpMode(pxConfig *config);
+static bool blockMode(pxConfig *config);
+static bool maskedMode(pxConfig *config);
+static bool unblockMode(pxConfig *config);
 
 # define MODECASE(caseName, func) \
@@ -48,4 +51,7 @@
         MODECASE(P3TOOL_MODE_PENDINGIMFILE,     pendingimfileMode);
         MODECASE(P3TOOL_MODE_ADDPROCESSEDEXP,   addprocessedexpMode);
+        MODECASE(P3TOOL_MODE_BLOCK,             blockMode);
+        MODECASE(P3TOOL_MODE_MASKED,            maskedMode);
+        MODECASE(P3TOOL_MODE_UNBLOCK,           unblockMode);
         default:
             psAbort(argv[0], "invalid option (this should not happen)");
@@ -76,6 +82,9 @@
             " LEFT JOIN p3ProcessedExp"
             "   USING(exp_tag)"
+            " LEFT JOIN p3Mask"
+            "   ON p3PendingExp.label = p3Mask.label"
             " WHERE"
             "   p3ProcessedExp.exp_tag IS NULL"
+            "   AND p3Mask.label IS NULL"
     );
 
@@ -132,8 +141,15 @@
 
     psString query = psStringCopy(
-        "SELECT p2ProcessedImfile.*"
-        " FROM p3PendingExp"
-        " JOIN p2ProcessedImfile"
-        " USING(exp_tag, p2_version)"
+            "SELECT p2ProcessedImfile.*"
+            " FROM p3PendingExp"
+            " JOIN p2ProcessedImfile"
+            "   USING(exp_tag, p2_version)"
+            " LEFT JOIN p3ProcessedExp"
+            "   USING(exp_tag)"
+            " LEFT JOIN p3Mask"
+            "   ON p3PendingExp.label = p3Mask.label"
+            " WHERE"
+            "   p3ProcessedExp.exp_tag IS NULL"
+            "   AND p3Mask.label IS NULL"
     );
 
@@ -349,5 +365,6 @@
         zp_stdev,
         pendingRow->p2_version,
-        pendingRow->p3_version
+        pendingRow->p3_version,
+        pendingRow->label
     );
     psFree(pendingRow);
@@ -364,2 +381,98 @@
     return true;
 }
+
+static bool blockMode(pxConfig *config)
+{
+    PS_ASSERT_PTR_NON_NULL(config, false);
+
+    bool status = false;
+    psString label = psMetadataLookupStr(&status, config->args, "-label");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -label");
+        return false;
+    }
+    if (!label) {
+        psError(PS_ERR_UNKNOWN, true, "-label is required");
+        return false;
+    }
+
+    if (!p3MaskInsert(config->dbh, label)) {
+        psError(PS_ERR_UNKNOWN, false, "database error");
+        return false;
+    }
+
+    return true;
+}
+
+static bool maskedMode(pxConfig *config)
+{
+    PS_ASSERT_PTR_NON_NULL(config, false);
+
+    psString query = psStringCopy("SELECT * FROM p3Mask");
+
+    if (!p_psDBRunQuery(config->dbh, query)) {
+        psError(PS_ERR_UNKNOWN, false, "database error");
+        psFree(query);
+        return false;
+    }
+    psFree(query);
+
+    psArray *output = p_psDBFetchResult(config->dbh);
+    if (!output) {
+        psError(PS_ERR_UNKNOWN, false, "database error");
+        return false;
+    }
+    if (!psArrayLength(output)) {
+        // XXX check psError here
+        psError(PS_ERR_UNKNOWN, false, "no p3Mask rows found");
+        psFree(output);
+        return true;
+    }
+
+    bool simple = false;
+    {
+        bool status = false;
+        simple = psMetadataLookupBool(&status, config->args, "-simple");
+        if (!status) {
+            psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");
+            return false;
+        }
+    }
+
+    // negative simple so the default is true
+    if (!ippdbPrintMetadatas(stdout, output, "p3Mask", !simple)) {
+        psError(PS_ERR_UNKNOWN, false, "failed to print array");
+        psFree(output);
+        return false;
+    }
+
+    psFree(output);
+
+    return true;
+}
+
+static bool unblockMode(pxConfig *config)
+{
+    PS_ASSERT_PTR_NON_NULL(config, false);
+
+    bool status = false;
+    psString label = psMetadataLookupStr(&status, config->args, "-label");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -label");
+        return false;
+    }
+    if (!label) {
+        psError(PS_ERR_UNKNOWN, true, "-label is required");
+        return false;
+    }
+
+    char *query = "DELETE FROM p3Mask WHERE label = '%s'";
+
+    if (!p_psDBRunQuery(config->dbh, query, label)) {
+        psError(PS_ERR_UNKNOWN, false, "database error");
+        psFree(query);
+        return false;
+    }
+
+    return true;
+}
