Index: /branches/eam_branches/largefiles.20100314/Ohana/configure.tcsh
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/configure.tcsh	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/configure.tcsh	(revision 27295)
@@ -13,4 +13,5 @@
 set use_tcmalloc = 0
 set use_gnu99 = 0
+set use_largefiles = 0
 
 set prefix  = ""
@@ -74,4 +75,7 @@
    set use_gnu99 = 1
    breaksw;
+  case --use-largefiles
+   set use_largefiles = 1
+   breaksw;
   case --pedantic
    set pedantic = 1
@@ -180,4 +184,8 @@
 # use_gnu99
 if ($use_gnu99) set CFLAGS = "$CFLAGS -std=gnu99"
+
+# use_largefiles
+# replace with `getconf LFS_CFLAGS`
+if ($use_largefiles) set CFLAGS = "$CFLAGS -D_FILE_OFFSET_BITS=64"
 
 if (! $?CPPFLAGS) then
@@ -650,6 +658,10 @@
   -h, --help              display this help and exit
   --enable-optimize       enable compiler optimization (-O2)
+  --enable-profile        enable 
   --enable-memcheck       enable ohana memory tests
   --pedantic              include -Wall -Werror on compilation
+  --use-tcmalloc          use the alternate tcmalloc from Google
+  --use-gnu99             use gnu99 flags to ensure C99 compatibility
+  --use-largefiles        ensure large file compatibility
 
 Installation directories:
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/include/addstar.h
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/include/addstar.h	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/include/addstar.h	(revision 27295)
@@ -44,5 +44,5 @@
 
 typedef struct {
-  int Nstars;
+  unsigned int Nstars;
   Stars *stars;
   int Nimages;
@@ -151,9 +151,9 @@
 AddstarClientOptions args         PROTO((int argc, char **argv, AddstarClientOptions options));
 
-void       AddToCalibration       PROTO((Average *average, SecFilt *secfilt, Measure *measure, Measure *new, int *next, int Nstar));
+void       AddToCalibration       PROTO((Average *average, SecFilt *secfilt, Measure *measure, Measure *new, off_t *next, off_t Nstar));
 void       FindCalibration        PROTO((Image *image));
 FILE      *GetDB                  PROTO((int *state));
 void       InitCalibration        PROTO((int mode));
-void       SaveCalibration        PROTO((float Mo, float dMo, float Mr, float dMr, float Mi, int N));
+void       SaveCalibration        PROTO((float Mo, float dMo, float Mr, float dMr, float Mi, off_t N));
 void       SetProtect             PROTO((int mode));
 int        SetSignals             PROTO((void));
@@ -165,31 +165,31 @@
 SkyTable  *SkyTableFromTychoIndex PROTO((char *filename, int VERBOSE));
 void       check_permissions      PROTO((char *basefile));
-int        dump_rawstars          PROTO((Stars *stars, int Nstars));
+int        dump_rawstars          PROTO((Stars *stars, unsigned int Nstars));
 int        edge_check             PROTO((double *x1, double *y1, double *x2, double *y2));
 Image     *fakeimage              PROTO((char *rootname, int *Nimage, int photcode));
 
-int        find_matches           PROTO((SkyRegion *region, Stars *stars, int Nstars, Catalog *catalog, AddstarClientOptions options));
-int        find_matches_closest   PROTO((SkyRegion *region, Stars *stars, int Nstars, Catalog *catalog, AddstarClientOptions options));
-int        find_matches_refstars  PROTO((SkyRegion *region, Stars **stars, int Nstars, Catalog *catalog, AddstarClientOptions options));
-int        find_matches_closest_refstars  PROTO((SkyRegion *region, Stars **stars, int Nstars, Catalog *catalog, AddstarClientOptions options));
-
-Stars    **find_subset            PROTO((SkyRegion *region, Stars *stars, int Nstars, int *NSTARS));
+int        find_matches           	 PROTO((SkyRegion *region, Stars *stars,  unsigned int Nstars, Catalog *catalog, AddstarClientOptions options));
+int        find_matches_closest   	 PROTO((SkyRegion *region, Stars *stars,  unsigned int Nstars, Catalog *catalog, AddstarClientOptions options));
+int        find_matches_refstars  	 PROTO((SkyRegion *region, Stars **stars, unsigned int Nstars, Catalog *catalog, AddstarClientOptions options));
+int        find_matches_closest_refstars PROTO((SkyRegion *region, Stars **stars, unsigned int Nstars, Catalog *catalog, AddstarClientOptions options));
+
+Stars    **find_subset            PROTO((SkyRegion *region, Stars *stars, unsigned int Nstars, unsigned int *NSTARS));
 int        gcatalog               PROTO((Catalog *catalog));
-Stars     *get2mass               PROTO((SkyRegion *patch, int photcode, int mode, int *NSTARS));
+Stars     *get2mass               PROTO((SkyRegion *patch, int photcode, int mode, unsigned int *NSTARS));
 double     get_subpix             PROTO((double x, double y));
 
-Stars     *greference             PROTO((char *Refcat, SkyRegion *catstats, int photcode, int *nstars));
-Stars     *getgsc                 PROTO((SkyRegion *patch, int *NSTARS));
-Stars     *gettycho               PROTO((SkyRegion *catstats, int photcode, int *Nstars));
-Stars     *getusno                PROTO((SkyRegion *catstats, int photcode, int *Nstars));
-Stars     *getusnob               PROTO((SkyRegion *catstats, int photcode, int *Nstars));
+Stars     *greference             PROTO((char *Refcat, SkyRegion *catstats, int photcode, unsigned int *nstars));
+Stars     *getgsc                 PROTO((SkyRegion *patch, unsigned int *NSTARS));
+Stars     *gettycho               PROTO((SkyRegion *catstats, int photcode, unsigned int *Nstars));
+Stars     *getusno                PROTO((SkyRegion *catstats, int photcode, unsigned int *Nstars));
+Stars     *getusnob               PROTO((SkyRegion *catstats, int photcode, unsigned int *Nstars));
 
 // load text-based stars (REF only in the sense of REF photcodes)
-Stars     *grefstars              PROTO((char *file, int photcode, int *Nstars));
-
-Stars     *LoadStars              PROTO((char *file, int *Nstars, Image **images, int *Nimages, AddstarClientOptions *options));
+Stars     *grefstars              PROTO((char *file, int photcode, unsigned int *Nstars));
+
+Stars     *LoadStars              PROTO((char *file, unsigned int *Nstars, Image **images, int *Nimages, AddstarClientOptions *options));
 Header   **LoadHeaders            PROTO((FILE *f, int *mode, int *Nheader));
-HeaderSet *MatchHeaders           PROTO((int **extsize, int *nimage, int mode, Header **headers, int Nheaders));
-int        LoadData               PROTO((FILE *f, char *file, Image **images, int *nvalid, Stars **stars, int *Nstars, Header **headers, int *extsize, HeaderSet *headerSets, int NheaderSets, AddstarClientOptions *options));
+HeaderSet *MatchHeaders           PROTO((off_t **extsize, int *nimage, int mode, Header **headers, int Nheaders));
+int        LoadData               PROTO((FILE *f, char *file, Image **images, int *nvalid, Stars **stars, unsigned int *Nstars, Header **headers, off_t *extsize, HeaderSet *headerSets, int NheaderSets, AddstarClientOptions *options));
 int        GetZeroPointExposure   PROTO((Header **headers, HeaderSet *headerSets, int Nimages));
 
@@ -199,14 +199,9 @@
 void       lock_image_db          PROTO((FITS_DB *db, char *filename));
 int        main                   PROTO((int argc, char **argv));
-void       make_backup            PROTO((char *filename));
-int        match_refstars         PROTO((Stars *stars, int Nstars));
-void       mkcatalog              PROTO((SkyRegion *region, Catalog *catalog));
 double     opening_angle          PROTO((double x1, double y1, double x2, double y2, double x3, double y3));
 int        parse_time             PROTO((Header *header));
-Stars     *rd_gsc                 PROTO((char *filename, int *nstars));
+Stars     *rd_gsc                 PROTO((char *filename, unsigned int *nstars));
 int        replace_match          PROTO((Average *average, Measure *measure, Stars *star));
 void       resort_catalog         PROTO((Catalog *catalog));
-Stars     *rfits                  PROTO((FILE *f, unsigned int *nstars));
-Stars     *rtext                  PROTO((FILE *f, unsigned int *nstars));
 Stars     *ReadStarsFITS          PROTO((FILE *f, Header *header, Header *in_theader, unsigned int *nstars));
 Stars     *ReadStarsTEXT          PROTO((FILE *f, unsigned int *nstars));
@@ -214,29 +209,15 @@
 int        ReadImageHeader        PROTO((Header *header, Image *image, int photcode));
 Stars     *FilterStars            PROTO((Stars *instars, Image *image, unsigned int imageID));
-Stars     *MergeStars             PROTO((Stars *stars, int *Nstars, Stars *instars, int Ninstars));
-void       save_pt_catalog        PROTO((Catalog *catalog));  /*** choose new name ***/
+Stars     *MergeStars             PROTO((Stars *stars, unsigned int *Nstars, Stars *instars, unsigned int Ninstars));
 double     scat_subpix            PROTO((double x, double y));
-time_t     short_date_to_sec      PROTO((char *date));
-void       sort_lists             PROTO((float *X, float *Y, int *S, int N));
-void       sort_stars             PROTO((Stars *stars, int N));
-int        str_to_radec           PROTO((double *ra, double *dec, char *str1, char *str2));
-void       unlock_image_db        PROTO((FITS_DB *db));
-void       update_coords          PROTO((Average *average, Measure *measure, int *next));
-void       wcatalog               PROTO((Catalog *catalog));
-void       free_catalog           PROTO((Catalog *catalog));
-void       wimage                 PROTO((FITS_DB *db, Image *image));
-void       create_image_db        PROTO((FITS_DB *db));
-void       set_db                 PROTO((FITS_DB *in));
-void       uppercase              PROTO((char *string));
-void       fsort                  PROTO((float *X, int N));
-void       fsort2                 PROTO((float *X, float *Y, int N));
-int 	  *init_measure_links     PROTO((Average *average, int Naverage, Measure *measure, int Nmeasure));
-int 	  *init_missing_links     PROTO((Average *average, int Naverage, Missing *missing, int Nmissing));
-int 	   add_meas_link     	  PROTO((Average *average, int *next, int Nmeasure, int NMEASURE));
-int 	   add_miss_link     	  PROTO((Average *average, int *next, int Nmissing));
-int 	  *build_measure_links    PROTO((Average *average, int Naverage, Measure *measure, int Nmeasure));
-Measure   *sort_measure     	  PROTO((Average *average, int Naverage, Measure *measure, int Nmeasure, int *next));
-Missing   *sort_missing     	  PROTO((Average *average, int Naverage, Missing *missing, int Nmissing, int *next_miss));
-int        ImageOptions		  PROTO((AddstarClientOptions *options, Image *images, int Nimages));
+void       update_coords          PROTO((Average *average, Measure *measure, off_t *next));
+off_t 	  *init_measure_links     PROTO((Average *average, off_t Naverage, Measure *measure, off_t Nmeasure));
+off_t 	  *init_missing_links     PROTO((Average *average, off_t Naverage, Missing *missing, off_t Nmissing));
+off_t 	   add_meas_link     	  PROTO((Average *average, off_t *next_meas, off_t Nmeasure, off_t NMEASURE));
+off_t 	   add_miss_link     	  PROTO((Average *average, off_t *next_miss, off_t Nmissing));
+off_t 	  *build_measure_links    PROTO((Average *average, off_t Naverage, Measure *measure, off_t Nmeasure));
+Measure   *sort_measure     	  PROTO((Average *average, off_t Naverage, Measure *measure, off_t Nmeasure, off_t *next_meas));
+Missing   *sort_missing     	  PROTO((Average *average, off_t Naverage, Missing *missing, off_t Nmissing, off_t *next_miss));
+int        ImageOptions		  PROTO((AddstarClientOptions *options, Image *images, off_t Nimages));
 int        GetFileMode		  PROTO((Header *header));
 AddstarClientOptions args_client  PROTO((int argc, char **argv, AddstarClientOptions options));
@@ -251,8 +232,8 @@
 int 	   WaitServerSocket	  PROTO((int InitSocket, SockAddress *Address, int *validIP, int Nvalid));
 int 	   GetClientSocket	  PROTO((char *hostname));
-int 	   UpdateDatabase_Image	  PROTO((AddstarClientOptions *options, Image *images, int Nimages, Coords *mosaic, Stars *stars, int Nstars));
-int 	   UpdateDatabase_Reflist PROTO((AddstarClientOptions *options, Stars *stars, int Nstars));
+int 	   UpdateDatabase_Image	  PROTO((AddstarClientOptions *options, Image *images, int Nimages, Coords *mosaic, Stars *stars, unsigned int Nstars));
+int 	   UpdateDatabase_Reflist PROTO((AddstarClientOptions *options, Stars *stars, unsigned int Nstars));
 int 	   UpdateDatabase_Refcat  PROTO((AddstarClientOptions *options, SkyRegion *UserPatch, char *refcat));
-SkyList   *SkyListForStars	  PROTO((SkyTable *table, int depth, Stars *stars, int Nstars));
+SkyList   *SkyListForStars	  PROTO((SkyTable *table, int depth, Stars *stars, unsigned int Nstars));
 SkyList   *SkyListExistingSubset  PROTO((SkyList *input, char *path));
 int        SkyListSetPath	  PROTO((SkyList *list, char *path));
@@ -265,10 +246,10 @@
 int 	   NewReflist_Thread	  PROTO((int BindSocket));
 
-Stars     *Convert_SMPDATA	  PROTO((FTable *table, int *nstars));
-Stars     *Convert_PS1_DEV_0	  PROTO((FTable *table, int *nstars));
-Stars     *Convert_PS1_DEV_1	  PROTO((FTable *table, int *nstars));
-Stars     *Convert_PS1_V1	  PROTO((FTable *table, int *nstars));
-Stars     *Convert_PS1_V1_Alt	  PROTO((FTable *table, int *nstars));
-Stars     *Convert_PS1_V2	  PROTO((FTable *table, int *nstars));
+Stars     *Convert_SMPDATA	  PROTO((FTable *table, unsigned int *nstars));
+Stars     *Convert_PS1_DEV_0	  PROTO((FTable *table, unsigned int *nstars));
+Stars     *Convert_PS1_DEV_1	  PROTO((FTable *table, unsigned int *nstars));
+Stars     *Convert_PS1_V1	  PROTO((FTable *table, unsigned int *nstars));
+Stars     *Convert_PS1_V1_Alt	  PROTO((FTable *table, unsigned int *nstars));
+Stars     *Convert_PS1_V2	  PROTO((FTable *table, unsigned int *nstars));
 
 int        InitStar               PROTO((Stars *star));
@@ -278,9 +259,9 @@
 int args_skycells (int argc, char **argv);
 int ConfigInit_skycells (int *argc, char **argv);
-int UpdateImageIDs (Stars *stars, int Nstars, Image *images, int Nimages);
-int LoadDataSDSS (FILE *f, char *file, Image **images, int *nvalid, Stars **stars, int *Nstars, Header **headers, int *extsize, HeaderSet *headerSets, int Nimages);
+int UpdateImageIDs (Stars *stars, unsigned int Nstars, Image *images, int Nimages);
+int LoadDataSDSS (FILE *f, char *file, Image **images, int *nvalid, Stars **stars, unsigned int *Nstars, Header **headers, off_t *extsize, HeaderSet *headerSets, int Nimages);
 int altaz (double *alt, double *az, double ha, double dec, double latitude);
 
-int LoadDataPMM (FILE *f, char *file, Image **images, int *nvalid, Stars **stars, int *Nstars);
+int LoadDataPMM (FILE *f, char *file, Image **images, int *nvalid, Stars **stars, unsigned int *Nstars);
 PhotCode *LoadMetadataPMM (char *datafile, Image *image);
 time_t pmm_date_to_sec (char *date, char *time);
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/FilterStars.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/FilterStars.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/FilterStars.c	(revision 27295)
@@ -109,5 +109,5 @@
 }
 
-Stars *MergeStars (Stars *stars, int *Nstars, Stars *instars, int Ninstars) {
+Stars *MergeStars (Stars *stars, unsigned int *Nstars, Stars *instars, unsigned int Ninstars) {
 
   int i, j;
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/LoadData.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/LoadData.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/LoadData.c	(revision 27295)
@@ -6,8 +6,9 @@
 
 // examine the header sets and set the Image entries for the the valid images
-int LoadData (FILE *f, char *file, Image **images, int *nvalid, Stars **stars, int *Nstars, Header **headers, int *extsize, HeaderSet *headerSets, int Nimages, AddstarClientOptions *options) {
+int LoadData (FILE *f, char *file, Image **images, int *nvalid, Stars **stars, unsigned int *Nstars, Header **headers, off_t *extsize, HeaderSet *headerSets, int Nimages, AddstarClientOptions *options) {
 
   char *name;
-  int i, j, Nvalid, Nhead, Ndata, Nskip;
+  off_t Nskip;
+  int i, j, Nvalid, Nhead, Ndata;
   uint32_t parentID = UINT32_MAX;
   Stars *inStars;
@@ -76,5 +77,5 @@
       Nskip += extsize[j];
     }
-    fseek (f, Nskip, SEEK_SET); 
+    fseeko (f, Nskip, SEEK_SET); 
 	 
     inStars = ReadStarsFITS (f, headers[Nhead], headers[Ndata], &images[0][Nvalid].nstar);
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/LoadDataPMM.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/LoadDataPMM.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/LoadDataPMM.c	(revision 27295)
@@ -16,5 +16,5 @@
 # define MAG_INDEX_ASC 22
 
-int LoadDataPMM (FILE *f, char *file, Image **images, int *nvalid, Stars **stars, int *Nstars) {
+int LoadDataPMM (FILE *f, char *file, Image **images, int *nvalid, Stars **stars, unsigned int *Nstars) {
 
   char *name, *buffer;
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/LoadDataSDSS.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/LoadDataSDSS.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/LoadDataSDSS.c	(revision 27295)
@@ -4,8 +4,9 @@
 // there should only be a single data set (phu + table) in this file
 // each SDSS data set corresponds to 5 images (ugriz)
-int LoadDataSDSS (FILE *f, char *file, Image **images, int *nvalid, Stars **stars, int *Nstars, Header **headers, int *extsize, HeaderSet *headerSets, int Nimages) {
+int LoadDataSDSS (FILE *f, char *file, Image **images, int *nvalid, Stars **stars, unsigned int *Nstars, Header **headers, off_t *extsize, HeaderSet *headerSets, int Nimages) {
 
+  off_t Nskip;
   char *name;
-  int j, Nvalid, Nhead, Ndata, Nskip;
+  int j, Nvalid, Nhead, Ndata;
   unsigned int Ninstars;
   Stars *inStars;
@@ -36,5 +37,5 @@
     Nskip += extsize[j];
   }
-  fseek (f, Nskip, SEEK_SET); 
+  fseeko (f, Nskip, SEEK_SET); 
 	 
   // XXX I think this is an error?  should this be &images[0][Nvalid] ??
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/LoadHeaders.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/LoadHeaders.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/LoadHeaders.c	(revision 27295)
@@ -4,5 +4,6 @@
 Header **LoadHeaders (FILE *f, int *mode, int *Nheaders) {
 
-  int i, status, Nskip, NHEADERS;
+  off_t Nskip;
+  int i, status, NHEADERS;
   Header **headers;
 
@@ -31,5 +32,5 @@
     // advance to the next header
     Nskip = gfits_data_size (headers[i]);
-    fseek (f, Nskip, SEEK_CUR); 
+    fseeko (f, Nskip, SEEK_CUR); 
     if (i == NHEADERS - 1) {
       NHEADERS += 10;
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/LoadStars.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/LoadStars.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/LoadStars.c	(revision 27295)
@@ -1,7 +1,8 @@
 # include "addstar.h"
 
-Stars *LoadStars (char *filename, int *Nstars, Image **images, int *Nimages, AddstarClientOptions *options) {
+Stars *LoadStars (char *filename, unsigned int *Nstars, Image **images, int *Nimages, AddstarClientOptions *options) {
 
-  int i, Nfile, NFILE, Nheaders, NheaderSets, mode, *extsize;
+  off_t *extsize;
+  int i, Nfile, NFILE, Nheaders, NheaderSets, mode;
   char **file, line[1024];
   FILE *f;
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/MatchHeaders.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/MatchHeaders.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/MatchHeaders.c	(revision 27295)
@@ -3,5 +3,5 @@
 // XXX largely psphot specific
 
-HeaderSet *MatchHeaders (int **extsize, int *nimage, int mode, Header **headers, int Nheaders) {
+HeaderSet *MatchHeaders (off_t **extsize, int *nimage, int mode, Header **headers, int Nheaders) {
 
   int i, j, Nimage, NIMAGE;
@@ -9,5 +9,5 @@
   HeaderSet *headerSets;
 
-  ALLOCATE (extsize[0], int, Nheaders);
+  ALLOCATE (extsize[0], off_t, Nheaders);
 
   Nimage = 0;
@@ -34,5 +34,5 @@
     headerSets[0].extnum_head = 0;
     headerSets[0].extnum_data = 1;
-    extsize[0][0] = headers[0][0].size;
+    extsize[0][0] = headers[0][0].datasize;
     *nimage = 1;
     return headerSets;
@@ -42,7 +42,7 @@
   for (i = 0; i < Nheaders; i++) {
     if (mode == SIMPLE_CMP) {
-      extsize[0][i] = headers[i][0].size;
+      extsize[0][i] = headers[i][0].datasize;
     } else {
-      extsize[0][i] = headers[i][0].size + gfits_data_size (headers[i]);
+      extsize[0][i] = headers[i][0].datasize + gfits_data_size (headers[i]);
     }
 
@@ -92,6 +92,6 @@
   // extension matched to the header in the PHU
   if (Nimage == 0) {
-    extsize[0][0] = headers[0][0].size + gfits_data_size (headers[0]);
-    extsize[0][1] = headers[1][0].size + gfits_data_size (headers[1]);
+    extsize[0][0] = headers[0][0].datasize + gfits_data_size (headers[0]);
+    extsize[0][1] = headers[1][0].datasize + gfits_data_size (headers[1]);
     gfits_scan (headers[1], ExtnameKeyword, "%s", 1, extname);
     if (!strcmp (extname, "SMPFILE")) {
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/ReadStarsFITS.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/ReadStarsFITS.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/ReadStarsFITS.c	(revision 27295)
@@ -5,5 +5,6 @@
 Stars *ReadStarsFITS (FILE *f, Header *header, Header *in_theader, unsigned int *nstars) {
 
-  int Nskip, Nstars;
+  off_t Nskip;
+  unsigned int Nstars;
   char type[80];
   Header theader;
@@ -16,6 +17,6 @@
   } else {
     table.header = in_theader;
-    Nskip = in_theader[0].size;
-    fseek (f, Nskip, SEEK_CUR); 
+    Nskip = in_theader[0].datasize;
+    fseeko (f, Nskip, SEEK_CUR); 
   }
 
@@ -57,7 +58,8 @@
 }
 
-Stars *Convert_SMPDATA (FTable *table, int *nstars) {
-
-  int i, Nstars, swapped;
+Stars *Convert_SMPDATA (FTable *table, unsigned int *nstars) {
+
+  unsigned int i, Nstars;
+  char swapped;
   double ZeroPt;
   Stars *stars = NULL;
@@ -96,7 +98,7 @@
 }
 
-Stars *Convert_PS1_DEV_0 (FTable *table, int *nstars) {
-
-  int i, Nstars;
+Stars *Convert_PS1_DEV_0 (FTable *table, unsigned int *nstars) {
+
+  unsigned int i, Nstars;
   double ZeroPt;
   Stars *stars;
@@ -140,7 +142,7 @@
 // XXX I need to make the IPP I/O functions and these functions
 // consistent wrt ZERO_POINT....
-Stars *Convert_PS1_DEV_1 (FTable *table, int *nstars) {
-
-  int i, Nstars;
+Stars *Convert_PS1_DEV_1 (FTable *table, unsigned int *nstars) {
+
+  unsigned int i, Nstars;
   double ZeroPt;
   Stars *stars;
@@ -185,7 +187,7 @@
 }
 
-Stars *Convert_PS1_V1 (FTable *table, int *nstars) {
-
-  int i, Nstars;
+Stars *Convert_PS1_V1 (FTable *table, unsigned int *nstars) {
+
+  unsigned int i, Nstars;
   double ZeroPt;
   Stars *stars;
@@ -261,7 +263,7 @@
 }
 
-Stars *Convert_PS1_V1_Alt (FTable *table, int *nstars) {
-
-  int i, Nstars;
+Stars *Convert_PS1_V1_Alt (FTable *table, unsigned int *nstars) {
+
+  unsigned int i, Nstars;
   double ZeroPt;
   Stars *stars;
@@ -332,7 +334,7 @@
 }
 
-Stars *Convert_PS1_V2 (FTable *table, int *nstars) {
-
-  int i, Nstars;
+Stars *Convert_PS1_V2 (FTable *table, unsigned int *nstars) {
+
+  unsigned int i, Nstars;
   double ZeroPt;
   Stars *stars;
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/ReadStarsSDSS.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/ReadStarsSDSS.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/ReadStarsSDSS.c	(revision 27295)
@@ -33,5 +33,6 @@
 Stars *ReadStarsSDSS (FILE *f, char *name, Header *header, Header *in_theader, Image *images, int *nimages, unsigned int *nstars) {
 
-  int i, j, N, Nskip, Nstars, camcol;
+  off_t Nskip;
+  int i, j, N, Nstars, camcol;
   char type[80];
   Header theader;
@@ -50,6 +51,6 @@
   } else {
     table.header = in_theader;
-    Nskip = in_theader[0].size;
-    fseek (f, Nskip, SEEK_CUR); 
+    Nskip = in_theader[0].datasize;
+    fseeko (f, Nskip, SEEK_CUR); 
   }
 
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/SkyListForStars.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/SkyListForStars.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/SkyListForStars.c	(revision 27295)
@@ -13,5 +13,5 @@
 }
 
-SkyList *SkyListForStars (SkyTable *table, int depth, Stars *stars, int Nstars) {
+SkyList *SkyListForStars (SkyTable *table, int depth, Stars *stars, unsigned int Nstars) {
   
   int i, j, Nr, NR;
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/SkyTableFromTychoIndex.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/SkyTableFromTychoIndex.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/SkyTableFromTychoIndex.c	(revision 27295)
@@ -147,5 +147,5 @@
     skytable[0].filename[i] = NULL;
   }
-  if (VERBOSE) fprintf (stderr, "loaded %d tables from tycho index\n", skytable[0].Nregions);
+  if (VERBOSE) fprintf (stderr, "loaded %lld tables from tycho index\n", (long long) skytable[0].Nregions);
 
   return (skytable);
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/UpdateDatabase_Image.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/UpdateDatabase_Image.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/UpdateDatabase_Image.c	(revision 27295)
@@ -1,5 +1,5 @@
 # include "addstar.h"
 
-int UpdateDatabase_Image (AddstarClientOptions *options, Image *images, int Nimages, Coords *mosaic, Stars *stars, int Nstars) {
+int UpdateDatabase_Image (AddstarClientOptions *options, Image *images, int Nimages, Coords *mosaic, Stars *stars, unsigned int Nstars) {
 
   int i, status;
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/UpdateDatabase_Reflist.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/UpdateDatabase_Reflist.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/UpdateDatabase_Reflist.c	(revision 27295)
@@ -1,5 +1,5 @@
 # include "addstar.h"
 
-int UpdateDatabase_Reflist (AddstarClientOptions *options, Stars *stars, int Nstars) {
+int UpdateDatabase_Reflist (AddstarClientOptions *options, Stars *stars, unsigned int Nstars) {
 
   int i, Nsubset;
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/UpdateImageIDs.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/UpdateImageIDs.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/UpdateImageIDs.c	(revision 27295)
@@ -1,5 +1,5 @@
 # include "addstar.h"
 
-int UpdateImageIDs (Stars *stars, int Nstars, Image *images, int Nimages) {
+int UpdateImageIDs (Stars *stars, unsigned int Nstars, Image *images, int Nimages) {
 
   int i, status, isEmpty;
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/addstar.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/addstar.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/addstar.c	(revision 27295)
@@ -1,9 +1,11 @@
 # include "addstar.h"
 
+// LARGEFILES: this program currently limits Nstars (input file) to < 2^31
 int main (int argc, char **argv) {
 
+  unsigned int Nstars, Nsubset;
   int Nmatch, status, loadObjects;
-  int i, Nstars, Nimages, Nsubset;
-  unsigned long long Naverage, Nmeasure;
+  int i, Nimages;
+  off_t Naverage, Nmeasure;
   Stars *stars, **subset;
   Image *images;
@@ -46,5 +48,5 @@
 	newlist = SkyListByImage (sky, -1, &images[i]);
 	SkyListMerge (&skylist, newlist);
-	if (VERBOSE) fprintf (stderr, "added %d regions to yield %d total\n", newlist[0].Nregions, skylist[0].Nregions);
+	if (VERBOSE) fprintf (stderr, "added %lld regions to yield %lld total\n", (long long) newlist[0].Nregions, (long long) skylist[0].Nregions);
 	SkyListFree (newlist);
       }
@@ -78,5 +80,5 @@
     skylist = tmp;
   }
-  if (VERBOSE) fprintf (stderr, "writing to %d regions\n", skylist[0].Nregions);
+  if (VERBOSE) fprintf (stderr, "writing to %lld regions\n", (long long) skylist[0].Nregions);
 
   /* don't load the object tables for only_images, unless we are getting the calibration. */
@@ -203,5 +205,5 @@
   gettimeofday (&stop, NULL);
   dtime = DTIME (stop, start);
-  fprintf (stderr, "SUCCESS: elapsed time %9.4f sec for %5d stars (%5d matches), %6lld average, %7lld measure\n", dtime, Nstars, Nmatch, Naverage, Nmeasure);
+  fprintf (stderr, "SUCCESS: elapsed time %9.4f sec for %5d stars (%5d matches), %6lld average, %7lld measure\n", dtime, Nstars, Nmatch, (long long) Naverage, (long long) Nmeasure);
 
   exit (0);
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/build_links.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/build_links.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/build_links.c	(revision 27295)
@@ -26,20 +26,20 @@
 /* build the initial links assuming the table is sorted, 
    not partial, and has a correct set of average[].measureOffset,Nmeasure values */
-int *init_measure_links (Average *average, int Naverage, Measure *measure, int Nmeasure) {
-
-  int i, j, N;
-  int *next;
+off_t *init_measure_links (Average *average, off_t Naverage, Measure *measure, off_t Nmeasure) {
+
+  off_t i, j, N;
+  off_t *next_meas;
 
   N = 0;
 
-  ALLOCATE (next, int, Nmeasure);
+  ALLOCATE (next_meas, off_t, Nmeasure);
   for (i = 0; i < Naverage; i++, N++) {
     for (j = 0; j < average[i].Nmeasure - 1; j++, N++) {
-      next[N] = N + 1;
+      next_meas[N] = N + 1;
       if (N >= Nmeasure) {
 	fprintf (stderr, "WARNING: N out of bounds (1)\n");
       }
     }
-    next[N] = -1;
+    next_meas[N] = -1;
     if (N >= Nmeasure) {
       fprintf (stderr, "WARNING: N out of bounds (2)\n");
@@ -51,5 +51,5 @@
     }
   }
-  return (next);
+  return (next_meas);
 }
 
@@ -61,10 +61,10 @@
  */ 
 
-int *build_measure_links (Average *average, int Naverage, Measure *measure, int Nmeasure) {
-
-  int i, m, k, Nm, averef;
-  int *next;
-
-  ALLOCATE (next, int, Nmeasure);
+off_t *build_measure_links (Average *average, off_t Naverage, Measure *measure, off_t Nmeasure) {
+
+  off_t i, m, k, Nm, averef;
+  off_t *next_meas;
+
+  ALLOCATE (next_meas, off_t, Nmeasure);
 
   /* reset the Nm, offset values for average */
@@ -77,5 +77,5 @@
     averef = measure[Nm].averef;
     m = average[averef].measureOffset;  
-    next[Nm] = -1;
+    next_meas[Nm] = -1;
 
     if (m == -1) { /* no links yet for source */
@@ -85,6 +85,6 @@
     }
 
-    for (k = 0; next[m] != -1; k++) {
-      m = next[m];
+    for (k = 0; next_meas[m] != -1; k++) {
+      m = next_meas[m];
       if (m >= Nmeasure) {
 	fprintf (stderr, "WARNING: m out of bounds (1)\n");
@@ -93,22 +93,22 @@
 
     average[averef].Nmeasure = k + 2;
-    next[m] = Nm;
+    next_meas[m] = Nm;
     if (m >= Nmeasure) {
       fprintf (stderr, "WARNING: m out of bounds (2)\n");
     }
   }
-  return (next);
+  return (next_meas);
 }
 
 /* average[].measureOffset, average[].Nmeasure are valid within an addstar run */
-int add_meas_link (Average *average, int *next, int Nmeasure, int NMEASURE) {
-
-  int k, m;
-
-  /* if we have trouble, check validity of next[m] : m < Nmeasure */
+off_t add_meas_link (Average *average, off_t *next_meas, off_t Nmeasure, off_t NMEASURE) {
+
+  off_t k, m;
+
+  /* if we have trouble, check validity of next_meas[m] : m < Nmeasure */
   m = average[0].measureOffset;  
 
   for (k = 0; k < average[0].Nmeasure - 1; k++)  {
-    m = next[m];
+    m = next_meas[m];
     if (m >= NMEASURE) {
       fprintf (stderr, "WARNING: m out of bounds (3)\n");
@@ -117,5 +117,5 @@
 
   /* set up references */
-  next[Nmeasure] = -1;
+  next_meas[Nmeasure] = -1;
   if (Nmeasure >= NMEASURE) {
     fprintf (stderr, "WARNING: Nmeasure out of bounds (1)\n");
@@ -125,5 +125,5 @@
     average[0].measureOffset = Nmeasure;
   } else {
-    next[m] = Nmeasure;
+    next_meas[m] = Nmeasure;
     if (m >= NMEASURE) {
       fprintf (stderr, "WARNING: m out of bounds (4)\n");
@@ -137,7 +137,7 @@
    we must always save the missing table, if it exists */
 
-Measure *sort_measure (Average *average, int Naverage, Measure *measure, int Nmeasure, int *next) {
-
-  int i, k, n, N;
+Measure *sort_measure (Average *average, off_t Naverage, Measure *measure, off_t Nmeasure, off_t *next_meas) {
+
+  off_t i, k, n, N;
   Measure *tmpmeasure;
 
@@ -153,5 +153,5 @@
       if (measure[n].averef != i) abort();
       tmpmeasure[N].averef = i;
-      n = next[n];
+      n = next_meas[n];
     }
   }
@@ -161,18 +161,18 @@
 
 /* build the initial links assuming the table is sorted */
-int *init_missing_links (Average *average, int Naverage, Missing *missing, int Nmissing) {
-
-  int i, j, N;
-  int *next;
+off_t *init_missing_links (Average *average, off_t Naverage, Missing *missing, off_t Nmissing) {
+
+  off_t i, j, N;
+  off_t *next_miss;
 
   N = 0;
 
-  ALLOCATE (next, int, Nmissing);
+  ALLOCATE (next_miss, off_t, Nmissing);
   for (i = 0; i < Naverage; i++) {
     for (j = 0; j < average[i].Nmissing - 1; j++, N++) {
-      next[N] = N + 1;
+      next_miss[N] = N + 1;
     }
     if (average[i].Nmissing > 0) {
-      next[N] = -1;
+      next_miss[N] = -1;
       if (N >= Nmissing) {
 	fprintf (stderr, "overflow in init_missing_links");
@@ -183,29 +183,29 @@
 
   }
-  return (next);
-}
-
-int add_miss_link (Average *average, int *next, int Nmissing) {
-
-  int k, m;
+  return (next_miss);
+}
+
+off_t add_miss_link (Average *average, off_t *next_miss, off_t Nmissing) {
+
+  off_t k, m;
 
   /* there may be 0 Nmiss; this is not true for Nmeas */
   if (average[0].Nmissing < 1) {
     average[0].missingOffset = Nmissing;
-    next[Nmissing] = -1;
+    next_miss[Nmissing] = -1;
     return (TRUE);
   }
 
   m = average[0].missingOffset;  
-  for (k = 0; k < average[0].Nmissing - 1; k++) m = next[m];
+  for (k = 0; k < average[0].Nmissing - 1; k++) m = next_miss[m];
   /* set up references */
-  next[Nmissing] = -1;
-  next[m] = Nmissing;
+  next_miss[Nmissing] = -1;
+  next_miss[m] = Nmissing;
   return (TRUE);
 }
 
-Missing *sort_missing (Average *average, int Naverage, Missing *missing, int Nmissing, int *next) {
-
-  int i, k, n, N;
+Missing *sort_missing (Average *average, off_t Naverage, Missing *missing, off_t Nmissing, off_t *next_miss) {
+
+  off_t i, k, n, N;
   Missing *tmpmissing;
 
@@ -218,5 +218,5 @@
     for (k = 0; k < average[i].Nmissing; k++, N++) {
       tmpmissing[N] = missing[n]; 
-      n = next[n];
+      n = next_miss[n];
     }
   }
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/calibrate.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/calibrate.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/calibrate.c	(revision 27295)
@@ -2,5 +2,6 @@
 
 static int InternalCal;
-static int Ncal, NCAL, *Nstar;
+static int Ncal, NCAL;
+static off_t *Nstar;
 static float *Mobs, *dMobs, *Mref, *dMref, *Minst;
 
@@ -13,12 +14,12 @@
   NCAL = 1000;
   ALLOCATE (Mobs,  float,  NCAL);
-  ALLOCATE (dMobs, float, NCAL);
+  ALLOCATE (dMobs, float,  NCAL);
   ALLOCATE (Mref,  float,  NCAL);
   ALLOCATE (dMref, float,  NCAL);
   ALLOCATE (Minst, float,  NCAL);
-  ALLOCATE (Nstar, int, NCAL);
+  ALLOCATE (Nstar, off_t,  NCAL);
 }
   
-void SaveCalibration (float Mo, float dMo, float Mr, float dMr, float Mi, int N) {
+void SaveCalibration (float Mo, float dMo, float Mr, float dMr, float Mi, off_t N) {
 
   Mobs[Ncal]  = Mo;
@@ -37,10 +38,10 @@
     REALLOCATE (dMref, float, NCAL);
     REALLOCATE (Minst, float, NCAL);
-    REALLOCATE (Nstar, int,   NCAL);
+    REALLOCATE (Nstar, off_t, NCAL);
   }
 }
 
 /* use the linked list to navigate the measures; safe for unsorted measures */
-void AddToCalibration (Average *average, SecFilt *secfilt, Measure *measure, Measure *new, int *next, int Nstar) {
+void AddToCalibration (Average *average, SecFilt *secfilt, Measure *measure, Measure *new, off_t *next, off_t Nstar) {
 
   int i, j, m, Nsec, found0, found1, found2;
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/dump.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/dump.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/dump.c	(revision 27295)
@@ -1,7 +1,7 @@
 # include "addstar.h"
 
-int dump_rawstars (Stars *stars, int Nstars) {
+int dump_rawstars (Stars *stars, unsigned int Nstars) {
 
-  int i;
+  unsigned int i;
   FILE *f;
 
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/find_matches.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/find_matches.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/find_matches.c	(revision 27295)
@@ -1,12 +1,12 @@
 # include "addstar.h"
 
-int find_matches (SkyRegion *region, Stars *stars, int NstarsIn, Catalog *catalog, AddstarClientOptions options) {
-
-  int i, j, n, N, J, status, Nstars;
+int find_matches (SkyRegion *region, Stars *stars, unsigned int NstarsIn, Catalog *catalog, AddstarClientOptions options) {
+
+  off_t i, j, n, N, J, status, Nstars;
   double RADIUS, RADIUS2;
   double *X1, *Y1, *X2, *Y2;
   double dX, dY, dR;
-  int *N1, *N2, *next_meas;
-  int Nave, NAVE, Nmeas, NMEAS, Nmatch;
+  off_t *N1, *N2, *next_meas;
+  off_t Nave, NAVE, Nmeas, NMEAS, Nmatch;
   int Nsecfilt, Nsec;
   unsigned int objID, catID;
@@ -24,5 +24,5 @@
   ALLOCATE (X1, double, NstarsIn);
   ALLOCATE (Y1, double, NstarsIn);
-  ALLOCATE (N1, int,    NstarsIn);
+  ALLOCATE (N1, off_t,  NstarsIn);
 
   /** allocate local arrays (catalog) **/
@@ -30,6 +30,6 @@
   ALLOCATE (X2, double, NAVE);
   ALLOCATE (Y2, double, NAVE);
-  ALLOCATE (N2, int,   NAVE);
-  ALLOCATE (catalog[0].found, int, NAVE);
+  ALLOCATE (N2, off_t,  NAVE);
+  ALLOCATE (catalog[0].found, off_t, NAVE);
   /* for secfilt j and star i, secfilt[i*Nsecfilt+j] */
 
@@ -140,5 +140,5 @@
       if (Nmeas >= NMEAS) {
 	NMEAS = Nmeas + 1000;
-	REALLOCATE (next_meas, int, NMEAS);
+	REALLOCATE (next_meas, off_t, NMEAS);
 	REALLOCATE (catalog[0].measure, Measure, NMEAS);
       }
@@ -231,5 +231,5 @@
     if (Nmeas >= NMEAS) {
       NMEAS = Nmeas + 1000;
-      REALLOCATE (next_meas, int, NMEAS);
+      REALLOCATE (next_meas, off_t, NMEAS);
       REALLOCATE (catalog[0].measure, Measure, NMEAS);
     }
@@ -339,5 +339,5 @@
   catalog[0].Nmeasure = Nmeas;
   catalog[0].Nsecf_mem = Nave*Nsecfilt;
-  if (VERBOSE) fprintf (stderr, "Nstars, Nave, Nmeas: %d %d %d, (%d matches)\n", Nstars, Nave, Nmeas, Nmatch);
+  if (VERBOSE) fprintf (stderr, "Nstars, Nave, Nmeas: %lld %lld %lld, (%lld matches)\n", (long long) Nstars, (long long) Nave, (long long) Nmeas, (long long) Nmatch);
 
   free (catalog[0].found);
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/find_matches_closest.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/find_matches_closest.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/find_matches_closest.c	(revision 27295)
@@ -1,12 +1,12 @@
 # include "addstar.h"
 
-int find_matches_closest (SkyRegion *region, Stars *stars, int NstarsIn, Catalog *catalog, AddstarClientOptions options) {
-
-  int i, j, n, N, J, Jmin, status, Nstars;
+int find_matches_closest (SkyRegion *region, Stars *stars, unsigned int NstarsIn, Catalog *catalog, AddstarClientOptions options) {
+  
+  off_t i, j, n, N, J, Jmin, status, Nstars;
   double RADIUS, RADIUS2, Rmin;
   double *X1, *Y1, *X2, *Y2;
   double dX, dY, dR;
-  int *N1, *N2,  *next_meas;
-  int Nave, NAVE, Nmeas, NMEAS, Nmatch;
+  off_t *N1, *N2, *next_meas;
+  off_t Nave, NAVE, Nmeas, NMEAS, Nmatch;
   int Nsecfilt, Nsec;
   unsigned int objID, catID;
@@ -24,5 +24,5 @@
   ALLOCATE (X1, double, NstarsIn);
   ALLOCATE (Y1, double, NstarsIn);
-  ALLOCATE (N1, int,    NstarsIn);
+  ALLOCATE (N1, off_t,  NstarsIn);
 
   /** allocate local arrays (catalog) **/
@@ -30,6 +30,6 @@
   ALLOCATE (X2, double, NAVE);
   ALLOCATE (Y2, double, NAVE);
-  ALLOCATE (N2, int,   NAVE);
-  ALLOCATE (catalog[0].found, int, NAVE);
+  ALLOCATE (N2, off_t,  NAVE);
+  ALLOCATE (catalog[0].found, off_t, NAVE);
   /* for secfilt j and star i, secfilt[i*Nsecfilt+j] */
 
@@ -155,5 +155,5 @@
     if (Nmeas >= NMEAS) {
       NMEAS = Nmeas + 1000;
-      REALLOCATE (next_meas, int, NMEAS);
+      REALLOCATE (next_meas, off_t, NMEAS);
       REALLOCATE (catalog[0].measure, Measure, NMEAS);
     }
@@ -226,5 +226,5 @@
     if (Nmeas >= NMEAS) {
       NMEAS = Nmeas + 1000;
-      REALLOCATE (next_meas, int, NMEAS);
+      REALLOCATE (next_meas, off_t, NMEAS);
       REALLOCATE (catalog[0].measure, Measure, NMEAS);
     }
@@ -335,5 +335,5 @@
   catalog[0].Nmeasure = Nmeas;
   catalog[0].Nsecf_mem = Nave*Nsecfilt;
-  if (VERBOSE) fprintf (stderr, "Nstars, Nave, Nmeas: %d %d %d, (%d matches)\n", Nstars, Nave, Nmeas, Nmatch);
+  if (VERBOSE) fprintf (stderr, "Nstars, Nave, Nmeas: %lld %lld %lld, (%lld matches)\n", (long long) Nstars, (long long) Nave, (long long) Nmeas, (long long) Nmatch);
 
   free (catalog[0].found);
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/find_matches_closest_refstars.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/find_matches_closest_refstars.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/find_matches_closest_refstars.c	(revision 27295)
@@ -1,12 +1,12 @@
 # include "addstar.h"
 
-int find_matches_closest_refstars (SkyRegion *region, Stars **stars, int NstarsIn, Catalog *catalog, AddstarClientOptions options) {
-
-  int i, j, n, N, J, Jmin, status;
+int find_matches_closest_refstars (SkyRegion *region, Stars **stars, unsigned int NstarsIn, Catalog *catalog, AddstarClientOptions options) {
+
+  off_t i, j, n, N, J, Jmin, status;
   double RADIUS, RADIUS2, Rmin;
   double *X1, *Y1, *X2, *Y2;
   double dX, dY, dR;
-  int *N1, *N2, *next_meas;
-  int Nave, NAVE, Nmeas, NMEAS, Nstars, Nmatch;
+  off_t *N1, *N2, *next_meas;
+  off_t Nave, NAVE, Nmeas, NMEAS, Nstars, Nmatch;
   unsigned int objID, catID;
   Coords tcoords;
@@ -24,5 +24,5 @@
   ALLOCATE (X1, double, NstarsIn);
   ALLOCATE (Y1, double, NstarsIn);
-  ALLOCATE (N1, int,    NstarsIn);
+  ALLOCATE (N1, off_t,  NstarsIn);
 
   /** allocate local arrays (catalog) **/
@@ -30,6 +30,6 @@
   ALLOCATE (X2, double, NAVE);
   ALLOCATE (Y2, double, NAVE);
-  ALLOCATE (N2, int, NAVE);
-  ALLOCATE (catalog[0].found, int, NAVE);
+  ALLOCATE (N2, off_t,  NAVE);
+  ALLOCATE (catalog[0].found, off_t, NAVE);
   /* for secfilt j and star i, secfilt[i*Nsecfilt+j] */
 
@@ -164,5 +164,5 @@
     if (Nmeas >= NMEAS) {
       NMEAS = Nmeas + 1000;
-      REALLOCATE (next_meas, int, NMEAS);
+      REALLOCATE (next_meas, off_t, NMEAS);
       REALLOCATE (catalog[0].measure, Measure, NMEAS);
     }
@@ -239,5 +239,5 @@
     if (Nmeas >= NMEAS - NREFSTAR_GROUP) {
       NMEAS = Nmeas + 1000;
-      REALLOCATE (next_meas, int, NMEAS);
+      REALLOCATE (next_meas, off_t, NMEAS);
       REALLOCATE (catalog[0].measure, Measure, NMEAS);
     }
@@ -351,5 +351,5 @@
   catalog[0].Nmeasure = Nmeas;
   catalog[0].Nsecf_mem = Nave*Nsecfilt;
-  if (VERBOSE) fprintf (stderr, "Nstars, Nave, Nmeas: %d %d %d, (%d matches)\n", Nstars, Nave, Nmeas, Nmatch);
+  if (VERBOSE) fprintf (stderr, "Nstars, Nave, Nmeas: %lld %lld %lld, (%lld matches)\n", (long long) Nstars, (long long) Nave, (long long) Nmeas, (long long) Nmatch);
 
   free (catalog[0].found);
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/find_matches_refstars.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/find_matches_refstars.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/find_matches_refstars.c	(revision 27295)
@@ -1,12 +1,12 @@
 # include "addstar.h"
 
-int find_matches_refstars (SkyRegion *region, Stars **stars, int Nstars, Catalog *catalog, AddstarClientOptions options) {
-
-  int i, j, n, N, J;
+int find_matches_refstars (SkyRegion *region, Stars **stars, unsigned int Nstars, Catalog *catalog, AddstarClientOptions options) {
+
+  off_t i, j, n, N, J;
   double RADIUS, RADIUS2;
   double *X1, *Y1, *X2, *Y2;
   double dX, dY, dR;
-  int *N1, *N2,  *next_meas;
-  int Nave, NAVE, Nmeas, NMEAS, Nmatch;
+  off_t *N1, *N2,  *next_meas;
+  off_t Nave, NAVE, Nmeas, NMEAS, Nmatch;
   unsigned int objID, catID;
   Coords tcoords;
@@ -24,5 +24,5 @@
   ALLOCATE (X1, double, Nstars);
   ALLOCATE (Y1, double, Nstars);
-  ALLOCATE (N1, int,   Nstars);
+  ALLOCATE (N1, off_t,  Nstars);
 
   /** allocate local arrays (catalog) **/
@@ -31,6 +31,6 @@
   ALLOCATE (X2, double, NAVE);
   ALLOCATE (Y2, double, NAVE);
-  ALLOCATE (N2, int, NAVE);
-  ALLOCATE (catalog[0].found, int, NAVE);
+  ALLOCATE (N2, off_t,  NAVE);
+  ALLOCATE (catalog[0].found, off_t, NAVE);
   REALLOCATE (catalog[0].average, Average, NAVE);
   REALLOCATE (catalog[0].secfilt, SecFilt, NAVE*catalog[0].Nsecfilt);
@@ -124,5 +124,5 @@
       if (Nmeas == NMEAS) {
 	NMEAS = Nmeas + 1000;
-	REALLOCATE (next_meas, int, NMEAS);
+	REALLOCATE (next_meas, off_t, NMEAS);
 	REALLOCATE (catalog[0].measure, Measure, NMEAS);
       }
@@ -209,5 +209,5 @@
     if (Nmeas >= NMEAS - NREFSTAR_GROUP) {
       NMEAS = Nmeas + 1000;
-      REALLOCATE (next_meas, int, NMEAS);
+      REALLOCATE (next_meas, off_t, NMEAS);
       REALLOCATE (catalog[0].measure, Measure, NMEAS);
     }
@@ -325,5 +325,5 @@
   catalog[0].Nmeasure = Nmeas;
   catalog[0].Nsecf_mem = Nave*Nsecfilt;
-  if (VERBOSE) fprintf (stderr, "Nstars, Nave, Nmeas: %d %d %d, (%d matches)\n", Nstars, Nave, Nmeas, Nmatch);
+  if (VERBOSE) fprintf (stderr, "Nstars, Nave, Nmeas: %lld %lld %lld, (%lld matches)\n", (long long) Nstars, (long long) Nave, (long long) Nmeas, (long long) Nmatch);
 
   free (catalog[0].found);
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/find_subset.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/find_subset.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/find_subset.c	(revision 27295)
@@ -2,5 +2,5 @@
 
 /* find stars within this region */
-Stars **find_subset (SkyRegion *region, Stars *stars, int Nstars, int *Nsubset) {
+Stars **find_subset (SkyRegion *region, Stars *stars, unsigned int Nstars, unsigned int *Nsubset) {
 
   int i, N, NSUBSET;
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/get2mass.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/get2mass.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/get2mass.c	(revision 27295)
@@ -2,5 +2,5 @@
 # include "2mass.h"
 
-Stars *get2mass (SkyRegion *patch, int photcode, int mode, int *NSTARS) {
+Stars *get2mass (SkyRegion *patch, int photcode, int mode, unsigned int *NSTARS) {
   
   char *path;
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/getgsc.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/getgsc.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/getgsc.c	(revision 27295)
@@ -7,5 +7,5 @@
 static SkyTable *sky = NULL;
 
-Stars *getgsc (SkyRegion *patch, int *NSTARS) {
+Stars *getgsc (SkyRegion *patch, unsigned int *NSTARS) {
   
   int i, Ngsc, Nstars; 
@@ -45,5 +45,5 @@
 }  
 
-Stars *rd_gsc (char *filename, int *nstars) {
+Stars *rd_gsc (char *filename, unsigned int *nstars) {
   
   int i, NSTARS, Nstars, Nbytes, nbytes, Nline, Nbyte;
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/gettycho.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/gettycho.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/gettycho.c	(revision 27295)
@@ -6,5 +6,5 @@
 static SkyTable *tychoTable = NULL;
 
-Stars *gettycho (SkyRegion *catstats, int photcode, int *nstars) {
+Stars *gettycho (SkyRegion *catstats, int photcode, unsigned int *nstars) {
 
   int i, j, nitems;
@@ -13,5 +13,5 @@
   FILE *f;
   int NTYCHO, Ntycho;
-  int firstRow, firstByte;
+  off_t firstRow, firstByte;
   short int TYCHO_B, TYCHO_V;
   e_time TychoEpoch;
@@ -60,7 +60,7 @@
 			  region[0].Rmin, region[0].Rmax, region[0].Dmin, region[0].Dmax);
 
-    firstRow  = atoi (region[0].name);
+    firstRow  = strtol (region[0].name, NULL, 0);
     firstByte = firstRow * NBYTE;
-    fseek (f, firstByte, SEEK_SET);
+    fseeko (f, firstByte, SEEK_SET);
 
     while (1) {
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/getusno.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/getusno.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/getusno.c	(revision 27295)
@@ -4,7 +4,7 @@
 # define NELEM  3
 
-Stars *getusno (SkyRegion *catstats, int photcode, int *nstars) {
+Stars *getusno (SkyRegion *catstats, int photcode, unsigned int *nstars) {
 
-  long int offset;
+  off_t offset;
   int i, bin, first, last, nitems, Nitems, Nbins, Nstars;
   float hours[100];
@@ -84,5 +84,5 @@
     /* advance file pointer to first slice */
     offset = NELEM*NBYTE*(start[first] - 1);
-    fseek (f, offset, SEEK_SET);
+    fseeko (f, offset, SEEK_SET);
 
     /* sum the number of stars in data segment of interest */
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/getusnob.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/getusnob.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/getusnob.c	(revision 27295)
@@ -3,7 +3,7 @@
 # define NELEM  20
 
-Stars *getusnob (SkyRegion *catstats, int photcode, int *nstars) {
+Stars *getusnob (SkyRegion *catstats, int photcode, unsigned int *nstars) {
 
-  long int offset;
+  off_t offset;
   int i, bin, first, last, nitems, Nitems, Nbins, Nitemsum;
   float hours[100];
@@ -93,5 +93,5 @@
     /* advance file pointer to first slice */
     offset = NELEM*NBYTE*(start[first] - 1);
-    fseek (f, offset, SEEK_SET);
+    fseeko (f, offset, SEEK_SET);
 
     /* sum the number of stars in data segment of interest */
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/greference.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/greference.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/greference.c	(revision 27295)
@@ -3,5 +3,5 @@
 # define LOAD_DR2    1
 
-Stars *greference (char *Refcat, SkyRegion *region, int photcode, int *nstars) {
+Stars *greference (char *Refcat, SkyRegion *region, int photcode, unsigned int *nstars) {
 
   int Nstars;
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/grefstars.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/grefstars.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/grefstars.c	(revision 27295)
@@ -2,5 +2,5 @@
 
 /* read ASCII file with ref star data */
-Stars *grefstars (char *file, int photcode, int *Nstars) {
+Stars *grefstars (char *file, int photcode, unsigned int *Nstars) {
 
   FILE *f;
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/gztest.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/gztest.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/gztest.c	(revision 27295)
@@ -5,5 +5,6 @@
 main (int argc, char **argv) {
 
-  int N, Nread, Nseek, Nback;
+  off_t Nseek, Nback;
+  int N, Nread;
   char *filename, *buffer;
   gzFile gf;
@@ -66,5 +67,5 @@
 
     gettimeofday (&start, NULL);
-    N = fseek (f, Nseek, SEEK_SET);
+    N = fseeko (f, Nseek, SEEK_SET);
     gettimeofday (&stop, NULL);
     if (N) {
@@ -84,5 +85,5 @@
 
     gettimeofday (&start, NULL);
-    N = fseek (f, Nback, SEEK_CUR);
+    N = fseeko (f, Nback, SEEK_CUR);
     gettimeofday (&stop, NULL);
     if (N) {
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/resort_catalog.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/resort_catalog.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/resort_catalog.c	(revision 27295)
@@ -3,6 +3,6 @@
 void resort_catalog (Catalog *catalog) {
 
-  int *next_meas;
-  int Naves, Nmeas;
+  off_t *next_meas;
+  off_t Naves, Nmeas;
   double dtime;
   struct timeval start, stop;
@@ -24,5 +24,5 @@
   gettimeofday (&stop, NULL);
   dtime = DTIME (stop, start);
-  fprintf (stderr, "  match time %9.4f sec for %7d measures, %6d average\n", dtime, Nmeas, Naves);
+  fprintf (stderr, "  match time %9.4f sec for %7lld measures, %6lld average\n", dtime, (long long) Nmeas, (long long) Naves);
 
   return;
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/update_coords.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/update_coords.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/addstar/src/update_coords.c	(revision 27295)
@@ -2,7 +2,7 @@
 
 /* find the average and scatter for R and D - no outlier rejection */
-void update_coords (Average *average, Measure *measure, int *next) {
+void update_coords (Average *average, Measure *measure, off_t *next) {
 
-  int i, m, Npt;
+  off_t i, m, Npt;
   double R, D, r, d;
   double r2, d2, dR2, dD2;
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/delstar/src/gimages.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/delstar/src/gimages.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/delstar/src/gimages.c	(revision 27295)
@@ -25,5 +25,5 @@
     Shutdown ("ERROR: can't find data file %s", filename);
   }
-  fseek (f, header.size, SEEK_SET); 
+  fseeko (f, header.datasize, SEEK_SET); 
 
   /* add file name to image structure */
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/dvomerge/src/merge_catalogs.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/dvomerge/src/merge_catalogs.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/dvomerge/src/merge_catalogs.c	(revision 27295)
@@ -5,6 +5,6 @@
 int merge_catalogs_new (Catalog *output, Catalog *input) {
   
-  int i, j, offset;
-  int NAVERAGE, NMEASURE, Naverage, Nmeasure, Nsecfilt, Nm;
+  off_t i, j, offset;
+  off_t NAVERAGE, NMEASURE, Naverage, Nmeasure, Nsecfilt, Nm;
 
   Naverage = output[0].Naverage;
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/dvomerge/src/merge_catalogs_new.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/dvomerge/src/merge_catalogs_new.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/dvomerge/src/merge_catalogs_new.c	(revision 27295)
@@ -9,6 +9,6 @@
 int merge_catalogs_new (SkyRegion *region, Catalog *output, Catalog *input) {
   
-  int i, j, offset;
-  int NAVERAGE, NMEASURE, Naverage, Nmeasure, Nsecfilt, Nm;
+  off_t i, j, offset;
+  off_t NAVERAGE, NMEASURE, Naverage, Nmeasure, Nsecfilt, Nm;
 
   Naverage = output[0].Naverage;
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/dvomerge/src/merge_catalogs_old.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/dvomerge/src/merge_catalogs_old.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/dvomerge/src/merge_catalogs_old.c	(revision 27295)
@@ -9,10 +9,10 @@
 int merge_catalogs_old (SkyRegion *region, Catalog *output, Catalog *input, double RADIUS) {
 
-  int i, j, n, N, Nin, offset, J, Jmin, status, Nstars;
+  off_t i, j, n, N, Nin, offset, J, Jmin, status, Nstars;
   double RADIUS2, Rmin, Rin, Din;
   double *X1, *Y1, *X2, *Y2;
   double dX, dY, dR;
-  int *N1, *N2,  *next_meas;
-  int Nave, NAVE, Nmeas, NMEAS, Nmatch;
+  off_t *N1, *N2,  *next_meas;
+  off_t Nave, NAVE, Nmeas, NMEAS, Nmatch;
   int Nsecfilt;
   unsigned int objID, catID;
@@ -24,6 +24,6 @@
   ALLOCATE (X1, double, input[0].Naverage);
   ALLOCATE (Y1, double, input[0].Naverage);
-  ALLOCATE (N1, int,    input[0].Naverage);
-  ALLOCATE (input[0].found, int, input[0].Naverage);
+  ALLOCATE (N1, off_t,  input[0].Naverage);
+  ALLOCATE (input[0].found, off_t, input[0].Naverage);
 
   /** allocate local arrays (catalog) **/
@@ -31,6 +31,6 @@
   ALLOCATE (X2, double, NAVE);
   ALLOCATE (Y2, double, NAVE);
-  ALLOCATE (N2, int,    NAVE);
-  ALLOCATE (output[0].found, int, NAVE);
+  ALLOCATE (N2, off_t,    NAVE);
+  ALLOCATE (output[0].found, off_t, NAVE);
   /* for secfilt j and star i, secfilt[i*Nsecfilt+j] */
 
@@ -157,5 +157,5 @@
     if (Nmeas + input[0].average[N].Nmeasure >= NMEAS) {
       NMEAS = Nmeas + input[0].average[N].Nmeasure + 1000;
-      REALLOCATE (next_meas, int, NMEAS);
+      REALLOCATE (next_meas, off_t, NMEAS);
       REALLOCATE (output[0].measure, Measure, NMEAS);
     }
@@ -220,5 +220,5 @@
     if (Nmeas + input[0].average[N].Nmeasure >= NMEAS) {
       NMEAS = Nmeas + input[0].average[N].Nmeasure + 1000;
-      REALLOCATE (next_meas, int, NMEAS);
+      REALLOCATE (next_meas, off_t, NMEAS);
       REALLOCATE (output[0].measure, Measure, NMEAS);
     }
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/elixir/src/DumpStatus.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/elixir/src/DumpStatus.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/elixir/src/DumpStatus.c	(revision 27295)
@@ -18,5 +18,5 @@
     f = fsetlockfile (filename, 0.1, LCK_XCLD, &state);
     if (f == NULL) return (2);
-    fseek (f, 0, SEEK_END);
+    fseeko (f, 0, SEEK_END);
   }  
   
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/elixir/src/MachineOps.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/elixir/src/MachineOps.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/elixir/src/MachineOps.c	(revision 27295)
@@ -454,5 +454,5 @@
     f = fsetlockfile (filename, 0.1, LCK_XCLD, &state);
     if (f == NULL) return (2);
-    fseek (f, 0, SEEK_END);
+    fseeko (f, 0, SEEK_END);
   }  
 
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/elixir/src/MsgOps.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/elixir/src/MsgOps.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/elixir/src/MsgOps.c	(revision 27295)
@@ -99,5 +99,5 @@
 
   /* write message to end of file */
-  fseek (f, 0, SEEK_END);
+  fseeko (f, 0, SEEK_END);
   fprintf (f, "%s\n", message);
 
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/fixcat/src/aregion.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/fixcat/src/aregion.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/fixcat/src/aregion.c	(revision 27295)
@@ -79,5 +79,5 @@
     NLINES += NDecLines[i];
   }
-  fseek (f, 5*2880 + 48*NLINES, SEEK_SET);
+  fseeko (f, 5*2880 + 48*NLINES, SEEK_SET);
       
   done = FALSE;
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/fixcat/src/find_bright_stars.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/fixcat/src/find_bright_stars.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/fixcat/src/find_bright_stars.c	(revision 27295)
@@ -6,10 +6,11 @@
 {
 
-  int i, j, n, m, first_j, Nave, Ngsc;
+  int j, n, m, first_j, Ngsc;
   Catalog GSCdata;
   double MinRA, MinDEC, MaxRA, MaxDEC, RaCenter, DecCenter;
   Coords *tcoords;
   double *X1, *Y1, *X2, *Y2;
-  int *N1, *N2;
+  off_t i, Nave;
+  off_t *N1, *N2;
   char *mark;
   double dX, dY, dR, MaxDist, MaxDist1, MaxRadius, radius, radius2;
@@ -27,5 +28,5 @@
   ALLOCATE (X1, double, Ngsc);
   ALLOCATE (Y1, double, Ngsc);
-  ALLOCATE (N1, int, Ngsc);
+  ALLOCATE (N1, off_t, Ngsc);
   ALLOCATE (mark, char, Nave);
   bzero (mark, Nave);
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/fixcat/src/find_images.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/fixcat/src/find_images.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/fixcat/src/find_images.c	(revision 27295)
@@ -73,5 +73,5 @@
     exit (0);
   }
-  fseek (f, header.size, SEEK_SET); 
+  fseeko (f, header.datasize, SEEK_SET); 
 
   /* set up buffers for images, temporary storage */
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/fixcat/src/find_matches.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/fixcat/src/find_matches.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/fixcat/src/find_matches.c	(revision 27295)
@@ -11,5 +11,5 @@
   double *X1, *Y1, *X2, *Y2;
   double dX, dY, dR;
-  int *N1, *N2;
+  off_t *N1, *N2;
   int Nstar, Nghost, Ng;
   unsigned int flags;
@@ -29,5 +29,5 @@
   ALLOCATE (X1, double, Nghost);
   ALLOCATE (Y1, double, Nghost);
-  ALLOCATE (N1, int, Nghost);
+  ALLOCATE (N1, off_t, Nghost);
 
   /* project ghosts to the frame of the catalog */
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/fixcat/src/gcatalog.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/fixcat/src/gcatalog.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/fixcat/src/gcatalog.c	(revision 27295)
@@ -28,5 +28,5 @@
     exit (0);
   }
-  fseek (f, catalog[0].header.size, SEEK_SET); 
+  fseeko (f, catalog[0].header.datasize, SEEK_SET); 
 
   /** find number of stars, measurements **/
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/fixcat/src/gcatstats.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/fixcat/src/gcatstats.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/fixcat/src/gcatstats.c	(revision 27295)
@@ -6,9 +6,8 @@
 {
 
-  int i;
+  off_t i;
   double RaCenter, DecCenter;
   double MinRA, MaxRA, MinDEC, MaxDEC;
   double *X1, *Y1;
-  int *N1;
   Coords tcoords;
   
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/fixcat/src/wcatalog.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/fixcat/src/wcatalog.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/fixcat/src/wcatalog.c	(revision 27295)
@@ -1,10 +1,8 @@
 # include "markstar.h"
 
-wcatalog (catname, catalog)
-char *catname;
-Catalog catalog[];
-{
+int wcatalog (char *catname, catalog *catalog) {
   
-  int i, Nitems, nitems, status, mode;
+  int status, mode;
+  off_t i, Nitems, nitems;
   char filename[128], line[256];
   FILE *f;
@@ -36,11 +34,11 @@
   chmod (filename, mode);
   
-  gfits_modify (&catalog[0].header, "NSTARS", "%d", 1, catalog[0].Naverage);
-  gfits_modify (&catalog[0].header, "NMEAS", "%d", 1, catalog[0].Nmeasure);
-  gfits_modify (&catalog[0].header, "NMISS", "%d", 1, catalog[0].Nmissing);
+  gfits_modify (&catalog[0].header, "NSTARS", "%lld", 1, catalog[0].Naverage);
+  gfits_modify (&catalog[0].header, "NMEAS",  "%lld", 1, catalog[0].Nmeasure);
+  gfits_modify (&catalog[0].header, "NMISS",  "%lld", 1, catalog[0].Nmissing);
 
   gfits_modify (&catalog[0].header, "MARKSTAR", "%t", 1, TRUE);
 
-  nitems = Fwrite (catalog[0].header.buffer, 1, catalog[0].header.size, f, "char");
+  nitems = Fwrite (catalog[0].header.buffer, 1, catalog[0].header.datasize, f, "char");
   if (nitems != catalog[0].header.size) {
     fprintf (stderr, "ERROR: failed to write header\n");
@@ -71,4 +69,4 @@
   fclose (f);
 
+  return TRUE;
 }
-
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/gastro/src/getusno.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/gastro/src/getusno.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/gastro/src/getusno.c	(revision 27295)
@@ -11,5 +11,5 @@
 USNOdata *getusno (USNOstats *usnostats, CatStats *catstats, int *Nusno) {
 
-  long int offset;
+  off_t offset;
   int i, bin, first, last, nitems, Nitems, Nbins;
   float hours[100];
@@ -91,5 +91,5 @@
     /* advance file pointer to first slice */
     offset = 3*sizeof(int)*(start[first] - 1);
-    fseek (f, offset, SEEK_SET);
+    fseeko (f, offset, SEEK_SET);
     /* on each loop, load data from an RA slice of the catalog */
     for (bin = first; bin < last; bin++) {
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/gastro/src/gfit.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/gastro/src/gfit.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/gastro/src/gfit.c	(revision 27295)
@@ -8,5 +8,5 @@
   
   int i, j, iteration, Niter, last, halt, first_j, *Nextra, extras;
-  int *tmpN1, *tmpN2;
+  off_t *tmpN1, *tmpN2;
   double X_O, X_X, X_Y, dX;
   double Y_O, Y_X, Y_Y, dY;
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/gastro/src/gfitpoly.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/gastro/src/gfitpoly.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/gastro/src/gfitpoly.c	(revision 27295)
@@ -5,5 +5,5 @@
   int i, j, m, n, M, N;
   int first_j, last;
-  int *tmpN1, *tmpN2;
+  off_t *tmpN1, *tmpN2;
   int NORDER, NTERM, NPARS, NPOWR;
   double **sum, **xsum, **ysum;
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/gastro/src/gheader.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/gastro/src/gheader.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/gastro/src/gheader.c	(revision 27295)
@@ -5,5 +5,5 @@
   Header header;
   FILE *f, *g;
-  int i, oldsize, nbytes, status;
+  off_t i, oldsize, nbytes, status;
   char line[1024];
 
@@ -12,5 +12,5 @@
     exit(0);
   }
-  oldsize = header.size;
+  oldsize = header.datasize;
 
   /* validating the photcode name should be the job of DVO/addstar */
@@ -80,5 +80,5 @@
 
 skipstuff:
-  if (header.size > oldsize) {
+  if (header.datasize > oldsize) {
     if (VERBOSE) fprintf (stderr, "header expanded, creating new copy\n");
     sprintf (line, "mv %s %s~", file, file);
@@ -99,7 +99,7 @@
       exit(0);
     }
-    nbytes = fwrite (header.buffer, 1, header.size, g);
-    fseek (f, oldsize, SEEK_SET);
-    for (i = 0; (nbytes = fread (header.buffer, 1, header.size, f)) > 0; i++) {
+    nbytes = fwrite (header.buffer, 1, header.datasize, g);
+    fseeko (f, oldsize, SEEK_SET);
+    for (i = 0; (nbytes = fread (header.buffer, 1, header.datasize, f)) > 0; i++) {
       if (nbytes != fwrite (header.buffer, 1, nbytes, g)) {
 	fprintf (stderr, "ERROR: failure writing output data file\n");
@@ -116,6 +116,6 @@
     }
     
-    fseek (f, 0, SEEK_SET);
-    nbytes = fwrite (header.buffer, 1, header.size, f);
+    fseeko (f, 0, SEEK_SET);
+    nbytes = fwrite (header.buffer, 1, header.datasize, f);
     
     fclose (f);
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/gastro/src/gstars.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/gastro/src/gstars.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/gastro/src/gstars.c	(revision 27295)
@@ -162,5 +162,5 @@
     exit(0);
   }
-  fseek (f, header.size, SEEK_SET); 
+  fseeko (f, header.datasize, SEEK_SET); 
 
   N = nstar = 0;
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/gastro2/src/getusno.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/gastro2/src/getusno.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/gastro2/src/getusno.c	(revision 27295)
@@ -11,5 +11,5 @@
 int getusno (CatStats *catstats, RefCatalog *Ref) {
 
-  long int offset;
+  off_t offset;
   int i, bin, first, last, nitems, Nitems, Nbins;
   float hours[100];
@@ -86,5 +86,5 @@
     /* advance file pointer to first slice */
     offset = 3*sizeof(int)*(start[first] - 1);
-    fseek (f, offset, SEEK_SET);
+    fseeko (f, offset, SEEK_SET);
     /* on each loop, load data from an RA slice of the catalog */
     for (bin = first; bin < last; bin++) {
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/gastro2/src/getusnob.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/gastro2/src/getusnob.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/gastro2/src/getusnob.c	(revision 27295)
@@ -5,5 +5,5 @@
 int getusnob (CatStats *catstats, RefCatalog *Ref, double epoch) {
 
-  long int offset;
+  off_t offset;
   int i, bin, first, last, nitems, Nitems, Nbins;
   float hours[100];
@@ -76,5 +76,5 @@
     /* advance file pointer to first slice */
     offset = NELEM*NBYTE*(start[first] - 1);
-    fseek (f, offset, SEEK_SET);
+    fseeko (f, offset, SEEK_SET);
 
     /* sum the number of stars in data segment of interest */
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/gastro2/src/gheader2.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/gastro2/src/gheader2.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/gastro2/src/gheader2.c	(revision 27295)
@@ -6,5 +6,5 @@
   Header header;
   FILE *f, *g;
-  int i, oldsize, nbytes, status;
+  off_t i, oldsize, nbytes, status;
   char line[1024];
 
@@ -13,5 +13,5 @@
     exit(0);
   }
-  oldsize = header.size;
+  oldsize = header.datasize;
 
   /* check for insufficient number of stars */
@@ -59,5 +59,5 @@
 
 skipstuff:
-  if (header.size > oldsize) {
+  if (header.datasize > oldsize) {
     if (VERBOSE) fprintf (stderr, "header expanded, creating new copy\n");
     sprintf (line, "mv %s %s~", file, file);
@@ -78,7 +78,7 @@
       exit(0);
     }
-    nbytes = fwrite (header.buffer, 1, header.size, g);
-    fseek (f, oldsize, SEEK_SET);
-    for (i = 0; (nbytes = fread (header.buffer, 1, header.size, f)) > 0; i++) {
+    nbytes = fwrite (header.buffer, 1, header.datasize, g);
+    fseeko (f, oldsize, SEEK_SET);
+    for (i = 0; (nbytes = fread (header.buffer, 1, header.datasize, f)) > 0; i++) {
       if (nbytes != fwrite (header.buffer, 1, nbytes, g)) {
 	fprintf (stderr, "ERROR: failure writing output data file\n");
@@ -95,6 +95,6 @@
     }
     
-    fseek (f, 0, SEEK_SET);
-    nbytes = fwrite (header.buffer, 1, header.size, f);
+    fseeko (f, 0, SEEK_SET);
+    nbytes = fwrite (header.buffer, 1, header.datasize, f);
     
     fclose (f);
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/gastro2/src/gstars2.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/gastro2/src/gstars2.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/gastro2/src/gstars2.c	(revision 27295)
@@ -6,5 +6,6 @@
   char line[80];
   double det;
-  int NX, NY, Nskip, FoundAstrom, extend, naxis;
+  off_t Nskip;
+  int NX, NY, FoundAstrom, extend, naxis;
   StarData *stars;
   FILE *f;
@@ -21,5 +22,5 @@
   }
   /* this line should not be needed */
-  fseek (f, Target[0].header.size, SEEK_SET); 
+  fseeko (f, Target[0].header.datasize, SEEK_SET); 
 
   NX = Target[0].header.Naxis[0];
@@ -128,5 +129,5 @@
   if ((naxis == 0) && !TEXTMODE) {
     Nskip = gfits_data_size (&Target[0].header);
-    fseek (f, Nskip, SEEK_CUR); 
+    fseeko (f, Nskip, SEEK_CUR); 
     stars = rfits (f, &Nstars);
   } else {
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/getstar/src/ReadImageFiles.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/getstar/src/ReadImageFiles.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/getstar/src/ReadImageFiles.c	(revision 27295)
@@ -4,5 +4,6 @@
 Image *ReadImageFiles (char *filename, int *Nimages) {
 
-  int i, j, N, Nfile, Nheader, NHEADER, Nimage, NIMAGE;
+  off_t Nskip, *extsize;
+  int i, j, N, Nfile, Nheader, Nimage, NHEADER, NIMAGE;
   int Nskip, Nhead, Ndata, done, status, mode;
   char **file, *name;
@@ -10,5 +11,5 @@
   glob_t globList;
   char **exthead, **extdata, **exttype, tmpword[80];
-  int *extnum_head, *extnum_data, *extsize;
+  int *extnum_head, *extnum_data;
   Header *header, **headers;
   Image *image;
@@ -89,5 +90,5 @@
   headers[0] = header;
   Nskip = gfits_data_size (header);
-  fseek (f, Nskip, SEEK_CUR); 
+  fseeko (f, Nskip, SEEK_CUR); 
 
   // load all headers into memory
@@ -118,5 +119,5 @@
   ALLOCATE (extnum_head, int, NIMAGE);
   ALLOCATE (extnum_data, int, NIMAGE);
-  ALLOCATE (extsize, int, Nheader);
+  ALLOCATE (extsize, off_t, Nheader);
 
   if (mode == MOSAIC_MEF) {
@@ -130,5 +131,5 @@
   // now examine the headers, count the table entries, find corresponding headers
   for (i = 0; i < Nheader; i++) {
-      extsize[i] = headers[i][0].size + gfits_data_size (headers[i]);
+      extsize[i] = headers[i][0].datasize + gfits_data_size (headers[i]);
       gfits_scan (headers[i], "EXTTYPE", "%s", 1, tmpword);
 
@@ -166,6 +167,6 @@
   // extension matched to the header in the PHU
   if (Nimage == 0) {
-      extsize[0] = headers[0][0].size + gfits_data_size (headers[0]);
-      extsize[1] = headers[1][0].size + gfits_data_size (headers[1]);
+      extsize[0] = headers[0][0].datasize + gfits_data_size (headers[0]);
+      extsize[1] = headers[1][0].datasize + gfits_data_size (headers[1]);
       gfits_scan (headers[1], "EXTNAME", "%s", 1, tmpword);
       if (!strcmp (tmpword, "SMPFILE")) {
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/gophot/src/gophot.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/gophot/src/gophot.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/gophot/src/gophot.c	(revision 27295)
@@ -26,5 +26,5 @@
   /* convert to float, set up noise array and axes */
   gfits_convert_format (&header, &matrix, -32, 1.0, 0.0, 0xffff, 0);
-  ALLOCATE (noise, float, matrix.size);
+  ALLOCATE (noise, float, matrix.datasize);
   big = (float *) matrix.buffer;
   nfast = matrix.Naxis[0];
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/imclean/src/wstars.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/imclean/src/wstars.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/imclean/src/wstars.c	(revision 27295)
@@ -14,5 +14,5 @@
   }
 
-  fwrite (header[0].buffer, 1, header[0].size, g);
+  fwrite (header[0].buffer, 1, header[0].datasize, g);
 
   for (i = 0; i < Nstars; i++) {
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/imregister/base/WriteFIFO.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/imregister/base/WriteFIFO.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/imregister/base/WriteFIFO.c	(revision 27295)
@@ -12,5 +12,5 @@
   }
 
-  fseek (f, 0, SEEK_END);
+  fseeko (f, 0LL, SEEK_END);
   fprintf (f, "%s\n", line);
 
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/imregister/imphot/rtext.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/imregister/imphot/rtext.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/imregister/imphot/rtext.c	(revision 27295)
@@ -4,5 +4,5 @@
 int rtext (FITS_DB *db) {
 
-  int Nimage, size, nimage;
+  off_t Nimage, size, nimage;
   struct stat filestatus;
   Image *image;
@@ -10,14 +10,14 @@
   /* check that file size makes sense */
   Nimage = 0;
-  gfits_scan (&db[0].header, "NIMAGES", "%d", 1, &Nimage);
+  gfits_scan (&db[0].header, "NIMAGES", "%lld", 1, &Nimage);
   if (stat (db[0].filename, &filestatus) == -1) {
     if (VERBOSE) fprintf (stderr, "ERROR: failed to get status of image catalog\n");
     exit (1);
   }
-  size = Nimage*sizeof(Image) + db[0].header.size;
+  size = Nimage*sizeof(Image) + db[0].header.datasize;
   if (size != filestatus.st_size) {
     int Ndata;
 
-    Ndata = (filestatus.st_size - db[0].header.size) / sizeof (Image);
+    Ndata = (filestatus.st_size - db[0].header.datasize) / sizeof (Image);
     if (VERBOSE) fprintf (stderr, "ERROR: image catalog has inconsistent size\n");
     if (VERBOSE) fprintf (stderr, "header: %d, data: %d\n", Nimage, Ndata);
@@ -41,7 +41,7 @@
   } 
   db[0].ftable.buffer = (char *) image;
-  gfits_modify (&db[0].theader, "NAXIS2", "%d", 1, Nimage);
+  gfits_modify (&db[0].theader, "NAXIS2", "%lld", 1, Nimage);
   db[0].theader.Naxis[1] = Nimage;
-  db[0].ftable.size = gfits_data_size (&db[0].theader);
+  db[0].ftable.datasize = gfits_data_size (&db[0].theader);
   
   return (TRUE);
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/imregister/src/imphotmerge.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/imregister/src/imphotmerge.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/imregister/src/imphotmerge.c	(revision 27295)
@@ -8,10 +8,11 @@
 int main (int argc, char **argv) {
  
+  off_t status, Nimage;
   Header header, theader;
   Image *image, *input;
   FILE *f, *g;
-  int i, j, status, N;
+  int i, j, N;
   char *dBFile;
-  int Nimage, Ninput, *index, Ntimes;
+  int Ninput, *index, Ntimes;
   time_t *tstart, *tstop;
   int VERBOSE, PHOTCODE, dbstate;
@@ -115,7 +116,7 @@
 
   /* position to begining of file to write header */
-  fseek (f, 0, SEEK_SET);
-  status = Fwrite (header.buffer, 1, header.size, f, "char");
-  if (status != header.size) {
+  fseeko (f, 0, SEEK_SET);
+  status = Fwrite (header.buffer, 1, header.datasize, f, "char");
+  if (status != header.datasize) {
     fprintf (stderr, "ERROR: failed writing data to image header\n");
     exit (0);
@@ -123,5 +124,5 @@
 
   /* position to end of file for new image data */
-  fseek (f, header.size, SEEK_SET);
+  fseeko (f, header.datasize, SEEK_SET);
   status = Fwrite (image, sizeof(Image), Nimage, f, "image");
   if (status != Nimage) {
@@ -137,7 +138,7 @@
 }
 
-Image *LoadImageTable (FILE *f, Header *header, int *nimage) {
+Image *LoadImageTable (FILE *f, Header *header, off_t *nimage) {
 
-  int Nimage, Ndata, Nread, size;
+  off_t Nimage, Ndata, Nread, size;
   struct stat filestatus;
   Image *image;
@@ -151,10 +152,10 @@
   /* check that file size makes sense */
   Nimage = 0;
-  gfits_scan (header, "NIMAGES", "%d", 1, &Nimage);
+  gfits_scan (header, "NIMAGES", "%lld", 1, &Nimage);
   if (fstat (fileno(f), &filestatus) == -1) {
     fprintf (stderr, "ERROR: failed to get status of image catalog\n");
     exit (1);
   }
-  size = Nimage*sizeof(Image) + header[0].size;
+  size = Nimage*sizeof(Image) + header[0].datasize;
   if (size != filestatus.st_size) {
     Ndata = (filestatus.st_size - header[0].size) / sizeof (Image);
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/kapa2/src/Image.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/kapa2/src/Image.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/kapa2/src/Image.c	(revision 27295)
@@ -11,5 +11,5 @@
 
   channel->coords.Npolyterms = 0;
-  channel->matrix.size = 0; /* a flag to show there is no data in the matrix */
+  channel->matrix.datasize = 0; /* a flag to show there is no data in the matrix */
   ALLOCATE (channel->matrix.buffer, char, 1);  /* allocate so later free will not crash! */
 
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/kapa2/src/LoadPicture.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/kapa2/src/LoadPicture.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/kapa2/src/LoadPicture.c	(revision 27295)
@@ -5,5 +5,5 @@
   Header header;
   char *buff;
-  int status, bytes_left;
+  off_t status, bytes_left;
   Section *section;
   KapaImageWidget *image;
@@ -24,5 +24,5 @@
   Xoffset = 0.0;
   Yoffset = 0.0;
-  if (image[0].image[0].matrix.size) {
+  if (image[0].image[0].matrix.datasize) {
     // XXX enforce int center here?
     Xoffset = image[0].picture.Xc - 0.5*image[0].image[0].matrix.Naxis[0];
@@ -41,5 +41,5 @@
 
   KiiScanMessage (sock, "%lf %lf %s %s",  &image[0].image[0].zero, &image[0].image[0].range, image[0].image[0].name, image[0].image[0].file);
-  KiiScanMessage (sock, "%lf %lf %d", &image[0].image[0].min,  &image[0].image[0].max, &header.size);
+  KiiScanMessage (sock, "%lf %lf %lld", &image[0].image[0].min,  &image[0].image[0].max, &header.datasize);
   KiiScanMessage (sock, "%lf %f %f %f %f", &image[0].image[0].coords.crval1, &image[0].image[0].coords.crpix1, &image[0].image[0].coords.cdelt1, &image[0].image[0].coords.pc1_1, &image[0].image[0].coords.pc1_2);
   KiiScanMessage (sock, "%lf %f %f %f %f", &image[0].image[0].coords.crval2, &image[0].image[0].coords.crpix2, &image[0].image[0].coords.cdelt2, &image[0].image[0].coords.pc2_1, &image[0].image[0].coords.pc2_2);
@@ -67,6 +67,6 @@
   status = 1;
   buff = image[0].image[0].matrix.buffer;
-  bytes_left = header.size;
-  image[0].image[0].matrix.size = 0;
+  bytes_left = header.datasize;
+  image[0].image[0].matrix.datasize = 0;
   while (bytes_left > 0) {
     status = read (sock, buff, bytes_left);
@@ -77,5 +77,5 @@
     }
     if (status != -1) { /* pipe has data */
-      image[0].image[0].matrix.size += status;
+      image[0].image[0].matrix.datasize += status;
       bytes_left -= status;
       buff = (char *)(buff + status);
@@ -85,8 +85,8 @@
   fcntl (sock, F_SETFL, !O_NONBLOCK);  
 
-  if (DEBUG) fprintf (stderr, "read %d bytes\n", image[0].image[0].matrix.size);
+  if (DEBUG) fprintf (stderr, "read %d bytes\n", image[0].image[0].matrix.datasize);
   /* it it not obvious this condition should kill kii, but ... */
-  if (image[0].image[0].matrix.size != header.size) {  
-    fprintf (stderr, "error: expected %d bytes, but got only %d\n", header.size, image[0].image[0].matrix.size);
+  if (image[0].image[0].matrix.datasize != header.datasize) {  
+    fprintf (stderr, "error: expected %lld bytes, but got only %lld\n", header.datasize, image[0].image[0].matrix.datasize);
     return (FALSE);
   }
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/libautocode/def/autocode.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/libautocode/def/autocode.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/libautocode/def/autocode.c	(revision 27295)
@@ -1,11 +1,11 @@
 # include "autocode.h"
 
-int gfits_convert_$STRUCT ($STRUCT *data, int size, int nitems) {
+int gfits_convert_$STRUCT ($STRUCT *data, off_t size, off_t nitems) {
 
-  int i;
+  off_t i;
   unsigned char *byte, tmp;
 
   if (size != $SIZE) { 
-    fprintf (stderr, "WARNING: mismatch in data types $STRUCT: %d vs %d\n", size, $SIZE);
+    fprintf (stderr, "WARNING: mismatch in data types $STRUCT: %lld vs %lld\n", (long long) size, (long long) $SIZE);
     return (FALSE);
   }
@@ -25,12 +25,12 @@
 } 
 
-$STRUCT *gfits_downsize_and_convert_$STRUCT ($STRUCT *data, int size, int nitems) {
+$STRUCT *gfits_downsize_and_convert_$STRUCT ($STRUCT *data, off_t size, off_t nitems) {
 
-  int i;
+  off_t i;
   unsigned char *byte, tmp;
   $STRUCT *output;
 
   if ($SIZE > size) { 
-    fprintf (stderr, "ERROR: uncorrectable mismatch in data types $STRUCT: %d vs %d\n", size, $SIZE);
+    fprintf (stderr, "ERROR: uncorrectable mismatch in data types $STRUCT: %lld vs %lld\n", (long long) size, (long long) $SIZE);
     exit (1);
   }
@@ -58,5 +58,5 @@
 /*** add test of EXTNAME and header-defined columns? ***/
 /* return internal structure representation */
-$STRUCT *gfits_table_get_$STRUCT (FTable *ftable, int *Ndata, int *swapped) {
+$STRUCT *gfits_table_get_$STRUCT (FTable *ftable, off_t *Ndata, char *swapped) {
 
   $STRUCT *data, *output;
@@ -68,5 +68,5 @@
       output = gfits_downsize_and_convert_$STRUCT (data, sizeof ($STRUCT), *Ndata);
       free (ftable[0].buffer);
-      ftable[0].buffer = output;
+      ftable[0].buffer = (char *) output;
       // XXX do I need to change NX?
     }
@@ -77,5 +77,5 @@
 }
 
-int gfits_table_set_$STRUCT (FTable *ftable, $STRUCT *data, int Ndata) {
+int gfits_table_set_$STRUCT (FTable *ftable, $STRUCT *data, off_t Ndata) {
 
   Header *header;
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/libautocode/def/autocode.h
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/libautocode/def/autocode.h	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/libautocode/def/autocode.h	(revision 27295)
@@ -2,8 +2,8 @@
 /** STRUCT DEFINITION **/
 
-$STRUCT *gfits_table_get_$STRUCT (FTable *table, int *Ndata, int *swapped);
-int      gfits_table_set_$STRUCT (FTable *ftable, $STRUCT *data, int Ndata);
+$STRUCT *gfits_table_get_$STRUCT (FTable *table, off_t *Ndata, char *swapped);
+int      gfits_table_set_$STRUCT (FTable *ftable, $STRUCT *data, off_t Ndata);
 int      gfits_table_mkheader_$STRUCT (Header *header);
-int      gfits_convert_$STRUCT ($STRUCT *data, int size, int nitems);
-int Send_$STRUCT (int device, $STRUCT *data, int Ndata, int copy);
-int Recv_$STRUCT (int device, $STRUCT **data, int *Ndata);
+int      gfits_convert_$STRUCT ($STRUCT *data, off_t size, off_t nitems);
+int      Send_$STRUCT (int device, $STRUCT *data, int Ndata, int copy);
+int      Recv_$STRUCT (int device, $STRUCT **data, int *Ndata);
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/libdvo/include/dvo.h
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/libdvo/include/dvo.h	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/libdvo/include/dvo.h	(revision 27295)
@@ -10,15 +10,16 @@
 
 /* DVO table formats */
-typedef enum {DVO_FORMAT_UNDEF, 
-	      DVO_FORMAT_INTERNAL, 
-	      DVO_FORMAT_ELIXIR, 
-	      DVO_FORMAT_LONEOS, 
-	      DVO_FORMAT_PANSTARRS_DEV_0,
-	      DVO_FORMAT_PANSTARRS_DEV_1,
-	      DVO_FORMAT_PS1_DEV_1,
-	      DVO_FORMAT_PS1_DEV_2,
-	      DVO_FORMAT_PS1_DEV_3,
-	      DVO_FORMAT_PS1_V1,
-	      DVO_FORMAT_PS1_REF
+typedef enum {
+  DVO_FORMAT_UNDEF, 
+  DVO_FORMAT_INTERNAL, 
+  DVO_FORMAT_ELIXIR, 
+  DVO_FORMAT_LONEOS, 
+  DVO_FORMAT_PANSTARRS_DEV_0,
+  DVO_FORMAT_PANSTARRS_DEV_1,
+  DVO_FORMAT_PS1_DEV_1,
+  DVO_FORMAT_PS1_DEV_2,
+  DVO_FORMAT_PS1_DEV_3,
+  DVO_FORMAT_PS1_V1,
+  DVO_FORMAT_PS1_REF
 } DVOTableFormat;
 
@@ -155,6 +156,4 @@
   FILE  *f;
   char  *filename;
-  int    dbstate;
-  int    lockstate;
   double timeout;
   Header header;
@@ -163,8 +162,10 @@
   FTable ftable;
   VTable vtable;
-  int    mode;          /* what data storage mode is used for disk file? */
-  int    format;        /* what data format is used for disk file? */
-  int    virtual;       /* is table in ftable or vtable? */
-  int    swapped;       /* is table in internal byte-order? */
+  int    dbstate;
+  char   lockstate;
+  char   mode;          /* what data storage mode is used for disk file? */
+  char   format;        /* what data format is used for disk file? */
+  char   virtual;       /* is table in ftable or vtable? */
+  char   swapped;       /* is table in internal byte-order? */
 } FITS_DB;
 
@@ -174,5 +175,5 @@
 /* SkyRegion : better implementation than GSCRegion */
 typedef struct {
-  int Nregions;
+  off_t Nregions;
   char **filename;
   SkyRegion *regions;
@@ -180,5 +181,5 @@
 
 typedef struct {
-  int Nregions;
+  off_t Nregions;
   int ownElements; 				  /* does this list own filename, regions? */
   char **filename;
@@ -187,13 +188,5 @@
 
 // special-case function:
-CMF_PS1_V2 *gfits_table_get_CMF_PS1_V1_Alt (FTable *ftable, int *Ndata, int *swapped);
-
-# if (0)
-/* structure for data on a catalog region */
-typedef struct {
-  char filename[256];
-  double DEC[2], RA[2];
-} GSCRegion;
-# endif
+CMF_PS1_V2 *gfits_table_get_CMF_PS1_V1_Alt (FTable *ftable, off_t *Ndata, char *swapped);
 
 typedef struct {
@@ -219,7 +212,9 @@
 
   int Nsecfilt;  /* number of secfilt entries for each average entry */
-  int Naverage,   Nmeasure,   Nmissing,   Nsecf_mem;  /* current number of each component in memory */
-  int Naves_disk, Nmeas_disk, Nmiss_disk, Nsecf_disk; /* current number of each component on disk */
-  int Naves_off,  Nmeas_off,  Nmiss_off,  Nsecf_off;  /* index of first loaded data value */
+  off_t Naverage,   Nmeasure,   Nmissing,   Nsecf_mem;  /* current number of each component in memory */
+  off_t Naves_disk, Nmeas_disk, Nmiss_disk, Nsecf_disk; /* current number of each component on disk */
+  off_t Naves_off,  Nmeas_off,  Nmiss_off,  Nsecf_off;  /* index of first loaded data value */
+
+  /* the Nsecf_* values above are number of table rows (eg, Naverage*Nsecfilt) */
 
   /* note the different counting for Nsecfilt:
@@ -239,14 +234,14 @@
 
   /* extra catalog information */
-  int lockmode;
-  int catmode;				/* storage mode (raw, mef, split, mysql) */
-  int catformat;			/* storage format (elixir, panstarrs, etc) */
-  int catflags;				/* choices to be loaded */
-  int sorted;				/* is measure table average-sorted? */
+  char lockmode;
+  char catmode;				/* storage mode (raw, mef, split, mysql) */
+  char catformat;			/* storage format (elixir, panstarrs, etc) */
+  char catflags;				/* choices to be loaded */
+  char sorted;				/* is measure table average-sorted? */
   
   /* pointers for data manipulation */
-  int *found;
-  int *image;
-  int *mosaic;
+  off_t *found;
+  off_t *image;
+  off_t *mosaic;
   float *X;
   float *Y;
@@ -261,5 +256,5 @@
 int   gfits_db_lock                PROTO((FITS_DB *db, char *filename));
 int   gfits_db_load                PROTO((FITS_DB *db));
-int   gfits_db_load_segment        PROTO((FITS_DB *db, int start, int Nrows));
+int   gfits_db_load_segment        PROTO((FITS_DB *db, off_t start, off_t Nrows));
 int   gfits_db_save                PROTO((FITS_DB *db));
 int   gfits_db_update              PROTO((FITS_DB *db));
@@ -348,12 +343,7 @@
 char *get_mode_name (int mode);
 
-/* these functions refer to the DVO structures defined in the includes above
- *  they are being replaced with autocode entries (drop when totally autocoded)
- */
-
+// read/write with byteswap for generic types
 int   Fread (void *ptr, int size, int nitems, FILE *f, char *type);
 int   Fwrite (void *ptr, int size, int nitems, FILE *f, char *type);
-int   ByteSwap (char *ptr, int size, int nitems, char *type);
-int   ConvertStruct (char *buffer, int size, int Nbytes, char *type);
 
 /** dvo_catalog APIs */
@@ -384,25 +374,25 @@
 int dvo_catalog_save_split_complete (Catalog *catalog, char VERBOSE);
 
-int dvo_catalog_load_segment (Catalog *catalog, int VERBOSE, int start, int Nrows);
-int dvo_catalog_load_segment_split (Catalog *catalog, int VERBOSE, int start, int Nrows);
+int dvo_catalog_load_segment (Catalog *catalog, int VERBOSE, off_t start, off_t Nrows);
+int dvo_catalog_load_segment_split (Catalog *catalog, int VERBOSE, off_t start, off_t Nrows);
 
 /*** conversion functions / I/O conversions ***/
-Average *ReadRawAverage (FILE *f, int Naverage, int format, SecFilt **primary);
-Measure *ReadRawMeasure (FILE *f, int Nmeasure, int format);
-SecFilt *ReadRawSecFilt (FILE *f, int Nsecfilt, int format);
-int WriteRawAverage (FILE *f, Average *average, int Naverage, int format, SecFilt *primary);
-int WriteRawMeasure (FILE *f, Measure *measure, int Nmeasure, int format);
-int WriteRawSecFilt (FILE *f, SecFilt *secfilt, int Nsecfilt, int format);
-
-Average *FtableToAverage (FTable *ftable, int *Naverage, int *format, SecFilt **primary);
-Measure *FtableToMeasure (FTable *ftable, int *Nmeasure, int *format);
-SecFilt *FtableToSecFilt (FTable *ftable, int *Nsecfilt, int *format);
-int FtableToImage (FTable *ftable, Header *theader, int *format);
-
-int AverageToFtable (FTable *ftable, Average *average, int Naverage, int format, SecFilt *primary);
-int MeasureToFtable (FTable *ftable, Measure *measure, int Nmeasure, int format);
-int SecFiltToFtable (FTable *ftable, SecFilt *secfilt, int Nsecfilt, int format);
-int ImageToFtable (FTable *ftable, Header *theader, int format);
-int ImageToVtable (VTable *vtable, Header *theader, int format);
+Average *ReadRawAverage (FILE *f, off_t Naverage, char format, SecFilt **primary);
+Measure *ReadRawMeasure (FILE *f, off_t Nmeasure, char format);
+SecFilt *ReadRawSecFilt (FILE *f, off_t Nsecfilt, char format);
+int WriteRawAverage (FILE *f, Average *average, off_t Naverage, char format, SecFilt *primary);
+int WriteRawMeasure (FILE *f, Measure *measure, off_t Nmeasure, char format);
+int WriteRawSecFilt (FILE *f, SecFilt *secfilt, off_t Nsecfilt, char format);
+
+Average *FtableToAverage (FTable *ftable, off_t *Naverage, char *format, SecFilt **primary);
+Measure *FtableToMeasure (FTable *ftable, off_t *Nmeasure, char *format);
+SecFilt *FtableToSecFilt (FTable *ftable, off_t *Nsecfilt, char *format);
+int      FtableToImage   (FTable *ftable, Header *theader, char *format);
+
+int AverageToFtable (FTable *ftable, Average *average, off_t Naverage, char format, SecFilt *primary);
+int MeasureToFtable (FTable *ftable, Measure *measure, off_t Nmeasure, char format);
+int SecFiltToFtable (FTable *ftable, SecFilt *secfilt, off_t Nsecfilt, char format);
+int ImageToFtable (FTable *ftable, Header *theader, char format);
+int ImageToVtable (VTable *vtable, Header *theader, char format);
 
 # include "loneos_defs.h"
@@ -425,5 +415,5 @@
 int dvo_image_update_raw (FITS_DB *db, int VERBOSE);
 int dvo_image_save_raw (FITS_DB *db, int VERBOSE);
-int dvo_image_addrows (FITS_DB *db, Image *new, int Nnew);
+int dvo_image_addrows (FITS_DB *db, Image *new, off_t Nnew);
 void dvo_image_create (FITS_DB *db, double ZeroPoint);
 
@@ -454,8 +444,8 @@
 
 /* dvo-specific sorting functions */
-void sortave (Average *ave, int N);
-void sort_image_subset (Image *image, int *subset, int N);
-void sort_coords_index (double *X, double *Y, int *S, int N);
-void sort_regions (SkyRegion *region, int N);
+void sortave (Average *ave, off_t N);
+void sort_image_subset (Image *image, off_t *subset, off_t N);
+void sort_coords_index (double *X, double *Y, off_t *S, off_t N);
+void sort_regions (SkyRegion *region, off_t N);
 
 # endif
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/libdvo/include/dvo_util.h
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/libdvo/include/dvo_util.h	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/libdvo/include/dvo_util.h	(revision 27295)
@@ -9,19 +9,19 @@
 
 typedef struct {
-    char        gscfile[256];
-    char        catdir[256];
-    char        catmode[256];
-    char        catformat[256];
-    char        photcodeFile[256];
-    char        skyTableFile[256];
-    int         skyDepth;
-    FITS_DB     imageDB;
-    Image       *images;
-    int         nImages;
-    SkyTable    *skyTable;
+  char        gscfile[256];
+  char        catdir[256];
+  char        catmode[256];
+  char        catformat[256];
+  char        photcodeFile[256];
+  char        skyTableFile[256];
+  int         skyDepth;
+  FITS_DB     imageDB;
+  Image       *images;
+  off_t       nImages;
+  SkyTable    *skyTable;
 #if (DVO_UTIL_READ_CAMERA_CONFIG)
-    char        cameraConfig[256];
-    int         *ccdNum;
-    int         nCCD;
+  char        cameraConfig[256];
+  int         *ccdNum;
+  int         nCCD;
 #endif
 } dvoConfig;
@@ -29,13 +29,13 @@
 // This structure needs to be fleshed out
 typedef struct {
-    int         valid;
-    Average     ave;
-    Measure     meas;
+  int         valid;
+  Average     ave;
+  Measure     meas;
 #ifdef notdef
-    int         objID;
-    int         catID;
-    int         detID;
-    uint64_t    pspsObjID;
-    uint64_t    pspsDetID;
+  int         objID;
+  int         catID;
+  int         detID;
+  uint64_t    pspsObjID;
+  uint64_t    pspsDetID;
 #endif
 } dvoDetection;
@@ -72,5 +72,5 @@
 // return a list of detectsions from a particular image id
 // Use dvoFree() to free the memory pointed to by results
-int dvoGetDetections(SkyList *skylist, int imageID, dvoDetection **results, int *pMaxDetID);
+off_t dvoGetDetections(SkyList *skylist, int imageID, dvoDetection **results, int *pMaxDetID);
 
 // free memory returned by various dvo util functions
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/libdvo/src/LoadPhotcodesFITS.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/libdvo/src/LoadPhotcodesFITS.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/libdvo/src/LoadPhotcodesFITS.c	(revision 27295)
@@ -11,5 +11,6 @@
   char extname[80];
 
-  int i, code, Ncode, Nsec, Nsecfilt;
+  int i, code, Nsec, Nsecfilt;
+  off_t Ncode;
 
   /* XXX choose more sensible lock timeouts! */
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/libdvo/src/cmf-ps1-v1-alt.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/libdvo/src/cmf-ps1-v1-alt.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/libdvo/src/cmf-ps1-v1-alt.c	(revision 27295)
@@ -1,7 +1,7 @@
 # include "dvo.h"
 
-CMF_PS1_V2 *gfits_table_get_CMF_PS1_V1_Alt (FTable *ftable, int *Ndata, int *swapped) {
+CMF_PS1_V2 *gfits_table_get_CMF_PS1_V1_Alt (FTable *ftable, off_t *Ndata, char *swapped) {
 
-  int i, nitems;
+  off_t i, nitems;
   unsigned char *byte, *inbyte, *otbyte, tmp;
   CMF_PS1_V2 *output;
@@ -13,5 +13,5 @@
   // this function is a special case : it must have Nx = 136
   if (ftable[0].header[0].Naxis[0] != 136) { 
-    fprintf (stderr, "ERROR: wrong format for CMF_PS1_V1_Alt: %d vs %d\n", ftable[0].header[0].Naxis[0], 136);
+    fprintf (stderr, "ERROR: wrong format for CMF_PS1_V1_Alt: %lld vs %d\n", (long long) ftable[0].header[0].Naxis[0], 136);
     exit (2);
   }
@@ -83,5 +83,5 @@
 
   free (ftable[0].buffer);
-  ftable[0].buffer = output;
+  ftable[0].buffer = (char *) output;
 
   // XXX other mods to make ftable consistent with CMF_PS1_V2? (Nx, EXTNAME?)
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/libdvo/src/coordops.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/libdvo/src/coordops.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/libdvo/src/coordops.c	(revision 27295)
@@ -307,5 +307,5 @@
   int i;
   double Ro, Xo, Yo;
-  double dX, dY, X, Y, Lo, Mo, dL, dM;
+  double dX, dY, Lo, Mo, dL, dM;
   double dLdX, dLdY, dMdX, dMdY, Do;
 
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/libdvo/src/dvo_catalog.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/libdvo/src/dvo_catalog.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/libdvo/src/dvo_catalog.c	(revision 27295)
@@ -141,5 +141,5 @@
   if (catalog[0].f == NULL)   return (DVO_CAT_OPEN_FAIL);
 
-  fseek (catalog[0].f, 0, SEEK_SET);
+  fseeko (catalog[0].f, 0, SEEK_SET);
   return (DVO_CAT_OPEN_OK);
 }
@@ -376,5 +376,6 @@
 int dvo_catalog_check (Catalog *catalog, int Nsecfilt, int extend) {
 
-  int i, j, Nextra, in, out;
+  off_t in, out, i;
+  int j, Nextra;
   SecFilt *insec, *outsec;
 
@@ -444,5 +445,5 @@
 */
 
-int dvo_catalog_load_segment (Catalog *catalog, int VERBOSE, int start, int Nrows) {
+int dvo_catalog_load_segment (Catalog *catalog, int VERBOSE, off_t start, off_t Nrows) {
 
   switch (catalog[0].catmode) {
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/libdvo/src/dvo_catalog_mef.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/libdvo/src/dvo_catalog_mef.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/libdvo/src/dvo_catalog_mef.c	(revision 27295)
@@ -3,5 +3,5 @@
 int dvo_catalog_load_mef (Catalog *catalog, int VERBOSE) {
   
-  int Nitems, Nbytes, Nexpect, Naverage, Nmeasure, Nmissing, Nsecfilt;
+  off_t Nitems, Nbytes, Nexpect, Naverage, Nmeasure, Nmissing, Nsecfilt;
   FILE *f;
 
@@ -15,5 +15,5 @@
 
   /* move pointer past header -- must be already read (load_catalog) */
-  fseek (f, catalog[0].header.size, SEEK_SET);
+  fseeko (f, catalog[0].header.datasize, SEEK_SET);
 
   /* matrix should be empty */
@@ -23,8 +23,8 @@
   }
   /* get the components from the header */
-  if (!gfits_scan (&catalog[0].header, "NSTARS",   "%d", 1, &Naverage)) return (FALSE);
-  if (!gfits_scan (&catalog[0].header, "NMEAS",    "%d", 1, &Nmeasure)) return (FALSE);
-  if (!gfits_scan (&catalog[0].header, "NMISS",    "%d", 1, &Nmissing)) return (FALSE);
-  if (!gfits_scan (&catalog[0].header, "NSECFILT", "%d", 1, &Nsecfilt)) Nsecfilt = 0;
+  if (!gfits_scan (&catalog[0].header, "NSTARS",   "%lld", 1, &Naverage)) return (FALSE);
+  if (!gfits_scan (&catalog[0].header, "NMEAS",    "%lld", 1, &Nmeasure)) return (FALSE);
+  if (!gfits_scan (&catalog[0].header, "NMISS",    "%lld", 1, &Nmissing)) return (FALSE);
+  if (!gfits_scan (&catalog[0].header, "NSECFILT", "%lld", 1, &Nsecfilt)) Nsecfilt = 0;
 
   /* the OBJID is a counter that uniquely defines an average entry and never changes.  if
@@ -72,5 +72,5 @@
     catalog[0].average = FtableToAverage (&ftable, &Naverage, &catalog[0].catformat, &primary);
     if (Naverage != catalog[0].Naves_disk) {
-      fprintf (stderr, "Warning: mismatch between Naverage in PHU and Table headers (%d vs %d)\n", Naverage, catalog[0].Naves_disk);
+      fprintf (stderr, "Warning: mismatch between Naverage in PHU and Table headers (%lld vs %lld)\n", (long long) Naverage, (long long) catalog[0].Naves_disk);
     }
     catalog[0].Naverage = catalog[0].Naves_disk;
@@ -78,5 +78,5 @@
   } else {
     Nbytes = gfits_data_size (&header);
-    fseek (f, Nbytes, SEEK_CUR);
+    fseeko (f, Nbytes, SEEK_CUR);
     ALLOCATE (catalog[0].average, Average, 1);
     catalog[0].Naverage = 0;
@@ -99,5 +99,5 @@
     catalog[0].measure = FtableToMeasure (&ftable, &catalog[0].Nmeasure, &catalog[0].catformat);
     if (Nmeasure != catalog[0].Nmeas_disk) {
-      fprintf (stderr, "Warning: mismatch between Nmeasure in PHU and Table headers (%d vs %d)\n", Nmeasure, catalog[0].Nmeas_disk);
+      fprintf (stderr, "Warning: mismatch between Nmeasure in PHU and Table headers (%lld vs %lld)\n", (long long) Nmeasure, (long long) catalog[0].Nmeas_disk);
     }
     catalog[0].Nmeasure = catalog[0].Nmeas_disk;
@@ -105,5 +105,5 @@
   } else {
     Nbytes = gfits_data_size (&header);
-    fseek (f, Nbytes, SEEK_CUR);
+    fseeko (f, Nbytes, SEEK_CUR);
     ALLOCATE (catalog[0].measure, Measure, 1);
     catalog[0].Nmeasure = 0;
@@ -125,5 +125,5 @@
     catalog[0].missing = gfits_table_get_Missing (&ftable, &catalog[0].Nmissing, NULL);
     if (Nmissing != catalog[0].Nmiss_disk) {
-      fprintf (stderr, "Warning: mismatch between Nmissing in PHU and Table headers (%d vs %d)\n", Nmissing, catalog[0].Nmiss_disk);
+      fprintf (stderr, "Warning: mismatch between Nmissing in PHU and Table headers (%lld vs %lld)\n", (long long) Nmissing, (long long) catalog[0].Nmiss_disk);
     }
     catalog[0].Nmissing = catalog[0].Nmiss_disk;
@@ -131,5 +131,5 @@
   } else {
     Nbytes = gfits_data_size (&header);
-    fseek (f, Nbytes, SEEK_CUR);
+    fseeko (f, Nbytes, SEEK_CUR);
     ALLOCATE (catalog[0].missing, Missing, 1);
     catalog[0].Nmissing = 0;
@@ -153,5 +153,5 @@
     catalog[0].secfilt = FtableToSecFilt (&ftable, &Nitems, &catalog[0].catformat);
     if (Nexpect != Nitems) {
-      fprintf (stderr, "Warning: mismatch between Nsecfilt items in PHU and Table headers (%d vs %d)\n", Nexpect, Nitems);
+      fprintf (stderr, "Warning: mismatch between Nsecfilt items in PHU and Table headers (%lld vs %lld)\n", (long long) Nexpect, (long long) Nitems);
     }
 
@@ -159,5 +159,5 @@
        we need to interleave these magnitudes with the secfilt entries just loaded */
     if (primary != NULL) {
-      int Ntmpfilt, Ntotal, i, j;
+      off_t Ntmpfilt, Ntotal, i, j;
       SecFilt *tmpfilt;
       tmpfilt  = catalog[0].secfilt;
@@ -182,5 +182,5 @@
     /* no real need to skip the data array here... */
     Nbytes = gfits_data_size (&header);
-    fseek (f, Nbytes, SEEK_CUR);
+    fseeko (f, Nbytes, SEEK_CUR);
     if (primary != NULL) {
       free (primary);
@@ -200,5 +200,5 @@
 int dvo_catalog_save_mef (Catalog *catalog, char VERBOSE) {
 
-  int Nitems;
+  off_t Nitems;
   FILE *f;
   Matrix matrix;
@@ -207,5 +207,5 @@
   SecFilt *primary;
   SecFilt *secfilt;
-  int i, j, Nsecfilt, Nallfilt, Ntotal;
+  off_t i, j, Nsecfilt, Nallfilt, Ntotal;
 
   if (catalog[0].Naverage == 0) {
@@ -236,8 +236,8 @@
 
   /* make sure header is consistent with data */
-  gfits_modify (&catalog[0].header, "NSTARS",   "%d", 1, catalog[0].Naverage);
-  gfits_modify (&catalog[0].header, "NMEAS",    "%d", 1, catalog[0].Nmeasure);
-  gfits_modify (&catalog[0].header, "NMISS",    "%d", 1, catalog[0].Nmissing);
-  gfits_modify (&catalog[0].header, "NSECFILT", "%d", 1, Nsecfilt);
+  gfits_modify (&catalog[0].header, "NSTARS",   "%lld", 1, catalog[0].Naverage);
+  gfits_modify (&catalog[0].header, "NMEAS",    "%lld", 1, catalog[0].Nmeasure);
+  gfits_modify (&catalog[0].header, "NMISS",    "%lld", 1, catalog[0].Nmissing);
+  gfits_modify (&catalog[0].header, "NSECFILT", "%lld", 1, Nsecfilt);
   gfits_modify (&catalog[0].header, "EXTEND",   "%t", 1, TRUE);
   gfits_modify (&catalog[0].header, "OBJID",    "%d", 1, catalog[0].objID);
@@ -245,5 +245,5 @@
   f = catalog[0].f;
   /* rewind file pointers and truncate */
-  fseek (f, 0, SEEK_SET);
+  fseeko (f, 0LL, SEEK_SET);
   ftruncate (fileno (catalog[0].f), 0);
   ftable.header = &header;
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/libdvo/src/dvo_catalog_raw.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/libdvo/src/dvo_catalog_raw.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/libdvo/src/dvo_catalog_raw.c	(revision 27295)
@@ -5,8 +5,8 @@
 int dvo_catalog_load_raw (Catalog *catalog, int VERBOSE) {
   
-  int Nitems, nitems;
-  int i, Nmeas, Nmiss, size;
-  int NewMeasure, Nskip;
-  int AverageSize, MeasureSize, MissingSize, SecFiltSize;
+  off_t Nitems, nitems;
+  off_t i, Nmeas, Nmiss, size;
+  off_t NewMeasure, Nskip;
+  off_t AverageSize, MeasureSize, MissingSize, SecFiltSize;
   FILE *f;
   struct stat filestatus;
@@ -17,12 +17,12 @@
 
   /* move pointer past header -- must be already read (load_catalog) */
-  fseek (f, catalog[0].header.size, SEEK_SET);
+  fseeko (f, catalog[0].header.datasize, SEEK_SET);
 
   /* get the components from the header */
   catalog[0].Naverage = catalog[0].Nmeasure = catalog[0].Nmissing = catalog[0].Nsecfilt = 0;
-  if (!gfits_scan (&catalog[0].header, "NSTARS",   "%d", 1, &catalog[0].Naverage)) return (FALSE);
-  if (!gfits_scan (&catalog[0].header, "NMEAS",    "%d", 1, &catalog[0].Nmeasure)) return (FALSE);
-  if (!gfits_scan (&catalog[0].header, "NMISS",    "%d", 1, &catalog[0].Nmissing)) return (FALSE);
-  if (!gfits_scan (&catalog[0].header, "NSECFILT", "%d", 1, &catalog[0].Nsecfilt)) catalog[0].Nsecfilt = 0;
+  if (!gfits_scan (&catalog[0].header, "NSTARS",   "%lld", 1, &catalog[0].Naverage)) return (FALSE);
+  if (!gfits_scan (&catalog[0].header, "NMEAS",    "%lld", 1, &catalog[0].Nmeasure)) return (FALSE);
+  if (!gfits_scan (&catalog[0].header, "NMISS",    "%lld", 1, &catalog[0].Nmissing)) return (FALSE);
+  if (!gfits_scan (&catalog[0].header, "NSECFILT", "%lld", 1, &catalog[0].Nsecfilt)) catalog[0].Nsecfilt = 0;
 
   /* the OBJID is a counter that uniquely defines an average entry and never changes.  if
@@ -98,5 +98,5 @@
 
   /* predicted file size - for double checking data validity */
-  size = catalog[0].header.size;
+  size = catalog[0].header.datasize;
   size += AverageSize * catalog[0].Naverage;
   size += MeasureSize * catalog[0].Nmeasure;
@@ -112,9 +112,9 @@
     if (VERBOSE) {
       fprintf (stderr, "star catalog has inconsistent size\n");
-      fprintf (stderr, "average: %d = %d bytes\n", catalog[0].Naverage, catalog[0].Naverage*AverageSize);
-      fprintf (stderr, "measure: %d = %d bytes\n", catalog[0].Nmeasure, catalog[0].Nmeasure*MeasureSize);
-      fprintf (stderr, "missing: %d = %d bytes\n", catalog[0].Nmissing, catalog[0].Nmissing*MissingSize);
-      fprintf (stderr, "secfilt: %d = %d bytes\n", catalog[0].Nsecfilt, catalog[0].Nsecfilt*SecFiltSize*catalog[0].Naverage);
-      fprintf (stderr, "expect: %d, found: %d\n", size, (int)filestatus.st_size);
+      fprintf (stderr, "average: %lld = %lld bytes\n", (long long) catalog[0].Naverage, (long long) catalog[0].Naverage*AverageSize);
+      fprintf (stderr, "measure: %lld = %lld bytes\n", (long long) catalog[0].Nmeasure, (long long) catalog[0].Nmeasure*MeasureSize);
+      fprintf (stderr, "missing: %lld = %lld bytes\n", (long long) catalog[0].Nmissing, (long long) catalog[0].Nmissing*MissingSize);
+      fprintf (stderr, "secfilt: %lld = %lld bytes\n", (long long) catalog[0].Nsecfilt, (long long) catalog[0].Nsecfilt*SecFiltSize*catalog[0].Naverage);
+      fprintf (stderr, "expect: %lld, found: %lld\n", (long long) size, (long long) filestatus.st_size);
     }
     return (FALSE);
@@ -136,5 +136,5 @@
     /* skip over averages */
     Nskip = catalog[0].Naverage * AverageSize;
-    fseek (f, Nskip, SEEK_CUR); 
+    fseeko (f, Nskip, SEEK_CUR); 
   }    
   
@@ -145,5 +145,5 @@
     /* skip over measures */
     Nskip = catalog[0].Nmeasure * MeasureSize;
-    fseek (f, Nskip, SEEK_CUR); 
+    fseeko (f, Nskip, SEEK_CUR); 
   }    
 
@@ -154,5 +154,5 @@
     nitems = fread (catalog[0].missing, MissingSize, Nitems, f);
     if (nitems != Nitems) {
-      if (VERBOSE) fprintf (stderr, "failed to read missing from catalog file %s (%d vs %d)\n", catalog[0].filename, nitems, Nitems);
+      if (VERBOSE) fprintf (stderr, "failed to read missing from catalog file %s (%lld vs %lld)\n", catalog[0].filename, (long long) nitems, (long long) Nitems);
       return (FALSE);
     }
@@ -161,5 +161,5 @@
     /* skip over missings */
     Nskip = catalog[0].Nmissing * MissingSize;
-    fseek (f, Nskip, SEEK_CUR); 
+    fseeko (f, Nskip, SEEK_CUR); 
   }
   
@@ -172,5 +172,5 @@
        we need to interleave these magnitudes with the secfilt entries just loaded */
     if (primary != NULL) {
-      int Ntmpfilt, Nsecfilt, Ntotal, i, j;
+      off_t Ntmpfilt, Nsecfilt, Ntotal, i, j;
       SecFilt *tmpfilt;
       tmpfilt  = catalog[0].secfilt;
@@ -193,10 +193,14 @@
     /* skip over secfilts */
     Nskip = catalog[0].Nsecfilt * catalog[0].Naverage * SecFiltSize;
-    fseek (f, Nskip, SEEK_CUR); 
+    fseeko (f, Nskip, SEEK_CUR); 
     if (primary != NULL) free (primary);
   }
 
-  if (VERBOSE) fprintf (stderr, "read %d stars from catalog file %s (%d measurements, %d missing, %d secondary filters)\n", 
-			catalog[0].Naverage, catalog[0].filename, catalog[0].Nmeasure, catalog[0].Nmissing, catalog[0].Nsecfilt);
+  if (VERBOSE) fprintf (stderr, "read %lld stars from catalog file %s (%lld measurements, %lld missing, %lld secondary filters)\n", 
+			(long long) catalog[0].Naverage, 
+			catalog[0].filename, 
+			(long long) catalog[0].Nmeasure, 
+			(long long) catalog[0].Nmissing, 
+			(long long) catalog[0].Nsecfilt);
 
   /* check data integrity */
@@ -209,6 +213,6 @@
       if (VERBOSE) {
 	fprintf (stderr, "****** data in catalog %s is corrupt, sums don't check\n", catalog[0].filename);
-	fprintf (stderr, "****** Nmeas: %d, %d\n", Nmeas, catalog[0].Nmeasure);
-	fprintf (stderr, "****** Nmiss: %d, %d\n", Nmiss, catalog[0].Nmissing);
+	fprintf (stderr, "****** Nmeas: %lld, %lld\n", (long long) Nmeas, (long long) catalog[0].Nmeasure);
+	fprintf (stderr, "****** Nmiss: %lld, %lld\n", (long long) Nmiss, (long long) catalog[0].Nmissing);
       }
       return (FALSE);
@@ -226,9 +230,9 @@
 int dvo_catalog_save_raw (Catalog *catalog, char VERBOSE) {
 
-  int Nitems, nitems;
+  off_t Nitems, nitems;
   FILE *f;
   SecFilt *primary;
   SecFilt *secfilt;
-  int i, j, Nsecfilt, Nallfilt, Ntotal;
+  off_t i, j, Nsecfilt, Nallfilt, Ntotal;
 
   if (catalog[0].Naverage == 0) {
@@ -259,8 +263,8 @@
 
   /* make sure header is consistent with data */
-  gfits_modify (&catalog[0].header, "NSTARS",   "%d", 1, catalog[0].Naverage);
-  gfits_modify (&catalog[0].header, "NMEAS",    "%d", 1, catalog[0].Nmeasure);
-  gfits_modify (&catalog[0].header, "NMISS",    "%d", 1, catalog[0].Nmissing);
-  gfits_modify (&catalog[0].header, "NSECFILT", "%d", 1, catalog[0].Nsecfilt);
+  gfits_modify (&catalog[0].header, "NSTARS",   "%lld", 1, (long long) catalog[0].Naverage);
+  gfits_modify (&catalog[0].header, "NMEAS",    "%lld", 1, (long long) catalog[0].Nmeasure);
+  gfits_modify (&catalog[0].header, "NMISS",    "%lld", 1, (long long) catalog[0].Nmissing);
+  gfits_modify (&catalog[0].header, "NSECFILT", "%lld", 1, (long long) catalog[0].Nsecfilt);
   gfits_modify (&catalog[0].header, "OBJID",    "%d", 1, catalog[0].objID);
 
@@ -278,10 +282,10 @@
   /* rewind file pointers and truncate file */
   f = catalog[0].f;
-  fseek (f, 0, SEEK_SET);
+  fseeko (f, 0, SEEK_SET);
   ftruncate (fileno (catalog[0].f), 0);
 
   /* write header data (use gfits_write_header?) */
-  nitems = fwrite (catalog[0].header.buffer, 1, catalog[0].header.size, f);
-  if (nitems != catalog[0].header.size) {
+  nitems = fwrite (catalog[0].header.buffer, 1, catalog[0].header.datasize, f);
+  if (nitems != catalog[0].header.datasize) {
     if (VERBOSE) fprintf (stderr, "failed to write header\n");
     goto failure;
@@ -330,5 +334,5 @@
    in these cases, save these values in primary; otherwise set primary to NULL */
 
-Average *ReadRawAverage (FILE *f, int Naverage, int format, SecFilt **primary) {
+Average *ReadRawAverage (FILE *f, off_t Naverage, char format, SecFilt **primary) {
 
   Average *average;
@@ -339,10 +343,10 @@
 # define FORMAT_CASE(NAME,TYPE) \
     case DVO_FORMAT_##NAME: { \
-      int nitems; \
+      off_t nitems; \
       Average_##TYPE *tmpAverage; \
       ALLOCATE (tmpAverage, Average_##TYPE, MAX (Naverage, 1)); \
       nitems = fread (tmpAverage, sizeof(Average_##TYPE), Naverage, f); \
       if (nitems != Naverage) { \
-	fprintf (stderr, "failed to read averages (%d vs %d)\n", nitems, Naverage); \
+	fprintf (stderr, "failed to read averages (%lld vs %lld)\n", (long long) nitems, (long long) Naverage); \
 	return (NULL); \
       } \
@@ -354,9 +358,9 @@
   switch (format) {
     case DVO_FORMAT_INTERNAL: {
-      int nitems;
+      off_t nitems;
       ALLOCATE (average, Average, MAX (Naverage, 1));
       nitems = fread (average, sizeof(Average), Naverage, f);
       if (nitems != Naverage) {
-	fprintf (stderr, "failed to read averages (%d vs %d)\n", nitems, Naverage);
+	fprintf (stderr, "failed to read averages (%lld vs %lld)\n", (long long) nitems, (long long) Naverage);
 	return (NULL);
       }
@@ -384,10 +388,10 @@
 /* accepts and converts internal average formats and outputs 
    raw data in the specified format */
-int WriteRawAverage (FILE *f, Average *average, int Naverage, int format, SecFilt *primary) {
+int WriteRawAverage (FILE *f, Average *average, off_t Naverage, char format, SecFilt *primary) {
 
 // this macro generates the case statements for each type
 # define FORMAT_CASE(NAME,TYPE) \
     case DVO_FORMAT_##NAME: { \
-      int nitems; \
+      off_t nitems; \
       Average_##TYPE *tmpAverage; \
       tmpAverage = AverageInternalTo_##TYPE (average, Naverage, primary); \
@@ -396,5 +400,5 @@
       free (tmpAverage); \
       if (nitems != Naverage) { \
-	fprintf (stderr, "failed to write averages (%d vs %d)\n", nitems, Naverage); \
+	fprintf (stderr, "failed to write averages (%lld vs %lld)\n", (long long) nitems, (long long) Naverage); \
 	return (FALSE); \
       } \
@@ -403,9 +407,9 @@
   switch (format) {
     case DVO_FORMAT_INTERNAL: {
-      int nitems;
+      off_t nitems;
       gfits_convert_Average (average, sizeof(Average), Naverage);
       nitems = fwrite (average, sizeof(Average), Naverage, f);
       if (nitems != Naverage) {
-	fprintf (stderr, "failed to write averages (%d vs %d)\n", nitems, Naverage);
+	fprintf (stderr, "failed to write averages (%lld vs %lld)\n", (long long) nitems, (long long) Naverage);
 	return (FALSE);
       }
@@ -432,5 +436,5 @@
 /** Average / Raw Table conversions **/
 
-Measure *ReadRawMeasure (FILE *f, int Nmeasure, int format) {
+Measure *ReadRawMeasure (FILE *f, off_t Nmeasure, char format) {
 
   Measure *measure;
@@ -439,10 +443,10 @@
 # define FORMAT_CASE(NAME,TYPE) \
     case DVO_FORMAT_##NAME: { \
-      int nitems; \
+      off_t nitems; \
       Measure_##TYPE *tmpMeasure; \
       ALLOCATE (tmpMeasure, Measure_##TYPE, MAX (Nmeasure, 1)); \
       nitems = fread (tmpMeasure, sizeof(Measure_##TYPE), Nmeasure, f); \
       if (nitems != Nmeasure) { \
-	fprintf (stderr, "failed to read measures (%d vs %d)\n", nitems, Nmeasure); \
+	fprintf (stderr, "failed to read measures (%lld vs %lld)\n", (long long) nitems, (long long) Nmeasure); \
 	return (NULL); \
       } \
@@ -454,9 +458,9 @@
   switch (format) {
     case DVO_FORMAT_INTERNAL: {
-      int nitems;
+      off_t nitems;
       ALLOCATE (measure, Measure, MAX (Nmeasure, 1));
       nitems = fread (measure, sizeof(Measure), Nmeasure, f);
       if (nitems != Nmeasure) {
-	fprintf (stderr, "failed to read measures (%d vs %d)\n", nitems, Nmeasure);
+	fprintf (stderr, "failed to read measures (%lld vs %lld)\n", (long long) nitems, (long long) Nmeasure);
 	return (NULL);
       }
@@ -484,10 +488,10 @@
 /* accepts and converts internal measure formats and outputs 
    raw data in the specified format */
-int WriteRawMeasure (FILE *f, Measure *measure, int Nmeasure, int format) {
+int WriteRawMeasure (FILE *f, Measure *measure, off_t Nmeasure, char format) {
 
 // this macro generates the case statements for each type
 # define FORMAT_CASE(NAME,TYPE) \
     case DVO_FORMAT_##NAME: { \
-      int nitems; \
+      off_t nitems; \
       Measure_##TYPE *tmpMeasure; \
       tmpMeasure = MeasureInternalTo_##TYPE (measure, Nmeasure); \
@@ -496,5 +500,5 @@
       free (tmpMeasure); \
       if (nitems != Nmeasure) { \
-	fprintf (stderr, "failed to write measures (%d vs %d)\n", nitems, Nmeasure); \
+	fprintf (stderr, "failed to write measures (%lld vs %lld)\n", (long long) nitems, (long long) Nmeasure); \
 	return (FALSE); \
       } \
@@ -503,9 +507,9 @@
   switch (format) {
     case DVO_FORMAT_INTERNAL: {
-      int nitems;
+      off_t nitems;
       gfits_convert_Measure (measure, sizeof(Measure), Nmeasure);
       nitems = fwrite (measure, sizeof(Measure), Nmeasure, f);
       if (nitems != Nmeasure) {
-	fprintf (stderr, "failed to write measures (%d vs %d)\n", nitems, Nmeasure);
+	fprintf (stderr, "failed to write measures (%lld vs %lld)\n", (long long) nitems, (long long) Nmeasure);
 	return (FALSE);
       }
@@ -532,5 +536,5 @@
 /** SecFilt / Raw Table conversions **/
 
-SecFilt *ReadRawSecFilt (FILE *f, int Nsecfilt, int format) {
+SecFilt *ReadRawSecFilt (FILE *f, off_t Nsecfilt, char format) {
 
   SecFilt *secfilt;
@@ -539,10 +543,10 @@
 # define FORMAT_CASE(NAME,TYPE) \
     case DVO_FORMAT_##NAME: { \
-      int nitems; \
+      off_t nitems; \
       SecFilt_##TYPE *tmpSecFilt; \
       ALLOCATE (tmpSecFilt, SecFilt_##TYPE, MAX (Nsecfilt, 1)); \
       nitems = fread (tmpSecFilt, sizeof(SecFilt_##TYPE), Nsecfilt, f); \
       if (nitems != Nsecfilt) { \
-	fprintf (stderr, "failed to read secfilts (%d vs %d)\n", nitems, Nsecfilt); \
+	fprintf (stderr, "failed to read secfilts (%lld vs %lld)\n", (long long) nitems, (long long) Nsecfilt); \
 	return (NULL); \
       } \
@@ -554,9 +558,9 @@
   switch (format) {
     case DVO_FORMAT_INTERNAL: {
-      int nitems;
+      off_t nitems;
       ALLOCATE (secfilt, SecFilt, MAX (Nsecfilt, 1));
       nitems = fread (secfilt, sizeof(SecFilt), Nsecfilt, f);
       if (nitems != Nsecfilt) {
-	fprintf (stderr, "failed to read secfilts (%d vs %d)\n", nitems, Nsecfilt);
+	fprintf (stderr, "failed to read secfilts (%lld vs %lld)\n", (long long) nitems, (long long) Nsecfilt);
 	return (NULL);
       }
@@ -584,10 +588,10 @@
 /* accepts and converts internal secfilt formats and outputs 
    raw data in the specified format */
-int WriteRawSecFilt (FILE *f, SecFilt *secfilt, int Nsecfilt, int format) {
+int WriteRawSecFilt (FILE *f, SecFilt *secfilt, off_t Nsecfilt, char format) {
 
 // this macro generates the case statements for each type
 # define FORMAT_CASE(NAME,TYPE) \
     case DVO_FORMAT_##NAME: { \
-      int nitems; \
+      off_t nitems; \
       SecFilt_##TYPE *tmpSecFilt; \
       tmpSecFilt = SecFiltInternalTo_##TYPE (secfilt, Nsecfilt); \
@@ -596,5 +600,5 @@
       free (tmpSecFilt); \
       if (nitems != Nsecfilt) { \
-	fprintf (stderr, "failed to write secfilts (%d vs %d)\n", nitems, Nsecfilt); \
+	fprintf (stderr, "failed to write secfilts (%lld vs %lld)\n", (long long) nitems, (long long) Nsecfilt); \
 	return (FALSE); \
       } \
@@ -603,9 +607,9 @@
   switch (format) {
     case DVO_FORMAT_INTERNAL: {
-      int nitems;
+      off_t nitems;
       gfits_convert_SecFilt (secfilt, sizeof(SecFilt), Nsecfilt);
       nitems = fwrite (secfilt, sizeof(SecFilt), Nsecfilt, f);
       if (nitems != Nsecfilt) {
-	fprintf (stderr, "failed to write secfilts (%d vs %d)\n", nitems, Nsecfilt);
+	fprintf (stderr, "failed to write secfilts (%lld vs %lld)\n", (long long) nitems, (long long) Nsecfilt);
 	return (FALSE);
       }
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/libdvo/src/dvo_catalog_split.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/libdvo/src/dvo_catalog_split.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/libdvo/src/dvo_catalog_split.c	(revision 27295)
@@ -6,7 +6,7 @@
 // * ok
 
-int dvo_catalog_secfilt_to_primary (Catalog *catalog, SecFilt **myPrimary, SecFilt **mySecfilt, int *myNsecfilt) {
-
-  int i, j, Nallfilt, Nsecfilt, Ntotal;
+int dvo_catalog_secfilt_to_primary (Catalog *catalog, SecFilt **myPrimary, SecFilt **mySecfilt, off_t *myNsecfilt) {
+
+  off_t i, j, Nallfilt, Nsecfilt, Ntotal;
 
   SecFilt *primary;
@@ -43,7 +43,7 @@
 }
 
-int dvo_catalog_primary_to_secfilt (Catalog *catalog, SecFilt *primary, int Naves) {
-
-  int Ntmpfilt, Nsecfilt, Ntotal, i, j;
+int dvo_catalog_primary_to_secfilt (Catalog *catalog, SecFilt *primary, off_t Naves) {
+
+  off_t Ntmpfilt, Nsecfilt, Ntotal, i, j;
   SecFilt *tmpfilt;
 
@@ -71,10 +71,10 @@
 }
 
-int dvo_catalog_save_subcat (Catalog *catalog, FTable *ftable, int start, int Nrows, int Ndisk, int Ntotal) {
+int dvo_catalog_save_subcat (Catalog *catalog, FTable *ftable, off_t start, off_t Nrows, off_t Ndisk, off_t Ntotal) {
 
   Matrix matrix;
 
   /* rewind file pointers and truncate (file is still open) */
-  fseek (catalog->f, 0, SEEK_SET);
+  fseeko (catalog->f, 0LL, SEEK_SET);
 
   // write PHU header
@@ -103,5 +103,6 @@
 int dvo_catalog_open_subcat (Catalog *catalog, Catalog **Subcat, Header *header, char *name, int VERBOSE) {
 
-  int Nskip, status;
+  off_t Nskip;
+  int status;
   char *path, string[80];
   Catalog *subcat;
@@ -145,5 +146,5 @@
   }
   Nskip = gfits_data_size (&subcat[0].header);
-  fseek (subcat[0].f, Nskip, SEEK_CUR);
+  fseeko (subcat[0].f, Nskip, SEEK_CUR);
 
   /* read Measure table header */
@@ -158,5 +159,8 @@
 int dvo_catalog_load_split (Catalog *catalog, int VERBOSE) {
 
-  int Nbytes, Nitems, Naverage, Nmeasure, Nmissing, Nsecfilt, status;
+  off_t Nbytes;
+  off_t Naverage, Nmeasure, Nmissing;
+  off_t Nitems, Nsecfilt;
+  int status;
   Header header;
   FTable ftable;
@@ -170,17 +174,17 @@
 
   /* get the components from the header - these duplicate information in the split files (NAXIS2) */
-  if (!gfits_scan (&catalog[0].header, "NSTARS",   "%d", 1, &Naverage)) return (FALSE);
-  if (!gfits_scan (&catalog[0].header, "NMEAS",    "%d", 1, &Nmeasure)) return (FALSE);
-  if (!gfits_scan (&catalog[0].header, "NMISS",    "%d", 1, &Nmissing)) return (FALSE);
-  if (!gfits_scan (&catalog[0].header, "NSECFILT", "%d", 1, &Nsecfilt)) Nsecfilt = 0;
+  if (!gfits_scan (&catalog[0].header, "NSTARS",   "%lld", 1, &Naverage)) return (FALSE);
+  if (!gfits_scan (&catalog[0].header, "NMEAS",    "%lld", 1, &Nmeasure)) return (FALSE);
+  if (!gfits_scan (&catalog[0].header, "NMISS",    "%lld", 1, &Nmissing)) return (FALSE);
+  if (!gfits_scan (&catalog[0].header, "NSECFILT", "%lld", 1, &Nsecfilt)) Nsecfilt = 0;
 
   /* the OBJID is a counter that uniquely defines an average entry and never changes.  if
      it is not defined for a legacy database, we can generate them using the existing index values.
      If it is missing, give a warning and recommend the user upgrade the DB */
-  if (!gfits_scan (&catalog[0].header, "OBJID",    "%d", 1, &catalog[0].objID)) {
+  if (!gfits_scan (&catalog[0].header, "OBJID",    "%u", 1, &catalog[0].objID)) {
     if (VERBOSE) fprintf (stderr, "WARNING: OBJID is not set for this database: upgrade for full feature set\n");
     catalog[0].objID = 0;
   }
-  if (!gfits_scan (&catalog[0].header, "CATID",    "%d", 1, &catalog[0].catID)) {
+  if (!gfits_scan (&catalog[0].header, "CATID",    "%u", 1, &catalog[0].catID)) {
     if (VERBOSE) fprintf (stderr, "WARNING: CATID is not set for this database: upgrade for full feature set\n");
     catalog[0].catID = 0;
@@ -206,6 +210,6 @@
   if (catalog[0].catflags & LOAD_AVES) {
     /* move pointer past header -- must be already read (load_catalog) */
-    Nbytes = catalog[0].header.size + gfits_data_size (&catalog[0].header);
-    fseek (catalog[0].f, Nbytes, SEEK_SET);
+    Nbytes = catalog[0].header.datasize + gfits_data_size (&catalog[0].header);
+    fseeko (catalog[0].f, Nbytes, SEEK_SET);
     /* read Average table header */
     if (!gfits_fread_header (catalog[0].f, &header)) { 
@@ -223,5 +227,5 @@
     catalog[0].average = FtableToAverage (&ftable, &Naverage, &catalog[0].catformat, &primary);
     if (Naverage != catalog[0].Naves_disk) {
-      fprintf (stderr, "Warning: mismatch between Naverage in PHU and Table headers (%d vs %d)\n", Naverage, catalog[0].Naves_disk);
+      fprintf (stderr, "Warning: mismatch between Naverage in PHU and Table headers (%lld vs %lld)\n", (long long) Naverage, (long long) catalog[0].Naves_disk);
     }
     gfits_free_header (&header);
@@ -252,5 +256,5 @@
     catalog[0].measure = FtableToMeasure (&ftable, &Nmeasure, &catalog[0].catformat);
     if (Nmeasure != catalog[0].Nmeas_disk) {
-      fprintf (stderr, "Warning: mismatch between Nmeasure in PHU and Table headers (%d vs %d)\n", Nmeasure, catalog[0].Nmeas_disk);
+      fprintf (stderr, "Warning: mismatch between Nmeasure in PHU and Table headers (%lld vs %lld)\n", (long long) Nmeasure, (long long) catalog[0].Nmeas_disk);
     }
     catalog[0].Nmeasure = catalog[0].Nmeas_disk;
@@ -282,5 +286,5 @@
     catalog[0].missing = gfits_table_get_Missing (&ftable, &Nmissing, NULL);
     if (Nmissing != catalog[0].Nmiss_disk) {
-      fprintf (stderr, "Warning: mismatch between Nmissing in PHU and Table headers (%d vs %d)\n", Nmissing, catalog[0].Nmiss_disk);
+      fprintf (stderr, "Warning: mismatch between Nmissing in PHU and Table headers (%lld vs %lld)\n", (long long) Nmissing, (long long) catalog[0].Nmiss_disk);
     }
     catalog[0].Nmissing = catalog[0].Nmiss_disk;
@@ -311,5 +315,5 @@
     catalog[0].secfilt = FtableToSecFilt (&ftable, &Nitems, &catalog[0].catformat);
     if (Nitems != catalog[0].Nsecf_disk) {
-      fprintf (stderr, "Warning: mismatch between Nsecfilt items in PHU and Table headers (%d vs %d)\n", Nitems, catalog[0].Nsecf_disk);
+      fprintf (stderr, "Warning: mismatch between Nsecfilt items in PHU and Table headers (%lld vs %lld)\n", (long long) Nitems, (long long) catalog[0].Nsecf_disk);
     }
     catalog[0].Nsecf_mem = catalog[0].Nsecf_disk;
@@ -339,7 +343,8 @@
 // I need to always read both average and secfilt at the same time to correctly manage the
 // primary secfilt values...
-int dvo_catalog_load_segment_split (Catalog *catalog, int VERBOSE, int start, int Nrows) {
-
-  int Nbytes, Naverage, Nexpect, Nitems, Nmeasure, Nmissing;
+int dvo_catalog_load_segment_split (Catalog *catalog, int VERBOSE, off_t start, off_t Nrows) {
+
+  off_t Nbytes;
+  off_t Naverage, Nexpect, Nitems, Nmeasure, Nmissing;
   Header header;
   FTable ftable;
@@ -357,6 +362,6 @@
     /*** load the Average data ***/
     /* move pointer past header and matrix -- must be already read (load_catalog) */
-    Nbytes = catalog[0].header.size + gfits_data_size (&catalog[0].header);
-    fseek (catalog[0].f, Nbytes, SEEK_SET);
+    Nbytes = catalog[0].header.datasize + gfits_data_size (&catalog[0].header);
+    fseeko (catalog[0].f, Nbytes, SEEK_SET);
     /* read Average table header */
     if (!gfits_fread_header (catalog[0].f, &header)) {
@@ -386,6 +391,6 @@
 
     /* move pointer past header -- must be already read (load_catalog) */
-    Nbytes = subcat[0].header.size + gfits_data_size (&subcat[0].header);
-    fseek (subcat[0].f, Nbytes, SEEK_SET);
+    Nbytes = subcat[0].header.datasize + gfits_data_size (&subcat[0].header);
+    fseeko (subcat[0].f, Nbytes, SEEK_SET);
 
     /* read Secfilt table header */
@@ -403,5 +408,5 @@
     catalog[0].secfilt = FtableToSecFilt (&ftable, &Nitems, &catalog[0].catformat);
     if (Nitems != Nexpect) {
-      fprintf (stderr, "Warning: mismatch between Nsecfilt items in PHU and Table headers (%d vs %d)\n", Nitems, Nexpect);
+      fprintf (stderr, "Warning: mismatch between Nsecfilt items in PHU and Table headers (%lld vs %lld)\n", (long long) Nitems, (long long) Nexpect);
     }
     catalog[0].Nsecf_mem = catalog[0].Naverage * catalog[0].Nsecfilt;
@@ -422,6 +427,6 @@
 
     /* move pointer past header -- must be already read (load_catalog) */
-    Nbytes = subcat[0].header.size + gfits_data_size (&subcat[0].header);
-    fseek (subcat[0].f, Nbytes, SEEK_SET);
+    Nbytes = subcat[0].header.datasize + gfits_data_size (&subcat[0].header);
+    fseeko (subcat[0].f, Nbytes, SEEK_SET);
 
     /* read Measure table header */
@@ -439,5 +444,5 @@
     catalog[0].measure = FtableToMeasure (&ftable, &Nmeasure, &catalog[0].catformat);
     if (Nmeasure != Nrows) {
-      fprintf (stderr, "Warning: mismatch between Nmeasure in PHU and Table headers (%d vs %d)\n", Nmeasure, Nrows);
+      fprintf (stderr, "Warning: mismatch between Nmeasure in PHU and Table headers (%lld vs %lld)\n", (long long) Nmeasure, (long long) Nrows);
     }
     gfits_free_header (&header);
@@ -452,6 +457,6 @@
 
     /* move pointer past header -- must be already read (load_catalog) */
-    Nbytes = subcat[0].header.size + gfits_data_size (&subcat[0].header);
-    fseek (subcat[0].f, Nbytes, SEEK_SET);
+    Nbytes = subcat[0].header.datasize + gfits_data_size (&subcat[0].header);
+    fseeko (subcat[0].f, Nbytes, SEEK_SET);
 
     /* read Missing table header */
@@ -469,5 +474,5 @@
     catalog[0].missing = gfits_table_get_Missing (&ftable, &Nmissing, NULL);
     if (Nmissing != Nrows) {
-      fprintf (stderr, "Warning: mismatch between Nmissing in PHU and Table headers (%d vs %d)\n", Nmissing, Nrows);
+      fprintf (stderr, "Warning: mismatch between Nmissing in PHU and Table headers (%lld vs %lld)\n", (long long) Nmissing, (long long) Nrows);
     }
     gfits_free_header (&header);
@@ -481,11 +486,11 @@
 int dvo_catalog_save_split (Catalog *catalog, char VERBOSE) {
 
-  int Nitems;
+  off_t Nitems;
   Header header;
   FTable ftable;
   SecFilt *primary, *secfilt;
-  int Nsecfilt;
-  int Naves_disk_new, Nmeas_disk_new, Nmiss_disk_new, Nsecf_disk_new;
-  int first, start, Nrows;
+  off_t Nsecfilt;
+  off_t Naves_disk_new, Nmeas_disk_new, Nmiss_disk_new, Nsecf_disk_new;
+  off_t first, start, Nrows;
 
   ftable.header = &header;
@@ -519,8 +524,8 @@
 
   /* make sure header is consistent with data */
-  gfits_modify (&catalog[0].header, "NSTARS",   "%d", 1, Naves_disk_new);
-  gfits_modify (&catalog[0].header, "NMEAS",    "%d", 1, Nmeas_disk_new);
-  gfits_modify (&catalog[0].header, "NMISS",    "%d", 1, Nmiss_disk_new);
-  gfits_modify (&catalog[0].header, "NSECFILT", "%d", 1, Nsecfilt);
+  gfits_modify (&catalog[0].header, "NSTARS",   "%lld", 1, Naves_disk_new);
+  gfits_modify (&catalog[0].header, "NMEAS",    "%lld", 1, Nmeas_disk_new);
+  gfits_modify (&catalog[0].header, "NMISS",    "%lld", 1, Nmiss_disk_new);
+  gfits_modify (&catalog[0].header, "NSECFILT", "%lld", 1, Nsecfilt);
   gfits_modify (&catalog[0].header, "EXTEND",   "%t", 1, TRUE);
   gfits_modify (&catalog[0].header, "OBJID",    "%d", 1, catalog[0].objID);
@@ -555,5 +560,5 @@
     // even if we do not save the average table, we need to keep the header in sync
     /* rewind file pointers and truncate (file is still open) */
-    fseek (catalog[0].f, 0, SEEK_SET);
+    fseeko (catalog[0].f, 0, SEEK_SET);
 
     /* write table PHU header - always write this out */
@@ -662,11 +667,11 @@
 int dvo_catalog_save_split_complete (Catalog *catalog, char VERBOSE) {
 
-  int Nitems;
+  off_t Nitems;
   Header header;
   FTable ftable;
   SecFilt *primary, *secfilt;
-  int Nsecfilt;
-  int Naves_disk_new, Nmeas_disk_new, Nmiss_disk_new, Nsecf_disk_new;
-  int first, start, Nrows;
+  off_t Nsecfilt;
+  off_t Naves_disk_new, Nmeas_disk_new, Nmiss_disk_new, Nsecf_disk_new;
+  off_t first, start, Nrows;
 
   ftable.header = &header;
@@ -693,12 +698,10 @@
   }
 
-  if ((catalog[0].Naverage > 0) && (Naves_disk_new == 0)) {
-    Naves_disk_new = catalog[0].Naverage;
+  Naves_disk_new = catalog[0].Naverage;
+  if (Naves_disk_new == 0) {
     if (VERBOSE) fprintf (stderr, "resulting catalog is empty; delete it\n");
     // unlink ();
     return (TRUE);
   }
-
-  Naves_disk_new = catalog[0].Naverage;
 
   // for the appropriate types, pull out the first secfilt and pass to AverageToFtable as primary
@@ -720,8 +723,8 @@
 
   /* make sure header is consistent with data */
-  gfits_modify (&catalog[0].header, "NSTARS",   "%d", 1, Naves_disk_new);
-  gfits_modify (&catalog[0].header, "NMEAS",    "%d", 1, Nmeas_disk_new);
-  gfits_modify (&catalog[0].header, "NMISS",    "%d", 1, Nmiss_disk_new);
-  gfits_modify (&catalog[0].header, "NSECFILT", "%d", 1, Nsecfilt);
+  gfits_modify (&catalog[0].header, "NSTARS",   "%lld", 1, Naves_disk_new);
+  gfits_modify (&catalog[0].header, "NMEAS",    "%lld", 1, Nmeas_disk_new);
+  gfits_modify (&catalog[0].header, "NMISS",    "%lld", 1, Nmiss_disk_new);
+  gfits_modify (&catalog[0].header, "NSECFILT", "%lld", 1, Nsecfilt);
   gfits_modify (&catalog[0].header, "EXTEND",   "%t", 1, TRUE);
   gfits_modify (&catalog[0].header, "OBJID",    "%d", 1, catalog[0].objID);
@@ -756,5 +759,5 @@
     // even if we do not save the average table, we need to keep the header in sync
     /* rewind file pointers and truncate (file is still open) */
-    fseek (catalog[0].f, 0, SEEK_SET);
+    fseeko (catalog[0].f, 0, SEEK_SET);
 
     /* write table PHU header - always write this out */
@@ -866,7 +869,7 @@
   FTable ftable;
   SecFilt *primary, *secfilt;
-  int Nsecfilt;
-  int Naves_disk_new, Nmeas_disk_new, Nmiss_disk_new, Nsecf_disk_new;
-  int first, start, Nrows;
+  off_t Nsecfilt;
+  off_t Naves_disk_new, Nmeas_disk_new, Nmiss_disk_new, Nsecf_disk_new;
+  off_t first, start, Nrows;
 
   ftable.header = &header;
@@ -899,8 +902,8 @@
 
   /* make sure header is consistent with data */
-  gfits_modify (&catalog[0].header, "NSTARS",   "%d", 1, Naves_disk_new);
-  gfits_modify (&catalog[0].header, "NMEAS",    "%d", 1, Nmeas_disk_new);
-  gfits_modify (&catalog[0].header, "NMISS",    "%d", 1, Nmiss_disk_new);
-  gfits_modify (&catalog[0].header, "NSECFILT", "%d", 1, Nsecfilt);
+  gfits_modify (&catalog[0].header, "NSTARS",   "%lld", 1, Naves_disk_new);
+  gfits_modify (&catalog[0].header, "NMEAS",    "%lld", 1, Nmeas_disk_new);
+  gfits_modify (&catalog[0].header, "NMISS",    "%lld", 1, Nmiss_disk_new);
+  gfits_modify (&catalog[0].header, "NSECFILT", "%lld", 1, Nsecfilt);
   gfits_modify (&catalog[0].header, "EXTEND",   "%t", 1, TRUE);
   gfits_modify (&catalog[0].header, "OBJID",    "%d", 1, catalog[0].objID);
@@ -935,5 +938,5 @@
     // even if we do not save the average table, we need to keep the header in sync
     /* rewind file pointers and truncate (file is still open) */
-    fseek (catalog[0].f, 0, SEEK_SET);
+    fseeko (catalog[0].f, 0, SEEK_SET);
 
     /* write table PHU header - always write this out */
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/libdvo/src/dvo_convert.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/libdvo/src/dvo_convert.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/libdvo/src/dvo_convert.c	(revision 27295)
@@ -13,5 +13,5 @@
 /*** Average / FTable conversion functions ***/
 
-Average *FtableToAverage (FTable *ftable, int *Naverage, int *format, SecFilt **primary) {
+Average *FtableToAverage (FTable *ftable, off_t *Naverage, char *format, SecFilt **primary) {
 
   Average *average;
@@ -59,5 +59,5 @@
 }
 
-int AverageToFtable (FTable *ftable, Average *average, int Naverage, int format, SecFilt *primary) {
+int AverageToFtable (FTable *ftable, Average *average, off_t Naverage, char format, SecFilt *primary) {
 
 # define FORMAT_CASE(FORMAT, TYPE) \
@@ -94,5 +94,5 @@
 /*** Measure / FTable conversion functions ***/
 
-Measure *FtableToMeasure (FTable *ftable, int *Nmeasure, int *format) {
+Measure *FtableToMeasure (FTable *ftable, off_t *Nmeasure, char *format) {
 
   Measure *measure;
@@ -136,5 +136,5 @@
 }
 
-int MeasureToFtable (FTable *ftable, Measure *measure, int Nmeasure, int format) {
+int MeasureToFtable (FTable *ftable, Measure *measure, off_t Nmeasure, char format) {
 
 # define FORMAT_CASE(FORMAT, TYPE) \
@@ -171,5 +171,5 @@
 /*** SecFilt / FTable conversion functions ***/
 
-SecFilt *FtableToSecFilt (FTable *ftable, int *Nsecfilt, int *format) {
+SecFilt *FtableToSecFilt (FTable *ftable, off_t *Nsecfilt, char *format) {
 
   SecFilt *secfilt;
@@ -213,5 +213,5 @@
 }
 
-int SecFiltToFtable (FTable *ftable, SecFilt *secfilt, int Nsecfilt, int format) {
+int SecFiltToFtable (FTable *ftable, SecFilt *secfilt, off_t Nsecfilt, char format) {
 
 # define FORMAT_CASE(FORMAT, TYPE) \
@@ -248,7 +248,7 @@
 /*** Image Conversions ***/
 
-int FtableToImage (FTable *ftable, Header *theader, int *format) {
-
-  int Nimage;
+int FtableToImage (FTable *ftable, Header *theader, char *format) {
+
+  off_t Nimage;
   char extname[80];
 
@@ -261,7 +261,7 @@
     gfits_free_header (theader);
     gfits_table_mkheader_Image (theader);
-    gfits_modify (theader, "NAXIS2", "%d", 1, Nimage);
+    gfits_modify (theader, "NAXIS2", "%lld", 1, Nimage);
     theader[0].Naxis[1] = Nimage;
-    ftable[0].size = gfits_data_size (theader);
+    ftable[0].datasize = gfits_data_size (theader);
     return (TRUE);
   }
@@ -282,7 +282,7 @@
     gfits_free_header (theader); \
     gfits_table_mkheader_Image (theader); \
-    gfits_modify (theader, "NAXIS2", "%d", 1, Nimage); \
+    gfits_modify (theader, "NAXIS2", "%lld", 1, Nimage); \
     theader[0].Naxis[1] = Nimage; \
-    ftable[0].size = gfits_data_size (theader); \
+    ftable[0].datasize = gfits_data_size (theader); \
     return (TRUE); }
 
@@ -312,7 +312,7 @@
 }
 
-int ImageToFtable (FTable *ftable, Header *theader, int format) {
-
-  int Nimage;
+int ImageToFtable (FTable *ftable, Header *theader, char format) {
+
+  off_t Nimage;
 
   Nimage = theader[0].Naxis[1];
@@ -353,7 +353,7 @@
 }
 
-int ImageToVtable (VTable *vtable, Header *theader, int format) {
-
-  int i, Nrow, Nimage;
+int ImageToVtable (VTable *vtable, Header *theader, char format) {
+
+  off_t i, Nrow, Nimage;
 
   Nrow = vtable[0].Nrow;
@@ -370,10 +370,10 @@
       } \
       /* convert header from old format to new format */ \
-      gfits_scan (theader, "NAXIS2", "%d", 1, &Nimage); \
+      gfits_scan (theader, "NAXIS2", "%lld", 1, &Nimage); \
       gfits_free_header (theader); \
       gfits_table_mkheader_Image_##TYPE (theader); \
-      gfits_modify (theader, "NAXIS2", "%d", 1, Nimage); \
+      gfits_modify (theader, "NAXIS2", "%lld", 1, Nimage); \
       theader[0].Naxis[1] = Nimage; \
-      vtable[0].size = gfits_data_size (theader); \
+      vtable[0].datasize = gfits_data_size (theader); \
       return (TRUE); }
 
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/libdvo/src/dvo_convert_PS1_REF.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/libdvo/src/dvo_convert_PS1_REF.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/libdvo/src/dvo_convert_PS1_REF.c	(revision 27295)
@@ -97,5 +97,5 @@
     out[i].P        	 = NAN;
     out[i].dP       	 = NAN;
-    out[i].Xp       	 = NAN;
+    out[i].Xp       	 = NAN_S_SHORT;
     out[i].ChiSq       	 = NAN;
     out[i].Npos       	 = 0;
@@ -148,5 +148,5 @@
     out[i].M     = in[i].M;      
     out[i].dM    = in[i].dM;      
-    out[i].Xm    = NAN;
+    out[i].Xm    = NAN_S_SHORT;
     out[i].Ncode = 0;
     out[i].Nused = 0;
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/libdvo/src/dvo_image.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/libdvo/src/dvo_image.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/libdvo/src/dvo_image.c	(revision 27295)
@@ -52,5 +52,5 @@
   /* test for NAXIS == 2 in line 3 */
   bzero (buffer, 241);
-  fseek (db[0].f, 0, SEEK_SET);
+  fseeko (db[0].f, 0, SEEK_SET);
   Nread = fread (buffer, 1, 240, db[0].f);
   if (Nread != 240) {
@@ -63,5 +63,5 @@
     return (FALSE);
   }
-  fseek (db[0].f, 0, SEEK_SET);
+  fseeko (db[0].f, 0, SEEK_SET);
 
   /* default values */
@@ -114,13 +114,13 @@
 }
 
-int dvo_image_addrows (FITS_DB *db, Image *new, int Nnew) {
-
-  int Nimages;
+int dvo_image_addrows (FITS_DB *db, Image *new, off_t Nnew) {
+
+  off_t Nimages;
 
   /* adjust header */
   Nimages = 0;
-  gfits_scan (&db[0].header, "NIMAGES", "%d", 1, &Nimages);
+  gfits_scan (&db[0].header, "NIMAGES", "%lld", 1, &Nimages);
   Nimages += Nnew;
-  gfits_modify (&db[0].header, "NIMAGES", "%d", 1, Nimages);
+  gfits_modify (&db[0].header, "NIMAGES", "%lld", 1, Nimages);
 
   gfits_table_to_vtable (&db[0].ftable, &db[0].vtable, 0, 0);
@@ -195,5 +195,5 @@
   gfits_table_set_Image (&db[0].ftable, NULL, 0);
 
-  gfits_modify (&db[0].header, "NIMAGES", "%d", 1, 0);
+  gfits_modify (&db[0].header, "NIMAGES", "%lld", 1, 0);
   gfits_modify (&db[0].header, "ZERO_PT", "%lf", 1, ZeroPoint);
 
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/libdvo/src/dvo_image_raw.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/libdvo/src/dvo_image_raw.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/libdvo/src/dvo_image_raw.c	(revision 27295)
@@ -7,5 +7,5 @@
 int dvo_image_load_raw (FITS_DB *db, int VERBOSE, int FORCE_READ) {
 
-  int Nimage, Ndata, size, ImageSize, nbytes, Nbytes;
+  off_t Nimage, Ndata, size, ImageSize, nbytes, Nbytes;
   struct stat filestatus;
   char format[80], telescope[80];
@@ -39,5 +39,5 @@
   /* find number of images */
   Nimage = 0;
-  gfits_scan (&db[0].header, "NIMAGES", "%d", 1, &Nimage);
+  gfits_scan (&db[0].header, "NIMAGES", "%lld", 1, &Nimage);
   if (stat (db[0].filename, &filestatus) == -1) {
     if (VERBOSE) fprintf (stderr, "ERROR: failed to get status of image catalog\n");
@@ -59,9 +59,9 @@
 
   /* check that filesize makes sense */
-  size = Nimage*ImageSize + db[0].header.size;
+  size = Nimage*ImageSize + db[0].header.datasize;
   if (size != filestatus.st_size) {
-    Ndata = (filestatus.st_size - db[0].header.size) / ImageSize;
+    Ndata = (filestatus.st_size - db[0].header.datasize) / ImageSize;
     if (VERBOSE) fprintf (stderr, "ERROR: image catalog has inconsistent size\n");
-    if (VERBOSE) fprintf (stderr, "header: %d, data: %d\n", Nimage, Ndata);
+    if (VERBOSE) fprintf (stderr, "header: %lld, data: %lld\n", (long long) Nimage, (long long) Ndata);
     if (!FORCE_READ) exit (1);
     Nimage = Ndata;
@@ -94,7 +94,7 @@
   } 
 
-  gfits_modify (&db[0].theader, "NAXIS2", "%d", 1, Nimage);
+  gfits_modify (&db[0].theader, "NAXIS2", "%lld", 1, Nimage);
   db[0].theader.Naxis[1] = Nimage;
-  db[0].ftable.size = gfits_data_size (&db[0].theader);
+  db[0].ftable.datasize = gfits_data_size (&db[0].theader);
   db[0].swapped = FALSE;  /* table does not have internal byte-order */
   return (TRUE);
@@ -104,16 +104,16 @@
 int dvo_image_update_raw (FITS_DB *db, int VERBOSE) {
 
-  int i, Nx, Ny, Nrow, Nbytes;
-  int status, start, offset;
-  int *row;
+  off_t i, Nx, Ny, Nrow, Nbytes, start, offset;
+  off_t status;
+  off_t *row;
 
-  if (VERBOSE) fprintf (stderr, "writing out %d images\n", db[0].vtable.Nrow);
+  if (VERBOSE) fprintf (stderr, "writing out %lld images\n", (long long) db[0].vtable.Nrow);
 
   /* position to start of file */
-  Fseek (db[0].f, 0, SEEK_SET);
+  fseeko (db[0].f, 0, SEEK_SET);
   
   /* write out complete header (no check on disk size?) */
-  status = fwrite (db[0].header.buffer, 1, db[0].header.size, db[0].f);
-  if (status != db[0].header.size) {
+  status = fwrite (db[0].header.buffer, 1, db[0].header.datasize, db[0].f);
+  if (status != db[0].header.datasize) {
     fprintf (stderr, "ERROR: failed writing data to image header\n");
     exit (1);
@@ -123,6 +123,6 @@
   Nrow = db[0].vtable.Nrow;
   row = db[0].vtable.row;
-  gfits_scan (db[0].vtable.header, "NAXIS1", "%d", 1, &Nx);
-  gfits_scan (db[0].vtable.header, "NAXIS2", "%d", 1, &Ny);
+  gfits_scan (db[0].vtable.header, "NAXIS1", "%lld", 1, &Nx);
+  gfits_scan (db[0].vtable.header, "NAXIS2", "%lld", 1, &Ny);
 
   /* file pointer is at beginning of desired table data */
@@ -131,5 +131,5 @@
   for (i = 0; i < Nrow; i++) {
     offset = start + Nx*row[i];
-    fseek (db[0].f, offset, SEEK_SET);
+    fseeko (db[0].f, offset, SEEK_SET);
     Nbytes = fwrite (db[0].vtable.buffer[i], sizeof (char), Nx, db[0].f);
     if (Nbytes != Nx) { return (FALSE); }
@@ -141,7 +141,8 @@
 int dvo_image_save_raw (FITS_DB *db, int VERBOSE) {
 
-  int status, Nx, Ny, size, Nbytes;
+  off_t Nx, Ny, size, Nbytes;
+  int status;
 
-  if (VERBOSE) fprintf (stderr, "writing out %d images\n", db[0].theader.Naxis[1]);
+  if (VERBOSE) fprintf (stderr, "writing out %lld images\n", (long long) db[0].theader.Naxis[1]);
 
   /* position to start of file */
@@ -149,12 +150,12 @@
   
   /* write out complete header (no check on disk size?) */
-  status = fwrite (db[0].header.buffer, 1, db[0].header.size, db[0].f);
-  if (status != db[0].header.size) {
+  status = fwrite (db[0].header.buffer, 1, db[0].header.datasize, db[0].f);
+  if (status != db[0].header.datasize) {
     fprintf (stderr, "ERROR: failed writing data to image header\n");
     exit (1);
   }
 
-  gfits_scan (db[0].ftable.header, "NAXIS1", "%d", 1, &Nx);
-  gfits_scan (db[0].ftable.header, "NAXIS2", "%d", 1, &Ny);
+  gfits_scan (db[0].ftable.header, "NAXIS1", "%lld", 1, &Nx);
+  gfits_scan (db[0].ftable.header, "NAXIS2", "%lld", 1, &Ny);
   size = Nx * Ny;
   Nbytes = fwrite (db[0].ftable.buffer, sizeof(char), size, db[0].f);
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/libdvo/src/dvo_util.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/libdvo/src/dvo_util.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/libdvo/src/dvo_util.c	(revision 27295)
@@ -18,4 +18,5 @@
 
     memset(config, 0, sizeof(dvoConfig));
+    return config;
 }
 
@@ -98,5 +99,5 @@
     }
 
-    char *catdir, filename[256];
+    char filename[256];
   
     sprintf (filename, "%s/Images.dat", dvoConfig->catdir);
@@ -136,6 +137,4 @@
 Image *dvoImageByExternID(dvoConfig *dvoConfig, int sourceID, int externID)
 {
-    Image *images;
-    int Nimage;
     int i;
     
@@ -199,12 +198,9 @@
 }
 
-int dvoGetDetections(SkyList *skylist, int imageID, dvoDetection **results, int *pMaxDetID)
-{
-  int QUIET = 0;
-  int FULL_OUTPUT = 0;
+off_t dvoGetDetections(SkyList *skylist, int imageID, dvoDetection **results, int *pMaxDetID)
+{
   int GetMeasures = 1;
-  int SaveVectors = 0;
   int reg;
-  int Ndetect = 0;
+  off_t Ndetect = 0;
 
   int detectionsArrayLength = 1000;
@@ -226,8 +222,7 @@
       dvo_catalog_unlock (&catalog);
 
-      int Nstars = catalog.Naverage;
-      int Nmeasure = catalog.Nmeasure;
-
-      int i;
+      off_t Nmeasure = catalog.Nmeasure;
+
+      off_t i;
       for (i=0; i< Nmeasure; i++) {
         Measure *m = catalog.measure + i;
@@ -265,5 +260,5 @@
 
       memset(sorted, 0, sizeof(dvoDetection) * *pMaxDetID);
-      int i;
+      off_t i;
       for (i = 0; i < Ndetect; i++) {
            sorted[detections[i].meas.detID] = detections[i];
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/libdvo/src/dvosorts.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/libdvo/src/dvosorts.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/libdvo/src/dvosorts.c	(revision 27295)
@@ -4,5 +4,5 @@
 
 /* values are ave[i].R, ave[i].D, ave[i].M */
-void sortave (Average *ave, int N) {
+void sortave (Average *ave, off_t N) {
 
 # define SWAPFUNC(A,B){ Average tmp; tmp = ave[A]; ave[A] = ave[B]; ave[B] = tmp; }
@@ -17,5 +17,5 @@
 
 /* sort subset by image[subset[i]].tzero */
-void sort_image_subset (Image *image, int *subset, int N) {
+void sort_image_subset (Image *image, off_t *subset, off_t N) {
 
 # define SWAPFUNC(A,B){ int tmp; tmp = subset[A]; subset[A] = subset[B]; subset[B] = tmp; }
@@ -30,7 +30,7 @@
 
 /* sort a coordinate pair (X,Y) and the associated index (S) */
-void sort_coords_index (double *X, double *Y, int *S, int N) {
+void sort_coords_index (double *X, double *Y, off_t *S, off_t N) {
   
-# define SWAPFUNC(A,B){ double dtmp; int itmp; \
+# define SWAPFUNC(A,B){ double dtmp; off_t itmp; \
   dtmp = X[A]; X[A] = X[B]; X[B] = dtmp; \
   dtmp = Y[A]; Y[A] = Y[B]; Y[B] = dtmp; \
@@ -46,5 +46,5 @@
 }
 
-void sort_regions (SkyRegion *region, int N) {
+void sort_regions (SkyRegion *region, off_t N) {
 
 # define SWAPFUNC(A,B){ SkyRegion tmp; tmp = region[A]; region[A] = region[B]; region[B] = tmp; }
@@ -57,17 +57,2 @@
 
 }
-
-# if (0)
-// deprecated along with Stars as an autocode type
-void sort_stars_ra (Stars *stars, int N) {
-
-# define SWAPFUNC(A,B){ Stars tmp; tmp = stars[A]; stars[A] = stars[B]; stars[B] = tmp; }
-# define COMPARE(A,B)(stars[A].R < stars[B].R)
-
-  OHANA_SORT (N, COMPARE, SWAPFUNC);
-
-# undef SWAPFUNC
-# undef COMPARE
-
-}
-# endif
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/libdvo/src/fits_db.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/libdvo/src/fits_db.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/libdvo/src/fits_db.c	(revision 27295)
@@ -92,8 +92,8 @@
 }
 
-/* load the data from Nrows from table starting at start; load header, etc if needed */
-int gfits_db_load_segment (FITS_DB *db, int start, int Nrows) {
-
-  int Nskip;
+/* load the Nrows data from table starting at start; load header, etc if needed */
+int gfits_db_load_segment (FITS_DB *db, off_t start, off_t Nrows) {
+
+  off_t Nskip;
 
   /* database name must be set first */
@@ -119,5 +119,5 @@
     }
   } else {
-    Nskip = db[0].header.size;
+    Nskip = db[0].header.datasize;
     Fseek (db[0].f, Nskip, SEEK_CUR);
   }
@@ -141,5 +141,5 @@
     }
   } else {
-    Nskip = db[0].header.size;
+    Nskip = db[0].header.datasize;
     Fseek (db[0].f, Nskip, SEEK_CUR);
   }
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/libdvo/src/skyregion_ops.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/libdvo/src/skyregion_ops.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/libdvo/src/skyregion_ops.c	(revision 27295)
@@ -386,7 +386,5 @@
 SkyList *SkyListChildrenByBounds_List (SkyList *table, int depth, double Rmin, double Rmax, double Dmin, double Dmax) {
 
-  int i, j, Ns, Ne, Nnew, NNEW;
-  int append;
-  SkyList *children;
+  int i, Nnew, NNEW;
   SkyList *list;
   SkyRegion **region;
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/header/F_H_field.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/header/F_H_field.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/header/F_H_field.c	(revision 27295)
@@ -6,5 +6,6 @@
 
   char *buf;
-  int i, Nwant, Nfound;
+  off_t i;
+  int Nwant, Nfound;
   char keyword[10];
 
@@ -19,5 +20,5 @@
     /* find the Nth entry */
     Nfound = 0;
-    for (i = 0; i < header[0].size; i+= FT_LINE_LENGTH, buf += FT_LINE_LENGTH) {
+    for (i = 0; i < header[0].datasize; i+= FT_LINE_LENGTH, buf += FT_LINE_LENGTH) {
       if (!strncmp (keyword, buf, 8)) {
 	Nfound ++;
@@ -30,5 +31,5 @@
     /* count the entries */
     Nfound = 0;
-    for (i = 0; i < header[0].size; i+= FT_LINE_LENGTH, buf += FT_LINE_LENGTH) {
+    for (i = 0; i < header[0].datasize; i+= FT_LINE_LENGTH, buf += FT_LINE_LENGTH) {
       if (!strncmp (keyword, buf, 8)) {
 	Nfound ++;
@@ -41,5 +42,5 @@
     /* find the Nwant entry */
     Nfound = 0;
-    for (i = 0; i < header[0].size; i+= FT_LINE_LENGTH, buf += FT_LINE_LENGTH) {
+    for (i = 0; i < header[0].datasize; i+= FT_LINE_LENGTH, buf += FT_LINE_LENGTH) {
       if (!strncmp (keyword, buf, 8)) {
 	Nfound ++;
@@ -66,5 +67,6 @@
 
   char *buf, *ptr;
-  int i, Nwant, Nfound, Nfield;
+  off_t i;
+  int Nwant, Nfound, Nfield;
 
   Nfield = strlen (field);
@@ -76,5 +78,5 @@
   if (N > 0) {
     Nfound = 0;
-    for (i = 0; i < header[0].size; i+= FT_LINE_LENGTH, buf += FT_LINE_LENGTH) {
+    for (i = 0; i < header[0].datasize; i+= FT_LINE_LENGTH, buf += FT_LINE_LENGTH) {
       // have we found a HIERARCH entry?
       if (strncmp ("HIERARCH", buf, 8)) continue;
@@ -90,5 +92,5 @@
     /* count the entries */
     Nfound = 0;
-    for (i = 0; i < header[0].size; i+= FT_LINE_LENGTH, buf += FT_LINE_LENGTH) {
+    for (i = 0; i < header[0].datasize; i+= FT_LINE_LENGTH, buf += FT_LINE_LENGTH) {
       if (strncmp ("HIERARCH", buf, 8)) continue;
       ptr = buf + 9; // start of following keyword
@@ -102,5 +104,5 @@
     /* find the Nwant entry */
     Nfound = 0;
-    for (i = 0; i < header[0].size; i+= FT_LINE_LENGTH, buf += FT_LINE_LENGTH) {
+    for (i = 0; i < header[0].datasize; i+= FT_LINE_LENGTH, buf += FT_LINE_LENGTH) {
       if (strncmp ("HIERARCH", buf, 8)) continue;
       ptr = buf + 9; // start of following keyword
@@ -122,9 +124,9 @@
 
 /*********************** fits header field ****************************/
-char *gfits_header_lineno (Header *header, int N) {
+char *gfits_header_lineno (Header *header, off_t N) {
 
   char *buf;
 
-  if (N*80 >= header[0].size) return NULL;
+  if (N*80 >= header[0].datasize) return NULL;
 
   buf = &header[0].buffer[N*80];
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/header/F_copy_H.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/header/F_copy_H.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/header/F_copy_H.c	(revision 27295)
@@ -16,5 +16,5 @@
     out[0].Naxis[i] = in[0].Naxis[i];
 
-  out[0].size   = in[0].size;
+  out[0].datasize = in[0].datasize;
 
   out[0].pcount = in[0].pcount;
@@ -24,7 +24,7 @@
 
   if (out[0].buffer != NULL) free (out[0].buffer);
-  ALLOCATE (out[0].buffer, char, out[0].size);
+  ALLOCATE (out[0].buffer, char, out[0].datasize);
   
-  strncpy (out[0].buffer, in[0].buffer, out[0].size);
+  memcpy (out[0].buffer, in[0].buffer, out[0].datasize);
 
   return (TRUE);
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/header/F_create_H.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/header/F_create_H.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/header/F_create_H.c	(revision 27295)
@@ -9,5 +9,5 @@
   char axis[10];
   
-  header[0].size = NBYTES;
+  header[0].datasize = NBYTES;
 
   ALLOCATE (header[0].buffer, char, NBYTES);
@@ -23,5 +23,5 @@
   for (i = 0; i < header[0].Naxes; i++) {
     snprintf (axis, 10, "NAXIS%d", i + 1);
-    gfits_modify (header,  axis, "%d", 1, header[0].Naxis[i]);
+    gfits_modify (header,  axis, "%lld", 1, header[0].Naxis[i]);
   }
 
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/header/F_delete.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/header/F_delete.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/header/F_delete.c	(revision 27295)
@@ -5,5 +5,6 @@
 int gfits_delete (Header *header, char *field, int N) {
   
-  int i, Nbytes;
+  int i;
+  off_t Nbytes;
   char *p1, *p2;
   
@@ -22,7 +23,7 @@
 
   p2 = gfits_header_field (header, "END", 1);
-  if (header[0].size - (p2 - header[0].buffer + FT_LINE_LENGTH) > FT_RECORD_SIZE) {
-    header[0].size -= FT_RECORD_SIZE;
-    REALLOCATE (header[0].buffer, char, header[0].size);
+  if (header[0].datasize - (p2 - header[0].buffer + FT_LINE_LENGTH) > FT_RECORD_SIZE) {
+    header[0].datasize -= FT_RECORD_SIZE;
+    REALLOCATE (header[0].buffer, char, header[0].datasize);
   }
   return (TRUE);
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/header/F_modify.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/header/F_modify.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/header/F_modify.c	(revision 27295)
@@ -29,7 +29,7 @@
     
     /* is there enough space for 1 more line? */
-    if (header[0].size - (p - (header[0].buffer)) < 2*FT_LINE_LENGTH) {
-      header[0].size += FT_RECORD_SIZE;
-      REALLOCATE (header[0].buffer, char, header[0].size);
+    if (header[0].datasize - (p - (header[0].buffer)) < 2*FT_LINE_LENGTH) {
+      header[0].datasize += FT_RECORD_SIZE;
+      REALLOCATE (header[0].buffer, char, header[0].datasize);
       p = gfits_header_field (header, "END", 1);
       if (p == NULL) return (FALSE); 
@@ -50,14 +50,19 @@
 
   /* write the numeric modes */
-  if (!strcmp (mode, "%d"))  snprintf (string, 81, "%-8s= %20d / %-s ",     field, va_arg (argp, int),      comment);
-  if (!strcmp (mode, "%u"))  snprintf (string, 81, "%-8s= %20d / %-s ",     field, va_arg (argp, unsigned), comment);
-  if (!strcmp (mode, "%ld")) snprintf (string, 81, "%-8s= %20ld / %-s ",    field, va_arg (argp, long),     comment);
-  if (!strcmp (mode, "%hd")) snprintf (string, 81, "%-8s= %20d / %-s ",     field, va_arg (argp, int),      comment);
-  if (!strcmp (mode, "%f"))  snprintf (string, 81, "%-8s= %20.10f / %-s ",  field, va_arg (argp, double),   comment); 
-  if (!strcmp (mode, "%lf")) snprintf (string, 81, "%-8s= %20.10f / %-s ",  field, va_arg (argp, double),   comment); 
-  if (!strcmp (mode, "%e"))  snprintf (string, 81, "%-8s= %20.10E / %-s ",  field, va_arg (argp, double),   comment); 
-  if (!strcmp (mode, "%le")) snprintf (string, 81, "%-8s= %20.10E / %-s ",  field, va_arg (argp, double),   comment); 
-  if (!strcmp (mode, "%g"))  snprintf (string, 81, "%-8s= %20.10G / %-s ",  field, va_arg (argp, double),   comment); 
-  if (!strcmp (mode, "%lg")) snprintf (string, 81, "%-8s= %20.10G / %-s ",  field, va_arg (argp, double),   comment); 
+  if (!strcmp (mode, "%d"))   snprintf (string, 81, "%-8s= %20d / %-s ",    field, va_arg (argp, int),       	      comment);
+  if (!strcmp (mode, "%ld"))  snprintf (string, 81, "%-8s= %20ld / %-s ",   field, va_arg (argp, long),      	      comment);
+  if (!strcmp (mode, "%lld")) snprintf (string, 81, "%-8s= %20lld / %-s ",  field, va_arg (argp, long long), 	      comment);
+  if (!strcmp (mode, "%Ld"))  snprintf (string, 81, "%-8s= %20lld / %-s ",  field, va_arg (argp, long long), 	      comment);
+  if (!strcmp (mode, "%u"))   snprintf (string, 81, "%-8s= %20u / %-s ",    field, va_arg (argp, unsigned),  	      comment);
+  if (!strcmp (mode, "%lu"))  snprintf (string, 81, "%-8s= %20lu / %-s ",   field, va_arg (argp, unsigned long),      comment);
+  if (!strcmp (mode, "%llu")) snprintf (string, 81, "%-8s= %20llu / %-s ",  field, va_arg (argp, unsigned long long), comment);
+  if (!strcmp (mode, "%Lu"))  snprintf (string, 81, "%-8s= %20llu / %-s ",  field, va_arg (argp, unsigned long long), comment);
+  if (!strcmp (mode, "%hd"))  snprintf (string, 81, "%-8s= %20d / %-s ",    field, va_arg (argp, int),      	      comment); 
+  if (!strcmp (mode, "%f"))   snprintf (string, 81, "%-8s= %20.10f / %-s ", field, va_arg (argp, double),   	      comment); 
+  if (!strcmp (mode, "%lf"))  snprintf (string, 81, "%-8s= %20.10f / %-s ", field, va_arg (argp, double),   	      comment); 
+  if (!strcmp (mode, "%e"))   snprintf (string, 81, "%-8s= %20.10E / %-s ", field, va_arg (argp, double),   	      comment); 
+  if (!strcmp (mode, "%le"))  snprintf (string, 81, "%-8s= %20.10E / %-s ", field, va_arg (argp, double),   	      comment); 
+  if (!strcmp (mode, "%g"))   snprintf (string, 81, "%-8s= %20.10G / %-s ", field, va_arg (argp, double),   	      comment); 
+  if (!strcmp (mode, "%lg"))  snprintf (string, 81, "%-8s= %20.10G / %-s ", field, va_arg (argp, double),   	      comment); 
 
   /* write the boolean mode */
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/header/F_print.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/header/F_print.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/header/F_print.c	(revision 27295)
@@ -27,7 +27,7 @@
 
   /* is there enough space for 1 more line? */
-  if (header[0].size - (p - (header[0].buffer)) < 2*FT_LINE_LENGTH) {
-    header[0].size += FT_RECORD_SIZE;
-    REALLOCATE (header[0].buffer, char, header[0].size);
+  if (header[0].datasize - (p - (header[0].buffer)) < 2*FT_LINE_LENGTH) {
+    header[0].datasize += FT_RECORD_SIZE;
+    REALLOCATE (header[0].buffer, char, header[0].datasize);
     /* re-find the "END" marker, in case new memory block is used */
     p = gfits_header_field (header, "END", 1);
@@ -45,14 +45,19 @@
 
   /* write the numeric modes */
-  if (!strcmp (mode, "%d"))  { snprintf (string, 81, "%-8s= %20d / %46s ",    field, va_arg (argp, int),      blank); }
-  if (!strcmp (mode, "%u"))  { snprintf (string, 81, "%-8s= %20d / %46s ",    field, va_arg (argp, unsigned), blank); }
-  if (!strcmp (mode, "%ld")) { snprintf (string, 81, "%-8s= %20ld / %46s ",   field, va_arg (argp, long),     blank); }
-  if (!strcmp (mode, "%hd")) { snprintf (string, 81, "%-8s= %20d / %46s ",    field, va_arg (argp, int),      blank); }
-  if (!strcmp (mode, "%f"))  { snprintf (string, 81, "%-8s= %20.10f / %46s ", field, va_arg (argp, double),   blank); }
-  if (!strcmp (mode, "%lf")) { snprintf (string, 81, "%-8s= %20.10f / %46s ", field, va_arg (argp, double),   blank); }
-  if (!strcmp (mode, "%e"))  { snprintf (string, 81, "%-8s= %20.10E / %46s ", field, va_arg (argp, double),   blank); }
-  if (!strcmp (mode, "%le")) { snprintf (string, 81, "%-8s= %20.10E / %46s ", field, va_arg (argp, double),   blank); }
-  if (!strcmp (mode, "%g"))  { snprintf (string, 81, "%-8s= %20.10G / %46s ", field, va_arg (argp, double),   blank); }
-  if (!strcmp (mode, "%lg")) { snprintf (string, 81, "%-8s= %20.10G / %46s ", field, va_arg (argp, double),   blank); }
+  if (!strcmp (mode, "%d"))  { snprintf (string, 81, "%-8s= %20d / %46s ",    field, va_arg (argp, int),                blank); }
+  if (!strcmp (mode, "%ld")) { snprintf (string, 81, "%-8s= %20ld / %46s ",   field, va_arg (argp, long),               blank); }
+  if (!strcmp (mode, "%lld")){ snprintf (string, 81, "%-8s= %20lld / %46s ",  field, va_arg (argp, long long),          blank); }
+  if (!strcmp (mode, "%Ld")) { snprintf (string, 81, "%-8s= %20lld / %46s ",  field, va_arg (argp, long long),          blank); }
+  if (!strcmp (mode, "%u"))  { snprintf (string, 81, "%-8s= %20u / %46s ",    field, va_arg (argp, unsigned),           blank); }
+  if (!strcmp (mode, "%lu")) { snprintf (string, 81, "%-8s= %20lu / %46s ",   field, va_arg (argp, unsigned long),      blank); }
+  if (!strcmp (mode, "%llu")){ snprintf (string, 81, "%-8s= %20llu / %46s ",  field, va_arg (argp, unsigned long long), blank); }
+  if (!strcmp (mode, "%Lu")) { snprintf (string, 81, "%-8s= %20llu / %46s ",  field, va_arg (argp, unsigned long long), blank); }
+  if (!strcmp (mode, "%hd")) { snprintf (string, 81, "%-8s= %20d / %46s ",    field, va_arg (argp, int),                blank); }
+  if (!strcmp (mode, "%f"))  { snprintf (string, 81, "%-8s= %20.10f / %46s ", field, va_arg (argp, double),             blank); }
+  if (!strcmp (mode, "%lf")) { snprintf (string, 81, "%-8s= %20.10f / %46s ", field, va_arg (argp, double),             blank); }
+  if (!strcmp (mode, "%e"))  { snprintf (string, 81, "%-8s= %20.10E / %46s ", field, va_arg (argp, double),             blank); }
+  if (!strcmp (mode, "%le")) { snprintf (string, 81, "%-8s= %20.10E / %46s ", field, va_arg (argp, double),             blank); }
+  if (!strcmp (mode, "%g"))  { snprintf (string, 81, "%-8s= %20.10G / %46s ", field, va_arg (argp, double),             blank); }
+  if (!strcmp (mode, "%lg")) { snprintf (string, 81, "%-8s= %20.10G / %46s ", field, va_arg (argp, double),             blank); }
 
   /* write the boolean mode */
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/header/F_read_H.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/header/F_read_H.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/header/F_read_H.c	(revision 27295)
@@ -23,8 +23,9 @@
 int gfits_load_header (FILE *f, Header *header) {
 
-  int i, done, Nbytes, t1, t2;
+  off_t i, Nbytes;
+  int done, t1, t2;
   char *p;
 
-  header[0].size = 0;
+  header[0].datasize = 0;
   done = FALSE;
   ALLOCATE (header[0].buffer, char, 1);
@@ -32,6 +33,5 @@
   for (i = 0; !done; i++) {
     REALLOCATE (header[0].buffer, char, (i + 1)*FT_RECORD_SIZE);
-    Nbytes = fread (&header[0].buffer[i*FT_RECORD_SIZE], 
-		    sizeof(char), FT_RECORD_SIZE, f);
+    Nbytes = fread (&header[0].buffer[i*FT_RECORD_SIZE], sizeof(char), FT_RECORD_SIZE, f);
     if (Nbytes != FT_RECORD_SIZE) {
       if (feof(f)) return (FALSE);
@@ -40,5 +40,5 @@
     }
     
-    header[0].size += Nbytes;
+    header[0].datasize += Nbytes;
 
     if (i == 0) { 
@@ -69,14 +69,14 @@
   gfits_scan (header,  "BZERO",  "%lf",  1, &header[0].bzero);
 				       
-  gfits_scan (header,  "NAXIS1", "%d", 1, &header[0].Naxis[0]);
-  gfits_scan (header,  "NAXIS2", "%d", 1, &header[0].Naxis[1]);
-  gfits_scan (header,  "NAXIS3", "%d", 1, &header[0].Naxis[2]);
-  gfits_scan (header,  "NAXIS4", "%d", 1, &header[0].Naxis[3]);
-  gfits_scan (header,  "NAXIS5", "%d", 1, &header[0].Naxis[4]);
-  gfits_scan (header,  "NAXIS6", "%d", 1, &header[0].Naxis[5]);
-  gfits_scan (header,  "NAXIS7", "%d", 1, &header[0].Naxis[6]);
-  gfits_scan (header,  "NAXIS8", "%d", 1, &header[0].Naxis[7]);
-  gfits_scan (header,  "NAXIS9", "%d", 1, &header[0].Naxis[8]);
-  gfits_scan (header, "NAXIS10", "%d", 1, &header[0].Naxis[9]);
+  gfits_scan (header,  "NAXIS1", "%lld", 1, &header[0].Naxis[0]);
+  gfits_scan (header,  "NAXIS2", "%lld", 1, &header[0].Naxis[1]);
+  gfits_scan (header,  "NAXIS3", "%lld", 1, &header[0].Naxis[2]);
+  gfits_scan (header,  "NAXIS4", "%lld", 1, &header[0].Naxis[3]);
+  gfits_scan (header,  "NAXIS5", "%lld", 1, &header[0].Naxis[4]);
+  gfits_scan (header,  "NAXIS6", "%lld", 1, &header[0].Naxis[5]);
+  gfits_scan (header,  "NAXIS7", "%lld", 1, &header[0].Naxis[6]);
+  gfits_scan (header,  "NAXIS8", "%lld", 1, &header[0].Naxis[7]);
+  gfits_scan (header,  "NAXIS9", "%lld", 1, &header[0].Naxis[8]);
+  gfits_scan (header, "NAXIS10", "%lld", 1, &header[0].Naxis[9]);
 
   if (!gfits_scan (header, "PCOUNT",  "%d", 1, &header[0].pcount)) {
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/header/F_read_XH.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/header/F_read_XH.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/header/F_read_XH.c	(revision 27295)
@@ -31,9 +31,10 @@
   /* read header for extension number N */
 
-  int j, Nmatrix, Nskip;
+  int j;
+  off_t Nmatrix, Nskip;
   Header theader;
   
   /* set f to beginning of file */
-  fseek (f, 0, SEEK_SET);
+  fseeko (f, 0, SEEK_SET);
 
   Nskip = 0;
@@ -47,6 +48,6 @@
 
     /* skip to next header */
-    fseek (f, Nmatrix, SEEK_CUR);
-    Nskip += (Nmatrix + theader.size);
+    fseeko (f, Nmatrix, SEEK_CUR);
+    Nskip += (Nmatrix + theader.datasize);
     gfits_free_header (&theader);
   }
@@ -55,5 +56,5 @@
     return (FALSE);
   }
-  Nskip += header[0].size;
+  Nskip += header[0].datasize;
   return (Nskip);
 }	
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/header/F_scan.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/header/F_scan.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/header/F_scan.c	(revision 27295)
@@ -17,5 +17,6 @@
   char *p, *q, *s, tmp[81];
   int Nchar, status;
-  double value;
+  long long value;
+  double fvalue;
   
   /* find the correct line with field */
@@ -77,14 +78,26 @@
   s = gfits_keyword_start (p); /* points at first char (not ') */
   q = gfits_keyword_end (p); /* points at following space or ' */
-  value = strtod (s, &q);
-  if ((*q == 'd') || (*q == 'D')) 
-    value *= pow (10.0, atof (q + 1));
-
-  if (!strcmp (mode, "%d"))  { *va_arg (argp, int *)       = value; return (TRUE); }
-  if (!strcmp (mode, "%u"))  { *va_arg (argp, unsigned *)  = value; return (TRUE); }
-  if (!strcmp (mode, "%ld")) { *va_arg (argp, long *)      = value; return (TRUE); }
-  if (!strcmp (mode, "%hd")) { *va_arg (argp, short *)     = value; return (TRUE); }
-  if (!strcmp (mode, "%f"))  { *va_arg (argp, float *)     = value; return (TRUE); }
-  if (!strcmp (mode, "%lf")) { *va_arg (argp, double *)    = value; return (TRUE); }
+
+  if (!strcmp (mode, "%f") || !strcmp (mode, "%lf")) {
+    fvalue = strtod (s, &q);
+    if ((*q == 'd') || (*q == 'D')) 
+      fvalue *= pow (10.0, atof (q + 1));
+
+    if (!strcmp (mode, "%f"))   { *va_arg (argp, float *)  = fvalue; return (TRUE); }
+    if (!strcmp (mode, "%lf"))  { *va_arg (argp, double *) = fvalue; return (TRUE); }
+  }
+
+  value = strtoll (s, &q, 0);
+  if ((*q == 'd') || (*q == 'D')) value *= pow (10.0, atof (q + 1));
+
+  if (!strcmp (mode, "%d"))   { *va_arg (argp, int *)       	     = value; return (TRUE); }
+  if (!strcmp (mode, "%ld"))  { *va_arg (argp, long *)      	     = value; return (TRUE); }
+  if (!strcmp (mode, "%lld")) { *va_arg (argp, long long *) 	     = value; return (TRUE); }
+  if (!strcmp (mode, "%Ld"))  { *va_arg (argp, long long *) 	     = value; return (TRUE); }
+  if (!strcmp (mode, "%u"))   { *va_arg (argp, unsigned *)  	     = value; return (TRUE); }
+  if (!strcmp (mode, "%lu"))  { *va_arg (argp, unsigned long *)      = value; return (TRUE); }
+  if (!strcmp (mode, "%llu")) { *va_arg (argp, unsigned long long *) = value; return (TRUE); }
+  if (!strcmp (mode, "%Lu"))  { *va_arg (argp, unsigned long long *) = value; return (TRUE); }
+  if (!strcmp (mode, "%hd"))  { *va_arg (argp, short *)     	     = value; return (TRUE); }
 
   /* no valid mode found */
@@ -97,5 +110,6 @@
   char *p, *q, *s, tmp[81];
   int Nchar, Nfield;
-  double value;
+  long long value;
+  double fvalue;
   
   /* find the correct line with field */
@@ -156,14 +170,26 @@
   s = gfits_hierarch_keyword_start (p, field); /* points at first char (not ') */
   q = gfits_hierarch_keyword_end (p, field); /* points at following space or ' */
-  value = strtod (s, &q);
-  if ((*q == 'd') || (*q == 'D')) 
-    value *= pow (10.0, atof (q + 1));
-
-  if (!strcmp (mode, "%d"))  { *va_arg (argp, int *)       = value; return (TRUE); }
-  if (!strcmp (mode, "%u"))  { *va_arg (argp, unsigned *)  = value; return (TRUE); }
-  if (!strcmp (mode, "%ld")) { *va_arg (argp, long *)      = value; return (TRUE); }
-  if (!strcmp (mode, "%hd")) { *va_arg (argp, short *)     = value; return (TRUE); }
-  if (!strcmp (mode, "%f"))  { *va_arg (argp, float *)     = value; return (TRUE); }
-  if (!strcmp (mode, "%lf")) { *va_arg (argp, double *)    = value; return (TRUE); }
+
+  if (!strcmp (mode, "%f") || !strcmp (mode, "%lf")) {
+    fvalue = strtod (s, &q);
+    if ((*q == 'd') || (*q == 'D')) 
+      fvalue *= pow (10.0, atof (q + 1));
+
+    if (!strcmp (mode, "%f"))   { *va_arg (argp, float *)  = fvalue; return (TRUE); }
+    if (!strcmp (mode, "%lf"))  { *va_arg (argp, double *) = fvalue; return (TRUE); }
+  }
+
+  value = strtoll (s, &q, 0);
+  if ((*q == 'd') || (*q == 'D')) value *= pow (10.0, atof (q + 1));
+
+  if (!strcmp (mode, "%d"))   { *va_arg (argp, int *)       	     = value; return (TRUE); }
+  if (!strcmp (mode, "%ld"))  { *va_arg (argp, long *)      	     = value; return (TRUE); }
+  if (!strcmp (mode, "%lld")) { *va_arg (argp, long long *) 	     = value; return (TRUE); }
+  if (!strcmp (mode, "%Ld"))  { *va_arg (argp, long long *) 	     = value; return (TRUE); }
+  if (!strcmp (mode, "%u"))   { *va_arg (argp, unsigned *)  	     = value; return (TRUE); }
+  if (!strcmp (mode, "%lu"))  { *va_arg (argp, unsigned long *)      = value; return (TRUE); }
+  if (!strcmp (mode, "%llu")) { *va_arg (argp, unsigned long long *) = value; return (TRUE); }
+  if (!strcmp (mode, "%Lu"))  { *va_arg (argp, unsigned long long *) = value; return (TRUE); }
+  if (!strcmp (mode, "%hd"))  { *va_arg (argp, short *)     	     = value; return (TRUE); }
 
   /* no valid mode found */
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/header/F_write_H.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/header/F_write_H.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/header/F_write_H.c	(revision 27295)
@@ -6,5 +6,6 @@
 
   FILE *f;
-  int Nbytes, status;
+  off_t Nbytes;
+  int status;
   
   status = TRUE;
@@ -13,7 +14,7 @@
   if (f == (FILE *) NULL) return (FALSE);
 
-  Nbytes = fwrite (header[0].buffer, sizeof(char), header[0].size, f);
+  Nbytes = fwrite (header[0].buffer, sizeof(char), header[0].datasize, f);
 
-  if (Nbytes != header[0].size) {
+  if (Nbytes != header[0].datasize) {
     status = FALSE;
   }
@@ -27,11 +28,12 @@
 int gfits_save_header (FILE *f, Header *header) {
 
-  int Nbytes, status;
+  off_t Nbytes; 
+  int status;
   
   status = TRUE;
 
-  Nbytes = fwrite (header[0].buffer, sizeof(char), header[0].size, f);
+  Nbytes = fwrite (header[0].buffer, sizeof(char), header[0].datasize, f);
 
-  if (Nbytes != header[0].size) {
+  if (Nbytes != header[0].datasize) {
     status = FALSE;
   }
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/include/gfitsio.h
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/include/gfitsio.h	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/include/gfitsio.h	(revision 27295)
@@ -44,11 +44,11 @@
 
 typedef struct {
-  int                     simple;
-  int                     unsign;
-  int                     extend;
-  int                     bitpix;
-  int                     Naxes;
-  int                     Naxis[FT_MAX_NAXES];
-  int                     size;
+  int                     simple; // T or F
+  int                     unsign; // T or F
+  int                     extend; // T or F
+  int                     bitpix; // 8, 16, 32, 64, or -32, -64
+  int                     Naxes;  // < FT_MAX_NAXES (10)
+  off_t                   Naxis[FT_MAX_NAXES];
+  off_t                   datasize;
   int                     pcount;
   int                     gcount;
@@ -65,6 +65,6 @@
   int                     bitpix;
   int                     Naxes;
-  int                     Naxis[FT_MAX_NAXES];
-  int                     size;
+  off_t                   Naxis[FT_MAX_NAXES];
+  off_t                   datasize;
   double                  bzero;
   double                  bscale;
@@ -76,5 +76,5 @@
   Header                 *header;
   char                   *buffer;
-  int                     size;
+  off_t                   datasize;
 } FTable;
 
@@ -83,16 +83,17 @@
   Header                 *header;
   char                  **buffer;
-  int                     Nrow;
-  int                    *row;
-  int                     size;  /* total buffer size */
-  int                     pad;   /* bytes of padding at the end */
+  off_t                   Nrow;
+  off_t                  *row;
+  off_t                   datasize;  /* total buffer size */
+  off_t                   pad;   /* bytes of padding at the end */
 } VTable;
 
 typedef struct {
-  int  maxlen; 		      // max size of all table rows
-  int  nbytes;		      // number of bytes per column element
-  int  Nstart;		      // byte offset of this column
-  int  heap_start;	      // byte offset to start of HEAP
-  char format;		      // data format character (one of: XLABIJEDCM)
+  int   maxlen; 	      // max size of all table rows
+  int   nbytes;		      // number of bytes per column element
+  int   Nstart;		      // byte offset of this column relative to first column
+  off_t heap_start;	      // byte offset to start of HEAP
+  char  format;		      // data format character (one of: XLABIJEDCM)
+  char  mode;		      // access data pointer type (one of P or Q)
 } VarLengthColumn;
 
@@ -106,5 +107,5 @@
 
 char   *gfits_header_field             PROTO((Header *header, char *field, int N)); 
-char   *gfits_header_lineno            PROTO((Header *header, int N)); 
+char   *gfits_header_lineno            PROTO((Header *header, off_t N)); 
 char   *gfits_keyword_end              PROTO((char *line));
 int     gfits_copy_header              PROTO((Header *in, Header *out)); 
@@ -128,6 +129,6 @@
 int     gfits_vscan                    PROTO((Header *header, char *field, char *mode, int N, va_list argp));
 int     gfits_write_header             PROTO((char *filename, Header *header)); 
-int     gfits_data_size                PROTO((Header *header));
-int     gfits_data_min_size            PROTO((Header *header));
+off_t   gfits_data_size                PROTO((Header *header));
+off_t   gfits_data_min_size            PROTO((Header *header));
 int 	gfits_extended_to_primary      PROTO((Header *header, int simple, char *comment));
 int 	gfits_primary_to_extended      PROTO((Header *header, char *exttype, char *comment));
@@ -143,5 +144,5 @@
 /******************************* Matrix functions *************/
 
-void   	gfits_add_matrix_value         PROTO((Matrix *matrix, int x, int y, double value)); 
+void   	gfits_add_matrix_value         PROTO((Matrix *matrix, off_t x, off_t y, double value)); 
 int    	gfits_convert_format           PROTO((Header *header, Matrix *matrix, int outBitpix, double outScale, double outZero, int inBlank, int outUnsign));
 int     gfits_copy_matrix              PROTO((Matrix *in, Matrix *out)); 
@@ -152,12 +153,12 @@
 void    gfits_free_matrix              PROTO((Matrix *matrix)); 
 int     gfits_fwrite_matrix            PROTO((FILE *f, Matrix *matrix));      
-double  gfits_get_matrix_value         PROTO((Matrix *matrix, int x, int y)); 
-void   	gfits_insert_array             PROTO((Matrix *matrix, Matrix *array, int x, int y)); 
+double  gfits_get_matrix_value         PROTO((Matrix *matrix, off_t x, off_t y)); 
+void   	gfits_insert_matrix            PROTO((Matrix *matrix, Matrix *array, off_t x, off_t y)); 
 int    	gfits_load_matrix              PROTO((FILE *f, Matrix *matrix, Header *header));
 int    	gfits_multiply_matrix          PROTO((Matrix *M1, Matrix *M2, Matrix *M3)); 
 int     gfits_read_matrix              PROTO((char *filename, Matrix *matrix));      
 int    	gfits_read_matrix_segment      PROTO((char *filename, Matrix *matrix, char *region));
-int     gfits_read_portion             PROTO((char *filename, Matrix *matrix, int Nskip, int Npix));
-void   	gfits_set_matrix_value         PROTO((Matrix *matrix, int x, int y, double value)); 
+int     gfits_read_portion             PROTO((char *filename, Matrix *matrix, off_t Nskip, off_t Npix));
+void   	gfits_set_matrix_value         PROTO((Matrix *matrix, off_t x, off_t y, double value)); 
 int     gfits_write_matrix             PROTO((char *filename, Matrix *matrix)); 
 int     gfits_uncompress_image 	       PROTO((Header *header, Matrix *matrix, FTable *ftable));
@@ -166,5 +167,5 @@
 int     gfits_byteswap_zdata   	       PROTO((char *zdata, int Nzdata, int bitpix));
 int     gfits_extension_is_compressed  PROTO((Header *header));
-int     gfits_tile_size                PROTO((Matrix *matrix, int *otile, int *ztile));
+off_t   gfits_tile_size                PROTO((Matrix *matrix, int *otile, int *ztile));
 int     gfits_uncompressed_data_pixsize PROTO((char *cmptype, int out_bitpix, char **optname, char **optvalue, int Noptions));
 int     gfits_vartable_heap_pixsize    PROTO((char format));
@@ -173,5 +174,5 @@
 
 char   *gfits_table_print              PROTO((FTable *ftable,...));
-int     gfits_add_rows                 PROTO((FTable *ftable, char *data, int Nrow, int Nbytes));
+int     gfits_add_rows                 PROTO((FTable *ftable, char *data, off_t Nrow, off_t Nbytes));
 int     gfits_bintable_format          PROTO((char *format, char *type, int *Nval, int *Nbytes));
 int     gfits_create_table             PROTO((Header *header, FTable *ftable));
@@ -181,28 +182,28 @@
 int   	gfits_fread_ftable             PROTO((FILE *f, FTable *ftable, char *extname)); 
 int   	gfits_fread_ftable_data        PROTO((FILE *f, FTable *ftable));
-int   	gfits_fread_ftable_range       PROTO((FILE *f, FTable *ftable, int start, int Nrows));
-int   	gfits_fread_vtable             PROTO((FILE *f, VTable *vtable, char *extname, int Nrow, int *row));
-int   	gfits_fread_vtable_range       PROTO((FILE *f, VTable *vtable, int start, int Nrows));
+int   	gfits_fread_ftable_range       PROTO((FILE *f, FTable *ftable, off_t start, off_t Nrows));
+int   	gfits_fread_vtable             PROTO((FILE *f, VTable *vtable, char *extname, off_t Nrow, off_t *row));
+int   	gfits_fread_vtable_range       PROTO((FILE *f, VTable *vtable, off_t start, off_t Nrows));
 int     gfits_free_table               PROTO((FTable *ftable));
 int     gfits_free_vtable              PROTO((VTable *vtable));
 int     gfits_fwrite_table             PROTO((FILE *f, FTable *table));
 int     gfits_fwrite_vtable            PROTO((FILE *f, VTable *table));
-int     gfits_fwrite_ftable_range      PROTO((FILE *f, FTable *table, int start, int Nrows, int Ndisk, int Ntotal));
+int     gfits_fwrite_ftable_range      PROTO((FILE *f, FTable *table, off_t start, off_t Nrows, off_t Ndisk, off_t Ntotal));
 int     gfits_get_bintable_column      PROTO((Header *header, FTable *table, char *label, void **data));
 int     gfits_get_bintable_column_type PROTO((Header *header, char *label, char *type, int *Nval));
-void   *gfits_get_bintable_column_data PROTO((Header *header, FTable *table, char *label, char *type, int *Nrow, int *Ncol));
+void   *gfits_get_bintable_column_data PROTO((Header *header, FTable *table, char *label, char *type, off_t *Nrow, int *Ncol));
 int     gfits_get_table_column         PROTO((Header *header, FTable *table, char *label, void **data));
 int     gfits_get_table_column_type    PROTO((Header *header, char *label, char *type));
 int     gfits_read_ftable              PROTO((char *filename, FTable *table, char *extname));
 int     gfits_read_table               PROTO((char *filename, FTable *ftable)); 
-int     gfits_set_bintable_column      PROTO((Header *header, FTable *table, char *label, void *data, int Nrow));
-int     gfits_set_table_column         PROTO((Header *header, FTable *table, char *label, void *data, int Nrow));
+int     gfits_set_bintable_column      PROTO((Header *header, FTable *table, char *label, void *data, off_t Nrow));
+int     gfits_set_table_column         PROTO((Header *header, FTable *table, char *label, void *data, off_t Nrow));
 int     gfits_table_column             PROTO((FTable *ftable, char *field, char *mode,...));
 int     gfits_table_format             PROTO((char *format, char *type, int *Nval, int *Nbytes));
 int     gfits_table_scale_data         PROTO((FTable *ftable));
 int     gfits_table_scale_storage      PROTO((FTable *ftable));
-int     gfits_table_to_vtable          PROTO((FTable *ftable, VTable *vtable, int start, int Nkeep));
-int     gfits_vadd_rows                PROTO((VTable *vtable, char *data, int Nrow, int Nbytes));
-int     gfits_vtable_from_ftable       PROTO((FTable *ftable, VTable *vtable, int *row, int Nrow));
+int     gfits_table_to_vtable          PROTO((FTable *ftable, VTable *vtable, off_t start, off_t Nkeep));
+int     gfits_vadd_rows                PROTO((VTable *vtable, char *data, off_t Nrow, off_t Nbytes));
+int     gfits_vtable_from_ftable       PROTO((FTable *ftable, VTable *vtable, off_t *row, off_t Nrow));
 int     gfits_write_table              PROTO((char *filename, FTable *ftable)); 
 
@@ -215,5 +216,5 @@
 
 int     gfits_varlength_column_define  PROTO((FTable *ftable, VarLengthColumn *def, int column));
-void   *gfits_varlength_column_pointer PROTO((FTable *ftable, VarLengthColumn *column, int row, int *length));
+void   *gfits_varlength_column_pointer PROTO((FTable *ftable, VarLengthColumn *column, off_t row, off_t *length));
 
 #endif /* FITSIO */
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/matrix/F_add_M.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/matrix/F_add_M.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/matrix/F_add_M.c	(revision 27295)
@@ -3,7 +3,5 @@
 
 /*********************** fits insert array ***********************************/
-void gfits_add_matrix (matrix, array, x, y) 
-Matrix *matrix, *array; 
-int x, y;
+void gfits_add_matrix (Matrix *matrix, Matrix *array, off_t x, off_t y) 
 {
 
@@ -15,7 +13,11 @@
   if ((x + array[0].Naxis[0] > matrix[0].Naxis[0]) ||
       (y + array[0].Naxis[1] > matrix[0].Naxis[1])) {
-    fprintf (stderr, "can't add array here: (%d,%d) - (%d,%d) vs (%d,%d)\n",
-	     x, y, x + array[0].Naxis[0], y + array[0].Naxis[1],
-	     matrix[0].Naxis[0], matrix[0].Naxis[1]);
+    fprintf (stderr, "can't add array here: (%lld,%lld) - (%lld,%lld) vs (%lld,%lld)\n",
+	     (long long) x, 
+	     (long long) y, 
+	     (long long) x + array[0].Naxis[0], 
+	     (long long) y + array[0].Naxis[1],
+	     (long long) matrix[0].Naxis[0], 
+	     (long long) matrix[0].Naxis[1]);
     return;
   }
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/matrix/F_add_M_value.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/matrix/F_add_M_value.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/matrix/F_add_M_value.c	(revision 27295)
@@ -3,8 +3,5 @@
 
 /***************** fits add matrix value ***********************************/
-void gfits_add_matrix_value (matrix, x, y, Value) 
-Matrix *matrix; 
-int x, y; 
-double Value;
+void gfits_add_matrix_value (Matrix *matrix, off_t x, off_t y, double Value) 
 {
 
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/matrix/F_compress_M.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/matrix/F_compress_M.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/matrix/F_compress_M.c	(revision 27295)
@@ -31,5 +31,6 @@
 int gfits_uncompress_image (Header *header, Matrix *matrix, FTable *ftable) {
 
-  int i, j, status, zimage, zcol, Nzrows, Nout, Nzdata, max_tile_size;
+  off_t Nzdata, Nzrows, zcol;
+  int i, j, status, zimage, Nout, max_tile_size;
   char cmptype[80];
   char zaxis[10], naxis[10], key[10], word[81], exttype[81], checksum[81], datasum[81];
@@ -196,7 +197,7 @@
   if (!gfits_varlength_column_define (ftable, &zdef, zcol)) ESCAPE;
   gfits_delete (header, "TFIELDS", 1);
-  snprintf (key, 10, "TTYPE%d", zcol);
+  snprintf (key, 10, "TTYPE%lld", (long long) zcol);
   gfits_delete (header, key, 1);
-  snprintf (key, 10, "TFORM%d", zcol);
+  snprintf (key, 10, "TFORM%lld", (long long) zcol);
   gfits_delete (header, key, 1);
 
@@ -236,12 +237,14 @@
   ALLOCATE (out, char, odata_pixsize*max_tile_size);
 
+  off_t row;
+
   // uncompress the data
   Nzrows = ftable->header->Naxis[1];
-  for (i = 0; i < Nzrows; i++) {
+  for (row = 0; row < Nzrows; row++) {
 
     // expected output size for this tile
     Nout = gfits_tile_size (matrix, otile, ztile);
 
-    zdata = gfits_varlength_column_pointer (ftable, &zdef, i, &Nzdata);
+    zdata = gfits_varlength_column_pointer (ftable, &zdef, row, &Nzdata);
     if (!zdata) return (FALSE);
 
@@ -254,4 +257,5 @@
 
     // gfits_uncompress_data uncompresses from zdata to the temporary output buffer which must be allocated
+    // XXX the tile must not be > 2GB
     if (!gfits_uncompress_data ((char *)zdata, Nzdata, cmptype, optname, optvalue, Noptions, out, &Nout, odata_pixsize)) return (FALSE);
 
@@ -284,7 +288,7 @@
 
 // true sizes of this tile (in pixels)
-int gfits_tile_size (Matrix *matrix, int *otile, int *ztile) {
-
-  int i, Npixels, Ndimen;
+off_t gfits_tile_size (Matrix *matrix, int *otile, int *ztile) {
+
+  off_t i, Npixels, Ndimen;
 
   Npixels = 1;
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/matrix/F_convert_format.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/matrix/F_convert_format.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/matrix/F_convert_format.c	(revision 27295)
@@ -24,5 +24,5 @@
       *out = *in*A + B;					\
     }							\
-  REALLOCATE (matrix[0].buffer, char, matrix[0].size); 
+  REALLOCATE (matrix[0].buffer, char, matrix[0].datasize); 
 
 # define CONVERTSAME(MY_NAN)			\
@@ -41,5 +41,5 @@
   inMode  *in;						\
   outMode *out;						\
-  REALLOCATE (matrix[0].buffer, char, matrix[0].size);	\
+  REALLOCATE (matrix[0].buffer, char, matrix[0].datasize);	\
   out = (outMode *)matrix[0].buffer + Npixels - 1;	\
   in  = (inMode  *)matrix[0].buffer + Npixels - 1;	\
@@ -62,5 +62,5 @@
       *out = *in*A + B;					\
     }							\
-  REALLOCATE (matrix[0].buffer, char, matrix[0].size); 
+  REALLOCATE (matrix[0].buffer, char, matrix[0].datasize); 
 
 # define CONVERTSAME_FF(MY_NAN)			\
@@ -79,5 +79,5 @@
   inMode  *in;						\
   outMode *out;						\
-  REALLOCATE (matrix[0].buffer, char, matrix[0].size);	\
+  REALLOCATE (matrix[0].buffer, char, matrix[0].datasize);	\
   out = (outMode *)matrix[0].buffer + Npixels - 1;	\
   in  = (inMode  *)matrix[0].buffer + Npixels - 1;	\
@@ -106,9 +106,9 @@
     return (TRUE);
 
-  matrix[0].bitpix = header[0].bitpix = outBitpix;
-  matrix[0].bscale = header[0].bscale = outScale;
-  matrix[0].bzero  = header[0].bzero  = outZero;
-  matrix[0].unsign = header[0].unsign = outUnsign;
-  matrix[0].size   = gfits_data_size (header);
+  matrix[0].bitpix   = header[0].bitpix = outBitpix;
+  matrix[0].bscale   = header[0].bscale = outScale;
+  matrix[0].bzero    = header[0].bzero  = outZero;
+  matrix[0].unsign   = header[0].unsign = outUnsign;
+  matrix[0].datasize = gfits_data_size (header);
   gfits_modify (header, "BITPIX", "%d", 1, outBitpix);
   gfits_modify (header, "BSCALE", "%lf", 1, outScale);
@@ -426,8 +426,8 @@
   {
     char *out;
-    int Nextra;
+    off_t Nextra;
     
     out = (char *)matrix[0].buffer;
-    Nextra = matrix[0].size - nbytes;
+    Nextra = matrix[0].datasize - nbytes;
     bzero (&out[nbytes], Nextra);
   }
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/matrix/F_copy_M.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/matrix/F_copy_M.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/matrix/F_copy_M.c	(revision 27295)
@@ -7,17 +7,17 @@
   int i;
 
-  matrix2[0].unsign = matrix1[0].unsign;
-  matrix2[0].bitpix = matrix1[0].bitpix;
-  matrix2[0].size   = matrix1[0].size;
-  matrix2[0].bzero  = matrix1[0].bzero;
-  matrix2[0].bscale = matrix1[0].bscale;
-  matrix2[0].Naxes  = matrix1[0].Naxes;
+  matrix2[0].unsign   = matrix1[0].unsign;
+  matrix2[0].bitpix   = matrix1[0].bitpix;
+  matrix2[0].datasize = matrix1[0].datasize;
+  matrix2[0].bzero    = matrix1[0].bzero;
+  matrix2[0].bscale   = matrix1[0].bscale;
+  matrix2[0].Naxes    = matrix1[0].Naxes;
   for (i = 0; i < FT_MAX_NAXES; i++) 
     matrix2[0].Naxis[i] = matrix1[0].Naxis[i];
 
   if (matrix2[0].buffer != NULL) free (matrix2[0].buffer);
-  ALLOCATE (matrix2[0].buffer, char, matrix2[0].size);
+  ALLOCATE (matrix2[0].buffer, char, matrix2[0].datasize);
   
-  memcpy (matrix2[0].buffer, matrix1[0].buffer, matrix2[0].size);
+  memcpy (matrix2[0].buffer, matrix1[0].buffer, matrix2[0].datasize);
 
   return (TRUE);
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/matrix/F_create_M.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/matrix/F_create_M.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/matrix/F_create_M.c	(revision 27295)
@@ -3,10 +3,8 @@
 
 /*********************** fits create matrix *******************************/
-int gfits_create_matrix (header, matrix) 
-Header *header;
-Matrix *matrix;
-{
+int gfits_create_matrix (Header *header, Matrix *matrix) {
 
-  int i, Nbytes;
+  int i;
+  off_t Nbytes;
 
   matrix[0].bitpix = header[0].bitpix;
@@ -20,7 +18,7 @@
   Nbytes = gfits_data_size (header);
   ALLOCATE (matrix[0].buffer, char, MAX (Nbytes, 1));
-  bzero (matrix[0].buffer, Nbytes);
+  memset (matrix[0].buffer, 0, Nbytes);
   
-  matrix[0].size = Nbytes;
+  matrix[0].datasize = Nbytes;
   return (TRUE);
 
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/matrix/F_get_M_value.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/matrix/F_get_M_value.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/matrix/F_get_M_value.c	(revision 27295)
@@ -3,5 +3,5 @@
 
 /***************** fits get matrix value ***********************************/
-double gfits_get_matrix_value (Matrix *matrix, int x, int y) {
+double gfits_get_matrix_value (Matrix *matrix, off_t x, off_t y) {
 
   double value;
@@ -11,5 +11,5 @@
     return (0.0);
   pixel = matrix[0].Naxis[0]*y + x;
-  value = HUGE_VAL;
+  value = NAN;
 
   if (matrix[0].unsign) {
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/matrix/F_insert_M.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/matrix/F_insert_M.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/matrix/F_insert_M.c	(revision 27295)
@@ -3,15 +3,20 @@
 
 /*********************** fits insert array ***********************************/
-void gfits_insert_matrix (Matrix *matrix, Matrix *array, int x, int y) {
+void gfits_insert_matrix (Matrix *matrix, Matrix *array, off_t x, off_t y) {
 
   /* there is no check here to match BITPIX, BZERO, or BSCALE */
 
-  int i, start_m, Nbytes_m, Nbytes;
+  int i;
+  off_t start_m, Nbytes_m, Nbytes;
 
   if ((x + array[0].Naxis[0] > matrix[0].Naxis[0]) ||
       (y + array[0].Naxis[1] > matrix[0].Naxis[1])) {
-    fprintf (stderr, "can't insert array here: (%d,%d) - (%d,%d) vs (%d,%d)\n",
-	     x, y, x + array[0].Naxis[0], y + array[0].Naxis[1],
-	     matrix[0].Naxis[0], matrix[0].Naxis[1]);
+    fprintf (stderr, "can't insert array here: (%lld,%lld) - (%lld,%lld) vs (%lld,%lld)\n",
+	     (long long) x, 
+	     (long long) y, 
+	     (long long) x + array[0].Naxis[0], 
+	     (long long) y + array[0].Naxis[1],
+	     (long long) matrix[0].Naxis[0], 
+	     (long long) matrix[0].Naxis[1]);
     return;
   }
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/matrix/F_load_M.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/matrix/F_load_M.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/matrix/F_load_M.c	(revision 27295)
@@ -13,5 +13,6 @@
 int gfits_load_matrix (FILE *f, Matrix *matrix, Header *header) {
 
-  int i, nbytes, Nbytes;
+  
+  off_t i, nbytes, Nbytes;
 
   matrix[0].bitpix = header[0].bitpix;
@@ -25,5 +26,5 @@
   Nbytes = gfits_data_size (header);
   ALLOCATE (matrix[0].buffer, char, Nbytes);
-  matrix[0].size = Nbytes;
+  matrix[0].datasize = Nbytes;
 
   nbytes = fread (matrix[0].buffer, sizeof(char), Nbytes, f);
@@ -94,5 +95,5 @@
   }
   if (nbytes != Nbytes) {  /* this is a FITS error, but often the image is OK */
-    fprintf (stderr, "incomplete block in FITS file: (%d, %d)\n", nbytes, Nbytes);
+    fprintf (stderr, "incomplete block in FITS file: (%lld, %lld)\n", (long long) nbytes, (long long) Nbytes);
     return (TRUE); 
   }
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/matrix/F_matrix.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/matrix/F_matrix.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/matrix/F_matrix.c	(revision 27295)
@@ -2,7 +2,8 @@
 # include <gfitsio.h>
 
-int gfits_data_size (Header *header) {
+off_t gfits_data_size (Header *header) {
   
-  int i, Nrec, size;
+  int i;
+  off_t Nrec, size;
 
   if (header[0].Naxes == 0) return (0);
@@ -25,7 +26,8 @@
 }
 
-int gfits_data_min_size (Header *header) {
+off_t gfits_data_min_size (Header *header) {
   
-  int i, size;
+  int i;
+  off_t size;
 
   if (header[0].Naxes == 0) return (0);
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/matrix/F_read_M.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/matrix/F_read_M.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/matrix/F_read_M.c	(revision 27295)
@@ -18,5 +18,5 @@
   if (f == NULL) return (FALSE);
 
-  fseek (f, header.size, 0);
+  fseeko (f, header.datasize, 0);
   
   status = gfits_load_matrix (f, matrix, &header);
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/matrix/F_read_portion.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/matrix/F_read_portion.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/matrix/F_read_portion.c	(revision 27295)
@@ -9,9 +9,10 @@
 /*********************** fits read matrix ***********************************/
 /** the result of this function is a matrix with dimension Npix * 1 **/
-int gfits_read_portion (char *filename, Matrix *matrix, int Nskip, int Npix) {
+int gfits_read_portion (char *filename, Matrix *matrix, off_t Nskip, off_t Npix) {
 
   FILE *f;
   Header header;
-  int status, nbytes, Nbytes, Nrec;
+  int status;
+  off_t nbytes, Nbytes, Nrec;
 
   status = gfits_read_header (filename, &header);
@@ -37,5 +38,5 @@
     Nbytes = FT_RECORD_SIZE * Nrec;
   }
-  matrix[0].size = Nbytes;
+  matrix[0].datasize = Nbytes;
   ALLOCATE (matrix[0].buffer, char, Nbytes);
 
@@ -43,5 +44,5 @@
   f = fopen (filename, "r");
   if (f == NULL) return (FALSE);
-  fseek (f, header.size + Nskip, SEEK_SET);
+  fseeko (f, header.datasize + Nskip, SEEK_SET);
   nbytes = fread (matrix[0].buffer, sizeof(char), Nbytes, f);
   if (nbytes != Nbytes) {
@@ -52,53 +53,54 @@
 
 # ifdef BYTE_SWAP  
- {
-  int i, perpix;
-  unsigned char *byte0, *byte1, *byte2, *byte3, *byte4, *byte5, *byte6, *byte7, ctmp;
+  {
+    off_t i;
+    int perpix;
+    unsigned char *byte0, *byte1, *byte2, *byte3, *byte4, *byte5, *byte6, *byte7, ctmp;
 
-  perpix = abs(header.bitpix) / 8;
-  if (perpix > 1) {
-    byte0 = (unsigned char *) matrix[0].buffer;
-    byte1 = (unsigned char *) matrix[0].buffer + 1;
-    byte2 = (unsigned char *) matrix[0].buffer + 2;
-    byte3 = (unsigned char *) matrix[0].buffer + 3;
-    byte4 = (unsigned char *) matrix[0].buffer + 4;
-    byte5 = (unsigned char *) matrix[0].buffer + 5;
-    byte6 = (unsigned char *) matrix[0].buffer + 6;
-    byte7 = (unsigned char *) matrix[0].buffer + 7;
-    if (perpix == 2) {
-      for (i = 0; i < nbytes; i+=2, byte0 += 2, byte1 += 2) {
-	ctmp = *byte0;
-	*byte0 = *byte1;
-	*byte1 = ctmp;
+    perpix = abs(header.bitpix) / 8;
+    if (perpix > 1) {
+      byte0 = (unsigned char *) matrix[0].buffer;
+      byte1 = (unsigned char *) matrix[0].buffer + 1;
+      byte2 = (unsigned char *) matrix[0].buffer + 2;
+      byte3 = (unsigned char *) matrix[0].buffer + 3;
+      byte4 = (unsigned char *) matrix[0].buffer + 4;
+      byte5 = (unsigned char *) matrix[0].buffer + 5;
+      byte6 = (unsigned char *) matrix[0].buffer + 6;
+      byte7 = (unsigned char *) matrix[0].buffer + 7;
+      if (perpix == 2) {
+	for (i = 0; i < nbytes; i+=2, byte0 += 2, byte1 += 2) {
+	  ctmp = *byte0;
+	  *byte0 = *byte1;
+	  *byte1 = ctmp;
+	}
       }
-    }
-    if (perpix == 4) {
-      for (i = 0; i < nbytes; i+=4, byte0 += 4, byte1 += 4, byte2 += 4, byte3 += 4) {
-	ctmp = *byte0;
-	*byte0 = *byte3;
-	*byte3 = ctmp;
-	ctmp = *byte1;
-	*byte1 = *byte2;
-	*byte2 = ctmp;
+      if (perpix == 4) {
+	for (i = 0; i < nbytes; i+=4, byte0 += 4, byte1 += 4, byte2 += 4, byte3 += 4) {
+	  ctmp = *byte0;
+	  *byte0 = *byte3;
+	  *byte3 = ctmp;
+	  ctmp = *byte1;
+	  *byte1 = *byte2;
+	  *byte2 = ctmp;
+	}
       }
-    }
-    if (perpix == 8) {
-      for (i = 0; i < nbytes; i+=8, byte0 += 8, byte1 += 8, byte2 += 8, byte3 += 8, byte4 += 8, byte5 += 8, byte6 += 8, byte7 += 8) {
-	ctmp = *byte0;
-	*byte0 = *byte7;
-	*byte7 = ctmp;
-	ctmp = *byte1;
-	*byte1 = *byte6;
-	*byte6 = ctmp;
-	ctmp = *byte1;
-	*byte2 = *byte5;
-	*byte5 = ctmp;
-	ctmp = *byte1;
-	*byte3 = *byte4;
-	*byte4 = ctmp;
+      if (perpix == 8) {
+	for (i = 0; i < nbytes; i+=8, byte0 += 8, byte1 += 8, byte2 += 8, byte3 += 8, byte4 += 8, byte5 += 8, byte6 += 8, byte7 += 8) {
+	  ctmp = *byte0;
+	  *byte0 = *byte7;
+	  *byte7 = ctmp;
+	  ctmp = *byte1;
+	  *byte1 = *byte6;
+	  *byte6 = ctmp;
+	  ctmp = *byte1;
+	  *byte2 = *byte5;
+	  *byte5 = ctmp;
+	  ctmp = *byte1;
+	  *byte3 = *byte4;
+	  *byte4 = ctmp;
+	}
       }
     }
   }
- }
 # endif
 
@@ -106,9 +108,9 @@
 
   if (nbytes < Nbytes - 2880) {  /* this is a bad FITS error: image is not OK */
-    fprintf (stderr, "error reading in matrix data from FITS file %s (%d < %d - 2880)\n", filename, nbytes, Nbytes);
+    fprintf (stderr, "error reading in matrix data from FITS file %s (%lld < %lld - 2880)\n", filename, (long long) nbytes, (long long) Nbytes);
     return (FALSE);
   }
   if (nbytes != Nbytes) {  /* this is a FITS error, but often the image is OK */
-    fprintf (stderr, "incomplete block in %s: (%d, %d)\n", filename, nbytes, Nbytes);
+    fprintf (stderr, "incomplete block in %s: (%lld, %lld)\n", filename, (long long) nbytes, (long long) Nbytes);
     return (TRUE); 
   }
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/matrix/F_read_segment.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/matrix/F_read_segment.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/matrix/F_read_segment.c	(revision 27295)
@@ -36,5 +36,6 @@
 int gfits_fread_matrix_segment (FILE *f, Matrix *matrix, Header *header, char *region) {
 
-  int status, i, nbytes, Nbytes, Nskip, NbytesData;
+  int status;
+  off_t i, nbytes, Nbytes, Nskip, NbytesData;
   int wantaxis[FT_MAX_NAXES][2];
   double tmp;
@@ -65,15 +66,15 @@
     matrix[0].Naxis[i] = wantaxis[i][1] - wantaxis[i][0];
 
-  matrix[0].size = abs (matrix[0].bitpix) / 8;
+  matrix[0].datasize = abs (matrix[0].bitpix) / 8;
   for (i = 0; i < matrix[0].Naxes; i++)
-    matrix[0].size *= matrix[0].Naxis[i];
+    matrix[0].datasize *= matrix[0].Naxis[i];
 
   Nskip = wantaxis[2][0]*matrix[0].Naxis[0]*matrix[0].Naxis[1]*abs(matrix[0].bitpix)/8;
-  NbytesData = Nskip + matrix[0].size;
+  NbytesData = Nskip + matrix[0].datasize;
 
   if (NbytesData % FT_RECORD_SIZE) 
-    Nbytes = FT_RECORD_SIZE * ((int) (NbytesData / FT_RECORD_SIZE) + 1) - Nskip;
+    Nbytes = FT_RECORD_SIZE * ((off_t) (NbytesData / FT_RECORD_SIZE) + 1) - Nskip;
   else 
-    Nbytes = FT_RECORD_SIZE * ((int) (NbytesData / FT_RECORD_SIZE)) - Nskip;
+    Nbytes = FT_RECORD_SIZE * ((off_t) (NbytesData / FT_RECORD_SIZE)) - Nskip;
 
   ALLOCATE (matrix[0].buffer, char, MAX (Nbytes, 1));
@@ -86,5 +87,5 @@
 
   /* currently only good for reading in full planes in 3-D */
-  fseek (f, Nskip, SEEK_CUR);
+  fseeko (f, Nskip, SEEK_CUR);
   nbytes = fread (matrix[0].buffer, sizeof(char), Nbytes, f);
   if (nbytes != Nbytes) {
@@ -92,5 +93,5 @@
   }
 
-  matrix[0].size = Nbytes;
+  matrix[0].datasize = Nbytes;
 
 # ifdef BYTE_SWAP  
@@ -147,9 +148,9 @@
 
   if (nbytes < Nbytes - 2880) {  /* this is a bad FITS error: image is not OK */
-    fprintf (stderr, "error reading in matrix data from FITS file (%d < %d - 2880)\n", nbytes, Nbytes);
+    fprintf (stderr, "error reading in matrix data from FITS file (%lld < %lld - 2880)\n", (long long) nbytes, (long long) Nbytes);
     return (FALSE);
   }
   if (nbytes != Nbytes) {  /* this is a FITS error, but often the image is OK */
-    fprintf (stderr, "incomplete block in FITS file: (%d, %d)\n", nbytes, Nbytes);
+    fprintf (stderr, "incomplete block in FITS file: (%lld, %lld)\n", (long long) nbytes, (long long) Nbytes);
     return (TRUE); 
   }
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/matrix/F_set_M_value.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/matrix/F_set_M_value.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/matrix/F_set_M_value.c	(revision 27295)
@@ -3,7 +3,7 @@
 
 /****************** fits set matrix value ***********************************/
-void gfits_set_matrix_value (Matrix *matrix, int x, int y, double Value) {
+void gfits_set_matrix_value (Matrix *matrix, off_t x, off_t y, double Value) {
 
-  int pixel;
+  off_t pixel;
   double value;
 
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/matrix/F_write_M.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/matrix/F_write_M.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/matrix/F_write_M.c	(revision 27295)
@@ -11,5 +11,5 @@
   if (f == NULL) return (FALSE);
   
-  fseek (f, 0, SEEK_END);  /* write matrix to end of file! */
+  fseeko (f, 0LL, SEEK_END);  /* write matrix to end of file! */
 
   status = gfits_fwrite_matrix (f, matrix);
@@ -21,5 +21,6 @@
 int gfits_fwrite_matrix (FILE *f, Matrix *matrix) {
 
-  int status, nbytes, Nbytes;
+  int status;
+  off_t nbytes, Nbytes;
 
   status = TRUE;
@@ -27,16 +28,16 @@
   /* this is a bit dangerous: we are not realloc'ing the matrix.
      if the size is wrong, it probably should simply pad the fwrite statement.
-     better policy should be defined (ie, matrix.size always correct blocking?)
+     better policy should be defined (ie, matrix.datasize always correct blocking?)
   */
 
-  if (matrix[0].size % FT_RECORD_SIZE) 
-    nbytes = FT_RECORD_SIZE * ((int) (matrix[0].size / FT_RECORD_SIZE) + 1);
+  if (matrix[0].datasize % FT_RECORD_SIZE) 
+    nbytes = FT_RECORD_SIZE * ((off_t) (matrix[0].datasize / FT_RECORD_SIZE) + 1);
   else 
-    nbytes = FT_RECORD_SIZE * ((int) (matrix[0].size / FT_RECORD_SIZE));
+    nbytes = FT_RECORD_SIZE * ((off_t) (matrix[0].datasize / FT_RECORD_SIZE));
 
   /* this is a bit cumbersome: swap all words, write out file, then swap back... */
 # ifdef BYTE_SWAP  
   { 
-    int i;
+    off_t i;
     unsigned char *byte0, *byte1, *byte2, *byte3, *byte4, *byte5, *byte6, *byte7, tmp;
     int perpix;
@@ -96,5 +97,5 @@
 # ifdef BYTE_SWAP 
   {
-    int i;
+    off_t i;
     unsigned char *byte0, *byte1, *byte2, *byte3, *byte4, *byte5, *byte6, *byte7, tmp;
     int perpix;
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/table/F_create_T.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/table/F_create_T.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/table/F_create_T.c	(revision 27295)
@@ -5,5 +5,5 @@
 int gfits_create_table (Header *header, FTable *table) {
 
-  int Nbytes;
+  off_t Nbytes;
   char type[80];
 
@@ -19,5 +19,5 @@
     memset (table[0].buffer, 0, Nbytes);
   }
-  table[0].size = Nbytes;
+  table[0].datasize = Nbytes;
   return (TRUE);
 
@@ -29,5 +29,5 @@
 int gfits_create_vtable (Header *header, VTable *table, int Nrow) {
 
-  int i, Nx, Ny;
+  off_t i, Nx, Ny;
   char type[80];
 
@@ -37,10 +37,10 @@
   Nx = table[0].header[0].Naxis[0];
   Ny = table[0].header[0].Naxis[0];
-  table[0].size = gfits_data_size (header);
-  table[0].pad = table[0].size - Nx*Ny;
+  table[0].datasize = gfits_data_size (header);
+  table[0].pad = table[0].datasize - Nx*Ny;
  
   table[0].Nrow = Nrow;
   ALLOCATE (table[0].buffer, char *, MAX (Nrow, 1));
-  ALLOCATE (table[0].row, int, MAX (Nrow, 1));
+  ALLOCATE (table[0].row, off_t, MAX (Nrow, 1));
   for (i = 0; i < Nrow; i++) {
     ALLOCATE (table[0].buffer[i], char, Nx);
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/table/F_create_TH.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/table/F_create_TH.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/table/F_create_TH.c	(revision 27295)
@@ -13,5 +13,5 @@
   char axis[10];
   
-  header[0].size = NBYTES;
+  header[0].datasize = NBYTES;
 
   ALLOCATE (header[0].buffer, char, NBYTES);
@@ -27,5 +27,5 @@
   for (i = 0; i < header[0].Naxes; i++) {
     sprintf (axis, "NAXIS%d", i + 1);
-    gfits_modify (header,  axis, "%d", 1, header[0].Naxis[i], 1);
+    gfits_modify (header,  axis, "%lld", 1, header[0].Naxis[i]);
   }
   
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/table/F_define_column.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/table/F_define_column.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/table/F_define_column.c	(revision 27295)
@@ -5,5 +5,6 @@
 int gfits_define_bintable_column (Header *header, char *format, char *label, char *comment, char *unit, double bscale, double bzero) {
 
-  int Nfields, Nbytes, Nval, Naxis1;
+  off_t Naxis1;
+  int Nfields, Nbytes, Nval;
   char type[16], field[16];
   
@@ -12,5 +13,5 @@
   Nfields = 0;
   gfits_scan (header, "TFIELDS", "%d", 1, &Nfields);
-  gfits_scan (header, "NAXIS1",  "%d", 1, &Naxis1);
+  gfits_scan (header, "NAXIS1",  "%lld", 1, &Naxis1);
   Nfields ++;
   Naxis1 += Nbytes*Nval;
@@ -34,5 +35,5 @@
   /* update TFIELDS & NAXIS1 */
   gfits_modify (header, "TFIELDS", "%d", 1, Nfields);
-  gfits_modify (header, "NAXIS1",  "%d", 1, Naxis1);
+  gfits_modify (header, "NAXIS1",  "%lld", 1, Naxis1);
   header[0].Naxis[0] = Naxis1;
 
@@ -43,5 +44,6 @@
 int gfits_define_table_column (Header *header, char *format, char *label, char *comment, char *unit) {
 
-  int Nstart, Nfields, Nbytes, Nval, Naxis1;
+  off_t Naxis1;
+  int Nstart, Nfields, Nbytes, Nval;
   char type[16], field[16], cformat[16];
 
@@ -51,5 +53,5 @@
   Nfields = 0;
   gfits_scan (header, "TFIELDS", "%d", 1, &Nfields);
-  gfits_scan (header, "NAXIS1",  "%d", 1, &Naxis1);
+  gfits_scan (header, "NAXIS1",  "%lld", 1, &Naxis1);
   Nstart = Naxis1 + 1;
   Nfields ++;
@@ -68,5 +70,5 @@
 
   gfits_modify (header, "TFIELDS", "%d", 1, Nfields);
-  gfits_modify (header, "NAXIS1",  "%d", 1, Naxis1);
+  gfits_modify (header, "NAXIS1",  "%lld", 1, Naxis1);
   header[0].Naxis[0] = Naxis1;
 
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/table/F_get_column.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/table/F_get_column.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/table/F_get_column.c	(revision 27295)
@@ -16,7 +16,8 @@
   tmp = Pin[3]; Pin[3] = Pin[4]; Pin[4] = tmp; }
 
-void *gfits_get_bintable_column_data (Header *header, FTable *table, char *label, char *type, int *Nrow, int *Ncol) {
-
-  int i, N, Nfields, Nval, Nbytes, Nx, Ny, Nstart, Nv, Nb;
+void *gfits_get_bintable_column_data (Header *header, FTable *table, char *label, char *type, off_t *Nrow, int *Ncol) {
+
+  off_t Nx, Ny;
+  int i, N, Nfields, Nval, Nbytes, Nstart, Nv, Nb;
   char tlabel[80], field[80], format[80], tmpline[16];
   char *Pin, *Pout, *array;
@@ -50,6 +51,6 @@
   
   /* check existing table dimensions */
-  gfits_scan (header, "NAXIS1",  "%d", 1, &Nx);
-  gfits_scan (header, "NAXIS2",  "%d", 1, &Ny);
+  gfits_scan (header, "NAXIS1",  "%lld", 1, &Nx);
+  gfits_scan (header, "NAXIS2",  "%lld", 1, &Ny);
 
   /* scan columns to find insert point */
@@ -153,5 +154,6 @@
 int gfits_get_bintable_column (Header *header, FTable *table, char *label, void **data) {
 
-  int i, N, Nfields, Nval, Nbytes, Nx, Ny, Nstart, Nv, Nb;
+  off_t Nx, Ny;
+  int i, N, Nfields, Nval, Nbytes, Nstart, Nv, Nb;
   char tlabel[80], field[80], format[80], type[16], tmpline[16];
   char *Pin, *Pout, *array;
@@ -185,6 +187,6 @@
   
   /* check existing table dimensions */
-  gfits_scan (header, "NAXIS1",  "%d", 1, &Nx);
-  gfits_scan (header, "NAXIS2",  "%d", 1, &Ny);
+  gfits_scan (header, "NAXIS1",  "%lld", 1, &Nx);
+  gfits_scan (header, "NAXIS2",  "%lld", 1, &Ny);
 
   /* scan columns to find insert point */
@@ -307,5 +309,6 @@
 int gfits_get_table_column (Header *header, FTable *table, char *label, void **data) {
 
-  int i, N, Nfields, Nval, Nbytes, Nx, Ny, Nstart, Nv, Nb;
+  off_t Nx, Ny;
+  int i, N, Nfields, Nval, Nbytes, Nstart, Nv, Nb;
   char tlabel[80], field[80], format[80], cformat[80], type[16], tmp[16];
   char *array, *Pin, *Pout, *line;
@@ -333,6 +336,6 @@
   
   /* check existing table dimensions */
-  gfits_scan (header, "NAXIS1",  "%d", 1, &Nx);
-  gfits_scan (header, "NAXIS2",  "%d", 1, &Ny);
+  gfits_scan (header, "NAXIS1",  "%lld", 1, &Nx);
+  gfits_scan (header, "NAXIS2",  "%lld", 1, &Ny);
 
   /* scan columns to find insert point */
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/table/F_read_T.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/table/F_read_T.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/table/F_read_T.c	(revision 27295)
@@ -19,10 +19,11 @@
 int gfits_fread_ftable (FILE *f, FTable *table, char *extname) {
 
-  int j, found, Nbytes;
+  int j, found;
+  off_t Nbytes;
   Header *header;
   char tname[80];
 
   header = table[0].header;
-  fseek (f, 0, SEEK_SET);
+  fseeko (f, 0, SEEK_SET);
 
   found = FALSE;
@@ -42,5 +43,5 @@
     /* skip to next header */
     Nbytes = gfits_data_size (header);
-    fseek (f, Nbytes, SEEK_CUR);
+    fseeko (f, Nbytes, SEEK_CUR);
     gfits_free_header (header);
   }
@@ -51,5 +52,5 @@
 int gfits_fread_ftable_data (FILE *f, FTable *table) {
 
-  int Nbytes, Nread;
+  off_t Nbytes, Nread;
   char string[128];
 
@@ -63,5 +64,5 @@
     perror (string);
     if (Nread < gfits_data_min_size (table[0].header)) {
-      fprintf (stderr, "error: fits read error in %s, read %d, need %d\n", __func__, Nread, gfits_data_min_size (table[0].header));
+      fprintf (stderr, "error: fits read error in %s, read %lld, need %lld\n", __func__, (long long) Nread, (long long) gfits_data_min_size (table[0].header));
       gfits_free_table  (table);
       return (FALSE);
@@ -69,12 +70,12 @@
     fprintf (stderr, "warning: file missing pad\n");
   }
-  table[0].size = Nbytes;
+  table[0].datasize = Nbytes;
   return (TRUE);
 }	
 
 /*********************** fits read ftable data ***********************************/
-int gfits_fread_ftable_range (FILE *f, FTable *table, int start, int Nrows) {
-
-  int Nbytes, Nread, Nskip, Nx, Ny;
+int gfits_fread_ftable_range (FILE *f, FTable *table, off_t start, off_t Nrows) {
+
+  off_t Nbytes, Nread, Nskip, Nx, Ny;
 
   /* find disk table size */
@@ -93,5 +94,5 @@
   ALLOCATE (table[0].buffer, char, MAX (Nbytes, 1));
 
-  fseek (f, Nskip, SEEK_CUR);
+  fseeko (f, Nskip, SEEK_CUR);
 
   Nread = fread (table[0].buffer, sizeof (char), Nbytes, f);
@@ -108,6 +109,6 @@
   /* modify structure and header to match actual read rows Ny */
   table[0].header[0].Naxis[1] = Nrows;
-  gfits_modify (table[0].header, "NAXIS2",  "%d", 1, Nrows);
-  table[0].size = gfits_data_size (table[0].header);
+  gfits_modify (table[0].header, "NAXIS2",  "%lld", 1, Nrows);
+  table[0].datasize = gfits_data_size (table[0].header);
 
   return (TRUE);
@@ -115,7 +116,7 @@
 
 /*********************** fits read ftable data ***********************************/
-int gfits_fread_vtable_range (FILE *f, VTable *table, int start, int Nrows) {
-
-  int i, Nbytes, Nread, Nskip, Nx, Ny;
+int gfits_fread_vtable_range (FILE *f, VTable *table, off_t start, off_t Nrows) {
+
+  off_t i, Nbytes, Nread, Nskip, Nx, Ny;
   char *buffer;
 
@@ -123,6 +124,6 @@
   Nx = table[0].header[0].Naxis[0];
   Ny = table[0].header[0].Naxis[1];
-  table[0].size = gfits_data_size (table[0].header);
-  table[0].pad = table[0].size - Nx*Ny;
+  table[0].datasize = gfits_data_size (table[0].header);
+  table[0].pad = table[0].datasize - Nx*Ny;
 
   if (start < 0) return (FALSE);
@@ -133,5 +134,5 @@
   ALLOCATE (buffer, char, MAX (Nbytes, 1));
 
-  fseek (f, Nskip, SEEK_CUR);
+  fseeko (f, Nskip, SEEK_CUR);
   Nread = fread (buffer, sizeof (char), Nbytes, f);
   if (Nread != Nbytes) {
@@ -141,5 +142,5 @@
   }
 
-  ALLOCATE (table[0].row, int, MAX (Nrows, 1));
+  ALLOCATE (table[0].row, off_t, MAX (Nrows, 1));
   ALLOCATE (table[0].buffer, char *, MAX (Nrows, 1));
   for (i = 0; i < Nrows; i++) {
@@ -154,13 +155,14 @@
 
 /*********************** fits read virtual table ***********************************/
-int gfits_fread_vtable (FILE *f, VTable *table, char *extname, int Nrow, int *row) {
-
-  int i, j, Nbytes, Nread;
-  int start, Nx, Ny, offset;
+int gfits_fread_vtable (FILE *f, VTable *table, char *extname, off_t Nrow, off_t *row) {
+
+  off_t i, j;
+  off_t Nbytes, Nread;
+  off_t start, Nx, Ny, offset;
   Header *header;
   char tname[80];
 
   header = table[0].header;
-  fseek (f, 0, SEEK_SET);
+  fseeko (f, 0, SEEK_SET);
 
   for (j = -1; TRUE; j++) {
@@ -176,5 +178,5 @@
     if (strcmp (tname, extname)) {
       /* skip to next header */
-      fseek (f, Nbytes, SEEK_CUR);
+      fseeko (f, Nbytes, SEEK_CUR);
       gfits_free_header (header);
       continue;
@@ -182,7 +184,7 @@
 
     /* file pointer is at beginning of desired table data */
-    start = ftell (f);
-    gfits_scan (header, "NAXIS1", "%d", 1, &Nx);
-    gfits_scan (header, "NAXIS2", "%d", 1, &Ny);
+    start = ftello (f);
+    gfits_scan (header, "NAXIS1", "%lld", 1, &Nx);
+    gfits_scan (header, "NAXIS2", "%lld", 1, &Ny);
     for (i = 0; i < Nrow; i++) {
       if (row[i] > Ny) { return (FALSE); }
@@ -193,5 +195,5 @@
       ALLOCATE (table[0].buffer[i], char, MAX (1, Nx));
       offset = start + Nx*row[i];
-      fseek (f, offset, SEEK_SET);
+      fseeko (f, offset, SEEK_SET);
       Nread = fread (table[0].buffer[i], sizeof (char), Nx, f);
       if (Nread != Nx) { 
@@ -202,8 +204,8 @@
 
     table[0].Nrow  = Nrow;
-    ALLOCATE (table[0].row, int, MAX (1, Nrow));    
+    ALLOCATE (table[0].row, off_t, MAX (1, Nrow));    
     for (i = 0; i < Nrow; i++) table[0].row[i] = row[i];
-    table[0].size   = gfits_data_size (table[0].header);
-    table[0].pad    = table[0].size - Nx*Ny;
+    table[0].datasize = gfits_data_size (table[0].header);
+    table[0].pad      = table[0].datasize - Nx*Ny;
     return (TRUE);
   }
@@ -212,8 +214,8 @@
 int gfits_fread_header_extname (FILE *f, Header *header, char *extname) {
 
-  int Nbytes;
+  off_t Nbytes;
   char current[80];
 
-  fseek (f, 0, SEEK_SET);
+  fseeko (f, 0, SEEK_SET);
   gfits_fread_header (f, header);
 
@@ -221,5 +223,5 @@
 
   Nbytes = gfits_data_size (header);
-  fseek (f, Nbytes, SEEK_CUR);
+  fseeko (f, Nbytes, SEEK_CUR);
 
   while (gfits_fread_header (f, header)) {
@@ -227,5 +229,5 @@
     if (!strcmp (current, extname)) return (TRUE);
     Nbytes = gfits_data_size (header);
-    fseek (f, Nbytes, SEEK_CUR);
+    fseeko (f, Nbytes, SEEK_CUR);
   }
   return (FALSE);
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/table/F_read_TH.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/table/F_read_TH.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/table/F_read_TH.c	(revision 27295)
@@ -7,5 +7,6 @@
   FILE *f;
   Header header;
-  int status, Nbytes;
+  int status;
+  off_t Nbytes;
   
   status = gfits_read_header (filename, &header);
@@ -23,5 +24,5 @@
 
   Nbytes = gfits_data_size (&header);
-  fseek (f, Nbytes, SEEK_SET);
+  fseeko (f, Nbytes, SEEK_SET);
   gfits_free_header (&header);
 
@@ -36,7 +37,8 @@
   
   char *p;
-  int i, done, status, Nbytes;
+  int i, done, status;
+  off_t Nbytes;
   
-  Theader[0].size = 0;
+  Theader[0].datasize = 0;
   done = FALSE;
   ALLOCATE (Theader[0].buffer, char, 1);
@@ -44,13 +46,13 @@
   for (i = 0; !done; i++) {
     REALLOCATE (Theader[0].buffer, char, (i + 1)*FT_RECORD_SIZE);
-    Nbytes = fread (&Theader[0].buffer[i*FT_RECORD_SIZE], 
-		    sizeof(char), FT_RECORD_SIZE, f);
+    Nbytes = fread (&Theader[0].buffer[i*FT_RECORD_SIZE], sizeof(char), FT_RECORD_SIZE, f);
     if (Nbytes != FT_RECORD_SIZE) {
       perror ("fits matrix read error");
     }
 
-    Theader[0].size += Nbytes;
-    if (Nbytes != FT_RECORD_SIZE) 
+    Theader[0].datasize += Nbytes;
+    if (Nbytes != FT_RECORD_SIZE) {
       done = TRUE;
+    }
     p = gfits_header_field (Theader, "END", 1);
     if (p != NULL)
@@ -68,14 +70,14 @@
   if (!status) return (FALSE);
 				                           
-  gfits_scan (Theader,  "NAXIS1", "%d", 1, &Theader[0].Naxis[0]);
-  gfits_scan (Theader,  "NAXIS2", "%d", 1, &Theader[0].Naxis[1]);
-  gfits_scan (Theader,  "NAXIS3", "%d", 1, &Theader[0].Naxis[2]);
-  gfits_scan (Theader,  "NAXIS4", "%d", 1, &Theader[0].Naxis[3]);
-  gfits_scan (Theader,  "NAXIS5", "%d", 1, &Theader[0].Naxis[4]);
-  gfits_scan (Theader,  "NAXIS6", "%d", 1, &Theader[0].Naxis[5]);
-  gfits_scan (Theader,  "NAXIS7", "%d", 1, &Theader[0].Naxis[6]);
-  gfits_scan (Theader,  "NAXIS8", "%d", 1, &Theader[0].Naxis[7]);
-  gfits_scan (Theader,  "NAXIS9", "%d", 1, &Theader[0].Naxis[8]);
-  gfits_scan (Theader, "NAXIS10", "%d", 1, &Theader[0].Naxis[9]);
+  gfits_scan (Theader,  "NAXIS1", "%lld", 1, &Theader[0].Naxis[0]);
+  gfits_scan (Theader,  "NAXIS2", "%lld", 1, &Theader[0].Naxis[1]);
+  gfits_scan (Theader,  "NAXIS3", "%lld", 1, &Theader[0].Naxis[2]);
+  gfits_scan (Theader,  "NAXIS4", "%lld", 1, &Theader[0].Naxis[3]);
+  gfits_scan (Theader,  "NAXIS5", "%lld", 1, &Theader[0].Naxis[4]);
+  gfits_scan (Theader,  "NAXIS6", "%lld", 1, &Theader[0].Naxis[5]);
+  gfits_scan (Theader,  "NAXIS7", "%lld", 1, &Theader[0].Naxis[6]);
+  gfits_scan (Theader,  "NAXIS8", "%lld", 1, &Theader[0].Naxis[7]);
+  gfits_scan (Theader,  "NAXIS9", "%lld", 1, &Theader[0].Naxis[8]);
+  gfits_scan (Theader, "NAXIS10", "%lld", 1, &Theader[0].Naxis[9]);
 
   return (TRUE);
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/table/F_set_column.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/table/F_set_column.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/table/F_set_column.c	(revision 27295)
@@ -16,7 +16,9 @@
 
 /***********************/
-int gfits_set_bintable_column (Header *header, FTable *table, char *label, void *data, int Nrow) {
-
-  int i, N, Nfields, Nval, Nbytes, Nx, Ny, nbytes, Nstart, Nv, Nb;
+int gfits_set_bintable_column (Header *header, FTable *table, char *label, void *data, off_t Nrow) {
+
+  off_t Nx, Ny, nbytes;
+  int i, N, Nfields;
+  int Nval, Nbytes, Nstart, Nv, Nb;
   char tlabel[80], field[80], format[80], type[16], tmpline[16];
   char *Pin, *Pout, *array;
@@ -47,15 +49,15 @@
   
   /* check existing table dimensions */
-  gfits_scan (header, "NAXIS1",  "%d", 1, &Nx);
-  gfits_scan (header, "NAXIS2",  "%d", 1, &Ny);
+  gfits_scan (header, "NAXIS1", "%lld", 1, &Nx);
+  gfits_scan (header, "NAXIS2", "%lld", 1, &Ny);
   if (Ny == 0) { 
     Ny = Nrow;
     header[0].Naxis[1] = Ny;
-    gfits_modify (header, "NAXIS2",  "%d", 1, Ny);
+    gfits_modify (header, "NAXIS2", "%lld", 1, Ny);
 
     nbytes = gfits_data_size (header);
     REALLOCATE (table[0].buffer, char, MAX (nbytes, 1));
     bzero (table[0].buffer, nbytes);
-    table[0].size = nbytes;
+    table[0].datasize = nbytes;
   }
   if (Ny != Nrow) return (FALSE);
@@ -151,7 +153,8 @@
 
 /***********************/
-int gfits_set_table_column (Header *header, FTable *table, char *label, void *data, int Nrow) {
-
-  int i, N, Nfields, Nval, Nbytes, Nx, Ny, nbytes, Nstart, Nv, Nb;
+int gfits_set_table_column (Header *header, FTable *table, char *label, void *data, off_t Nrow) {
+
+  off_t Nx, Ny, nbytes;
+  int i, N, Nfields, Nval, Nbytes, Nstart, Nv, Nb;
   char tlabel[80], field[80], format[80], cformat[80], type[16], tmp[16];
   char *array, *Pin, *Pout, *line;
@@ -178,15 +181,15 @@
   
   /* check existing table dimensions */
-  gfits_scan (header, "NAXIS1",  "%d", 1, &Nx);
-  gfits_scan (header, "NAXIS2",  "%d", 1, &Ny);
+  gfits_scan (header, "NAXIS1", "%lld", 1, &Nx);
+  gfits_scan (header, "NAXIS2", "%lld", 1, &Ny);
   if (Ny == 0) { 
     Ny = Nrow;
     header[0].Naxis[1] = Ny;
-    gfits_modify (header, "NAXIS2",  "%d", 1, Ny);
+    gfits_modify (header, "NAXIS2", "%lld", 1, Ny);
 
     nbytes = gfits_data_size (header);
     REALLOCATE (table[0].buffer, char, MAX (nbytes, 1));
     bzero (table[0].buffer, nbytes);
-    table[0].size = nbytes;
+    table[0].datasize = nbytes;
   }
   if (Ny != Nrow) return (FALSE);
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/table/F_table_format.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/table/F_table_format.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/table/F_table_format.c	(revision 27295)
@@ -3,4 +3,7 @@
 
 /***********************/
+// get the format of a table column
+// Nval : number of joined columns
+// Nbytes : width of column
 int gfits_bintable_format (char *format, char *type, int *Nval, int *Nbytes) {
 
@@ -119,5 +122,5 @@
 
 /** extract a table subset to a vtable ***/
-int gfits_table_to_vtable (FTable *ftable, VTable *vtable, int start, int Nkeep) {
+int gfits_table_to_vtable (FTable *ftable, VTable *vtable, off_t start, off_t Nkeep) {
 
   /* gfits_table_to_vtable (f, v, 0, Ny - 1) - keep all of table
@@ -125,8 +128,8 @@
   */  
 
-  int i, Nx, Ny;
-
-  gfits_scan (ftable[0].header, "NAXIS1", "%d", 1, &Nx);
-  gfits_scan (ftable[0].header, "NAXIS2", "%d", 1, &Ny);
+  off_t i, Nx, Ny;
+
+  gfits_scan (ftable[0].header, "NAXIS1", "%lld", 1, &Nx);
+  gfits_scan (ftable[0].header, "NAXIS2", "%lld", 1, &Ny);
   
   if (start + Nkeep > Ny) return (FALSE);
@@ -134,5 +137,5 @@
   if (Nkeep < 0) return (FALSE);
 
-  ALLOCATE (vtable[0].row, int, MAX (1, Nkeep));
+  ALLOCATE (vtable[0].row, off_t, MAX (1, Nkeep));
   ALLOCATE (vtable[0].buffer, char *, MAX (1, Nkeep));
   for (i = 0; i < Nkeep; i++) {
@@ -143,7 +146,7 @@
   
   vtable[0].header = ftable[0].header;
-  vtable[0].size = ftable[0].size;
+  vtable[0].datasize = ftable[0].datasize;
   vtable[0].Nrow = Nkeep;
-  vtable[0].pad = vtable[0].size - Nx*Ny;
+  vtable[0].pad = vtable[0].datasize - Nx*Ny;
 
   return (TRUE);
@@ -151,19 +154,19 @@
 
 /** convert specified rows to vtable */
-int gfits_vtable_from_ftable (FTable *ftable, VTable *vtable, int *row, int Nrow) {
-
-  int i, N, Nx, Ny;
-
-  gfits_scan (ftable[0].header, "NAXIS1", "%d", 1, &Nx);
-  gfits_scan (ftable[0].header, "NAXIS2", "%d", 1, &Ny);
+int gfits_vtable_from_ftable (FTable *ftable, VTable *vtable, off_t *row, off_t Nrow) {
+
+  off_t i, N, Nx, Ny;
+
+  gfits_scan (ftable[0].header, "NAXIS1", "%lld", 1, &Nx);
+  gfits_scan (ftable[0].header, "NAXIS2", "%lld", 1, &Ny);
 
   /* make empty vtable from table */
-  vtable[0].header = ftable[0].header;  /* make this a copy? */
-  vtable[0].size   = ftable[0].size;
-  vtable[0].pad    = vtable[0].size - Nx*Ny;
-  vtable[0].Nrow   = Ny;
+  vtable[0].header   = ftable[0].header;  /* make this a copy? */
+  vtable[0].datasize = ftable[0].datasize;
+  vtable[0].pad      = vtable[0].datasize - Nx*Ny;
+  vtable[0].Nrow     = Ny;
 
   /* insert selected rows in vtable (mask rows marked with -1) */ 
-  ALLOCATE (vtable[0].row, int, Nrow);
+  ALLOCATE (vtable[0].row, off_t, Nrow);
   ALLOCATE (vtable[0].buffer, char *, Nrow);
   for (N = i = 0; i < Nrow; i++) {
@@ -181,6 +184,6 @@
 char *gfits_table_print (FTable *table,...) { 
   
-  int i, Nx, Nfields;
-  int off, Nchar, Nval, Nbytes;
+  off_t Nx, off;
+  int i, Nchar, Nval, Nbytes, Nfields;
   char *line, format[64], field[16], type[16];
   va_list argp;
@@ -188,5 +191,5 @@
   va_start (argp, table);
 
-  gfits_scan (table[0].header, "NAXIS1",  "%d", 1, &Nx);
+  gfits_scan (table[0].header, "NAXIS1",  "%lld", 1, &Nx);
   gfits_scan (table[0].header, "TFIELDS", "%d", 1, &Nfields);
 
@@ -220,7 +223,8 @@
 // apply table tzero, tscal in situ (from storage to data)
 int gfits_table_scale_data (FTable *ftable) {
-
-  int i, j, n, Nx, Ny, Nfields;
-  int off, Nchar, Nval, Nbytes, status;
+  
+  off_t Nx, Ny, off;
+  int i, j, n, Nfields;
+  int Nchar, Nval, Nbytes, status;
   char format[64], field[16], type[16];
   double tzero, tscale;
@@ -232,6 +236,6 @@
   off = 0;
 
-  gfits_scan (ftable[0].header, "NAXIS1",  "%d", 1, &Nx);
-  gfits_scan (ftable[0].header, "NAXIS2",  "%d", 1, &Ny);
+  gfits_scan (ftable[0].header, "NAXIS1",  "%lld", 1, &Nx);
+  gfits_scan (ftable[0].header, "NAXIS2",  "%lld", 1, &Ny);
   gfits_scan (ftable[0].header, "TFIELDS", "%d", 1, &Nfields);
 
@@ -304,6 +308,7 @@
 int gfits_table_scale_storage (FTable *ftable) {
 
-  int i, j, n, Nx, Ny, Nfields;
-  int off, Nchar, Nval, Nbytes, status;
+  off_t Nx, Ny, off;
+  int i, j, n, Nfields;
+  int Nchar, Nval, Nbytes, status;
   char format[64], field[16], type[16];
   double tzero, tscale;
@@ -315,6 +320,6 @@
   off = 0;
 
-  gfits_scan (ftable[0].header, "NAXIS1",  "%d", 1, &Nx);
-  gfits_scan (ftable[0].header, "NAXIS2",  "%d", 1, &Ny);
+  gfits_scan (ftable[0].header, "NAXIS1",  "%lld", 1, &Nx);
+  gfits_scan (ftable[0].header, "NAXIS2",  "%lld", 1, &Ny);
   gfits_scan (ftable[0].header, "TFIELDS", "%d", 1, &Nfields);
 
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/table/F_table_row.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/table/F_table_row.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/table/F_table_row.c	(revision 27295)
@@ -3,14 +3,14 @@
 
 /*********************** fits table column ****************************/
-int gfits_add_rows (FTable *table, char *data, int Nrow, int Nbytes) {
+int gfits_add_rows (FTable *table, char *data, off_t Nrow, off_t Nbytes) {
 
-  int Nx, Ny;
-  int nbytes, Nstart;
+  off_t Nx, Ny;
+  off_t nbytes, Nstart;
   Header *header;
 
   header = table[0].header;
 
-  gfits_scan (header, "NAXIS1", "%d", 1, &Nx);
-  gfits_scan (header, "NAXIS2", "%d", 1, &Ny);
+  gfits_scan (header, "NAXIS1", "%lld", 1, &Nx);
+  gfits_scan (header, "NAXIS2", "%lld", 1, &Ny);
   
   if (header[0].Naxis[1] != Ny) return (FALSE);
@@ -23,9 +23,9 @@
   Ny += Nrow;
   header[0].Naxis[1] = Ny;
-  gfits_modify (header, "NAXIS2",  "%d", 1, Ny);
+  gfits_modify (header, "NAXIS2",  "%lld", 1, Ny);
 
   nbytes = gfits_data_size (header);
   REALLOCATE (table[0].buffer, char, MAX (nbytes, 1));
-  table[0].size = nbytes;
+  table[0].datasize = nbytes;
   
   memcpy (&table[0].buffer[Nstart], data, Nbytes*Nrow);
@@ -35,14 +35,14 @@
 
 /*********************** fits add (real) rows to virtual table ****************************/
-int gfits_vadd_rows (VTable *table, char *data, int Nrow, int Nbytes) {
+int gfits_vadd_rows (VTable *table, char *data, off_t Nrow, off_t Nbytes) {
 
-  int i, Nx, Ny;
-  int Nstart;
+  off_t i, Nx, Ny;
+  off_t Nstart;
   Header *header;
 
   header = table[0].header;
 
-  gfits_scan (header, "NAXIS1", "%d", 1, &Nx);
-  gfits_scan (header, "NAXIS2", "%d", 1, &Ny);
+  gfits_scan (header, "NAXIS1", "%lld", 1, &Nx);
+  gfits_scan (header, "NAXIS2", "%lld", 1, &Ny);
   
   if (header[0].Naxis[1] != Ny) return (FALSE);
@@ -54,5 +54,5 @@
   table[0].Nrow += Nrow;
   REALLOCATE (table[0].buffer, char *, table[0].Nrow);
-  REALLOCATE (table[0].row, int, table[0].Nrow);
+  REALLOCATE (table[0].row, off_t, table[0].Nrow);
   for (i = 0; i < Nrow; i++) {
     ALLOCATE (table[0].buffer[Nstart+i], char, MAX (1, Nx));
@@ -64,8 +64,8 @@
   Ny += Nrow;
   header[0].Naxis[1] = Ny;
-  gfits_modify (header, "NAXIS2",  "%d", 1, Ny);
+  gfits_modify (header, "NAXIS2", "%lld", 1, Ny);
 
-  table[0].size   = gfits_data_size (table[0].header);
-  table[0].pad    = table[0].size - Nx*Ny;
+  table[0].datasize = gfits_data_size (table[0].header);
+  table[0].pad      = table[0].datasize - Nx*Ny;
 
   return (TRUE);
@@ -73,14 +73,14 @@
 
 /*********************** fits table column ****************************/
-int gfits_delete_rows (FTable *table, int Nstart, int Nrow) {
+int gfits_delete_rows (FTable *table, off_t Nstart, off_t Nrow) {
 
-  int Nx, Ny, N0, N1, N2;
-  int nbytes;
+  off_t Nx, Ny, N0, N1, N2;
+  off_t nbytes;
   Header *header;
 
   header = table[0].header;
 
-  gfits_scan (header, "NAXIS1", "%d", 1, &Nx);
-  gfits_scan (header, "NAXIS2", "%d", 1, &Ny);
+  gfits_scan (header, "NAXIS1", "%lld", 1, &Nx);
+  gfits_scan (header, "NAXIS2", "%lld", 1, &Ny);
   
   if (header[0].Naxis[1] != Ny) return (FALSE);
@@ -97,9 +97,9 @@
   Ny -= Nrow;
   header[0].Naxis[1] = Ny;
-  gfits_modify (header, "NAXIS2",  "%d", 1, Ny);
+  gfits_modify (header, "NAXIS2", "%lld", 1, Ny);
 
   nbytes = gfits_data_size (header);
   REALLOCATE (table[0].buffer, char, MAX (nbytes, 1));
-  table[0].size = nbytes;
+  table[0].datasize = nbytes;
   return (TRUE);
 }
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/table/F_table_varlength.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/table/F_table_varlength.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/table/F_table_varlength.c	(revision 27295)
@@ -4,5 +4,6 @@
 int gfits_varlength_column_define (FTable *ftable, VarLengthColumn *def, int column) {
 
-  int i, Nv, Nb;
+  int i;
+  int Nv, Nb;
   char *p1, *p2, *p3;
   char field[81];
@@ -32,5 +33,6 @@
   // now p1 must be 'P';
   if (*p1 == 0) return (FALSE);
-  if (*p1 != 'P') return (FALSE);
+  if ((*p1 != 'P') && (*p1 != 'Q')) return (FALSE);
+  def->mode = *p1;
 
   // next value is the actual varlength column format
@@ -61,5 +63,6 @@
   }
 
-  if (!gfits_scan (ftable->header, "THEAP", "%d", 1, &def->heap_start)) {
+  // heap_start must be long long so file may be very large
+  if (!gfits_scan (ftable->header, "THEAP", "%lld", 1, &def->heap_start)) {
     def->heap_start = ftable->header->Naxis[0]*ftable->header->Naxis[1];
   }
@@ -68,8 +71,12 @@
 }
 
-void *gfits_varlength_column_pointer (FTable *ftable, VarLengthColumn *column, int row, int *length) {
+// return the data and length for row 'row' of a variable length column
+// is this capable of handling large files (value holding length and offset is an int)?
+void *gfits_varlength_column_pointer (FTable *ftable, VarLengthColumn *column, off_t row, off_t *length) {
 
   void *result;
-  int offset, Nx, *ptr;
+  off_t offset, Nx;
+
+  if ((column->mode != 'P') && (column->mode != 'Q')) abort();
 
   // find the values for the specified row
@@ -89,7 +96,16 @@
 # endif
 
-  ptr = (int *) &ftable->buffer[row*Nx + column->Nstart];
-  *length = ptr[0];
-  offset = ptr[1];
+  if (column->mode == 'P') {
+    int *ptr;
+    ptr = (int *) &ftable->buffer[row*Nx + column->Nstart];
+    *length = ptr[0];
+    offset = ptr[1];
+  }
+  if (column->mode == 'Q') {
+    off_t *ptr;
+    ptr = (off_t *) &ftable->buffer[row*Nx + column->Nstart];
+    *length = ptr[0];
+    offset = ptr[1];
+  }
 
   result = (void *) (ftable->buffer + column->heap_start + offset);
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/table/F_write_T.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/table/F_write_T.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/table/F_write_T.c	(revision 27295)
@@ -13,5 +13,5 @@
   if (f == (FILE *) NULL) return (FALSE);
   
-  status = fseek (f, 0, SEEK_END);  /* write table to end of file! */
+  status = fseeko (f, 0LL, SEEK_END);  /* write table to end of file! */
   status = gfits_fwrite_table (f, table);
 
@@ -23,9 +23,9 @@
 int gfits_fwrite_table (FILE *f, FTable *table) {
   
-  int Nbytes;
+  off_t Nbytes;
   
-  Nbytes = fwrite (table[0].buffer, sizeof(char), table[0].size, f);
+  Nbytes = fwrite (table[0].buffer, sizeof(char), table[0].datasize, f);
   
-  if (Nbytes != table[0].size) return (FALSE);
+  if (Nbytes != table[0].datasize) return (FALSE);
   return (TRUE);
 }	
@@ -34,29 +34,29 @@
 int gfits_fwrite_vtable (FILE *f, VTable *table) {
   
-  int i, Nx, Ny, Npad, offset, start;
-  int Nbytes, *row, Nrow;
+  off_t i, Nx, Ny, Npad, offset, start;
+  off_t Nbytes, *row, Nrow;
   char *pad;
 
   Nrow = table[0].Nrow;
   row = table[0].row;
-  gfits_scan (table[0].header, "NAXIS1", "%d", 1, &Nx);
-  gfits_scan (table[0].header, "NAXIS2", "%d", 1, &Ny);
+  gfits_scan (table[0].header, "NAXIS1", "%lld", 1, &Nx);
+  gfits_scan (table[0].header, "NAXIS2", "%lld", 1, &Ny);
 
   /* file pointer is at beginning of desired table data */
-  start = ftell (f);
+  start = ftello (f);
   
   for (i = 0; i < Nrow; i++) {
     offset = start + Nx*row[i];
-    fseek (f, offset, SEEK_SET);
+    fseeko (f, offset, SEEK_SET);
     Nbytes = fwrite (table[0].buffer[i], sizeof (char), Nx, f);
     if (Nbytes != Nx) { return (FALSE); }
   }
   
-  Npad = table[0].size - Nx*Ny;
+  Npad = table[0].datasize - Nx*Ny;
   ALLOCATE (pad, char, Npad);
   bzero (pad, Npad);
 
   offset = start + Nx*Ny;
-  fseek (f, offset, SEEK_SET);
+  fseeko (f, offset, SEEK_SET);
   Nbytes = fwrite (pad, sizeof (char), Npad, f);
   if (Nbytes != Npad) { return (FALSE); }
@@ -71,7 +71,7 @@
 
 /*********************** fits read ftable data ***********************************/
-int gfits_fwrite_ftable_range (FILE *f, FTable *ftable, int start, int Nrows, int Ndisk, int Ntotal) {
+int gfits_fwrite_ftable_range (FILE *f, FTable *ftable, off_t start, off_t Nrows, off_t Ndisk, off_t Ntotal) {
 
-  int Nbytes, Nwrite, Nskip, Nx, Npad;
+  off_t Nbytes, Nwrite, Nskip, Nx, Npad;
   char *pad;
 
@@ -79,9 +79,9 @@
   
   /* modify vtable to represent full disk table */
-  gfits_modify (ftable[0].header, "NAXIS2", "%d", 1, Ntotal);
+  gfits_modify (ftable[0].header, "NAXIS2", "%lld", 1, Ntotal);
   ftable[0].header[0].Naxis[1] = Ntotal;
 
   Nx = ftable[0].header[0].Naxis[0]; // final output table size on disk 
-  ftable[0].size = gfits_data_size (ftable[0].header);
+  ftable[0].datasize = gfits_data_size (ftable[0].header);
 
   Nskip = start * Nx;
@@ -95,5 +95,5 @@
 
   // cursor must be at start of the table (after table header)
-  fseek (f, Nskip, SEEK_CUR);
+  fseeko (f, Nskip, SEEK_CUR);
   Nwrite = fwrite (ftable[0].buffer, sizeof (char), Nbytes, f);
   if (Nwrite != Nbytes) {
@@ -102,5 +102,5 @@
 
   if (Ntotal >= Ndisk) {
-    Npad = ftable[0].size - Nx*Ntotal;
+    Npad = ftable[0].datasize - Nx*Ntotal;
     ALLOCATE (pad, char, Npad);
     bzero (pad, Npad);
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/table/F_write_TH.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/table/F_write_TH.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/libfits/table/F_write_TH.c	(revision 27295)
@@ -13,5 +13,5 @@
   if (f == (FILE *) NULL) return (FALSE);
   
-  status = fseek (f, 0, SEEK_END);  /* write header to end of file! */
+  status = fseeko (f, 0LL, SEEK_END);  /* write header to end of file! */
   status = gfits_fwrite_Theader (f, header);
 
@@ -23,9 +23,9 @@
 int gfits_fwrite_Theader (FILE *f, Header *header) {
   
-  int Nbytes;
+  off_t Nbytes;
   
-  Nbytes = fwrite (header[0].buffer, sizeof(char), header[0].size, f);
+  Nbytes = fwrite (header[0].buffer, sizeof(char), header[0].datasize, f);
 
-  if (Nbytes != header[0].size) return (FALSE);
+  if (Nbytes != header[0].datasize) return (FALSE);
   return (TRUE);
 }	
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/libohana/src/CommOps.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/libohana/src/CommOps.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/libohana/src/CommOps.c	(revision 27295)
@@ -103,5 +103,4 @@
 int SendMessageFixed (int device, int length, char *message) {
 
-  int status;
   int Nbytes, Nsent;
   struct timespec request, remain;
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/libohana/src/Fread.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/libohana/src/Fread.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/libohana/src/Fread.c	(revision 27295)
@@ -1,5 +1,5 @@
 # include <ohana.h>
 
-int   ByteSwap (char *ptr, int size, int nitems, char *type);
+static int ByteSwap (char *ptr, off_t size, off_t nitems, char *type);
 
 # define BYTE_EXCHANGE(X,Y) tmp = byte[X]; byte[X] = byte[Y]; byte[Y] = tmp;
@@ -30,7 +30,8 @@
 /* add other architectures here, ie dec, alpha, etc */ 
 
-int Fread (void *ptr, int size, int nitems, FILE *f, char *type) {
+off_t Fread (void *ptr, off_t size, off_t nitems, FILE *f, char *type) {
 
-  int valid, status;
+  int valid;
+  off_t status;
 
   status = fread (ptr, size, nitems, f);
@@ -42,7 +43,8 @@
 }
 
-int Fwrite (void *ptr, int size, int nitems, FILE *f, char *type) {
+off_t Fwrite (void *ptr, off_t size, off_t nitems, FILE *f, char *type) {
 
-  int valid, status;
+  int valid;
+  off_t status;
 
   valid = ByteSwap (ptr, size, nitems, type);
@@ -54,9 +56,9 @@
 }
 
-int ByteSwap (char *ptr, int size, int nitems, char *type) {
+static int ByteSwap (char *ptr, off_t size, off_t nitems, char *type) {
 
 # ifdef BYTE_SWAP
 
-  int i;
+  off_t i;
   unsigned char *byte0, *byte1, *byte2, *byte3, *byte4, *byte5, *byte6, *byte7, tmp;
 
@@ -116,351 +118,4 @@
   }
 
-# if (0) /** now in autocode **/
-  if (!strcmp (type, "regimage")) {
-    if (size != REGIMAGE_SIZE) {
-      fprintf (stderr, "mismatch in type sizes (RegImage) %d vs %d\n", size, REGIMAGE_SIZE);
-      return (FALSE);
-    }
-    byte = (unsigned char *)ptr;
-    for (i = 0; i < nitems; i++, byte += REGIMAGE_SIZE) {
-      SWAP_WORD (284); /* exptime */ 
-      SWAP_WORD (288); /* airmass */ 
-      SWAP_WORD (292); /* sky */     
-      SWAP_WORD (296); /* bias */    
-      SWAP_WORD (300); /* fwhm */    
-      SWAP_WORD (304); /* telfocus */ 
-      SWAP_WORD (308); /* xprobe */ 
-      SWAP_WORD (312); /* yprobe */ 
-      SWAP_WORD (316); /* zprobe */ 
-      SWAP_WORD (320); /* dettemp */ 
-      SWAP_WORD (324); /* teltemp[0] */ 
-      SWAP_WORD (328); /* teltemp[1] */  
-      SWAP_WORD (332); /* teltemp[2] */ 
-      SWAP_WORD (336); /* teltemp[3] */ 
-      SWAP_WORD (340); /* rotangle */
-      SWAP_WORD (344); /* ra */      
-      SWAP_WORD (348); /* dec */     
-      SWAP_WORD (352); /* obstime */ 
-      SWAP_WORD (356); /* regtime */  
-    }
-    return (TRUE);
-  }
-
-  if (!strcmp (type, "detreg")) {
-    if (size != DETREG_SIZE) {
-      fprintf (stderr, "mismatch in type sizes (DetReg) %d vs %d\n", size, DETREG_SIZE);
-      return (FALSE);
-    }
-    byte = (unsigned char *)ptr;
-    for (i = 0; i < nitems; i++, byte += DETREG_SIZE) {
-      SWAP_WORD (0);   /* tstart */
-      SWAP_WORD (4);   /* tstop */
-      SWAP_WORD (8);   /* treg */
-      SWAP_WORD (12);  /* exptime */
-      SWAP_WORD (16);  /* type */
-      SWAP_WORD (20);  /* filter */
-      SWAP_WORD (24);  /* ccd */
-      SWAP_WORD (28);  /* Nentry */
-      SWAP_WORD (32);  /* Norder */
-    }
-    return (TRUE);
-  }
-
-  if (!strcmp (type, "photpars")) {
-    if (size != PHOTPARS_SIZE) {
-      fprintf (stderr, "mismatch in type sizes (PhotPars) %d vs %d\n", size, PHOTPARS_SIZE);
-      return (FALSE);
-    }
-    byte = (unsigned char *)ptr;
-    for (i = 0; i < nitems; i++, byte += PHOTPARS_SIZE) {
-      SWAP_WORD (0);    /* ZP */
-      SWAP_WORD (4);    /* ZPo */
-      SWAP_WORD (8);    /* dZP */
-      SWAP_WORD (12);   /* K */
-      SWAP_WORD (16);   /* A */
-      SWAP_WORD (20);   /* tstart */
-      SWAP_WORD (24);   /* tstop */
-      SWAP_BYTE (28);   /* c1 */
-      SWAP_BYTE (30);   /* c2 */
-      SWAP_BYTE (32);   /* photcode */
-      SWAP_WORD (100);   /* Ntime */
-      SWAP_WORD (104);   /* Nmeas */
-    }
-    return (TRUE);
-  }
-
-  if (!strcmp (type, "missing")) {
-    if (size != MISSING_SIZE) {
-      fprintf (stderr, "mismatch in type sizes (Missing) %d vs %d\n", size, MISSING_SIZE);
-      return (FALSE);
-    }
-    byte0 = (unsigned char *)ptr;
-    byte1 = (unsigned char *)ptr + 1;
-    byte2 = (unsigned char *)ptr + 2;
-    byte3 = (unsigned char *)ptr + 3;
-    for (i = 0; i < nitems; i++, byte0 += 4, byte1 += 4, byte2 += 4, byte3 += 4) {
-      tmp = *byte0;
-      *byte0 = *byte3;
-      *byte3 = tmp;
-      tmp = *byte1;
-      *byte1 = *byte2;
-      *byte2 = tmp;
-    }
-    return (TRUE);
-  }
-
-  if (!strcmp (type, "secfilt")) {
-    if (size != SECFILT_SIZE) {
-      fprintf (stderr, "mismatch in type sizes (SecFilt) %d vs %d\n", size, SECFILT_SIZE);
-      return (FALSE);
-    }
-    byte = (unsigned char *) ptr;
-    for (i = 0; i < nitems; i++, byte += SECFILT_SIZE) {
-      SWAP_BYTE (0);   /* M */
-      SWAP_BYTE (2);   /* Xm */
-      SWAP_BYTE (4);   /* dM */
-    }
-    return (TRUE);
-  }
-
-  if (!strcmp (type, "spectrum")) {
-    if (size != SPECTRUM_SIZE) {
-      fprintf (stderr, "mismatch in type sizes (Spectrum) %d vs %d\n", size, SPECTRUM_SIZE);
-      return (FALSE);
-    }
-    byte = (unsigned char *)ptr;
-    for (i = 0; i < nitems; i++, byte += SPECTRUM_SIZE) {
-      SWAP_WORD (0);  /* ra */ 
-      SWAP_WORD (4);  /* dec */ 
-      SWAP_WORD (8);  /* exptime */ 
-      SWAP_WORD (12); /* airmass */ 
-      SWAP_WORD (16); /* Ws */ 
-      SWAP_WORD (20); /* We */ 
-      SWAP_WORD (24); /* dW */ 
-      SWAP_WORD (28); /* Nspec */ 
-      SWAP_WORD (32); /* obstime */ 
-      SWAP_WORD (36); /* regtime */ 
-    }
-    return (TRUE);
-  }
-
-  if (!strcmp (type, "image")) {
-    if (size != IMAGE_SIZE) {
-      fprintf (stderr, "mismatch in type sizes (Image) %d vs %d\n", size, IMAGE_SIZE);
-      return (FALSE);
-    }
-    byte = (unsigned char *)ptr;
-    for (i = 0; i < nitems; i++, byte += IMAGE_SIZE) {
-      SWAP_DBLE (0); /* coords.crval1 */
-      SWAP_DBLE (8); /* coords.crval2 */
-      for (j = 16; j < 104; j+=4) { /* coords.crpix, delt, pc_ij, polyterms[7][2] */
-	SWAP_WORD (j);
-      }
-      SWAP_WORD (120); /* tzero */
-      SWAP_WORD (124); /* nstar */
-      for (j = 128; j < 146; j+=2) { /* sec z, NX, NY, apmifit, dapmifit, source, Mcal, dMcal, Xm */
-	SWAP_BYTE (j);
-      }
-      SWAP_WORD (184); /* exptime */
-      SWAP_WORD (210); /* order */
-      /**** this (210) is an error! (don't fix, replaced with autocode) ****/
-      for (j = 212; j < 240; j+=2) {
-	SWAP_BYTE (j); /* Mx - Myyy */
-      }
-    }
-    return (TRUE);
-  }
-
-# if (PANSTARRS)
-  if (!strcmp (type, "average")) {
-    if (size != AVERAGE_SIZE) {
-      fprintf (stderr, "mismatch in type sizes (Average) %d vs %d\n", size, AVERAGE_SIZE);
-      return (FALSE);
-    }
-    byte = (unsigned char *)ptr;
-    for (i = 0; i < nitems; i++, byte += AVERAGE_SIZE) {
-      SWAP_DBLE (0);   /* R */
-      SWAP_DBLE (8);   /* D */
-      SWAP_BYTE (16);  /* M */
-      SWAP_BYTE (18);  /* Nm */
-      SWAP_BYTE (20);  /* Nn */
-      SWAP_BYTE (22);  /* Xp */
-      SWAP_BYTE (24);  /* Xm */
-      SWAP_BYTE (26);  /* code */
-      SWAP_WORD (28);  /* offset */
-      SWAP_WORD (32);  /* missing */
-      SWAP_BYTE (36);  /* dM */
-      SWAP_BYTE (38);  /* Xg */
-    }
-    return (TRUE);
-  } 
-  if (!strcmp (type, "measure")) {
-    if (size != MEASURE_SIZE) {
-      fprintf (stderr, "mismatch in type sizes (Measure) %d vs %d\n", size, MEASURE_SIZE);
-      return (FALSE);
-    }
-    byte = (unsigned char *)ptr;
-    for (i = 0; i < nitems; i++, byte += MEASURE_SIZE) {
-      SWAP_BYTE (0);   /* dR */
-      SWAP_BYTE (2);   /* dD */
-      SWAP_BYTE (4);   /* M  */
-      SWAP_BYTE (6);   /* Mcal */
-      SWAP_BYTE (8);   /* Mgal */
-      SWAP_BYTE (10);  /* Map  */
-      SWAP_BYTE (12);  /* FWx */
-      /* 14, 15, 16, 17 - char */
-      SWAP_BYTE (18);  /* source */
-      SWAP_WORD (20);  /* t */
-      SWAP_WORD (24);  /* averef */
-      SWAP_BYTE (28);  /* dt */
-      SWAP_BYTE (30);  /* flags */
-    }
-    return (TRUE);
-  }
-
-# endif /** PANSTARRS **/
-
-
-# if (ELIXIR)
-  if (!strcmp (type, "average")) {
-    if (size != AVERAGE_SIZE) {
-      fprintf (stderr, "mismatch in type sizes (Average) %d vs %d\n", size, AVERAGE_SIZE);
-      return (FALSE);
-    }
-    byte = (unsigned char *)ptr;
-    for (i = 0; i < nitems; i++, byte += AVERAGE_SIZE) {
-      SWAP_WORD (0);   /* R */
-      SWAP_WORD (4);   /* D */
-      SWAP_BYTE (8);   /* M */
-      SWAP_BYTE (10);  /* Nm */
-      SWAP_BYTE (12);  /* Nn */
-      SWAP_BYTE (14);  /* Xp */
-      SWAP_BYTE (16);  /* Xm */
-      SWAP_BYTE (18);  /* code */
-      SWAP_WORD (20);  /* offset */
-      SWAP_WORD (24);  /* missing */
-      SWAP_BYTE (28);  /* dM */
-      SWAP_BYTE (30);  /* Xg */
-    }
-    return (TRUE);
-  } 
-  if (!strcmp (type, "measure")) {
-    if (size != MEASURE_SIZE) {
-      fprintf (stderr, "mismatch in type sizes (Measure) %d vs %d\n", size, MEASURE_SIZE);
-      return (FALSE);
-    }
-    byte = (unsigned char *)ptr;
-    for (i = 0; i < nitems; i++, byte += MEASURE_SIZE) {
-      SWAP_BYTE (0);   /* dR */
-      SWAP_BYTE (2);   /* dD */
-      SWAP_BYTE (4);   /* M  */
-      SWAP_BYTE (6);   /* Mcal */
-      SWAP_BYTE (8);   /* Mgal */
-      SWAP_BYTE (10);  /* Map  */
-      SWAP_BYTE (12);  /* FWx */
-      /* 14, 15, 16, 17 - char */
-      SWAP_BYTE (18);  /* source */
-      SWAP_WORD (20);  /* t */
-      SWAP_WORD (24);  /* averef */
-      SWAP_BYTE (28);  /* dt */
-      SWAP_BYTE (30);  /* flags */
-    }
-    return (TRUE);
-  }
-
-# endif /** ELIXIR **/
-
-
-# if (LONEOS)
-  if (!strcmp (type, "average")) {
-    if (size != OLDAVERAGE_SIZE) {
-      fprintf (stderr, "mismatch in type sizes (OldAverage) %d vs %d\n", size, OLDAVERAGE_SIZE);
-      return (FALSE);
-    }
-    byte = (unsigned char *)ptr;
-    for (i = 0; i < nitems; i++, byte += OLDAVERAGE_SIZE) {
-      SWAP_WORD (0);   /* R */
-      SWAP_WORD (4);   /* D */
-      SWAP_BYTE (8);   /* M */
-      SWAP_BYTE (10); /* Nm */
-      SWAP_BYTE (12); /* Nn */
-      SWAP_BYTE (14); /* Xp */
-      SWAP_BYTE (16); /* Xm */
-      SWAP_BYTE (18); /* code */
-      SWAP_WORD (20); /* offset */
-      SWAP_WORD (24); /* missing */
-    }
-    return (TRUE);
-  } 
-  if (!strcmp (type, "measure")) {
-    if (size != OLDMEASURE_SIZE) {
-      fprintf (stderr, "mismatch in type sizes (OldMeasure) %d vs %d\n", size, OLDMEASURE_SIZE);
-      return (FALSE);
-    }
-    byte = (unsigned char *)ptr;
-    for (i = 0; i < nitems; i++, byte += OLDMEASURE_SIZE) {
-      SWAP_BYTE (0);   /* dR */
-      SWAP_BYTE (2);   /* dD */
-      SWAP_BYTE (4);   /* M  */
-      SWAP_BYTE (6);   /* Mcal */
-      SWAP_BYTE (10);  /* source */
-      SWAP_WORD (12);  /* t */
-      SWAP_WORD (16);  /* average */
-    }
-    return (TRUE);
-  }
-# endif /** LONEOS **/
-
-# if (0) /*** others ***/
-  if (!strcmp (type, "oldsecfilt")) {
-    if (size != OLDSECFILT_SIZE) {
-      fprintf (stderr, "mismatch in type sizes (OldSecFilt) %d vs %d\n", size, OLDSECFILT_SIZE);
-      return (FALSE);
-    }
-    byte = (unsigned char *) ptr;
-    for (i = 0; i < nitems; i++, byte += OLDSECFILT_SIZE) {
-      SWAP_BYTE (0);   /* M */
-      SWAP_BYTE (2);   /* Xm */
-    }
-    return (TRUE);
-  }
-  if (!strcmp (type, "rufimage")) {
-    if (size != RUFIMAGE_SIZE) {
-      fprintf (stderr, "mismatch in type sizes (RufImage) %d vs %d\n", size, RUFIMAGE_SIZE);
-      return (FALSE);
-    }
-    byte = (unsigned char *)ptr;
-    for (i = 0; i < nitems; i++, byte += RUFIMAGE_SIZE) {
-      SWAP_WORD (0);   /* sky */
-      SWAP_WORD (4);   /* bias */
-      SWAP_WORD (8);  /* fwhm */
-      SWAP_WORD (12); /* exptime */
-      SWAP_WORD (16); /* airmass */
-      SWAP_WORD (20); /* obstime */
-      SWAP_BYTE (24); /* ccdnum */
-    }
-    return (TRUE);
-  }
-  if (!strcmp (type, "olddetreg")) {
-    if (size != OLDDETREG_SIZE) {
-      fprintf (stderr, "mismatch in type sizes (DetReg) %d vs %d\n", size, OLDDETREG_SIZE);
-      return (FALSE);
-    }
-    byte = (unsigned char *)ptr;
-    for (i = 0; i < nitems; i++, byte += OLDDETREG_SIZE) {
-      SWAP_WORD (0);   /* tstart */
-      SWAP_WORD (4);   /* tstop */
-      SWAP_WORD (8);   /* treg */
-      SWAP_WORD (12);  /* sigma */
-      SWAP_WORD (16);  /* clipsigma */
-      SWAP_WORD (20);  /* type */
-      SWAP_WORD (24);  /* filter */
-      SWAP_WORD (28);  /* ccd */
-    }
-    return (TRUE);
-  }
-# endif /** others **/
-# endif /** now in autocode **/
-
   fprintf (stderr, "unknown type %s\n", type);
   return (FALSE);
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/libohana/src/findexec.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/libohana/src/findexec.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/libohana/src/findexec.c	(revision 27295)
@@ -391,15 +391,15 @@
 
 /* fseek with timeout - 0.5 sec */
-int Fseek (FILE *f, long offset, int whence) {
+int Fseek (FILE *f, off_t offset, int whence) {
 
   int status, k;
 
-  status = fseek (f, offset, whence);
+  status = fseeko (f, offset, whence);
   if (status == -1) {
-    for (k = 0; (k < 10) && ((status = fseek (f, 0, SEEK_SET)) == -1); k++) usleep (50000);
+    for (k = 0; (k < 10) && ((status = fseeko (f, 0, SEEK_SET)) == -1); k++) usleep (50000);
     if (status == -1) {
-      return (0);
-    }
-  }
-  return (1);
-}
+      return FALSE;
+    }
+  }
+  return TRUE;
+}
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/libohana/src/glockfile.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/libohana/src/glockfile.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/libohana/src/glockfile.c	(revision 27295)
@@ -117,5 +117,5 @@
   if (type == LCK_HARD) {
     /* we've really got the lock, write BUSY to protect it */
-    fseek (flock, 0, SEEK_SET);
+    fseeko (flock, 0LL, SEEK_SET);
     nbytes = fprintf (flock, "BUSY\n");
 
@@ -212,5 +212,5 @@
 
     /* set value to IDLE */
-    fseek (flock, 0, SEEK_SET);
+    fseeko (flock, 0LL, SEEK_SET);
     nbytes = fprintf (flock, "IDLE\n");
     if (nbytes != 5) {
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/lightcurve/src/fix_header.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/lightcurve/src/fix_header.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/lightcurve/src/fix_header.c	(revision 27295)
@@ -7,7 +7,5 @@
 */
 
-void
-  fix_header 
-  (Header     *header)
+void fix_header (Header *header)
 {
 
@@ -15,7 +13,7 @@
   char *p1, *p2;
 
-  Nbytes = 2880 * (int) (header[0].size / 2880 + 1);
+  Nbytes = 2880 * (int) (header[0].datasize / 2880 + 1);
   reallocate (header[0].buffer, char, Nbytes);
-  bzero (&header[0].buffer[header[0].size], Nbytes - header[0].size - 1);
+  bzero (&header[0].buffer[header[0].datasize], Nbytes - header[0].datasize - 1);
 
   p1 = header[0].buffer - 1;
@@ -24,9 +22,9 @@
   while (p2 != NULL) {
     if ((N = p2 - p1) != 80) {
-      bcopy (p2, p1 + 80, header[0].size - (p2 - header[0].buffer));
+      bcopy (p2, p1 + 80, header[0].datasize - (p2 - header[0].buffer));
       for (i = 0; i < 80 - N; i++) {
 	*(p2 + i) = ' ';
       }
-      header[0].size += 80 - N;
+      header[0].datasize += 80 - N;
     }
     p1 = strchr (p1 + 1, RETURN);
@@ -34,5 +32,5 @@
   }
 
-  header[0].size = Nbytes;
+  header[0].datasize = Nbytes;
   p1 = gfits_header_field (header, "END", 1);
   for (i = 3; i < 79; i++) 
@@ -40,5 +38,5 @@
   *(p1 + 79) = RETURN;
   
-  Nbytes = header[0].size - (p1 - header[0].buffer) - 80;
+  Nbytes = header[0].datasize - (p1 - header[0].buffer) - 80;
   
   for (i = 0; i < Nbytes; i++) {
@@ -48,11 +46,11 @@
   }
 
-  Nbytes = header[0].size - (p1 - header[0].buffer) - 80;
+  Nbytes = header[0].datasize - (p1 - header[0].buffer) - 80;
   while (Nbytes >= 2880) {
-    header[0].size -= 2880;
-    Nbytes = header[0].size - (p1 - header[0].buffer) - 80;
+    header[0].datasize -= 2880;
+    Nbytes = header[0].datasize - (p1 - header[0].buffer) - 80;
   }
 
-  reallocate (header[0].buffer, char, header[0].size);
+  reallocate (header[0].buffer, char, header[0].datasize);
 }
 
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/markrock/src/find_bright_stars.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/markrock/src/find_bright_stars.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/markrock/src/find_bright_stars.c	(revision 27295)
@@ -3,10 +3,10 @@
 void find_bright_stars (Catalog *catalog, CatStats *catstats) {
 
-  int i, j, n, m, first_j, Nave, Ngsc, Nmark;
+  off_t i, j, n, m, first_j, Nave, Ngsc, Nmark;
   Catalog GSCdata;
   double MinRA, MinDEC, MaxRA, MaxDEC, RaCenter, DecCenter;
   Coords *tcoords;
   double *X1, *Y1, *X2, *Y2;
-  int *N1, *N2;
+  off_t *N1, *N2;
   char *mark;
   double dX, dY, dR, MaxDist, MaxDist1, MaxRadius, radius, radius2;
@@ -24,5 +24,5 @@
   ALLOCATE (X1, double, Ngsc);
   ALLOCATE (Y1, double, Ngsc);
-  ALLOCATE (N1, int, Ngsc);
+  ALLOCATE (N1, off_t, Ngsc);
   ALLOCATE (mark, char, Nave);
   bzero (mark, Nave);
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/markrock/src/gcatstats.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/markrock/src/gcatstats.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/markrock/src/gcatstats.c	(revision 27295)
@@ -6,9 +6,8 @@
 {
 
-  int i;
+  off_t i;
   double RaCenter, DecCenter;
   double MinRA, MaxRA, MinDEC, MaxDEC;
   double *X1, *Y1;
-  int *N1;
   Coords tcoords;
   
@@ -31,5 +30,5 @@
   ALLOCATE (catstats[0].X, double, catalog[0].Naverage);
   ALLOCATE (catstats[0].Y, double, catalog[0].Naverage);
-  ALLOCATE (catstats[0].N, int,   catalog[0].Naverage);
+  ALLOCATE (catstats[0].N, off_t,   catalog[0].Naverage);
 
   /* project onto rectilinear grid with 1 arcsec pixels, sort by X */
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/markrock/src/wrocks.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/markrock/src/wrocks.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/markrock/src/wrocks.c	(revision 27295)
@@ -16,5 +16,5 @@
   }
   /* position to begining of file to write header */
-  fseek (f, 0, SEEK_END);
+  fseeko (f, 0, SEEK_END);
 
   /* get statistics on rocks */
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/markstar/src/find_bright_stars.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/markstar/src/find_bright_stars.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/markstar/src/find_bright_stars.c	(revision 27295)
@@ -3,10 +3,10 @@
 void find_bright_stars (Catalog *catalog, CatStats *catstats) {
 
-  int i, j, n, m, first_j, Nave, Ngsc;
+  off_t i, j, n, m, first_j, Nave, Ngsc;
   Catalog GSCdata;
   double MinRA, MinDEC, MaxRA, MaxDEC, RaCenter, DecCenter;
   Coords *tcoords;
   double *X1, *Y1, *X2, *Y2;
-  int *N1, *N2;
+  off_t *N1, *N2;
   char *mark;
   double dX, dY, dR, MaxDist, MaxDist1, MaxRadius, radius, radius2;
@@ -25,5 +25,5 @@
   ALLOCATE (X1, double, Ngsc);
   ALLOCATE (Y1, double, Ngsc);
-  ALLOCATE (N1, int, Ngsc);
+  ALLOCATE (N1, off_t, Ngsc);
   ALLOCATE (mark, char, Nave);
   bzero (mark, Nave);
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/markstar/src/find_matches.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/markstar/src/find_matches.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/markstar/src/find_matches.c	(revision 27295)
@@ -7,5 +7,5 @@
   double *X1, *Y1, *X2, *Y2;
   double dX, dY, dR;
-  int *N1, *N2;
+  off_t *N1, *N2;
   int Nstar, Nghost, Ng;
   unsigned int flags;
@@ -25,5 +25,5 @@
   ALLOCATE (X1, double, Nghost);
   ALLOCATE (Y1, double, Nghost);
-  ALLOCATE (N1, int, Nghost);
+  ALLOCATE (N1, off_t, Nghost);
 
   /* project ghosts to the frame of the catalog */
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/markstar/src/gcatstats.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/markstar/src/gcatstats.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/markstar/src/gcatstats.c	(revision 27295)
@@ -3,9 +3,8 @@
 void gcatstats (Catalog *catalog, CatStats *catstats) {
 
-  int i;
+  off_t i;
   double RaCenter, DecCenter;
   double MinRA, MaxRA, MinDEC, MaxDEC;
   double *X1, *Y1;
-  int *N1;
   Coords tcoords;
   
@@ -41,5 +40,5 @@
   ALLOCATE (catstats[0].X, double, catalog[0].Naverage);
   ALLOCATE (catstats[0].Y, double, catalog[0].Naverage);
-  ALLOCATE (catstats[0].N, int,   catalog[0].Naverage);
+  ALLOCATE (catstats[0].N, off_t,  catalog[0].Naverage);
 
   /* project onto rectilinear grid with 1 arcsec pixels, sort by X */
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/misc/src/addastro.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/misc/src/addastro.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/misc/src/addastro.c	(revision 27295)
@@ -6,5 +6,6 @@
   /* USAGE: addastro (cmp) (ref) */
 
-  int i, j, nbytes, itmp, oldsize;
+  off_t nbytes, oldsize;
+  int i, j, itmp;
   double tmp;
   Header header, refhead;
@@ -22,5 +23,5 @@
     exit (1);
   }
-  oldsize = header.size;
+  oldsize = header.datasize;
 
   if (!gfits_read_header (argv[2], &refhead)) {
@@ -72,6 +73,6 @@
     exit (1);
   }
-  nbytes = fwrite (header.buffer, 1, header.size, g);
-  fseek (g, header.size, SEEK_SET); 
+  nbytes = fwrite (header.buffer, 1, header.datasize, g);
+  fseeko (g, header.datasize, SEEK_SET); 
 
   /* read date from file */
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/misc/src/applyscat.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/misc/src/applyscat.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/misc/src/applyscat.c	(revision 27295)
@@ -14,5 +14,6 @@
   Matrix matrix;
   Stars *stars;
-  int Nstar, Nbytes, nbytes;
+  int Nstar;
+  off_t Nbytes, nbytes;
   FILE *f;
   char *buffer, line[10];
@@ -37,5 +38,5 @@
     exit (1);
   }
-  fseek (f, header.size, SEEK_SET); 
+  fseeko (f, header.datasize, SEEK_SET); 
 
   /* find expected number of stars */
@@ -110,5 +111,5 @@
     exit (1);
   }
-  fseek (f, header.size, SEEK_SET); 
+  fseeko (f, header.datasize, SEEK_SET); 
 
   /* load in data */
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/misc/src/fakecmp.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/misc/src/fakecmp.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/misc/src/fakecmp.c	(revision 27295)
@@ -4,6 +4,7 @@
 void main (int argc, char **argv) {
 
-  int i, j, N, status;
-  int Nreserved, start_size;
+  off_t start_size, status;
+  int i, j, N;
+  int Nreserved;
   char *p, keyword[16], line[256];
   FILE *f;
@@ -69,5 +70,5 @@
     exit (1);
   }
-  start_size = header.size;
+  start_size = header.datasize;
 
   /* run through the lines in the header data file */
@@ -94,5 +95,5 @@
     p = (char *) NULL;
     Nreserved = strlen (reserved);
-    for (i = 0; (i < header.size) && (p == (char *) NULL) ; i+= FT_LINE_LENGTH) {
+    for (i = 0; (i < header.datasize) && (p == (char *) NULL) ; i+= FT_LINE_LENGTH) {
       if (!strncmp (&header.buffer[i], reserved, Nreserved)) {
 	p = &header.buffer[i];
@@ -114,5 +115,5 @@
   */
 
-  if (header.size != start_size) {
+  if (header.datasize != start_size) {
     fprintf (stderr, "header changed size: should not happen!\n");
     exit (1);
@@ -125,7 +126,7 @@
   }
 
-  fseek (f, 0, SEEK_SET);
-  status = fwrite (header.buffer, 1, header.size, f);
-  if (status != header.size) {
+  fseeko (f, 0, SEEK_SET);
+  status = fwrite (header.buffer, 1, header.datasize, f);
+  if (status != header.datasize) {
     fprintf (stderr, "failed to write data to image header\n");
     exit (1);
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/misc/src/fakestars.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/misc/src/fakestars.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/misc/src/fakestars.c	(revision 27295)
@@ -57,5 +57,5 @@
     exit (1);
   }
-  fseek (f, header.size, SEEK_SET); 
+  fseeko (f, header.datasize, SEEK_SET); 
 
   /* find expected number of stars */
@@ -108,5 +108,5 @@
     exit (1);
   }
-  fseek (f, header.size, SEEK_SET); 
+  fseeko (f, header.datasize, SEEK_SET); 
 
   for (i = 0; i < Nstar; i++) {
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/misc/src/fiximg.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/misc/src/fiximg.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/misc/src/fiximg.c	(revision 27295)
@@ -31,5 +31,5 @@
   fprintf (stderr, "deleted %d comments\n", N);
   p = gfits_header_field (&header, "END", 1);
-  for (i = 3; i < header.size - (int) (p - header.buffer); i++) { 
+  for (i = 3; i < header.datasize - (int) (p - header.buffer); i++) { 
     p[i] = ' '; 
   }
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/misc/src/fixsimple.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/misc/src/fixsimple.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/misc/src/fixsimple.c	(revision 27295)
@@ -26,5 +26,5 @@
   fprintf (stderr, "deleted %d comments\n", N);
   p = gfits_header_field (&header, "END", 1);
-  for (i = 3; i < header.size - (int) (p - header.buffer); i++) { 
+  for (i = 3; i < header.datasize - (int) (p - header.buffer); i++) { 
     p[i] = ' '; 
   }
@@ -47,7 +47,7 @@
   }
 
-  fseek (f, skip, SEEK_SET);
-  status = fwrite (header.buffer, 1, header.size, f);
-  if (status != header.size) {
+  fseeko (f, skip, SEEK_SET);
+  status = fwrite (header.buffer, 1, header.datasize, f);
+  if (status != header.datasize) {
     fprintf (stderr, "failed to write data to image header\n");
     exit (1);
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/misc/src/striphead.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/misc/src/striphead.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/misc/src/striphead.c	(revision 27295)
@@ -51,5 +51,5 @@
     }
     
-    for (j = 79; j < header.size; j+= 80) {
+    for (j = 79; j < header.datasize; j+= 80) {
       header.buffer[j] = 10;
     }
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/mosastro/src/getusno.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/mosastro/src/getusno.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/mosastro/src/getusno.c	(revision 27295)
@@ -11,6 +11,6 @@
 StarData *getusno (CatStats *catstats, int *Nstars) {
 
-  long int offset;
-  int i, bin, first, last, nitems, Nitems, Nbins;
+  off_t offset, nitems, Nitems;
+  int i, bin, first, last, Nbins;
   float hours[100];
   int start[100], number[100], *buffer, *buf;
@@ -91,5 +91,5 @@
     /* advance file pointer to first slice */
     offset = 3*sizeof(int)*(start[first] - 1);
-    fseek (f, offset, SEEK_SET);
+    fseeko (f, offset, SEEK_SET);
     /* on each loop, load data from an RA slice of the catalog */
     for (bin = first; bin < last; bin++) {
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/mosastro/src/getusnob.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/mosastro/src/getusnob.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/mosastro/src/getusnob.c	(revision 27295)
@@ -5,6 +5,6 @@
 StarData *getusnob (CatStats *catstats, int *Nstars) {
 
-  long int offset;
-  int i, bin, first, last, nitems, Nitems, Nbins;
+  off_t offset, nitems, Nitems;
+  int i, bin, first, last, Nbins;
   float hours[100];
   int start[100], number[100], *buffer, *buf;
@@ -76,5 +76,5 @@
     /* advance file pointer to first slice */
     offset = NELEM*NBYTE*(start[first] - 1);
-    fseek (f, offset, SEEK_SET);
+    fseeko (f, offset, SEEK_SET);
 
     /* sum the number of stars in data segment of interest */
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/mosastro/src/match.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/mosastro/src/match.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/mosastro/src/match.c	(revision 27295)
@@ -8,5 +8,5 @@
   double dp, dq, radius, Radius;
   double *p, *q, *P, *Q;
-  int *U, *u;
+  off_t *U, *u;
 
   /* requested radius is in arcsec ; internally radius is in pixels */
@@ -17,5 +17,5 @@
   ALLOCATE (P, double, Nrefcat);
   ALLOCATE (Q, double, Nrefcat);
-  ALLOCATE (U, int, Nrefcat);
+  ALLOCATE (U, off_t, Nrefcat);
   for (i = 0; i < Nrefcat; i++) {
     U[i] = i;
@@ -35,5 +35,5 @@
     ALLOCATE (p, double, chip[i].Nstars);
     ALLOCATE (q, double, chip[i].Nstars);
-    ALLOCATE (u, int, chip[i].Nstars);
+    ALLOCATE (u, off_t,  chip[i].Nstars);
     for (j = 0; j < chip[i].Nstars; j++) {
       u[j] = j;
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/mosastro/src/output.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/mosastro/src/output.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/mosastro/src/output.c	(revision 27295)
@@ -41,5 +41,5 @@
   }
 
-  fwrite (header[0].buffer, 1, header[0].size, f);
+  fwrite (header[0].buffer, 1, header[0].datasize, f);
   fclose (f);
 }
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/mosastro/src/rfits.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/mosastro/src/rfits.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/mosastro/src/rfits.c	(revision 27295)
@@ -14,5 +14,5 @@
     exit (1);
   }
-  fseek (f, mychip[0].header.size, SEEK_SET); 
+  fseeko (f, mychip[0].header.datasize, SEEK_SET); 
 
   /* init & load in table data */
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/mosastro/src/rtext.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/mosastro/src/rtext.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/mosastro/src/rtext.c	(revision 27295)
@@ -12,5 +12,5 @@
     return (FALSE);
   }
-  fseek (f, mychip[0].header.size, SEEK_SET); 
+  fseeko (f, mychip[0].header.datasize, SEEK_SET); 
 
   /* find expected number of stars */
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/mosastro/src/wstars.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/mosastro/src/wstars.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/mosastro/src/wstars.c	(revision 27295)
@@ -16,5 +16,5 @@
     }
 
-    fwrite (data[0].header.buffer, 1, data[0].header.size, g);
+    fwrite (data[0].header.buffer, 1, data[0].header.datasize, g);
     fwrite (data[0].buffer, 1, data[0].Nbuffer, g);
     fclose (g);
@@ -34,5 +34,5 @@
   }
 
-  fwrite (header[0].buffer, 1, header[0].size, g);
+  fwrite (header[0].buffer, 1, header[0].datasize, g);
 
   for (i = 0; i < Nstars; i++) {
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/opihi/cmd.data/rd.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/opihi/cmd.data/rd.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/opihi/cmd.data/rd.c	(revision 27295)
@@ -153,5 +153,5 @@
     buf[0].header.Naxes = 0;
     ALLOCATE (buf[0].matrix.buffer, char, 1);
-    buf[0].matrix.size = 0;
+    buf[0].matrix.datasize = 0;
     buf[0].bitpix = 16;
     buf[0].bzero = 0;
@@ -222,6 +222,6 @@
   buf[0].unsign = buf[0].header.unsign;
 
-  gprint (GP_LOG, "read %d bytes from %s into buffer %s\n", 
-	   buf[0].header.size + buf[0].matrix.size, argv[2], argv[1]);
+  gprint (GP_LOG, "read %lld bytes from %s into buffer %s\n", 
+	   buf[0].header.datasize + buf[0].matrix.datasize, argv[2], argv[1]);
 
   blank = 0xffff;
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/opihi/cmd.data/rdseg.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/opihi/cmd.data/rdseg.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/opihi/cmd.data/rdseg.c	(revision 27295)
@@ -62,6 +62,5 @@
   buf[0].bzero  = buf[0].header.bzero;     /* store the original values */
   buf[0].unsign = buf[0].header.unsign;
-  gprint (GP_LOG, "read %d bytes from %s into buffer %s\n", 
-	   buf[0].header.size + buf[0].matrix.size, argv[2], argv[1]);
+  gprint (GP_LOG, "read %d bytes from %s into buffer %s\n", buf[0].header.datasize + buf[0].matrix.datasize, argv[2], argv[1]);
 
   gfits_scan (&buf[0].header, "BLANK", "%d", 1, &blank);
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/opihi/cmd.data/read_vectors.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/opihi/cmd.data/read_vectors.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/opihi/cmd.data/read_vectors.c	(revision 27295)
@@ -57,5 +57,5 @@
     return (FALSE);
   }
-  fseek (f, 0, SEEK_SET);
+  fseeko (f, 0LL, SEEK_SET);
 
   Nvec = (argc - 1) / 2;
@@ -159,5 +159,6 @@
 int read_table_vectors (int argc, char **argv, char *extname) {
 
-  int i, j, k, N, Nbytes, Nextend, Ny, Binary, vecType;
+  off_t Nbytes;
+  int i, j, k, N, Nextend, Ny, Binary, vecType;
   char type[16], ID[80], *CCDKeyword;
   FTable table;
@@ -184,5 +185,5 @@
 
   if (f == NULL) ESCAPE ("file not found");
-  fseek (f, 0, SEEK_SET);
+  fseeko (f, 0LL, SEEK_SET);
   table.header = &header;
 
@@ -193,5 +194,5 @@
     if (!gfits_load_header (f, &header)) ESCAPE ("error reading primary header for file");
     Nbytes = gfits_data_size (&header);
-    fseek (f, Nbytes, SEEK_CUR);
+    fseeko (f, Nbytes, SEEK_CUR);
     gfits_free_header (&header);
 
@@ -200,5 +201,5 @@
       Nbytes = gfits_data_size (&header);
       /* skip the prior data buffers */
-      fseek (f, Nbytes, SEEK_CUR);
+      fseeko (f, Nbytes, SEEK_CUR);
       gfits_free_header (&header);
     }
@@ -215,14 +216,14 @@
 
     while (1) {
-      if (!gfits_load_header (f, &header)) ESCAPE ("extensio not found in file");
+      if (!gfits_load_header (f, &header)) ESCAPE ("extension not found in file");
       Nbytes = gfits_data_size (&header);
 
       if (!gfits_scan (&header, CCDKeyword, "%s", 1, ID)) {
-	fseek (f, Nbytes, SEEK_CUR);
+	fseeko (f, Nbytes, SEEK_CUR);
 	gfits_free_header (&header);
 	continue;
       }
       if (strcmp (ID, extname)) {
-	fseek (f, Nbytes, SEEK_CUR);
+	fseeko (f, Nbytes, SEEK_CUR);
 	gfits_free_header (&header);
 	continue;
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/opihi/cmd.data/wd.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/opihi/cmd.data/wd.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/opihi/cmd.data/wd.c	(revision 27295)
@@ -75,9 +75,9 @@
   /* save the (float) version, write out a temporary buffer */
   temp_matrix = buf[0].matrix;
-  ALLOCATE (temp_matrix.buffer, char, MAX(1, temp_matrix.size));
-  memcpy (temp_matrix.buffer, buf[0].matrix.buffer, temp_matrix.size);
+  ALLOCATE (temp_matrix.buffer, char, MAX(1, temp_matrix.datasize));
+  memcpy (temp_matrix.buffer, buf[0].matrix.buffer, temp_matrix.datasize);
   temp_header = buf[0].header;
-  ALLOCATE (temp_header.buffer, char, MAX(1, temp_header.size));
-  memcpy (temp_header.buffer, buf[0].header.buffer, temp_header.size);
+  ALLOCATE (temp_header.buffer, char, MAX(1, temp_header.datasize));
+  memcpy (temp_header.buffer, buf[0].header.buffer, temp_header.datasize);
 
   if (temp_header.Naxes) {
@@ -94,4 +94,5 @@
     Header Xhead;
     FILE *f;
+    off_t nbytes;
     int status, Nextend;
 
@@ -125,7 +126,7 @@
     
     /* position to begining of file to write header */
-    fseek (f, 0, SEEK_SET);
-    status = fwrite (Xhead.buffer, 1, Xhead.size, f);
-    if (status != Xhead.size) {
+    fseeko (f, 0LL, SEEK_SET);
+    nbytes = fwrite (Xhead.buffer, 1, Xhead.datasize, f);
+    if (nbytes != Xhead.datasize) {
       gprint (GP_ERR, "ERROR: failed writing data to image header\n");
       status = FALSE;
@@ -144,8 +145,8 @@
 
     /* position to end of file to write new extend */
-    fseek (f, 0, SEEK_END);
-    status = fwrite (temp_header.buffer, 1, temp_header.size, f);
+    fseeko (f, 0LL, SEEK_END);
+    nbytes = fwrite (temp_header.buffer, 1, temp_header.datasize, f);
     fclose (f);
-    if (status != temp_header.size) {
+    if (nbytes != temp_header.datasize) {
       gprint (GP_ERR, "failed to write file\n");
       status = FALSE;
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/opihi/dvo/aregion.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/opihi/dvo/aregion.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/opihi/dvo/aregion.c	(revision 27295)
@@ -44,5 +44,5 @@
     NLINES += NDecLines[i];
   }
-  fseek (f, 5*2880 + 48*NLINES, SEEK_SET);
+  fseeko (f, 5*2880 + 48*NLINES, SEEK_SET);
       
   done = FALSE;
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/opihi/dvo/cmpload.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/opihi/dvo/cmpload.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/opihi/dvo/cmpload.c	(revision 27295)
@@ -56,5 +56,5 @@
     return (FALSE);
   }
-  fseek (f, header.size, SEEK_SET); 
+  fseeko (f, header.datasize, SEEK_SET); 
 
   Noverlay = 0;
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/opihi/dvo/cmpread.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/opihi/dvo/cmpread.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/opihi/dvo/cmpread.c	(revision 27295)
@@ -6,5 +6,6 @@
 int cmpread (int argc, char **argv) {
   
-  int i, field, Naxis, Nbytes, Nstars;
+  off_t Nbytes;
+  int i, field, Naxis, Nstars;
   double tR, tD;
   float value;
@@ -61,5 +62,5 @@
     return (FALSE);
   }
-  fseek (f, header.size, SEEK_SET); 
+  fseeko (f, header.datasize, SEEK_SET); 
 
   /* find expected number of stars */
@@ -84,5 +85,5 @@
     gprint (GP_ERR, "reading from FITS cmp file %s\n", argv[2]);
     Nbytes = gfits_data_size (&header);
-    fseek (f, Nbytes, SEEK_CUR); 
+    fseeko (f, Nbytes, SEEK_CUR); 
     stars = cmpReadFits (f, &Nstars);
   }
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/opihi/dvo/detrend.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/opihi/dvo/detrend.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/opihi/dvo/detrend.c	(revision 27295)
@@ -133,5 +133,5 @@
     return (FALSE);
   }
-  fseek (f, header.size, SEEK_SET);
+  fseeko (f, header.datasize, SEEK_SET);
 
   /* load existing data from database */
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/opihi/dvo/elixir.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/opihi/dvo/elixir.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/opihi/dvo/elixir.c	(revision 27295)
@@ -73,5 +73,5 @@
 
   /* write message to end of file */
-  fseek (f, 0, SEEK_END);
+  fseeko (f, 0LL, SEEK_END);
   fprintf (f, "%s\n", message);
 
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/opihi/dvo/find_regions.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/opihi/dvo/find_regions.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/opihi/dvo/find_regions.c	(revision 27295)
@@ -13,5 +13,6 @@
   double RA0, RA1, DEC0, DEC1;
   int i, j, NBigDec;
-  int NLINES, done, NREGIONS, nregion;
+  int done, NREGIONS, nregion;
+  off_t NLINES;
   
   VarConfig ("GSCFILE", "%s", filename);
@@ -91,5 +92,5 @@
     NLINES += NDecLines[i];
   }
-  fseek (f, 5*2880 + 48*NLINES, SEEK_SET);
+  fseeko (f, 5*2880 + 48*NLINES, SEEK_SET);
   
   /* should be in this section.  if not, there is a problem counting... */
@@ -140,5 +141,5 @@
 	NLINES += NDecLines[i];
       }
-      fseek (f, 5*2880 + 48*NLINES, SEEK_SET);
+      fseeko (f, 5*2880 + 48*NLINES, SEEK_SET);
       done = FALSE;
       j = 12;
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/opihi/dvo/gstar.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/opihi/dvo/gstar.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/opihi/dvo/gstar.c	(revision 27295)
@@ -11,6 +11,7 @@
   double Mcat, Mrel;
   double *RA, *DEC;
-  int i, j, k, m, N, *N1, Nsecfilt, NPTS, QUIET, FULL_OUTPUT, INST;
-  int Nstars, found, GetMeasures, Nlo, Nhi;
+  off_t i, Nstars, *N1;
+  int j, k, m, N, Nsecfilt, NPTS, QUIET, FULL_OUTPUT, INST;
+  int found, GetMeasures, Nlo, Nhi;
   int SaveVectors;
   Vector *vec1, *vec2, *vec3, *vec4, *vec5, *vec6;
@@ -102,5 +103,5 @@
   ALLOCATE (RA, double, Nstars);
   ALLOCATE (DEC, double, Nstars);
-  ALLOCATE (N1, int, Nstars);
+  ALLOCATE (N1, off_t, Nstars);
 
   /* find star(s) in RA, DEC list -- use a dumb algorithm for now, improve later */
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/opihi/dvo/imbox.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/opihi/dvo/imbox.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/opihi/dvo/imbox.c	(revision 27295)
@@ -1,7 +1,9 @@
 # include "dvoshell.h"
 
+// LARGEFILES: this function is currently limited to images with Nx,Ny each < 2^31
 int imbox (int argc, char **argv) {
   
-  int j, kapa, Nskip, status, InPic, flipped, N, haveNx, haveNy, Nx, Ny, SOLO_PHU, Npts, NPTS;
+  off_t Nskip;
+  int j, kapa, status, InPic, flipped, N, haveNx, haveNy, Nx, Ny, SOLO_PHU, Npts, NPTS;
   Vector Xvec, Yvec;
   double r, d, x[4], y[4], Rmin, Rmax, Rmid;
@@ -112,5 +114,5 @@
   skip:
     Nskip = gfits_data_size (&header);
-    fseek (f, Nskip, SEEK_CUR); 
+    fseeko (f, Nskip, SEEK_CUR); 
     gfits_free_header (&header);
   }
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/opihi/dvo/imrough.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/opihi/dvo/imrough.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/opihi/dvo/imrough.c	(revision 27295)
@@ -262,5 +262,5 @@
   if (!strcmp (line, "MDM Observatory")) {
 
-    fseek (f, header.size, SEEK_SET);
+    fseeko (f, header.datasize, SEEK_SET);
     
     /* load existing data from database */
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/opihi/dvo/imsearch.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/opihi/dvo/imsearch.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/opihi/dvo/imsearch.c	(revision 27295)
@@ -7,5 +7,6 @@
   Header header;
   RegImage *pimage;
-  int i, Nimage, status, N, TimeSelect, SaveNames;
+  off_t i, Nimage, status;
+  int N, TimeSelect, SaveNames;
   int ModeSelect, TypeSelect, CCDSelect, FilterSelect;
   char *Filter, *obstime;
@@ -102,13 +103,13 @@
     return (FALSE);
   }
-  fseek (f, header.size, SEEK_SET);
+  fseeko (f, header.datasize, SEEK_SET);
 
   /* load existing data from database */
-  gfits_scan (&header, "NIMAGES", "%d", 1, &Nimage);
+  gfits_scan (&header, "NIMAGES", "%lld", 1, &Nimage);
   ALLOCATE (pimage, RegImage, Nimage);
   status = fread (pimage, sizeof(RegImage), Nimage, f);
   fclose (f);
   if (status != Nimage) {
-    gprint (GP_ERR, "ERROR: header and data in dB don't match (%d vs %d)\n", Nimage, status);
+    gprint (GP_ERR, "ERROR: header and data in dB don't match (%lld vs %lld)\n", (long long) Nimage, (long long) status);
     gfits_free_header (&header);
     free (pimage);
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/opihi/dvo/lcurve.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/opihi/dvo/lcurve.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/opihi/dvo/lcurve.c	(revision 27295)
@@ -7,6 +7,7 @@
   double *RA, *DEC;
   int kapa, TimeFormat;
-  int Nstars, found, AutoLimits, ErrorBars, GalMag, AbsPhot, SaveVectors;
-  int i, j, m, N, NPTS, *N1;
+  int found, AutoLimits, ErrorBars, GalMag, AbsPhot, SaveVectors;
+  off_t i, Nstars, *N1;
+  int j, m, N, NPTS;
   time_t TimeReference;
   struct tm *timeptr;
@@ -88,5 +89,5 @@
   ALLOCATE (RA, double, Nstars);
   ALLOCATE (DEC, double, Nstars);
-  ALLOCATE (N1, int, Nstars);
+  ALLOCATE (N1, off_t, Nstars);
 
   /* find star(s) in RA, DEC list -- use a dumb algorithm for now, improve later */
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/opihi/dvo/lightcurve.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/opihi/dvo/lightcurve.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/opihi/dvo/lightcurve.c	(revision 27295)
@@ -5,6 +5,7 @@
   double Ra, Dec, Radius, Radius2, r;
   double *RA, *DEC;
-  int Nstars, found, PhotCodeSelect;
-  int i, j, k, m, N, NPTS, Nsecfilt, RELPHOT, *N1, TimeFormat;
+  off_t i, Nstars, *N1;
+  int found, PhotCodeSelect;
+  int j, k, m, N, NPTS, Nsecfilt, RELPHOT, TimeFormat;
   time_t TimeReference;
 
@@ -71,5 +72,5 @@
   ALLOCATE (RA, double, Nstars);
   ALLOCATE (DEC, double, Nstars);
-  ALLOCATE (N1, int, Nstars);
+  ALLOCATE (N1, off_t, Nstars);
 
   /* find star(s) in RA, DEC list -- use a dumb algorithm for now, improve later */
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/opihi/dvo/simage.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/opihi/dvo/simage.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/opihi/dvo/simage.c	(revision 27295)
@@ -89,5 +89,5 @@
     return (FALSE);
   }
-  fseek (f, header.size, SEEK_SET); 
+  fseeko (f, header.datasize, SEEK_SET); 
 
   /* set up storage buffers */
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/opihi/dvo/subpix.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/opihi/dvo/subpix.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/opihi/dvo/subpix.c	(revision 27295)
@@ -3,6 +3,6 @@
 int subpix (int argc, char **argv) {
   
-  int i, j, I, Nlo, Nhi, Nentry, Nstars, Nimage, Nmeasure;
-  int *index, *entry;
+  int i, j, I, Nlo, Nhi, *entry, Nentry;
+  off_t *index, Nstars, Nimage, Nmeasure;
   int Nmin, Nsub, NSUB, status;
   int TimeFormat;
@@ -54,5 +54,5 @@
   ALLOCATE (RA, double, Nstars);
   ALLOCATE (DEC, double, Nstars);
-  ALLOCATE (index, int, Nstars);
+  ALLOCATE (index, off_t, Nstars);
   for (i = 0; i < Nstars; i++) {
     RA[i] = catalog.average[i].R;
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/opihi/lib.shell/BufferOps.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/opihi/lib.shell/BufferOps.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/opihi/lib.shell/BufferOps.c	(revision 27295)
@@ -241,5 +241,5 @@
 	       i, buffers[i][0].name, buffers[i][0].file, 
 	       buffers[i][0].header.Naxis[0], buffers[i][0].header.Naxis[1],
-	       buffers[i][0].header.size + buffers[i][0].matrix.size, buffers[i][0].bitpix, 
+	       buffers[i][0].header.datasize + buffers[i][0].matrix.datasize, buffers[i][0].bitpix, 
 	       buffers[i][0].unsign, buffers[i][0].bzero, buffers[i][0].bscale);
     }
@@ -252,6 +252,6 @@
 	     i, buffers[i][0].name, buffers[i][0].file, 
 	     buffers[i][0].header.Naxis[0], buffers[i][0].header.Naxis[1],
-	     buffers[i][0].header.size + buffers[i][0].matrix.size);
-  }
-  return (TRUE);
-}
+	     buffers[i][0].header.datasize + buffers[i][0].matrix.datasize);
+  }
+  return (TRUE);
+}
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/opihi/lib.shell/stack_math.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/opihi/lib.shell/stack_math.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/opihi/lib.shell/stack_math.c	(revision 27295)
@@ -1135,13 +1135,13 @@
   /* copy all but the matrix */
 
-  matrix2[0].unsign = matrix1[0].unsign;
-  matrix2[0].bitpix = matrix1[0].bitpix;
-  matrix2[0].size   = matrix1[0].size;
-  matrix2[0].bzero  = matrix1[0].bzero;
-  matrix2[0].bscale = matrix1[0].bscale;
-  matrix2[0].Naxes  = matrix1[0].Naxes;
-  for (i = 0; i < FT_MAX_NAXES; i++) 
+  matrix2[0].unsign   = matrix1[0].unsign;
+  matrix2[0].bitpix   = matrix1[0].bitpix;
+  matrix2[0].datasize = matrix1[0].datasize;
+  matrix2[0].bzero    = matrix1[0].bzero;
+  matrix2[0].bscale   = matrix1[0].bscale;
+  matrix2[0].Naxes    = matrix1[0].Naxes;
+  for (i = 0; i < FT_MAX_NAXES; i++) {
     matrix2[0].Naxis[i] = matrix1[0].Naxis[i];
-
+  }
 
   return (TRUE);
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/photdbc/src/join_stars.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/photdbc/src/join_stars.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/photdbc/src/join_stars.c	(revision 27295)
@@ -3,10 +3,10 @@
 void join_stars (Catalog *catalog) {
 
-  int i, j, k, m, M, Ni, Nj, first_j;
-  int Naves, Nmeas, Ncurr;
-  int Naverage, Nmeasure, *found, *index;
+  off_t i, j, k, m, M, Ni, Nj, first_j, Nfirst;
+  off_t Naves, Nmeas, Ncurr;
+  off_t Naverage, Nmeasure, *index;
   double *X, *Y, dX, dY, dR, RADIUS2;
   double Sr, Sd, Rmid, Dmid;
-  int basecode, baseNsec, Nsecfilt, Nfirst;
+  int basecode, baseNsec, Nsecfilt, *found;
 
   Average *naverage, *average;
@@ -61,5 +61,5 @@
   ALLOCATE (X, double, Naverage);
   ALLOCATE (Y, double, Naverage);
-  ALLOCATE (index, int, Naverage);
+  ALLOCATE (index, off_t, Naverage);
   for (i = 0; i < Naverage; i++) {
     index[i] = i;
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/relphot/src/GridOps.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/relphot/src/GridOps.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/relphot/src/GridOps.c	(revision 27295)
@@ -781,6 +781,6 @@
     theader.Naxis[0] = RELPHOT_GRID_X;
     theader.Naxis[1] = RELPHOT_GRID_Y;
-    gfits_modify (&theader, "NAXIS1", "%d", 1, RELPHOT_GRID_X);
-    gfits_modify (&theader, "NAXIS2", "%d", 1, RELPHOT_GRID_Y);
+    gfits_modify (&theader, "NAXIS1", "%lld", 1, RELPHOT_GRID_X);
+    gfits_modify (&theader, "NAXIS2", "%lld", 1, RELPHOT_GRID_Y);
     gfits_create_matrix  (&theader, &matrix);
 
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/relphot/src/load_images.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/relphot/src/load_images.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/relphot/src/load_images.c	(revision 27295)
@@ -40,5 +40,5 @@
 
   Image     *image;
-  int        Nimage, Nx, i;
+  off_t     Nimage, Nx, i;
   VTable    *vtable;
 
@@ -47,5 +47,5 @@
   vtable = &db[0].vtable;
 
-  gfits_scan (vtable[0].header, "NAXIS1", "%d", 1, &Nx);
+  gfits_scan (vtable[0].header, "NAXIS1", "%lld", 1, &Nx);
   for (i = 0; i < Nimage; i++) {
     memcpy (vtable[0].buffer[i], &image[i], Nx);
Index: anches/eam_branches/largefiles.20100314/Ohana/src/skycalc/src/misc.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/skycalc/src/misc.c	(revision 27294)
+++ 	(revision )
@@ -1,314 +1,0 @@
-# include <ohana.h>
-# include <skycalc_internal.h>
-
-/***** convert [-]00:00:00 to 0.0000 ****/
-int dms_to_ddd (double *Value, char *string) {
-  
-  int valid, neg, status;
-  double tmp, value;
-  char *p1, *p2, *px;
-
-  valid = FALSE; 
-  neg = FALSE;
-  stripwhite (string);
-  p1 = string;
-  px = string + strlen(string);
-
-  if (string[0] == '-') { 
-    valid = TRUE; 
-    neg = TRUE;
-    p1 = &string[1];
-  }
-  if (string[0] == '+') { 
-    valid = TRUE; 
-    neg = FALSE;
-    p1 = &string[1];
-  }
-  if (isdigit(string[0])) { 
-    valid = TRUE;
-    p1 = &string[0];
-  }
-  if (!valid) { return (FALSE); }
-
-  status = 1;
-  tmp = strtod (p1, &p2);
-  if (p2 == p1) return (FALSE); /* entry not a number: +fred */
-  value = tmp;
-  if (p2 == px) goto escape;    /* entry only number: +1.0 */ 
-  p1 = p2 + 1;
-
-  tmp = strtod (p1, &p2);
-  if (p2 == p1) goto escape;    /* entry not a number: +1:fred */
-  status = 2;
-  value += tmp / 60.0;
-  if (p2 == px) goto escape;    /* entry only number: +1:1 */
-  p1 = p2 + 1;
-
-  tmp = strtod (p1, &p2);
-  if (p2 == p1) goto escape;    /* entry not a number: +1:1:fred */
-  value += tmp / 3600.0;
-
- escape:
-  if (neg) {
-    value *= -1;
-  }
-  *Value = value;
-
-  return (status);
-}
-
-/**********/
-int str_to_radec (double *ra, double *dec, char *str1, char *str2) {
-
-  double Ra, Dec;
-
-  *ra = *dec = 0;
-  switch (dms_to_ddd (&Ra, str1)) {
-  case 0:
-    fprintf (stderr, "syntax error in RA\n");
-    return (FALSE);
-  case 1:
-    break;
-  case 2:
-    Ra = Ra * 15;
-    break;
-  }
-  switch (dms_to_ddd (&Dec, str2)) {
-  case 0:
-    fprintf (stderr, "syntax error in DEC\n");
-    return (FALSE);
-  case 1:
-  case 2:
-    break;
-  }
-  *ra = Ra;
-  *dec = Dec;
-  return (TRUE);
-}
-
-# define FORMAT_DAYS    1
-# define FORMAT_HOURS   2
-# define FORMAT_MINUTES 3
-# define FORMAT_SECONDS 4
-# define FORMAT_JD      5
-# define FORMAT_DATE    6
-
-/**********/
-int chk_time (char *line) {
-
-  char *p1, *p2;
-  double tmp;
-  int mode;
-
-  p1 = line;
-  tmp = strtod (p1, &p2);
-  if (p2 == p1 + strlen (p1) - 1) {
-    if (*p2 == 'd') {
-      mode = FORMAT_DAYS;
-    }
-    if (*p2 == 'h') {
-      mode = FORMAT_HOURS;
-    }
-    if (*p2 == 'm') {
-      mode = FORMAT_MINUTES;
-    }
-    if (*p2 == 's') {
-      mode = FORMAT_SECONDS;
-    }
-    if (*p2 == 'j') {
-      mode = FORMAT_JD;
-    }
-  } else { 
-    mode = FORMAT_DATE;
-  }
-  return (mode);
-}
-
-/**********/
-int str_to_time (char *line, time_t *second) {
-  
-  struct timeval now;
-  double jd;
-
-  if (!strcasecmp (line, "NOW")) {
-    gettimeofday (&now, (struct timezone *) NULL);
-    *second = now.tv_sec;
-    return (TRUE);
-  }
-    
-  if (!strcasecmp (line, "TODAY")) {
-    gettimeofday (&now, (struct timezone *) NULL);
-    *second = 86400 * ((int)(now.tv_sec / 86400));
-    return (TRUE);
-  }
-    
-  switch (chk_time (line)) {
-  case 0:
-    return (FALSE);
-  case FORMAT_DAYS:
-    *second = strtod (line, 0) * 86400.0;
-    return (TRUE);
-  case FORMAT_HOURS:
-    *second = strtod (line, 0) * 3600.0;
-    return (TRUE);
-  case FORMAT_MINUTES:
-    *second = strtod (line, 0) * 60.0;
-    return (TRUE);
-  case FORMAT_SECONDS:
-    *second = strtod (line, 0);
-    return (TRUE);
-  case FORMAT_JD:
-    jd = strtod (line, 0);
-    *second = jd_to_sec (jd);
-    return (TRUE);
-  case FORMAT_DATE:
-    *second = date_to_sec (line);
-    return (TRUE);
-  }
-  return (FALSE);
-}
-
-/**********/
-int str_to_dtime (char *line, double *second) {
-  
-  switch (chk_time (line)) {
-  case 0:
-  case FORMAT_JD:
-  case FORMAT_DATE:
-    return (FALSE);
-  case FORMAT_DAYS:
-    *second = strtod (line, 0) * 86400.0;
-    return (TRUE);
-  case FORMAT_HOURS:
-    *second = strtod (line, 0) * 3600.0;
-    return (TRUE);
-  case FORMAT_MINUTES:
-    *second = strtod (line, 0) * 60.0;
-    return (TRUE);
-  case FORMAT_SECONDS:
-    *second = strtod (line, 0);
-    return (TRUE);
-  }
-  return (FALSE);
-}
-
-/**********/
-double sec_to_jd (time_t second) {
-
-  double jd;
-  
-  jd = second/86400.0 + 2440587.5;
-  return (jd);
-}
-
-/**********/
-time_t jd_to_sec (double jd) {
-
-  time_t second;
-
-  second = (jd - 2440587.5)*86400;
-  return (second);
-}
-
-/**********/
-char *sec_to_date (time_t second) {
-  
-  struct tm *gmt;
-  char *line;
-  
-  ALLOCATE (line, char, 64);
-  gmt   = gmtime (&second);
-  sprintf (line, "%4d/%02d/%02d,%02d:%02d:%02d", 1900+gmt[0].tm_year, gmt[0].tm_mon+1, gmt[0].tm_mday, gmt[0].tm_hour, gmt[0].tm_min, gmt[0].tm_sec); 
-  return (line);
-
-}
-
-/***** date in format yyyy/mm/dd,hh:mm:ss *****/
-time_t date_to_sec (char *date) {
-  
-  time_t second;
-  double tmp, jd;
-  struct tm now;
-  char *p1, *p2, *px;
-  
-  p1 = date;
-  px = date + strlen(date);
-  bzero (&now, sizeof(now));
-
-  tmp = strtod (p1, &p2);
-  if (p2 == p1) goto escape;
-  now.tm_year = tmp;
-  if (now.tm_year > 1000) now.tm_year -= 1900;
-  if (now.tm_year <   50) now.tm_year += 100;
-  if (p2 == px) goto escape;  
-  p1 = p2 + 1;
-
-  tmp = strtod (p1, &p2);
-  if (p2 == p1) goto escape;
-  now.tm_mon = tmp - 1; /* mon runs from 0 - 11 */
-  if (p2 == px) goto escape;  
-  p1 = p2 + 1;
-
-  tmp = strtod (p1, &p2);
-  if (p2 == p1) goto escape;
-  now.tm_mday = tmp;
-  if (p2 == px) goto escape;  
-  p1 = p2 + 1;
-
-  tmp = strtod (p1, &p2);
-  if (p2 == p1) goto escape;
-  p1 = p2 + 1;
-  now.tm_hour = tmp;
-  if (p2 == px) goto escape;  
-
-  tmp = strtod (p1, &p2);
-  if (p2 == p1) goto escape;
-  now.tm_min = tmp;
-  if (p2 == px) goto escape;  
-  p1 = p2 + 1;
-
-  tmp = strtod (p1, &p2);
-  if (p2 == p1) goto escape;
-  now.tm_sec = tmp;
-  if (p2 == px) goto escape;  
-  p1 = p2 + 1;
-
- escape:
-  jd = now.tm_mday - 32075 + (int)(1461*(1900 + now.tm_year + 4800 + (int)(((now.tm_mon+1)-14)/12))/4)
-    + (int)(367*((now.tm_mon+1) - 2 - (int)(((now.tm_mon+1) - 14)/12)*12)/12)
-    - (int)(3*(int)((1900 + now.tm_year + 4900 + (int)(((now.tm_mon+1) - 14)/12))/100)/4) - 0.5;
-  
-  second = (jd - 2440587.5)*86400 + 3600.0*now.tm_hour + now.tm_min*60.0 + now.tm_sec;
-
-  return (second);
-}
-
-
-/* times may be in forms as:
-   20040200450s (N seconds since 1970.0)
-   2440900.232j (julian date)
-   99/02/23,03:22:18 (date string)
-   (separators may be anything except space, +, -)
-   99:02:15:12:23:30
-   99:02:15:12h23m30s
-   */
-
-
-/* fseek with timeout - 0.5 sec */
-int Fseek (FILE *f, long offset, int whence) {
-
-  int status, k;
-
-  status = fseek (f, offset, whence);
-  if (status == -1) {
-    int k;
-    /* fprintf (stderr, "problem seeking position: %d\n", errno); */
-    for (k = 0; (k < 10) && ((status = fseek (f, 0, SEEK_SET)) == -1); k++) usleep (50000);
-    if (status == -1) {
-      /* fprintf (stderr, "ERROR: serious problem seeking position: %d\n", errno); */
-      /* clear lock at this point? */
-      return (0);
-    }
-  }
-  return (1);
-}
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/tools/src/ckfits.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/tools/src/ckfits.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/tools/src/ckfits.c	(revision 27295)
@@ -4,5 +4,6 @@
 int main (int argc, char **argv) {
 
-  int i, Nbytes, nbytes, Ndata, Ntotal, nskip, status;
+  off_t i, Nbytes, nbytes, Ndata, Ntotal, nskip;
+  int status;
   Header header;
   FILE *f;
@@ -26,5 +27,5 @@
 
   nbytes = Ntotal - Ndata;
-  nskip = Ndata + header.size;
+  nskip = Ndata + header.datasize;
 
   f = fopen (argv[1], "r");
@@ -35,5 +36,5 @@
 
   ALLOCATE (buffer, char, MAX (nbytes, 1));
-  fseek (f, nskip, SEEK_SET);
+  fseeko (f, nskip, SEEK_SET);
   Nbytes = fread (buffer, 1, nbytes, f);
   fclose (f);
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/tools/src/fhead.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/tools/src/fhead.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/tools/src/fhead.c	(revision 27295)
@@ -5,5 +5,6 @@
 
   int N, Extend, Nextend, status;
-  int i, j, nbytes;
+  int i, j;
+  off_t nbytes;
   Header head;
   char *p;
@@ -29,5 +30,5 @@
     if (!status) continue;
 
-    for (j = 79; j < head.size; j+= 80) {
+    for (j = 79; j < head.datasize; j+= 80) {
       head.buffer[j] = 10;
     }
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/tools/src/fields.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/tools/src/fields.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/tools/src/fields.c	(revision 27295)
@@ -22,6 +22,6 @@
   Header header;
   char filename[1000], *CCDKeyword, *Extname, extname[80];
-  int N, Nbytes, Extnum, Nextend, status, GotFile, GotField, GotExtension;
-
+  int N, Extnum, Nextend, status, GotFile, GotField, GotExtension;
+  off_t Nbytes;
   regex_t preg;
 
@@ -97,5 +97,5 @@
     
 	Nbytes = gfits_data_size (&header);
-	fseek (f, Nbytes, SEEK_CUR);
+	fseeko (f, Nbytes, SEEK_CUR);
 	Nextend ++;
 
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/tools/src/fits_insert.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/tools/src/fits_insert.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/tools/src/fits_insert.c	(revision 27295)
@@ -7,6 +7,7 @@
 int main (int argc, char **argv) {
 
-  int i, N, status, EXTNUM, Nbytes, skip, Delete, DeleteStart, DeleteStop;
-  int Nreserved, start_size;
+  off_t i, skip, Nbytes, start_size;
+  int N, status, EXTNUM, Delete, DeleteStart, DeleteStop;
+  int Nreserved;
   char *p, keyword[16], line[256];
   FILE *f;
@@ -62,6 +63,6 @@
       exit (1);
   }
-  start_size = header.size;
-  skip = Nbytes - header.size;
+  start_size = header.datasize;
+  skip = Nbytes - header.datasize;
 
   /* open header data file */
@@ -116,5 +117,5 @@
     /* check that the line does not already exist */
     p = (char *) NULL;
-    for (i = 0; (i < header.size) && (p == (char *) NULL) ; i+= FT_LINE_LENGTH) {
+    for (i = 0; (i < header.datasize) && (p == (char *) NULL) ; i+= FT_LINE_LENGTH) {
       if (!strncmp (&header.buffer[i], line, 80)) {
 	p = &header.buffer[i];
@@ -126,5 +127,5 @@
     p = (char *) NULL;
     Nreserved = strlen (reserved);
-    for (i = 0; (i < header.size) && (p == (char *) NULL) ; i+= FT_LINE_LENGTH) {
+    for (i = 0; (i < header.datasize) && (p == (char *) NULL) ; i+= FT_LINE_LENGTH) {
       if (!strncmp (&header.buffer[i], "END     ", 8)) break;
       if (!strncmp (&header.buffer[i], reserved, Nreserved)) {
@@ -142,5 +143,5 @@
 	exit (1);
       }
-      if (p - header.buffer + 80 == header.size) {
+      if (p - header.buffer + 80 == header.datasize) {
 	fprintf (stderr, "no free space in block, can't insert keyword\n");
 	exit (1);
@@ -161,5 +162,5 @@
   */
 
-  if (header.size != start_size) {
+  if (header.datasize != start_size) {
     fprintf (stderr, "header changed size: should not happen!\n");
     exit (1);
@@ -172,7 +173,7 @@
   }
 
-  fseek (f, skip, SEEK_SET);
-  status = fwrite (header.buffer, 1, header.size, f);
-  if (status != header.size) {
+  fseeko (f, skip, SEEK_SET);
+  status = fwrite (header.buffer, 1, header.datasize, f);
+  if (status != header.datasize) {
     fprintf (stderr, "failed to write data to image header\n");
     exit (1);
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/tools/src/ftable.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/tools/src/ftable.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/tools/src/ftable.c	(revision 27295)
@@ -8,11 +8,10 @@
 void list_extnames (char *file);
 void print_layout (Header *header);
-int   ByteSwap (char *ptr, int size, int nitems, char *type);
 int Binary;
 
 int main (int argc, char **argv) {
 
-  int i, N, Nx, Ny, Nbytes, Nread;
-  int Nextend, Column, Row, ListExtname, Layout;
+  off_t i, Nx, Ny, Nbytes, Nread, Row;
+  int N, Nextend, Column, ListExtname, Layout;
   char *Extname, *Colname, *line, ttype[80];
   FTable table;
@@ -94,8 +93,8 @@
     exit (1);
   }
-  table.size = Nbytes;
-
-  gfits_scan (table.header, "NAXIS1",  "%d", 1, &Nx);
-  gfits_scan (table.header, "NAXIS2",  "%d", 1, &Ny);
+  table.datasize = Nbytes;
+
+  gfits_scan (table.header, "NAXIS1",  "%lld", 1, &Nx);
+  gfits_scan (table.header, "NAXIS2",  "%lld", 1, &Ny);
 
   /* print a column */
@@ -122,8 +121,9 @@
 char *print_table_row (char *row, Header *header) {
   
-  int i, j, Nx, Nfields, Nbytes, Nvals, Oout, Oin;
+  off_t Nx;
+  int i, j, Nfields, Nbytes, Nvals, Oout, Oin;
   char field[16], type[16], format[16], *line;
 
-  gfits_scan (header, "NAXIS1",  "%d", 1, &Nx);
+  gfits_scan (header, "NAXIS1",  "%lld", 1, &Nx);
   gfits_scan (header, "TFIELDS", "%d", 1, &Nfields);
 
@@ -160,5 +160,6 @@
 
   FILE *f;
-  int i, Naxis, Nelem, Ncomp, extend, Nbytes, status;
+  off_t Nbytes, Nelem;
+  int i, Naxis, Ncomp, extend, status;
   char extname[82], exttype[82], axisname[32];
   Header header;
@@ -169,13 +170,4 @@
     exit (1);
   }
-
-  /* 
-     if (!gfits_fread_header (f, &header)) {
-     fprintf (stderr, "can't read header from %s\n", file);
-     exit (1);
-     }
-     Nbytes = gfits_data_size (&header);
-     fseek (f, Nbytes, SEEK_CUR);
-  */
 
   fprintf (stdout, "%-30s %-15s NAXIS NAXIS(i)...\n", "extname", "datatype"); 
@@ -217,5 +209,5 @@
     for (i = 0; i < Naxis; i++) {
       sprintf (axisname, "NAXIS%d", i+1);
-      status = gfits_scan (&header, axisname,  "%d", 1, &Nelem);
+      status = gfits_scan (&header, axisname,  "%lld", 1, &Nelem);
       if (!status) {
 	fprintf (stderr, "missing %s\n", axisname);
@@ -235,5 +227,5 @@
 
     Nbytes = gfits_data_size (&header);
-    fseek (f, Nbytes, SEEK_CUR);
+    fseeko (f, Nbytes, SEEK_CUR);
 
     Ncomp ++;
@@ -245,5 +237,6 @@
 FILE *load_extension (char *file, int Nextend, char *Extname, Header *header) {
 
-  int i, extend, Nbytes;
+  off_t Nbytes;
+  int i, extend;
   char extname[82];
   FILE *f;
@@ -271,5 +264,5 @@
   /* skip first data array */
   Nbytes = gfits_data_size (header);
-  fseek (f, Nbytes, SEEK_CUR);
+  fseeko (f, Nbytes, SEEK_CUR);
 
   /* search for extension of interest */
@@ -281,5 +274,5 @@
 
     Nbytes = gfits_data_size (header);
-    fseek (f, Nbytes, SEEK_CUR);
+    fseeko (f, Nbytes, SEEK_CUR);
     gfits_free_header (header);
   }
@@ -292,5 +285,6 @@
 void print_column (FTable *table, int Column, char *Colname) {
   
-  int i, j, Nfields, Nstart, Nv, Nb, Nx, Ny;
+  off_t Nx, Ny;
+  int i, j, Nfields, Nstart, Nv, Nb;
   Header *header;
   char format[16], field[16], type[16], *line, *data;
@@ -300,6 +294,6 @@
 
   gfits_scan (header, "TFIELDS", "%d", 1, &Nfields);
-  gfits_scan (header, "NAXIS1",  "%d", 1, &Nx);
-  gfits_scan (header, "NAXIS2",  "%d", 1, &Ny);
+  gfits_scan (header, "NAXIS1",  "%lld", 1, &Nx);
+  gfits_scan (header, "NAXIS2",  "%lld", 1, &Ny);
 
   if (Colname != (char *) NULL) {
Index: /branches/eam_branches/largefiles.20100314/Ohana/src/tools/src/mefhead.c
===================================================================
--- /branches/eam_branches/largefiles.20100314/Ohana/src/tools/src/mefhead.c	(revision 27294)
+++ /branches/eam_branches/largefiles.20100314/Ohana/src/tools/src/mefhead.c	(revision 27295)
@@ -5,5 +5,6 @@
 
   struct stat filestat;
-  int NEXTEND, Nextend, Nmatrix, status;
+  int NEXTEND, Nextend, status;
+  off_t Nmatrix;
   Header header;
   FILE *f, *g;
@@ -43,5 +44,5 @@
   /* skip matrix */
   Nmatrix = gfits_data_size (&header);
-  fseek (g, Nmatrix, SEEK_CUR);
+  fseeko (g, Nmatrix, SEEK_CUR);
 
   /* write PHU */
@@ -65,5 +66,5 @@
     /* skip matrix */
     Nmatrix = gfits_data_size (&header);
-    fseek (g, Nmatrix, SEEK_CUR);
+    fseeko (g, Nmatrix, SEEK_CUR);
     
     /* write header */
