Index: trunk/ippdb/src/ippdb.h
===================================================================
--- trunk/ippdb/src/ippdb.h	(revision 17872)
+++ trunk/ippdb/src/ippdb.h	(revision 18044)
@@ -3483,5 +3483,4 @@
 typedef struct {
     psS64           cam_id;
-    psS64           chip_id;
     char            *uri;
     psF32           bg;
@@ -3520,5 +3519,4 @@
 camProcessedExpRow *camProcessedExpRowAlloc(
     psS64           cam_id,
-    psS64           chip_id,
     const char      *uri,
     psF32           bg,
@@ -3578,5 +3576,4 @@
     psDB            *dbh,               ///< Database handle
     psS64           cam_id,
-    psS64           chip_id,
     const char      *uri,
     psF32           bg,
@@ -3950,4 +3947,643 @@
     bool            mdcf                ///< format as mdconfig or simple
 );
+/** fakeRunRow data structure
+ *
+ * Structure for representing a single row of fakeRun table data.
+ */
+
+typedef struct {
+    psS64           fake_id;
+    psS64           cam_id;
+    char            *state;
+    char            *workdir;
+    char            *label;
+    char            *reduction;
+    char            *expgroup;
+    char            *dvodb;
+    char            *tess_id;
+    char            *end_stage;
+    psTime*         epoch;
+} fakeRunRow;
+
+/** Creates a new fakeRunRow object
+ *
+ *  @return A new fakeRunRow object or NULL on failure.
+ */
+
+fakeRunRow *fakeRunRowAlloc(
+    psS64           fake_id,
+    psS64           cam_id,
+    const char      *state,
+    const char      *workdir,
+    const char      *label,
+    const char      *reduction,
+    const char      *expgroup,
+    const char      *dvodb,
+    const char      *tess_id,
+    const char      *end_stage,
+    psTime*         epoch
+);
+
+/** Creates a new fakeRun table
+ *
+ * @return true on success
+ */
+
+bool fakeRunCreateTable(
+    psDB            *dbh                ///< Database handle
+);
+
+/** Deletes a fakeRun table
+ *
+ * @return true on success
+ */
+
+bool fakeRunDropTable(
+    psDB            *dbh                ///< Database handle
+);
+
+/** Insert a single row into a table
+ *
+ * This function constructs and inserts a single row based on it's parameters.
+ *
+ * @return true on success
+ */
+
+bool fakeRunInsert(
+    psDB            *dbh,               ///< Database handle
+    psS64           fake_id,
+    psS64           cam_id,
+    const char      *state,
+    const char      *workdir,
+    const char      *label,
+    const char      *reduction,
+    const char      *expgroup,
+    const char      *dvodb,
+    const char      *tess_id,
+    const char      *end_stage,
+    psTime*         epoch
+);
+
+/** Deletes up to limit rows from the database and returns the number of rows actually deleted. 
+ *
+ * @return A The number of rows removed or a negative value on error
+ */
+
+long long fakeRunDelete(
+    psDB            *dbh,               ///< Database handle
+    const psMetadata *where,            ///< Row match criteria
+    unsigned long long limit            ///< Maximum number of elements to delete 
+);
+
+/** Insert a single fakeRunRow object into a table
+ *
+ * This function constructs and inserts a single row based on it's parameters.
+ *
+ * @return true on success
+ */
+
+bool fakeRunInsertObject(
+    psDB            *dbh,               ///< Database handle
+    fakeRunRow      *object             ///< fakeRunRow object
+);
+
+/** Insert an array of fakeRunRow object into a table
+ *
+ * This function constructs and inserts multiple rows based on it's parameters.
+ *
+ * @return true on success
+ */
+
+bool fakeRunInsertObjects(
+    psDB            *dbh,               ///< Database handle
+    psArray         *objects            ///< array of fakeRunRow objects
+);
+
+/** Insert data from a binary FITS table fakeRunRow into the database
+ *
+ * This function expects a psFits object with a FITS table as the first
+ * extension.  The table must have at least one row of data in it, that is of
+ * the appropriate format (number of columns and their type).  All other
+ * extensions are ignored.
+ *
+ * @return true on success
+ */
+
+bool fakeRunInsertFits(
+    psDB            *dbh,               ///< Database handle
+    const psFits    *fits               ///< psFits object
+);
+
+/** Selects up to limit from the database and returns them in a binary FITS table
+ *
+ * This function assumes an empty psFits object and will create a FITS table
+ * as the first extension.
+ *
+ *  See psDBSelectRows() for documentation on the format of where.
+ *
+ * @return true on success
+ */
+
+bool fakeRunSelectRowsFits(
+    psDB            *dbh,               ///< Database handle
+    psFits          *fits,              ///< psFits object
+    const psMetadata *where,            ///< Row match criteria
+    unsigned long long limit            ///< Maximum number of elements to return
+);
+
+/** Convert a fakeRunRow into an equivalent psMetadata
+ *
+ * @return A psMetadata pointer or NULL on error
+ */
+
+psMetadata *fakeRunMetadataFromObject(
+    const fakeRunRow *object             ///< fooRow to convert into a psMetadata
+);
+
+/** Convert a psMetadata into an equivalent fooRow
+ *
+ * @return A fakeRunRow pointer or NULL on error
+ */
+
+fakeRunRow *fakeRunObjectFromMetadata(
+    psMetadata      *md                 ///< psMetadata to convert into a fooRow
+);
+/** Selects up to limit rows from the database and returns as fakeRunRow objects in a psArray
+ *
+ *  See psDBSelectRows() for documentation on the format of where.
+ *
+ * @return A psArray pointer or NULL on error
+ */
+
+psArray *fakeRunSelectRowObjects(
+    psDB            *dbh,               ///< Database handle
+    const psMetadata *where,            ///< Row match criteria
+    unsigned long long limit            ///< Maximum number of elements to return
+);
+/** Deletes a row from the database coresponding to an fakeRun
+ *
+ *  Note that a 'where' search psMetadata is constructed from each object and
+ *  used to find rows to delete.
+ *
+ * @return A The number of rows removed or a negative value on error
+ */
+
+bool fakeRunDeleteObject(
+    psDB            *dbh,               ///< Database handle
+    const fakeRunRow *object    ///< Object to delete
+);
+/** Deletes up to limit rows from the database and returns the number of rows actually deleted. 
+ *
+ *  Note that a 'where' search psMetadata is constructed from each object and
+ *  used to find rows to delete.
+ *
+ * @return A The number of rows removed or a negative value on error
+ */
+
+long long fakeRunDeleteRowObjects(
+    psDB            *dbh,               ///< Database handle
+    const psArray   *objects,           ///< Array of objects to delete
+    unsigned long long limit            ///< Maximum number of elements to delete 
+);
+/** Formats and prints an array of fakeRunRow objects
+ *
+ * When mdcf is set the formated output is in psMetadataConfig
+ * format, otherwise it is in a simple tabular format.
+ *
+ * @return true on success
+ */
+
+bool fakeRunPrintObjects(
+    FILE            *stream,            ///< a stream
+    psArray         *objects,           ///< An array of fakeRunRow objects
+    bool            mdcf                ///< format as mdconfig or simple
+);
+/** Formats and prints an fakeRunRow object
+ *
+ * When mdcf is set the formated output is in psMetadataConfig
+ * format, otherwise it is in a simple tabular format.
+ *
+ * @return true on success
+ */
+
+bool fakeRunPrintObject(
+    FILE            *stream,            ///< a stream
+    fakeRunRow *object,    ///< an fakeRunRow object
+    bool            mdcf                ///< format as mdconfig or simple
+);
+/** fakeProcessedImfileRow data structure
+ *
+ * Structure for representing a single row of fakeProcessedImfile table data.
+ */
+
+typedef struct {
+    psS64           fake_id;
+    psS64           exp_id;
+    char            *class_id;
+    char            *uri;
+    psF32           dtime_fake;
+    char            *hostname;
+    char            *path_base;
+    psS16           fault;
+    psTime*         epoch;
+} fakeProcessedImfileRow;
+
+/** Creates a new fakeProcessedImfileRow object
+ *
+ *  @return A new fakeProcessedImfileRow object or NULL on failure.
+ */
+
+fakeProcessedImfileRow *fakeProcessedImfileRowAlloc(
+    psS64           fake_id,
+    psS64           exp_id,
+    const char      *class_id,
+    const char      *uri,
+    psF32           dtime_fake,
+    const char      *hostname,
+    const char      *path_base,
+    psS16           fault,
+    psTime*         epoch
+);
+
+/** Creates a new fakeProcessedImfile table
+ *
+ * @return true on success
+ */
+
+bool fakeProcessedImfileCreateTable(
+    psDB            *dbh                ///< Database handle
+);
+
+/** Deletes a fakeProcessedImfile table
+ *
+ * @return true on success
+ */
+
+bool fakeProcessedImfileDropTable(
+    psDB            *dbh                ///< Database handle
+);
+
+/** Insert a single row into a table
+ *
+ * This function constructs and inserts a single row based on it's parameters.
+ *
+ * @return true on success
+ */
+
+bool fakeProcessedImfileInsert(
+    psDB            *dbh,               ///< Database handle
+    psS64           fake_id,
+    psS64           exp_id,
+    const char      *class_id,
+    const char      *uri,
+    psF32           dtime_fake,
+    const char      *hostname,
+    const char      *path_base,
+    psS16           fault,
+    psTime*         epoch
+);
+
+/** Deletes up to limit rows from the database and returns the number of rows actually deleted. 
+ *
+ * @return A The number of rows removed or a negative value on error
+ */
+
+long long fakeProcessedImfileDelete(
+    psDB            *dbh,               ///< Database handle
+    const psMetadata *where,            ///< Row match criteria
+    unsigned long long limit            ///< Maximum number of elements to delete 
+);
+
+/** Insert a single fakeProcessedImfileRow object into a table
+ *
+ * This function constructs and inserts a single row based on it's parameters.
+ *
+ * @return true on success
+ */
+
+bool fakeProcessedImfileInsertObject(
+    psDB            *dbh,               ///< Database handle
+    fakeProcessedImfileRow *object             ///< fakeProcessedImfileRow object
+);
+
+/** Insert an array of fakeProcessedImfileRow object into a table
+ *
+ * This function constructs and inserts multiple rows based on it's parameters.
+ *
+ * @return true on success
+ */
+
+bool fakeProcessedImfileInsertObjects(
+    psDB            *dbh,               ///< Database handle
+    psArray         *objects            ///< array of fakeProcessedImfileRow objects
+);
+
+/** Insert data from a binary FITS table fakeProcessedImfileRow into the database
+ *
+ * This function expects a psFits object with a FITS table as the first
+ * extension.  The table must have at least one row of data in it, that is of
+ * the appropriate format (number of columns and their type).  All other
+ * extensions are ignored.
+ *
+ * @return true on success
+ */
+
+bool fakeProcessedImfileInsertFits(
+    psDB            *dbh,               ///< Database handle
+    const psFits    *fits               ///< psFits object
+);
+
+/** Selects up to limit from the database and returns them in a binary FITS table
+ *
+ * This function assumes an empty psFits object and will create a FITS table
+ * as the first extension.
+ *
+ *  See psDBSelectRows() for documentation on the format of where.
+ *
+ * @return true on success
+ */
+
+bool fakeProcessedImfileSelectRowsFits(
+    psDB            *dbh,               ///< Database handle
+    psFits          *fits,              ///< psFits object
+    const psMetadata *where,            ///< Row match criteria
+    unsigned long long limit            ///< Maximum number of elements to return
+);
+
+/** Convert a fakeProcessedImfileRow into an equivalent psMetadata
+ *
+ * @return A psMetadata pointer or NULL on error
+ */
+
+psMetadata *fakeProcessedImfileMetadataFromObject(
+    const fakeProcessedImfileRow *object             ///< fooRow to convert into a psMetadata
+);
+
+/** Convert a psMetadata into an equivalent fooRow
+ *
+ * @return A fakeProcessedImfileRow pointer or NULL on error
+ */
+
+fakeProcessedImfileRow *fakeProcessedImfileObjectFromMetadata(
+    psMetadata      *md                 ///< psMetadata to convert into a fooRow
+);
+/** Selects up to limit rows from the database and returns as fakeProcessedImfileRow objects in a psArray
+ *
+ *  See psDBSelectRows() for documentation on the format of where.
+ *
+ * @return A psArray pointer or NULL on error
+ */
+
+psArray *fakeProcessedImfileSelectRowObjects(
+    psDB            *dbh,               ///< Database handle
+    const psMetadata *where,            ///< Row match criteria
+    unsigned long long limit            ///< Maximum number of elements to return
+);
+/** Deletes a row from the database coresponding to an fakeProcessedImfile
+ *
+ *  Note that a 'where' search psMetadata is constructed from each object and
+ *  used to find rows to delete.
+ *
+ * @return A The number of rows removed or a negative value on error
+ */
+
+bool fakeProcessedImfileDeleteObject(
+    psDB            *dbh,               ///< Database handle
+    const fakeProcessedImfileRow *object    ///< Object to delete
+);
+/** Deletes up to limit rows from the database and returns the number of rows actually deleted. 
+ *
+ *  Note that a 'where' search psMetadata is constructed from each object and
+ *  used to find rows to delete.
+ *
+ * @return A The number of rows removed or a negative value on error
+ */
+
+long long fakeProcessedImfileDeleteRowObjects(
+    psDB            *dbh,               ///< Database handle
+    const psArray   *objects,           ///< Array of objects to delete
+    unsigned long long limit            ///< Maximum number of elements to delete 
+);
+/** Formats and prints an array of fakeProcessedImfileRow objects
+ *
+ * When mdcf is set the formated output is in psMetadataConfig
+ * format, otherwise it is in a simple tabular format.
+ *
+ * @return true on success
+ */
+
+bool fakeProcessedImfilePrintObjects(
+    FILE            *stream,            ///< a stream
+    psArray         *objects,           ///< An array of fakeProcessedImfileRow objects
+    bool            mdcf                ///< format as mdconfig or simple
+);
+/** Formats and prints an fakeProcessedImfileRow object
+ *
+ * When mdcf is set the formated output is in psMetadataConfig
+ * format, otherwise it is in a simple tabular format.
+ *
+ * @return true on success
+ */
+
+bool fakeProcessedImfilePrintObject(
+    FILE            *stream,            ///< a stream
+    fakeProcessedImfileRow *object,    ///< an fakeProcessedImfileRow object
+    bool            mdcf                ///< format as mdconfig or simple
+);
+/** fakeMaskRow data structure
+ *
+ * Structure for representing a single row of fakeMask table data.
+ */
+
+typedef struct {
+    char            *label;
+} fakeMaskRow;
+
+/** Creates a new fakeMaskRow object
+ *
+ *  @return A new fakeMaskRow object or NULL on failure.
+ */
+
+fakeMaskRow *fakeMaskRowAlloc(
+    const char      *label
+);
+
+/** Creates a new fakeMask table
+ *
+ * @return true on success
+ */
+
+bool fakeMaskCreateTable(
+    psDB            *dbh                ///< Database handle
+);
+
+/** Deletes a fakeMask table
+ *
+ * @return true on success
+ */
+
+bool fakeMaskDropTable(
+    psDB            *dbh                ///< Database handle
+);
+
+/** Insert a single row into a table
+ *
+ * This function constructs and inserts a single row based on it's parameters.
+ *
+ * @return true on success
+ */
+
+bool fakeMaskInsert(
+    psDB            *dbh,               ///< Database handle
+    const char      *label
+);
+
+/** Deletes up to limit rows from the database and returns the number of rows actually deleted. 
+ *
+ * @return A The number of rows removed or a negative value on error
+ */
+
+long long fakeMaskDelete(
+    psDB            *dbh,               ///< Database handle
+    const psMetadata *where,            ///< Row match criteria
+    unsigned long long limit            ///< Maximum number of elements to delete 
+);
+
+/** Insert a single fakeMaskRow object into a table
+ *
+ * This function constructs and inserts a single row based on it's parameters.
+ *
+ * @return true on success
+ */
+
+bool fakeMaskInsertObject(
+    psDB            *dbh,               ///< Database handle
+    fakeMaskRow     *object             ///< fakeMaskRow object
+);
+
+/** Insert an array of fakeMaskRow object into a table
+ *
+ * This function constructs and inserts multiple rows based on it's parameters.
+ *
+ * @return true on success
+ */
+
+bool fakeMaskInsertObjects(
+    psDB            *dbh,               ///< Database handle
+    psArray         *objects            ///< array of fakeMaskRow objects
+);
+
+/** Insert data from a binary FITS table fakeMaskRow into the database
+ *
+ * This function expects a psFits object with a FITS table as the first
+ * extension.  The table must have at least one row of data in it, that is of
+ * the appropriate format (number of columns and their type).  All other
+ * extensions are ignored.
+ *
+ * @return true on success
+ */
+
+bool fakeMaskInsertFits(
+    psDB            *dbh,               ///< Database handle
+    const psFits    *fits               ///< psFits object
+);
+
+/** Selects up to limit from the database and returns them in a binary FITS table
+ *
+ * This function assumes an empty psFits object and will create a FITS table
+ * as the first extension.
+ *
+ *  See psDBSelectRows() for documentation on the format of where.
+ *
+ * @return true on success
+ */
+
+bool fakeMaskSelectRowsFits(
+    psDB            *dbh,               ///< Database handle
+    psFits          *fits,              ///< psFits object
+    const psMetadata *where,            ///< Row match criteria
+    unsigned long long limit            ///< Maximum number of elements to return
+);
+
+/** Convert a fakeMaskRow into an equivalent psMetadata
+ *
+ * @return A psMetadata pointer or NULL on error
+ */
+
+psMetadata *fakeMaskMetadataFromObject(
+    const fakeMaskRow *object             ///< fooRow to convert into a psMetadata
+);
+
+/** Convert a psMetadata into an equivalent fooRow
+ *
+ * @return A fakeMaskRow pointer or NULL on error
+ */
+
+fakeMaskRow *fakeMaskObjectFromMetadata(
+    psMetadata      *md                 ///< psMetadata to convert into a fooRow
+);
+/** Selects up to limit rows from the database and returns as fakeMaskRow objects in a psArray
+ *
+ *  See psDBSelectRows() for documentation on the format of where.
+ *
+ * @return A psArray pointer or NULL on error
+ */
+
+psArray *fakeMaskSelectRowObjects(
+    psDB            *dbh,               ///< Database handle
+    const psMetadata *where,            ///< Row match criteria
+    unsigned long long limit            ///< Maximum number of elements to return
+);
+/** Deletes a row from the database coresponding to an fakeMask
+ *
+ *  Note that a 'where' search psMetadata is constructed from each object and
+ *  used to find rows to delete.
+ *
+ * @return A The number of rows removed or a negative value on error
+ */
+
+bool fakeMaskDeleteObject(
+    psDB            *dbh,               ///< Database handle
+    const fakeMaskRow *object    ///< Object to delete
+);
+/** Deletes up to limit rows from the database and returns the number of rows actually deleted. 
+ *
+ *  Note that a 'where' search psMetadata is constructed from each object and
+ *  used to find rows to delete.
+ *
+ * @return A The number of rows removed or a negative value on error
+ */
+
+long long fakeMaskDeleteRowObjects(
+    psDB            *dbh,               ///< Database handle
+    const psArray   *objects,           ///< Array of objects to delete
+    unsigned long long limit            ///< Maximum number of elements to delete 
+);
+/** Formats and prints an array of fakeMaskRow objects
+ *
+ * When mdcf is set the formated output is in psMetadataConfig
+ * format, otherwise it is in a simple tabular format.
+ *
+ * @return true on success
+ */
+
+bool fakeMaskPrintObjects(
+    FILE            *stream,            ///< a stream
+    psArray         *objects,           ///< An array of fakeMaskRow objects
+    bool            mdcf                ///< format as mdconfig or simple
+);
+/** Formats and prints an fakeMaskRow object
+ *
+ * When mdcf is set the formated output is in psMetadataConfig
+ * format, otherwise it is in a simple tabular format.
+ *
+ * @return true on success
+ */
+
+bool fakeMaskPrintObject(
+    FILE            *stream,            ///< a stream
+    fakeMaskRow *object,    ///< an fakeMaskRow object
+    bool            mdcf                ///< format as mdconfig or simple
+);
 /** warpRunRow data structure
  *
@@ -3957,5 +4593,5 @@
 typedef struct {
     psS64           warp_id;
-    psS64           cam_id;
+    psS64           fake_id;
     char            *mode;
     char            *state;
@@ -3977,5 +4613,5 @@
 warpRunRow *warpRunRowAlloc(
     psS64           warp_id,
-    psS64           cam_id,
+    psS64           fake_id,
     const char      *mode,
     const char      *state,
@@ -4018,5 +4654,5 @@
     psDB            *dbh,               ///< Database handle
     psS64           warp_id,
-    psS64           cam_id,
+    psS64           fake_id,
     const char      *mode,
     const char      *state,
@@ -4187,5 +4823,4 @@
     char            *skycell_id;
     char            *tess_id;
-    psS64           cam_id;
     char            *class_id;
     psS16           fault;
@@ -4201,5 +4836,4 @@
     const char      *skycell_id,
     const char      *tess_id,
-    psS64           cam_id,
     const char      *class_id,
     psS16           fault
@@ -4236,5 +4870,4 @@
     const char      *skycell_id,
     const char      *tess_id,
-    psS64           cam_id,
     const char      *class_id,
     psS16           fault
