- Timestamp:
- May 3, 2010, 8:41:49 AM (16 years ago)
- Location:
- branches/tap_branches
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/tap_branches
- Property svn:mergeinfo changed
-
branches/tap_branches/Ohana
-
Property svn:mergeinfo
set to (toggle deleted branches)
/trunk/Ohana merged eligible /branches/eam_branches/Ohana.20100407 27635-27772 /branches/pap_delete/Ohana 27530-27595
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
branches/tap_branches/Ohana/src/libfits/table/F_read_T.c
r15751 r27838 19 19 int gfits_fread_ftable (FILE *f, FTable *table, char *extname) { 20 20 21 int j, found, Nbytes; 21 int j, found; 22 off_t Nbytes; 22 23 Header *header; 23 24 char tname[80]; 24 25 25 26 header = table[0].header; 26 fseek (f, 0, SEEK_SET);27 fseeko (f, 0, SEEK_SET); 27 28 28 29 found = FALSE; … … 42 43 /* skip to next header */ 43 44 Nbytes = gfits_data_size (header); 44 fseek (f, Nbytes, SEEK_CUR);45 fseeko (f, Nbytes, SEEK_CUR); 45 46 gfits_free_header (header); 46 47 } … … 51 52 int gfits_fread_ftable_data (FILE *f, FTable *table) { 52 53 53 int Nbytes, Nread;54 off_t Nbytes, Nread; 54 55 char string[128]; 55 56 … … 63 64 perror (string); 64 65 if (Nread < gfits_data_min_size (table[0].header)) { 65 fprintf (stderr, "error: fits read error in %s, read % d, need %d\n", __func__, Nread,gfits_data_min_size (table[0].header));66 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)); 66 67 gfits_free_table (table); 67 68 return (FALSE); … … 69 70 fprintf (stderr, "warning: file missing pad\n"); 70 71 } 71 table[0]. size = Nbytes;72 table[0].datasize = Nbytes; 72 73 return (TRUE); 73 74 } 74 75 75 76 /*********************** fits read ftable data ***********************************/ 76 int gfits_fread_ftable_range (FILE *f, FTable *table, int start, int Nrows) {77 78 int Nbytes, Nread, Nskip, Nx, Ny;77 int gfits_fread_ftable_range (FILE *f, FTable *table, off_t start, off_t Nrows) { 78 79 off_t Nbytes, Nread, Nskip, Nx, Ny; 79 80 80 81 /* find disk table size */ … … 93 94 ALLOCATE (table[0].buffer, char, MAX (Nbytes, 1)); 94 95 95 fseek (f, Nskip, SEEK_CUR);96 fseeko (f, Nskip, SEEK_CUR); 96 97 97 98 Nread = fread (table[0].buffer, sizeof (char), Nbytes, f); … … 108 109 /* modify structure and header to match actual read rows Ny */ 109 110 table[0].header[0].Naxis[1] = Nrows; 110 gfits_modify (table[0].header, "NAXIS2", "% d", 1,Nrows);111 table[0]. size = gfits_data_size (table[0].header);111 gfits_modify (table[0].header, "NAXIS2", "%lld", 1, (long long) Nrows); 112 table[0].datasize = gfits_data_size (table[0].header); 112 113 113 114 return (TRUE); … … 115 116 116 117 /*********************** fits read ftable data ***********************************/ 117 int gfits_fread_vtable_range (FILE *f, VTable *table, int start, int Nrows) {118 119 int i, Nbytes, Nread, Nskip, Nx, Ny;118 int gfits_fread_vtable_range (FILE *f, VTable *table, off_t start, off_t Nrows) { 119 120 off_t i, Nbytes, Nread, Nskip, Nx, Ny; 120 121 char *buffer; 121 122 … … 123 124 Nx = table[0].header[0].Naxis[0]; 124 125 Ny = table[0].header[0].Naxis[1]; 125 table[0]. size = gfits_data_size (table[0].header);126 table[0].pad = table[0]. size - Nx*Ny;126 table[0].datasize = gfits_data_size (table[0].header); 127 table[0].pad = table[0].datasize - Nx*Ny; 127 128 128 129 if (start < 0) return (FALSE); … … 133 134 ALLOCATE (buffer, char, MAX (Nbytes, 1)); 134 135 135 fseek (f, Nskip, SEEK_CUR);136 fseeko (f, Nskip, SEEK_CUR); 136 137 Nread = fread (buffer, sizeof (char), Nbytes, f); 137 138 if (Nread != Nbytes) { … … 141 142 } 142 143 143 ALLOCATE (table[0].row, int, MAX (Nrows, 1));144 ALLOCATE (table[0].row, off_t, MAX (Nrows, 1)); 144 145 ALLOCATE (table[0].buffer, char *, MAX (Nrows, 1)); 145 146 for (i = 0; i < Nrows; i++) { … … 154 155 155 156 /*********************** fits read virtual table ***********************************/ 156 int gfits_fread_vtable (FILE *f, VTable *table, char *extname, int Nrow, int *row) { 157 158 int i, j, Nbytes, Nread; 159 int start, Nx, Ny, offset; 157 int gfits_fread_vtable (FILE *f, VTable *table, char *extname, off_t Nrow, off_t *row) { 158 159 off_t i, j; 160 off_t Nbytes, Nread; 161 off_t start, Nx, Ny, offset; 160 162 Header *header; 161 163 char tname[80]; 162 164 163 165 header = table[0].header; 164 fseek (f, 0, SEEK_SET);166 fseeko (f, 0, SEEK_SET); 165 167 166 168 for (j = -1; TRUE; j++) { … … 176 178 if (strcmp (tname, extname)) { 177 179 /* skip to next header */ 178 fseek (f, Nbytes, SEEK_CUR);180 fseeko (f, Nbytes, SEEK_CUR); 179 181 gfits_free_header (header); 180 182 continue; … … 182 184 183 185 /* file pointer is at beginning of desired table data */ 184 start = ftell (f);185 gfits_scan (header, "NAXIS1", "% d", 1,&Nx);186 gfits_scan (header, "NAXIS2", "% d", 1,&Ny);186 start = ftello (f); 187 gfits_scan (header, "NAXIS1", "%lld", 1, (long long *) &Nx); 188 gfits_scan (header, "NAXIS2", "%lld", 1, (long long *) &Ny); 187 189 for (i = 0; i < Nrow; i++) { 188 190 if (row[i] > Ny) { return (FALSE); } … … 193 195 ALLOCATE (table[0].buffer[i], char, MAX (1, Nx)); 194 196 offset = start + Nx*row[i]; 195 fseek (f, offset, SEEK_SET);197 fseeko (f, offset, SEEK_SET); 196 198 Nread = fread (table[0].buffer[i], sizeof (char), Nx, f); 197 199 if (Nread != Nx) { … … 202 204 203 205 table[0].Nrow = Nrow; 204 ALLOCATE (table[0].row, int, MAX (1, Nrow));206 ALLOCATE (table[0].row, off_t, MAX (1, Nrow)); 205 207 for (i = 0; i < Nrow; i++) table[0].row[i] = row[i]; 206 table[0]. size= gfits_data_size (table[0].header);207 table[0].pad = table[0].size - Nx*Ny;208 table[0].datasize = gfits_data_size (table[0].header); 209 table[0].pad = table[0].datasize - Nx*Ny; 208 210 return (TRUE); 209 211 } … … 212 214 int gfits_fread_header_extname (FILE *f, Header *header, char *extname) { 213 215 214 int Nbytes;216 off_t Nbytes; 215 217 char current[80]; 216 218 217 fseek (f, 0, SEEK_SET);219 fseeko (f, 0, SEEK_SET); 218 220 gfits_fread_header (f, header); 219 221 … … 221 223 222 224 Nbytes = gfits_data_size (header); 223 fseek (f, Nbytes, SEEK_CUR);225 fseeko (f, Nbytes, SEEK_CUR); 224 226 225 227 while (gfits_fread_header (f, header)) { … … 227 229 if (!strcmp (current, extname)) return (TRUE); 228 230 Nbytes = gfits_data_size (header); 229 fseek (f, Nbytes, SEEK_CUR);231 fseeko (f, Nbytes, SEEK_CUR); 230 232 } 231 233 return (FALSE);
Note:
See TracChangeset
for help on using the changeset viewer.
