Index: /branches/eam_branch_20071015/Ohana/src/opihi/cmd.data/rd.c
===================================================================
--- /branches/eam_branch_20071015/Ohana/src/opihi/cmd.data/rd.c	(revision 15440)
+++ /branches/eam_branch_20071015/Ohana/src/opihi/cmd.data/rd.c	(revision 15441)
@@ -5,5 +5,5 @@
   
   int i, N, status, plane, Nplane, extend, Nextend, Nskip, JustHead;
-  int ccdsel, done;
+  int ccdsel, done, Nword, IsCompressed;
   char region[512], *ccdid, *filename;
   FILE *f;
@@ -84,4 +84,7 @@
       fclose (f);
       return (FALSE);
+    }
+    if (gfits_extension_is_compressed (&buf[0].header)) {
+	IsCompressed = TRUE;
     }
   } 
@@ -115,5 +118,5 @@
       Nword = 1;
       IsCompressed = FALSE;
-      if (gfits_extension_is_compressed_data (&buf[0].header)) {
+      if (gfits_extension_is_compressed (&buf[0].header)) {
 	if (!strcmp (CCDKeyword, "EXTNAME")) Nword = 2;
 	IsCompressed = TRUE;
@@ -137,5 +140,5 @@
   if (extend || ccdsel) {
     if (!IsCompressed) {
-      gfits_extended_to_primary (buf[0].header, TRUE, "Standard FITS");
+      gfits_extended_to_primary (&buf[0].header, TRUE, "Standard FITS");
     }
   } else {
@@ -179,6 +182,6 @@
     ftable.header = &theader;
     gfits_copy_header (&buf[0].header, ftable.header);
-    status = gfits_fread_table (f, &ftable);  // XXX does this do more than read the bytes?
-    status = gfits_uncompress_image (&buf[0].header, &buf[0].matrix, ftable, ccdsel || extend);
+    status = gfits_fread_ftable_data (f, &ftable);  // XXX does this do more than read the bytes?
+    status = gfits_uncompress_image (&buf[0].header, &buf[0].matrix, &ftable, !(ccdsel || extend));
     gfits_free_table (&ftable);
     // XXX this currently does not work for a cube (we get a cube back, not a specific plane)
