Index: /trunk/ippTools/src/chiptool.c
===================================================================
--- /trunk/ippTools/src/chiptool.c	(revision 6169)
+++ /trunk/ippTools/src/chiptool.c	(revision 6170)
@@ -154,9 +154,9 @@
 static bool doneMode(p2Config *config)
 {
-  // get exp_id/class/class_id/url from the CLI
-  // add the completed imfile to the p2DoneImfile tables
-  // remove corresponding entries from the p2PendingImfile table
-  // check to see if any p2PendingExps have no associated p2PendingImfiles
-  //    if so move the p2PendingExp(s) to p2DoneExp
+    // get exp_id/class/class_id/url from the CLI // add the completed imfile to
+    // the p2DoneImfile tables // remove corresponding entries from the
+    // p2PendingImfile table // check to see if any p2PendingExps have no
+    // associated p2PendingImfiles //    if so move the p2PendingExp(s) to
+    // p2DoneExp
 
     // find pending
@@ -181,4 +181,44 @@
     }
 
+    // look for pending exposures
+    psArray *pendingExps = p2searchPendingExp(config);
+    if (!pendingExps) {
+        psError(PS_ERR_UNKNOWN, false, "no p2PendingExps found");
+        return false;
+    }
+
+    for (int i = 0; i < pendingExps->n; i++) {
+        p2PendingExpRow *pendingExp = pendingExps->data[i];
+
+        psMetadata *where = psMetadataAlloc();
+        psMetadataAddStr(where, PS_LIST_TAIL, "exp_id", 0, "==", pendingExp->exp_id);
+        psArray *pendingImfiles = p2PendingImfileSelectRowObjects(config->database, where, MAX_ROWS);
+        psFree(where)
+        if (!pendingImfiles) {
+            // exp has no coresponding imfiles
+            psArray *nukeMe = psArrayAlloc(1);
+            nukeMe->n = 0;
+            psArrayAdd(nukeMe, 0, pendingExp);
+            bool status = p2PendingExpDeleteRowObjects(config->database, nukeMe, MAX_ROWS);
+            psFree(nukeMe);
+            if (!status) {
+                psError(PS_ERR_UNKNOWN, false, "database access failed");
+                return false;
+            }
+            // XXX need a func to convert from p2PendingExp -> p2DoneExp
+
+            p2DoneExpRow *doneExp = p2pendingToDoneExp(pendingExp);
+            if (!doneExp) {
+                psError(PS_ERR_UNKNOWN, false, "p2PendingExp -> p2DoneExp failed");
+                return false;
+            }
+            if (!p2DoneExpInsertObject(config->database, doneExp)) {
+                psError(PS_ERR_UNKNOWN, false, "database access failed");
+                return false;
+            }
+        }
+        // skip phase 3 for the time being
+        psFree(pendingImfiles);
+    }
 
     /*
