Index: trunk/Ohana/src/imregister/imphot/rtext.c
===================================================================
--- trunk/Ohana/src/imregister/imphot/rtext.c	(revision 3650)
+++ trunk/Ohana/src/imregister/imphot/rtext.c	(revision 4018)
@@ -1,21 +1,8 @@
 
-Image *rtext () {
-
-  f = fsetlockfile (dBFile, 120.0, LCK_SOFT, &dbstate);
-  if (f == (FILE *) NULL) {
-    fprintf (stderr, "ERROR: can't set lock on %s, state is %d\n", dBFile, dbstate);
-    exit (1);
-  }
-  Fseek (f, 0, SEEK_SET);
-
-  /* read header */
-  if (!fits_fread_header (f, &header)) {
-    if (VERBOSE) fprintf (stderr, "ERROR: can't read image catalog %s\n", dBFile);
-    exit (1);
-  }
+int rtext (FITS_DB *db) {
 
   /* check that file size makes sense */
   Nimage = 0;
-  fits_scan (&header, "NIMAGES", "%d", 1, &Nimage);
+  fits_scan (&db[0].header, "NIMAGES", "%d", 1, &Nimage);
   if (stat (dBFile, &filestatus) == -1) {
     if (VERBOSE) fprintf (stderr, "ERROR: failed to get status of image catalog\n");
@@ -33,13 +20,27 @@
   } 
 
+  /* create a dummy set of table information */
+  /* (original table has NAXIS = 2, change to 0) */
+  fits_modify (&db[0].header, "NAXIS", "%d", 1, 0);
+  fits_create_matrix (&db[0].header, &db[0].matrix);
+  fits_table_mkheader_Image (&db[0].theader);
+  db[0].ftable.header = &db[0].theader;
+
+  /* set theader size information to match loaded data */
+
   /* alloc, read images */
   ALLOCATE (image, Image, MAX (Nimage, 1));
-  nimage = Fread (image, sizeof(Image), Nimage, f, "image");
+  nimage = fread (image, sizeof(Image), Nimage, db[0].f);
   if (nimage != Nimage) {
     if (VERBOSE) fprintf (stderr, "ERROR: problem loading image catalog\n");
     exit (1);
   } 
-  fclearlockfile (dBFile, f, LCK_SOFT, &dbstate);
+  db[0].ftable.buffer = image;
+  return (TRUE);
+}
 
-  return (image);
-}
+/* the old Image.dat files used a fake FITS header defining a finite data block
+   this function reads in the 
+*/
+
+
