Changeset 15743 for trunk/Ohana/src/libfits/table/F_write_T.c
- Timestamp:
- Dec 5, 2007, 3:29:29 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/libfits/table/F_write_T.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/libfits/table/F_write_T.c
r7054 r15743 69 69 /* this will add data beyond the end of the table in the file if needed, 70 70 filling intervening gap with 0 */ 71 72 /*********************** fits read ftable data ***********************************/ 73 int gfits_fwrite_ftable_range (FILE *f, FTable *ftable, int start, int Nrows, int Ndisk, int Ntotal) { 74 75 int Nbytes, Nwrite, Nskip, Nx, Npad; 76 char *pad; 77 78 if (start < 0) return (FALSE); 79 80 /* modify vtable to represent full disk table */ 81 gfits_modify (ftable[0].header, "NAXIS2", "%d", 1, Ntotal); 82 ftable[0].header[0].Naxis[1] = Ntotal; 83 84 Nx = ftable[0].header[0].Naxis[0]; // final output table size on disk 85 ftable[0].size = gfits_data_size (ftable[0].header); 86 87 Nskip = start * Nx; 88 Nbytes = Nrows * Nx; 89 90 // cursor must be at start of the table header 91 if (!gfits_fwrite_Theader (f, ftable[0].header)) { 92 fprintf (stderr, "can't write table header"); 93 return (FALSE); 94 } 95 96 // cursor must be at start of the table (after table header) 97 fseek (f, Nskip, SEEK_CUR); 98 Nwrite = fwrite (ftable[0].buffer, sizeof (char), Nbytes, f); 99 if (Nwrite != Nbytes) { 100 return (FALSE); 101 } 102 103 if (Ntotal >= Ndisk) { 104 Npad = ftable[0].size - Nx*Ntotal; 105 ALLOCATE (pad, char, Npad); 106 bzero (pad, Npad); 107 Nbytes = fwrite (pad, sizeof (char), Npad, f); 108 free (pad); 109 110 if (Nbytes != Npad) return (FALSE); 111 } 112 113 return (TRUE); 114 } 115
Note:
See TracChangeset
for help on using the changeset viewer.
