Index: /tags/ipp-20101215/ippTools/src/regtool.c
===================================================================
--- /tags/ipp-20101215/ippTools/src/regtool.c	(revision 30203)
+++ /tags/ipp-20101215/ippTools/src/regtool.c	(revision 30204)
@@ -343,9 +343,19 @@
     psMetadata *row = output->data[i];
 
+    bool status = false;
+    char *tmp_id = psMetadataLookupStr(&status,row,"tmp_class_id");
+    if (!status) {
+        // fprintf (stderr, "incomplete on %s\n", psMetadataLookupStr(NULL,row,"exp_name"));
+        continue;
+    }
+
     // Add the information about this row and the previous, if it exists.
     // Write the class_id stuff for debugging.
-    this_class_id = psStringCopy(psMetadataLookupStr(NULL,row,"tmp_class_id"));
+    // this_class_id = psStringCopy(psMetadataLookupStr(NULL,row,"tmp_class_id"));
+    this_class_id = psStringCopy(tmp_id);
+
     psStringSubstitute(&this_class_id,"XY","ota");
     psMetadataAddStr(row,PS_LIST_TAIL,"this_class_id",PS_META_REPLACE,"",this_class_id);
+
     if (previous_class_id) {
       psMetadataAddStr(row,PS_LIST_TAIL,"previous_class_id",PS_META_REPLACE,"",previous_class_id);
@@ -355,4 +365,14 @@
       continue;
     }
+
+    if (0 && !strcmp(this_class_id, "XY44")) {
+        printf("STAT 1: %s (%d %d) %d %d %d\n",
+               this_class_id,
+               ok_to_burn, already_burned,
+               psMetadataLookupS32(NULL,row,"burntool_state"),
+               psMetadataLookupS32(NULL,row,"is_registered"),
+               psMetadataLookupS32(NULL,row,"is_downloaded"));
+    }
+
     // Determine if we've crossed a class_id boundary, as this resets the bits.
     if (previous_class_id) {
@@ -361,4 +381,5 @@
         already_burned = true;
         previous_uri = NULL;
+        // fprintf (stderr, "crossed boundary: %s : %s to %s\n", psMetadataLookupStr(NULL,row,"exp_name"), previous_class_id, this_class_id);
       }
     }
@@ -395,4 +416,6 @@
         ok_to_burn = false;
         already_burned = false;
+
+        // fprintf (stderr, "missing uri: %s %s\n", psMetadataLookupStr(NULL,row,"exp_name"), this_class_id);
 
         // Save this round for next round.
@@ -405,6 +428,7 @@
     }
 
-    // printf("STATUS: %s %s %s %s (%d %d) %d %d %d\n",this_uri,previous_uri,this_class_id,previous_class_id,ok_to_burn,already_burned,psMetadataLookupS32(NULL,row,"burntool_state"),psMetadataLookupS32(NULL,row,"is_registered"),psMetadataLookupS32(NULL,row,"is_downloaded"));
-
+    if (0 && !strcmp(this_class_id, "XY44")) {
+        printf("STATUS: %s %s %s %s (%d %d) %d %d %d\n",this_uri,previous_uri,this_class_id,previous_class_id,ok_to_burn,already_burned,psMetadataLookupS32(NULL,row,"burntool_state"),psMetadataLookupS32(NULL,row,"is_registered"),psMetadataLookupS32(NULL,row,"is_downloaded"));
+    }
     // If the state of this imfile is not "pending_burntool" then we can't burn it.
     if (!ignore_state) {
@@ -413,4 +437,6 @@
       if (!imfile_state) { // imfile state is NULL, so we probably aren't registered.
         ok_to_burn = false;
+
+        // fprintf (stderr, "missing imfile_state: %s %s\n", psMetadataLookupStr(NULL,row,"exp_name"), this_class_id);
 
         // Save this round for next round.
@@ -423,4 +449,9 @@
       }
       if (strcmp("pending_burntool",imfile_state) != 0) { // Probably the state is full, do not twiddle states
+
+          if (0 && strcmp(imfile_state, "full")) {
+              fprintf (stderr, "not pending nor full: %s %s %s\n", psMetadataLookupStr(NULL,row,"exp_name"), this_class_id, imfile_state);
+          }
+
         // Save this round for next round.
         psFree(previous_class_id);
@@ -620,6 +651,6 @@
         bytes,
         md5sum,
-        video_cells,
-        0   // burntool_state
+        0,   // burntool_state
+        video_cells
     )) {
         psError(PS_ERR_UNKNOWN, false, "database error");
@@ -773,8 +804,4 @@
         psStringAppend(&query, " AND %s", whereClause);
         psFree(whereClause);
-    } else {
-        psFree(where);
-        psError(PXTOOLS_ERR_CONFIG, false, "search parameters are required");
-        return false;
     }
     psFree(where);
Index: /tags/ipp-20101215/ippTools/src/regtoolConfig.c
===================================================================
--- /tags/ipp-20101215/ippTools/src/regtoolConfig.c	(revision 30203)
+++ /tags/ipp-20101215/ippTools/src/regtoolConfig.c	(revision 30204)
@@ -178,4 +178,5 @@
     ADD_OPT(S64, revertprocessedimfileArgs, "-exp_id_begin",  "search by exposure ID", 0);
     ADD_OPT(S64, revertprocessedimfileArgs, "-exp_id_end",    "search by exposure ID", 0);
+    ADD_OPT(U64, revertprocessedimfileArgs, "-limit",     "limit result set to N items",           0);
 
     // -updateprocessedimfile
