Index: trunk/Ohana/src/opihi/dvo/badimages.c
===================================================================
--- trunk/Ohana/src/opihi/dvo/badimages.c	(revision 4689)
+++ trunk/Ohana/src/opihi/dvo/badimages.c	(revision 4864)
@@ -8,14 +8,9 @@
 int badimages (int argc, char **argv) {
   
-  FILE *f;
-  int i, Nimage, nimage, entry, First, Cross;
+  int i, Nimage, entry, First, Cross;
   float *ptr;
   double nominal, big, small, value;
-  Header header;
   Image *image;
-  char ImageCat[256];
 
-  VarConfig ("IMAGE_CATALOG", "%s", ImageCat);
-  
   if (argc != 3) {
     fprintf (stderr, "USAGE: badimages entry value\n");
@@ -24,4 +19,6 @@
   }
   
+  image = LoadImages (&Nimage);
+
   Cross = FALSE;
   First = FALSE;
@@ -36,30 +33,4 @@
       Cross = TRUE;
     }
-  }
-  
-  /* check if image datafile exists, get header */
-  if (!fits_read_header (ImageCat, &header)) {
-    fprintf (stderr, "can't open image catalog %s\n", ImageCat);
-    return (FALSE);
-  }
-  
-  /* get ready to read data on images */ 
-  f = fopen (ImageCat, "r");
-  if (f == (FILE *) NULL) {
-    fprintf (stderr, "can't open image catalog %s\n", ImageCat);
-    return (FALSE);
-  }
-  fseek (f, header.size, SEEK_SET); 
-  
-  /* read in image data */
-  Nimage = 0;
-  fits_scan (&header, "NIMAGES", "%d", 1, &Nimage);
-  ALLOCATE (image, Image, Nimage);
-  nimage = Fread (image, sizeof(Image), Nimage, f, "image");
-  fclose (f);
-  if (nimage != Nimage) {
-    fprintf (stderr, "error reading all data from image file (%d != %d)\n", nimage, Nimage);
-    free (image);
-    return (FALSE);
   }
   
@@ -101,3 +72,2 @@
 
 }
-  
