- Timestamp:
- Mar 5, 2017, 11:23:19 AM (9 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/libfits/table/F_read_T.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/libfits/table/F_read_T.c
r38986 r39996 29 29 } 30 30 31 /*********************** gfits_fread_incomplete_case ***********************************/ 32 int gfits_fread_incomplete_case (FILE *f, FTable *table, int padIfShort, off_t Nread, off_t Nbytes) { 33 char string[128]; 34 35 snprintf (string, 128, "FITS file is short (%s)", __func__); 36 perror (string); 37 if (Nread < gfits_data_min_size (table[0].header)) { 38 fprintf (stderr, "error: fits read error in %s, read "OFF_T_FMT", need "OFF_T_FMT"\n", __func__, Nread, gfits_data_min_size (table[0].header)); 39 if (!padIfShort) { 40 gfits_free_table (table); 41 return FALSE; 42 } 43 memset (&table[0].buffer[Nread], 0, Nbytes - Nread); 44 fprintf (stderr, "warning: file missing data, padding with zeros: USE AT YOUR OWN RISK!\n"); 45 } else { 46 fprintf (stderr, "warning: file missing pad\n"); 47 } 48 return TRUE; 49 } 50 31 51 /*********************** fits read ftable data ***********************************/ 32 52 int gfits_fread_ftable_data (FILE *f, FTable *table, int padIfShort) { 33 53 34 54 off_t Nbytes, Nread; 35 char string[128];36 55 37 56 /* find buffer size */ … … 41 60 Nread = fread (table[0].buffer, sizeof (char), Nbytes, f); 42 61 if (Nread != Nbytes) { 43 snprintf (string, 128, "FITS file is short (%s)", __func__); 44 perror (string); 45 if (Nread < gfits_data_min_size (table[0].header)) { 46 fprintf (stderr, "error: fits read error in %s, read "OFF_T_FMT", need "OFF_T_FMT"\n", __func__, Nread, gfits_data_min_size (table[0].header)); 47 if (!padIfShort) { 48 gfits_free_table (table); 49 return (FALSE); 62 if (feof(f)) { 63 if (!gfits_fread_incomplete_case(f, table, padIfShort, Nread, Nbytes)) return FALSE; 64 } else { 65 off_t Nextra = Nbytes - Nread; 66 off_t Nxread = fread (&table[0].buffer[Nread], sizeof (char), Nextra, f); 67 Nread += Nxread; 68 if (Nread != Nbytes) { 69 if (!gfits_fread_incomplete_case(f, table, padIfShort, Nread, Nbytes)) return FALSE; 50 70 } 51 memset (&table[0].buffer[Nread], 0, Nbytes - Nread);52 fprintf (stderr, "warning: file missing data, padding with zeros: USE AT YOUR OWN RISK!\n");53 } else {54 fprintf (stderr, "warning: file missing pad\n");55 71 } 56 72 }
Note:
See TracChangeset
for help on using the changeset viewer.
