Index: trunk/Ohana/src/getstar/src/gimages.c
===================================================================
--- trunk/Ohana/src/getstar/src/gimages.c	(revision 4844)
+++ trunk/Ohana/src/getstar/src/gimages.c	(revision 4864)
@@ -10,15 +10,10 @@
   Header header;
   
-  f = fopen (ImageCat, "r");
-  if (f == (FILE *) NULL) {
-    fprintf (stderr, "error opening image cat %s\n", ImageCat);
-    exit (1);
-  }
-
-  /* read header */
-  if (!fits_load_header (f, &header)) {
-    if (VERBOSE) fprintf (stderr, "ERROR: can't read image catalog %s\n", ImageCat);
-    exit (1);
-  }
+  set_db (&db);
+  lock_image_db (&db, ImageCat);
+  if (db[0].dbstate == LCK_EMPTY) Shutdown ("ERROR: No images in catalog %s (1)", db[0].filename);
+  if (!dvo_image_load (db, VERBOSE, FALSE)) Shutdown ("can't read image catalog %s", db[0].filename);
+  timage = fits_table_get_Image (&db[0].ftable, &Nimage, &db[0].swapped);
+  unlock_image_db (&db, ImageCat);
 
   fits_scan (&header, "ZERO_PT", "%lf", 1, &zeropt);
@@ -26,27 +21,4 @@
     fprintf (stderr, "ERROR: zero point in image table (%f:%s) inconsistent with zero point in image header (%f:%s)\n",
 	     zeropt, ImageCat, ZeroPt, filename);
-    exit (1);
-  }
-
-  /* advance to data segment */ 
-  fseek (f, header.size, SEEK_SET); 
-
-  Nimage = 0;
-  fits_scan (&header, "NIMAGES", "%d", 1, &Nimage);
-  /* check that file size makes sense */
-  if (stat (ImageCat, &filestatus) == -1) {
-    fprintf (stderr, "ERROR: failed to get status of image catalog\n");
-    exit (1);
-  }
-  size = Nimage*sizeof(Image) + header.size;
-  if (size != filestatus.st_size) {
-    fprintf (stderr, "ERROR: image catalog has inconsistent size\n");
-    exit (1);
-  } 
-
-  ALLOCATE (timage, Image, Nimage);
-  nimage = Fread (timage, sizeof(Image), Nimage, f, "image");
-  if (nimage != Nimage) {
-    fprintf (stderr, "error reading images from table\n");
     exit (1);
   }
