Index: trunk/ippTools/src/chiptool.c
===================================================================
--- trunk/ippTools/src/chiptool.c	(revision 11997)
+++ trunk/ippTools/src/chiptool.c	(revision 12024)
@@ -1,4 +1,4 @@
 /*
- * p2tool.c
+ * chiptool.c
  *
  * Copyright (C) 2006  Joshua Hoblitt
@@ -38,8 +38,8 @@
 static bool unblockMode(pxConfig *config);
 
-static p2ProcessedImfileRow *p2PendingToProcessedImfile(pxConfig *config, p2PendingImfileRow *imfile);
-static p2ProcessedExpRow *p2PendingToProcessedExp(pxConfig *config, p2PendingExpRow *pendingExp);
-static p3PendingExpRow *p2PendingToP3PendingExp(pxConfig *config, p2PendingExpRow *pendingExp);
-static bool p2ProcessedCompleteExp(pxConfig *config);
+static chipProcessedImfileRow *chipPendingToProcessedImfile(pxConfig *config, chipPendingImfileRow *imfile);
+static chipProcessedExpRow *chipPendingToProcessedExp(pxConfig *config, chipPendingExpRow *pendingExp);
+static camPendingExpRow *chipPendingTocamPendingExp(pxConfig *config, chipPendingExpRow *pendingExp);
+static bool chipProcessedCompleteExp(pxConfig *config);
 
 # define MODECASE(caseName, func) \
@@ -166,13 +166,13 @@
     // XXX this does not work!!!
     psString query = psStringCopy(
-            "INSERT INTO p2PendingExp\n"
+            "INSERT INTO chipPendingExp\n"
             "   SElECT\n"
             "       exp_tag,\n"
             "       'my recipe',\n"  // recipe
-            "       255\n"         // p1_version
-            "       255\n"         // p2_version
+            "       255\n"         // guide_version
+            "       255\n"         // chip_version
             "       %s\n"
             "   FROM rawExp"
-            "   LEFT JOIN p2ProcessedExp"
+            "   LEFT JOIN chipProcessedExp"
             "       USING(exp_tag)"
             "   WHERE"
@@ -200,5 +200,5 @@
     if (!psArrayLength(output)) {
         // XXX check psError here
-        psError(PS_ERR_UNKNOWN, false, "no p2PendingImfile rows found");
+        psError(PS_ERR_UNKNOWN, false, "no chipPendingImfile rows found");
         psFree(output);
         return false;
@@ -220,23 +220,23 @@
 
     // XXX does this need to be constrained so that it won't return any results
-    // if a match p2PendingExp hasn't been registered?
+    // if a match chipPendingExp hasn't been registered?
     psString query = psStringCopy(
             "SELECT"
-            "   p2PendingImfile.*,"
+            "   chipPendingImfile.*,"
             "   rawExp.camera,"
             "   rawExp.workdir"
-            " FROM p2PendingImfile"
-            " JOIN p2PendingExp"
+            " FROM chipPendingImfile"
+            " JOIN chipPendingExp"
             "   USING(exp_tag)"
             " JOIN rawExp"
             "   USING(exp_tag)"
-            " LEFT JOIN p2Mask"
-            "   ON p2PendingExp.label = p2Mask.label"
+            " LEFT JOIN chipMask"
+            "   ON chipPendingExp.label = chipMask.label"
             " WHERE"
-            "   p2Mask.label IS NULL"
+            "   chipMask.label IS NULL"
         );
 
     if (config->where) {
-        psString whereClause = psDBGenerateWhereConditionSQL(config->where, "p2PendingImfile");
+        psString whereClause = psDBGenerateWhereConditionSQL(config->where, "chipPendingImfile");
         psStringAppend(&query, " AND %s", whereClause);
         psFree(whereClause);
@@ -264,5 +264,5 @@
     if (!psArrayLength(output)) {
         // XXX check psError here
-        psError(PS_ERR_UNKNOWN, false, "no p2PendingImfile rows found");
+        psError(PS_ERR_UNKNOWN, false, "no chipPendingImfile rows found");
         psFree(output);
         return true;
@@ -280,5 +280,5 @@
 
     // negative simple so the default is true
-    if (!ippdbPrintMetadatas(stdout, output, "p2PendingImfile", !simple)) {
+    if (!ippdbPrintMetadatas(stdout, output, "chipPendingImfile", !simple)) {
         psError(PS_ERR_UNKNOWN, false, "failed to print array");
         psFree(output);
@@ -296,25 +296,25 @@
     PS_ASSERT_PTR_NON_NULL(config, false);
 
-    // select * from p2ProcessedImfiles
+    // select * from chipProcessedImfiles
     // where
-    // exp_tag & class_id are not in p2PendingImfile
+    // exp_tag & class_id are not in chipPendingImfile
 
     // add the completed imfile to
-    // the p2ProcessedeImfile tables
+    // the chipProcessedeImfile 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 p2ProcessedExp
+    // chipPendingImfile table
+    // check to see if any chipPendingExps have no
+    // associated chipPendingImfiles
+    // if so move the chipPendingExp(s) to chipProcessedExp
 
     psString query = psStringCopy(
         "SELECT DISTINCT"
-        "   p2PendingImfile.*"
-        " FROM p2PendingImfile "
-        " LEFT JOIN p2ProcessedImfile"
+        "   chipPendingImfile.*"
+        " FROM chipPendingImfile "
+        " LEFT JOIN chipProcessedImfile"
         "   USING(exp_tag, class_id)"
         " WHERE"
-        "  p2ProcessedImfile.exp_tag IS NULL"
-        "  AND p2ProcessedImfile.class_id IS NULL"
+        "  chipProcessedImfile.exp_tag IS NULL"
+        "  AND chipProcessedImfile.class_id IS NULL"
         );
     {
@@ -349,5 +349,5 @@
         }
 
-        psString whereClause = psDBGenerateWhereConditionSQL(config->where, "p2PendingImfile");
+        psString whereClause = psDBGenerateWhereConditionSQL(config->where, "chipPendingImfile");
         psFree(where);
         if (whereClause) {
@@ -371,5 +371,5 @@
     if (!psArrayLength(output)) {
         // XXX check psError here
-        psError(PS_ERR_UNKNOWN, false, "no p2PendingImfile rows found");
+        psError(PS_ERR_UNKNOWN, false, "no chipPendingImfile rows found");
         psFree(output);
         return false;
@@ -384,12 +384,12 @@
     }
 
-    // insert into p2ProcessedImfile
-    // remove p2PendingImfile entry
+    // insert into chipProcessedImfile
+    // remove chipPendingImfile entry
     for (long i = 0; i < psArrayLength(output); i++) {
         psMetadata *row = output->data[i];
-        // convert metadata into a p2PendingImfile object
-        p2PendingImfileRow *object = p2PendingImfileObjectFromMetadata(row);
-        // convert p2PendingImfile object into a p2ProcessedImfile object
-        p2ProcessedImfileRow *imfile = p2PendingToProcessedImfile(config, object);
+        // convert metadata into a chipPendingImfile object
+        chipPendingImfileRow *object = chipPendingImfileObjectFromMetadata(row);
+        // convert chipPendingImfile object into a chipProcessedImfile object
+        chipProcessedImfileRow *imfile = chipPendingToProcessedImfile(config, object);
         if (!imfile) {
             // rollback
@@ -397,11 +397,11 @@
                 psError(PS_ERR_UNKNOWN, false, "database error");
             }
-            psError(PS_ERR_UNKNOWN, false, "failed to convert p2PendingImfile to p2ProcessedImfile");
+            psError(PS_ERR_UNKNOWN, false, "failed to convert chipPendingImfile to chipProcessedImfile");
             psFree(object);
             psFree(output);
             return false;
         }
-        // insert p2ProccessedImfile object into the database
-        if (!p2ProcessedImfileInsertObject(config->dbh, imfile)) {
+        // insert chipProccessedImfile object into the database
+        if (!chipProcessedImfileInsertObject(config->dbh, imfile)) {
             // rollback
             if (!psDBRollback(config->dbh)) {
@@ -415,6 +415,6 @@
         }
         psFree(imfile);
-        // delete the p2PendingImfile object from the database
-        if (!p2PendingImfileDeleteObject(config->dbh, object)) {
+        // delete the chipPendingImfile object from the database
+        if (!chipPendingImfileDeleteObject(config->dbh, object)) {
             // there must be atleast 1 Imfile to get this far
             // rollback
@@ -437,5 +437,5 @@
     // migration can't happen.
 
-    if (!p2ProcessedCompleteExp(config)) {
+    if (!chipProcessedCompleteExp(config)) {
         // rollback
         if (!psDBRollback(config->dbh)) {
@@ -446,6 +446,6 @@
     }
 
-    // point of no return for p2PendingImfile -> p2ProcessedImfile
-    // point of no return for p2PendingExp -> p2ProcessedExp
+    // point of no return for chipPendingImfile -> chipProcessedImfile
+    // point of no return for chipPendingExp -> chipProcessedExp
     if (!psDBCommit(config->dbh)) {
         psError(PS_ERR_UNKNOWN, false, "database error");
@@ -475,19 +475,19 @@
 
     // XXX does this need to be constrained so that it won't return any results
-    // if a match p2PendingExp hasn't been registered?
+    // if a match chipPendingExp hasn't been registered?
     psString query = psStringCopy(
             "SELECT"
-            "   p2ProcessedImfile.*,"
+            "   chipProcessedImfile.*,"
             "   rawExp.camera,"
             "   rawExp.workdir"
-            " FROM p2ProcessedImfile"
+            " FROM chipProcessedImfile"
             " JOIN rawExp"
             "   USING(exp_tag)"
             " WHERE "
-            "   p2ProcessedImfile.exp_tag is NOT NULL" // bogus test -- just here so there there is a 'WHERE' stmt to append conditionals too
+            "   chipProcessedImfile.exp_tag is NOT NULL" // bogus test -- just here so there there is a 'WHERE' stmt to append conditionals too
         );
 
     if (config->where) {
-        psString whereClause = psDBGenerateWhereConditionSQL(config->where, "p2ProcessedImfile");
+        psString whereClause = psDBGenerateWhereConditionSQL(config->where, "chipProcessedImfile");
         psStringAppend(&query, " AND %s", whereClause);
         psFree(whereClause);
@@ -496,8 +496,8 @@
     if (faulted) {
         // list only faulted rows
-        psStringAppend(&query, " %s", "AND p2ProcessedImfile.fault != 0");
+        psStringAppend(&query, " %s", "AND chipProcessedImfile.fault != 0");
     } else {
         // don't list faulted rows
-        psStringAppend(&query, " %s", "AND p2ProcessedImfile.fault = 0");
+        psStringAppend(&query, " %s", "AND chipProcessedImfile.fault = 0");
     }
 
@@ -523,5 +523,5 @@
     if (!psArrayLength(output)) {
         // XXX check psError here
-        psError(PS_ERR_UNKNOWN, false, "no p2ProcessedImfile rows found");
+        psError(PS_ERR_UNKNOWN, false, "no chipProcessedImfile rows found");
         psFree(output);
         return true;
@@ -539,5 +539,5 @@
 
     // negative simple so the default is true
-    if (!ippdbPrintMetadatas(stdout, output, "p2ProcessedImfile", !simple)) {
+    if (!ippdbPrintMetadatas(stdout, output, "chipProcessedImfile", !simple)) {
         psError(PS_ERR_UNKNOWN, false, "failed to print array");
         psFree(output);
@@ -562,5 +562,5 @@
     }
 
-    if (!pxSetFaultCode(config->dbh, "p2ProcessedImfile", config->where, code)) {
+    if (!pxSetFaultCode(config->dbh, "chipProcessedImfile", config->where, code)) {
         psError(PS_ERR_UNKNOWN, false, "failed to set set fault flag");
         return false;
@@ -586,5 +586,5 @@
     }
 
-    if (!p2MaskInsert(config->dbh, label)) {
+    if (!chipMaskInsert(config->dbh, label)) {
         psError(PS_ERR_UNKNOWN, false, "database error");
         return false;
@@ -599,5 +599,5 @@
     PS_ASSERT_PTR_NON_NULL(config, false);
 
-    psString query = psStringCopy("SELECT * FROM p2Mask");
+    psString query = psStringCopy("SELECT * FROM chipMask");
 
     if (!p_psDBRunQuery(config->dbh, query)) {
@@ -615,5 +615,5 @@
     if (!psArrayLength(output)) {
         // XXX check psError here
-        psError(PS_ERR_UNKNOWN, false, "no p2Mask rows found");
+        psError(PS_ERR_UNKNOWN, false, "no chipMask rows found");
         psFree(output);
         return true;
@@ -631,5 +631,5 @@
 
     // negative simple so the default is true
-    if (!ippdbPrintMetadatas(stdout, output, "p2Mask", !simple)) {
+    if (!ippdbPrintMetadatas(stdout, output, "chipMask", !simple)) {
         psError(PS_ERR_UNKNOWN, false, "failed to print array");
         psFree(output);
@@ -658,5 +658,5 @@
     }
 
-    char *query = "DELETE FROM p2Mask WHERE label = '%s'";
+    char *query = "DELETE FROM chipMask WHERE label = '%s'";
 
     if (!p_psDBRunQuery(config->dbh, query, label)) {
@@ -670,37 +670,37 @@
 
 
-static bool p2ProcessedCompleteExp(pxConfig *config)
+static bool chipProcessedCompleteExp(pxConfig *config)
 {
     PS_ASSERT_PTR_NON_NULL(config, false);
 
-    // look for completed p2PendingExp
-    // migrate them to p2ProccessedExp & p3PendingExp
-
-    // select * from p2PendingExp
-    // where exp_tag is not in p2ProcessedExp
-    // where exp_tag is not in p2PendingImfile
-    // where the number of entries in p2ProccessedImfile matches the .imfiles
+    // look for completed chipPendingExp
+    // migrate them to chipProccessedExp & camPendingExp
+
+    // select * from chipPendingExp
+    // where exp_tag is not in chipProcessedExp
+    // where exp_tag is not in chipPendingImfile
+    // where the number of entries in chipProccessedImfile matches the .imfiles
     // entry in rawExp
     psString query = psStringCopy(
         "SELECT DISTINCT"
-        "   p2PendingExp.*,"
+        "   chipPendingExp.*,"
         "   rawExp.imfiles,"
-        "   p2ProcessedImfile.class_id"
-        " FROM p2PendingExp"
+        "   chipProcessedImfile.class_id"
+        " FROM chipPendingExp"
         " JOIN rawExp"
-        "   ON p2PendingExp.exp_tag = rawExp.exp_tag"
-        " LEFT JOIN p2ProcessedExp"
-        "   ON p2PendingExp.exp_tag = p2ProcessedExp.exp_tag"
-        " LEFT JOIN p2PendingImfile"
-        "   ON p2PendingExp.exp_tag = p2PendingImfile.exp_tag"
-        " LEFT JOIN p2ProcessedImfile"
-        "   ON p2PendingExp.exp_tag = p2ProcessedImfile.exp_tag"
+        "   ON chipPendingExp.exp_tag = rawExp.exp_tag"
+        " LEFT JOIN chipProcessedExp"
+        "   ON chipPendingExp.exp_tag = chipProcessedExp.exp_tag"
+        " LEFT JOIN chipPendingImfile"
+        "   ON chipPendingExp.exp_tag = chipPendingImfile.exp_tag"
+        " LEFT JOIN chipProcessedImfile"
+        "   ON chipPendingExp.exp_tag = chipProcessedImfile.exp_tag"
         " WHERE"
-        "  p2ProcessedExp.exp_tag IS NULL"
-        "  AND p2PendingImfile.exp_tag IS NULL"
-        "  AND p2ProcessedImfile.exp_tag IS NOT NULL"
+        "  chipProcessedExp.exp_tag IS NULL"
+        "  AND chipPendingImfile.exp_tag IS NULL"
+        "  AND chipProcessedImfile.exp_tag IS NOT NULL"
         " GROUP BY"
-        "   p2PendingExp.exp_tag"
-        " HAVING rawExp.imfiles = COUNT(p2ProcessedImfile.class_id)"
+        "   chipPendingExp.exp_tag"
+        " HAVING rawExp.imfiles = COUNT(chipProcessedImfile.class_id)"
         );
 
@@ -719,30 +719,30 @@
     if (!psArrayLength(output)) {
         // XXX check psError here
-        psError(PS_ERR_UNKNOWN, false, "no p2PendingExp rows found");
+        psError(PS_ERR_UNKNOWN, false, "no chipPendingExp rows found");
         psFree(output);
         return true;
     }
 
-    // insert into p2ProcessedExp
-    // insert into p3PendingExp
-    // remove p2PendingExp entry
+    // insert into chipProcessedExp
+    // insert into camPendingExp
+    // remove chipPendingExp entry
     for (long i = 0; i < psArrayLength(output); i++) {
         psMetadata *row = output->data[i];
-        // convert metadata into a p2PendingExp object
-        p2PendingExpRow *object = p2PendingExpObjectFromMetadata(row);
+        // convert metadata into a chipPendingExp object
+        chipPendingExpRow *object = chipPendingExpObjectFromMetadata(row);
         // do both *Exp type conversion first so we don't insert one and then
         // have to rollback the change as the 2nd failed
-        // convert p2PendingExp object into a p2ProcesseExp object
-        p2ProcessedExpRow *processedExp = p2PendingToProcessedExp(config, object);
+        // convert chipPendingExp object into a chipProcesseExp object
+        chipProcessedExpRow *processedExp = chipPendingToProcessedExp(config, object);
         if (!processedExp) {
-            psError(PS_ERR_UNKNOWN, false, "failed to convert p2PendingExp to p2ProcessedExp");
+            psError(PS_ERR_UNKNOWN, false, "failed to convert chipPendingExp to chipProcessedExp");
             psFree(object);
             psFree(output);
             return false;
         }
-        // convert p2PendingExp object into a p3PendingExp object
-        p3PendingExpRow *pendingExp = p2PendingToP3PendingExp(config, object);
+        // convert chipPendingExp object into a camPendingExp object
+        camPendingExpRow *pendingExp = chipPendingTocamPendingExp(config, object);
         if (!processedExp) {
-            psError(PS_ERR_UNKNOWN, false, "failed to convert p2PendingExp to p3PendingExp");
+            psError(PS_ERR_UNKNOWN, false, "failed to convert chipPendingExp to camPendingExp");
             psFree(processedExp);
             psFree(object);
@@ -750,6 +750,6 @@
             return false;
         }
-        // insert p2ProccessedExp object into the database
-        if (!p2ProcessedExpInsertObject(config->dbh, processedExp)) {
+        // insert chipProccessedExp object into the database
+        if (!chipProcessedExpInsertObject(config->dbh, processedExp)) {
             psError(PS_ERR_UNKNOWN, false, "database error");
             psFree(processedExp);
@@ -760,6 +760,6 @@
         }
         psFree(processedExp);
-        // insert p3PendingExp object into the database
-        if (!p3PendingExpInsertObject(config->dbh, pendingExp)) {
+        // insert camPendingExp object into the database
+        if (!camPendingExpInsertObject(config->dbh, pendingExp)) {
             psError(PS_ERR_UNKNOWN, false, "database error");
             psFree(pendingExp);
@@ -769,6 +769,6 @@
         }
         psFree(pendingExp);
-        // delete the p2PendingExp object from the database
-        if (!p2PendingExpDeleteObject(config->dbh, object)) {
+        // delete the chipPendingExp object from the database
+        if (!chipPendingExpDeleteObject(config->dbh, object)) {
             // there must be atleast 1 Imfile to get this far
             psError(PS_ERR_UNKNOWN, false, "database error");
@@ -786,5 +786,5 @@
 
 
-static p2ProcessedImfileRow *p2PendingToProcessedImfile(pxConfig *config, p2PendingImfileRow *imfile)
+static chipProcessedImfileRow *chipPendingToProcessedImfile(pxConfig *config, chipPendingImfileRow *imfile)
 {
     PS_ASSERT_PTR_NON_NULL(config, NULL);
@@ -850,8 +850,8 @@
     }
 
-    return p2ProcessedImfileRowAlloc(
+    return chipProcessedImfileRowAlloc(
         imfile->exp_tag,
-        imfile->p2_version,
-        imfile->p1_version,
+        imfile->chip_version,
+        imfile->guide_version,
         imfile->class_id,
         recipe,
@@ -867,12 +867,12 @@
 
 
-static p2ProcessedExpRow *p2PendingToProcessedExp(pxConfig *config, p2PendingExpRow *pendingExp)
+static chipProcessedExpRow *chipPendingToProcessedExp(pxConfig *config, chipPendingExpRow *pendingExp)
 {
     PS_ASSERT_PTR_NON_NULL(pendingExp, NULL);
  
-    return p2ProcessedExpRowAlloc(
+    return chipProcessedExpRowAlloc(
         pendingExp->exp_tag,
-        pendingExp->p2_version,
-        pendingExp->p1_version,
+        pendingExp->chip_version,
+        pendingExp->guide_version,
         pendingExp->label,
         pendingExp->expgroup,
@@ -882,12 +882,12 @@
 
 
-static p3PendingExpRow *p2PendingToP3PendingExp(pxConfig *config, p2PendingExpRow *pendingExp)
+static camPendingExpRow *chipPendingTocamPendingExp(pxConfig *config, chipPendingExpRow *pendingExp)
 {
     PS_ASSERT_PTR_NON_NULL(pendingExp, NULL);
 
-    return p3PendingExpRowAlloc(
+    return camPendingExpRowAlloc(
         pendingExp->exp_tag,
-        0x0,        // p3 version
-        pendingExp->p2_version,
+        0x0,        // cam version
+        pendingExp->chip_version,
         pendingExp->label,
         pendingExp->expgroup,
