Changeset 15743 for trunk/Ohana/src/libfits/table/F_read_T.c
- Timestamp:
- Dec 5, 2007, 3:29:29 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/libfits/table/F_read_T.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/libfits/table/F_read_T.c
r15487 r15743 59 59 Nread = fread (table[0].buffer, sizeof (char), Nbytes, f); 60 60 if (Nread != Nbytes) { 61 perror ("fits read error"); 61 62 gfits_free_table (table); 62 63 return (FALSE); 63 64 } 64 65 table[0].size = Nbytes; 66 return (TRUE); 67 } 68 69 /*********************** fits read ftable data ***********************************/ 70 int gfits_fread_ftable_range (FILE *f, FTable *table, int start, int Nrows) { 71 72 int Nbytes, Nread, Nskip, Nx, Ny; 73 74 /* find disk table size */ 75 Nx = table[0].header[0].Naxis[0]; 76 Ny = table[0].header[0].Naxis[1]; 77 78 // it is an error to ask for data starting out-of-bounds 79 if (start < 0) return (FALSE); 80 if (start >= Ny) return (FALSE); 81 82 // if we request more data than is available, we will stop at the table end. 83 Nrows = MIN (Nrows, Ny - start); 84 85 Nskip = start * Nx; 86 Nbytes = Nrows * Nx; 87 ALLOCATE (table[0].buffer, char, MAX (Nbytes, 1)); 88 89 fseek (f, Nskip, SEEK_CUR); 90 91 Nread = fread (table[0].buffer, sizeof (char), Nbytes, f); 92 if (Nread != Nbytes) { 93 if (ferror (f)) { 94 perror ("fits read error"); 95 } else { 96 fprintf (stderr, "unexpected eof\n"); 97 } 98 free (table[0].buffer); 99 return (FALSE); 100 } 101 102 /* modify structure and header to match actual read rows Ny */ 103 table[0].header[0].Naxis[1] = Nrows; 104 gfits_modify (table[0].header, "NAXIS2", "%d", 1, Nrows); 105 table[0].size = gfits_data_size (table[0].header); 106 65 107 return (TRUE); 66 108 } … … 88 130 Nread = fread (buffer, sizeof (char), Nbytes, f); 89 131 if (Nread != Nbytes) { 132 perror ("fits read error"); 90 133 free (buffer); 91 134 return (FALSE); … … 146 189 fseek (f, offset, SEEK_SET); 147 190 Nread = fread (table[0].buffer[i], sizeof (char), Nx, f); 148 if (Nread != Nx) { return (FALSE); } 191 if (Nread != Nx) { 192 perror ("fits read error"); 193 return (FALSE); 194 } 149 195 } 150 196
Note:
See TracChangeset
for help on using the changeset viewer.
