Changeset 38553 for trunk/Ohana/src/libfits
- Timestamp:
- Jun 25, 2015, 10:41:05 PM (11 years ago)
- Location:
- trunk/Ohana/src/libfits
- Files:
-
- 20 edited
-
header/F_write_H.c (modified) (2 diffs)
-
include/gfitsio.h (modified) (1 diff)
-
matrix/F_write_M.c (modified) (1 diff)
-
table/F_compress_T.c (modified) (4 diffs)
-
table/F_create_TH.c (modified) (2 diffs)
-
table/F_define_column.c (modified) (7 diffs)
-
table/F_get_T_column.c (modified) (2 diffs)
-
table/F_get_T_value.c (modified) (2 diffs)
-
table/F_get_column.c (modified) (16 diffs)
-
table/F_set_column.c (modified) (12 diffs)
-
table/F_table_column.c (modified) (4 diffs)
-
table/F_table_format.c (modified) (9 diffs)
-
table/F_table_varlength.c (modified) (2 diffs)
-
table/F_uncompress_T.c (modified) (4 diffs)
-
table/F_write_T.c (modified) (2 diffs)
-
table/F_write_TH.c (modified) (2 diffs)
-
test (modified) (1 prop)
-
test/imagecomp.c (modified) (4 diffs)
-
test/tablecomp.c (modified) (1 diff)
-
test/tcomptiming.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/libfits/header/F_write_H.c
r27435 r38553 5 5 int gfits_write_header (char *filename, Header *header) { 6 6 7 FILE *f; 8 off_t Nbytes; 9 int status; 10 11 status = TRUE; 7 FILE *f = fopen (filename, "w"); 8 if (!f) return (FALSE); 12 9 13 f = fopen (filename, "w"); 14 if (f == (FILE *) NULL) return (FALSE); 15 16 Nbytes = fwrite (header[0].buffer, sizeof(char), header[0].datasize, f); 17 18 if (Nbytes != header[0].datasize) { 19 status = FALSE; 20 } 21 10 int status = gfits_fwrite_header (f, header); 22 11 fclose (f); 23 12 … … 29 18 30 19 off_t Nbytes; 31 int status; 32 33 status = TRUE; 20 21 # ifdef OHANA_MEMORY 22 { // check memory before writing: 23 // memblock of supplied pointer 24 OhanaMemblock *myBlock = (OhanaMemblock *) header[0].buffer - 1; 25 myAssert (myBlock->startblock == OHANA_MEMMAGIC, "bad memory"); 26 myAssert (myBlock->endblock == OHANA_MEMMAGIC, "bad memory"); 27 myAssert (myBlock->size >= header[0].datasize, "overflow"); 28 } 29 # endif 34 30 35 31 Nbytes = fwrite (header[0].buffer, sizeof(char), header[0].datasize, f); 36 37 if (Nbytes != header[0].datasize) {38 status = FALSE;32 if (Nbytes != header[0].datasize) { 33 perror ("fwrite: "); 34 return FALSE; 39 35 } 40 41 return (status); 36 return TRUE; 42 37 } 43 38 44 39 45 40 int gfits_fwrite_header (FILE *f, Header *header) { 46 47 int status; 48 status = gfits_save_header (f, header); 41 int status = gfits_save_header (f, header); 49 42 return (status); 50 43 } -
trunk/Ohana/src/libfits/include/gfitsio.h
r38441 r38553 99 99 100 100 typedef struct { 101 char ttype[ 16]; // TTYPE field of original table102 char ttype_cmt[ 80]; // comment associated with TTYPE103 char tunit[ 16]; // TUNIT field of original table104 char tunit_cmt[ 80]; // comment associated with TUNIT105 char tformat[ 16]; // TFORM field of original table106 char tformat_cmt[ 80];// comment associated with TFORM107 char zctype[ 80]; // compression type for this field101 char ttype[256]; // TTYPE field of original table 102 char ttype_cmt[256]; // comment associated with TTYPE 103 char tunit[256]; // TUNIT field of original table 104 char tunit_cmt[256]; // comment associated with TUNIT 105 char tformat[256]; // TFORM field of original table 106 char tformat_cmt[256]; // comment associated with TFORM 107 char zctype[256]; // compression type for this field 108 108 VarLengthColumn zdef; // description of the output variable length column 109 109 110 char datatype[ 80]; // named data type associated with ttype (eg, 18J -> int, 18D -> double)110 char datatype[256]; // named data type associated with ttype (eg, 18J -> int, 18D -> double) 111 111 int Nvalues; // number of values per row (eg 18J -> 18 int values) 112 112 int pixsize; // number of bytes per value of this row (eg, 18J -> 4 bytes) -
trunk/Ohana/src/libfits/matrix/F_write_M.c
r33648 r38553 35 35 else 36 36 nbytes = FT_RECORD_SIZE * ((off_t) (matrix[0].datasize / FT_RECORD_SIZE)); 37 38 // fprintf (stderr, "write matrix: %d bytes (%d datasize)\n", (int) nbytes, (int) matrix[0].datasize); 39 if (nbytes == 0) return TRUE; 37 40 38 41 # define DOSWAP(A,B) { char tmp = A; A = B; B = tmp; } -
trunk/Ohana/src/libfits/table/F_compress_T.c
r38471 r38553 57 57 char *raw = NULL; 58 58 char *zdata = NULL; 59 TableField *fields = NULL; 59 60 60 61 Header *srcheader = srctable->header; … … 100 101 gettimeofday (&startTimer, (void *) NULL); 101 102 102 TableField *fields = NULL;103 103 ALLOCATE_ZERO (fields, TableField, Nfields); 104 104 for (i = 0; i < Nfields; i++) { … … 351 351 gfits_dump_cmp_table (tgttable, "cmp"); 352 352 353 free (raw); 354 free (zdata); 353 FREE (raw); 354 FREE (zdata); 355 FREE (fields); 355 356 return (TRUE); 356 357 … … 358 359 FREE (raw); 359 360 FREE (zdata); 361 FREE (fields); 360 362 return FALSE; 361 363 } -
trunk/Ohana/src/libfits/table/F_create_TH.c
r28241 r38553 11 11 12 12 int i; 13 char axis[1 0];13 char axis[128]; 14 14 15 15 header[0].datasize = NBYTES; 16 16 17 myAssert (!header->buffer, "failed to init header or free buffer?"); 17 18 ALLOCATE (header[0].buffer, char, NBYTES); 18 19 … … 26 27 27 28 for (i = 0; i < header[0].Naxes; i++) { 28 s printf (axis, "NAXIS%d", i + 1);29 snprintf (axis, 64, "NAXIS%d", i + 1); 29 30 gfits_modify (header, axis, OFF_T_FMT, 1, header[0].Naxis[i]); 30 31 } -
trunk/Ohana/src/libfits/table/F_define_column.c
r38441 r38553 11 11 off_t Naxis1; 12 12 int Nfields, Nbytes, Nval; 13 char type[ 16], field[16];13 char type[64], field[64]; 14 14 15 15 if (!gfits_bintable_format (format, type, &Nval, &Nbytes)) return (FALSE); … … 21 21 Naxis1 += Nbytes*Nval; 22 22 23 s printf (field, "TTYPE%d", Nfields);23 snprintf (field, 64, "TTYPE%d", Nfields); 24 24 gfits_modify (header, field, "%s", 1, label); 25 25 gfits_modify_alt (header, field, "%C", 1, comment); 26 s printf (field, "TUNIT%d", Nfields);26 snprintf (field, 64, "TUNIT%d", Nfields); 27 27 gfits_modify (header, field, "%s", 1, unit); 28 s printf (field, "TFORM%d", Nfields);28 snprintf (field, 64, "TFORM%d", Nfields); 29 29 gfits_modify (header, field, "%s", 1, format); 30 30 31 31 // add scaling parameters unless they amount to a noop 32 32 if ((bscale != 1.0) || (bzero != 0.0)) { 33 s printf (field, "TSCAL%d", Nfields);33 snprintf (field, 64, "TSCAL%d", Nfields); 34 34 gfits_modify (header, field, "%lf", 1, bscale); 35 s printf (field, "TZERO%d", Nfields);35 snprintf (field, 64, "TZERO%d", Nfields); 36 36 gfits_modify (header, field, "%lf", 1, bzero); 37 37 } … … 54 54 off_t Naxis1; 55 55 int Nfields, Nbytes, Nval; 56 char type[ 16], field[16];56 char type[64], field[64]; 57 57 58 58 if (!gfits_bintable_format (format, type, &Nval, &Nbytes)) return (FALSE); … … 64 64 Naxis1 += Nbytes*Nval; 65 65 66 s printf (field, "TTYPE%d", Nfields);66 snprintf (field, 64, "TTYPE%d", Nfields); 67 67 gfits_modify (header, field, "%s", 1, label); 68 68 if (comment) { … … 70 70 } 71 71 if (unit) { 72 s printf (field, "TUNIT%d", Nfields);72 snprintf (field, 64, "TUNIT%d", Nfields); 73 73 gfits_modify (header, field, "%s", 1, unit); 74 74 } 75 s printf (field, "TFORM%d", Nfields);75 snprintf (field, 64, "TFORM%d", Nfields); 76 76 gfits_modify (header, field, "%s", 1, format); 77 77 78 78 // add scaling parameters unless they amount to a noop 79 79 if ((bscale != 1.0) || (bzero != 0.0)) { 80 s printf (field, "TSCAL%d", Nfields);80 snprintf (field, 64, "TSCAL%d", Nfields); 81 81 gfits_modify (header, field, "%lf", 1, bscale); 82 s printf (field, "TZERO%d", Nfields);82 snprintf (field, 64, "TZERO%d", Nfields); 83 83 gfits_modify (header, field, "%lf", 1, bzero); 84 84 } … … 97 97 off_t Naxis1; 98 98 int Nstart, Nfields, Nbytes, Nval; 99 char type[ 16], field[16], cformat[16];99 char type[64], field[64], cformat[64]; 100 100 101 101 strcpy (cformat, format); … … 109 109 Naxis1 += Nbytes*Nval; 110 110 111 s printf (field, "TTYPE%d", Nfields);111 snprintf (field, 64, "TTYPE%d", Nfields); 112 112 gfits_modify (header, field, "%s", 1, label); 113 113 gfits_modify_alt (header, field, "%C", 1, comment); 114 s printf (field, "TUNIT%d", Nfields);114 snprintf (field, 64, "TUNIT%d", Nfields); 115 115 gfits_modify (header, field, "%s", 1, unit); 116 s printf (field, "TFORM%d", Nfields);116 snprintf (field, 64, "TFORM%d", Nfields); 117 117 gfits_modify (header, field, "%s", 1, format); 118 118 119 s printf (field, "TBCOL%d", Nfields);119 snprintf (field, 64, "TBCOL%d", Nfields); 120 120 gfits_modify (header, field, "%d", 1, Nstart); 121 121 -
trunk/Ohana/src/libfits/table/F_get_T_column.c
r7054 r38553 9 9 { 10 10 11 char Tform[ 100], field[100], tmp[100];11 char Tform[256], field[256], tmp[256]; 12 12 int start, Nchar, i, N; 13 13 … … 22 22 /* should I count fields from 0 or from 1? */ 23 23 24 s printf (field, "TBCOL%d\0", X);24 snprintf (field, 256, "TBCOL%d\0", X); 25 25 gfits_scan (&table[0].header, field, "%d", &start, 1); 26 26 start --; 27 s printf (field, "TFORM%d\0", X);27 snprintf (field, 256, "TFORM%d\0", X); 28 28 gfits_scan (&table[0].header, field, "%s", Tform, 1); 29 29 Nchar = atof (&Tform[1]); -
trunk/Ohana/src/libfits/table/F_get_T_value.c
r7054 r38553 10 10 { 11 11 12 char Tform[ 100], field[100];12 char Tform[256], field[256]; 13 13 int start, Nchar, byte; 14 14 char tmp[1000]; … … 16 16 /* no error checking, all sorts of problems! */ 17 17 18 s printf (field, "TBCOL%d\0", X);18 snprintf (field, 256, "TBCOL%d\0", X); 19 19 gfits_scan (&table[0].header, field, "%d", &start, 1); 20 20 start --; 21 21 22 s printf (field, "TFORM%d\0", X);22 snprintf (field, 256, "TFORM%d\0", X); 23 23 gfits_scan (&table[0].header, field, "%s", Tform, 1); 24 24 Nchar = atof (&Tform[1]); 25 myAssert (Nchar < 999, "overflow"); 25 26 26 27 byte = Y*table[0].Naxis[0] + start; -
trunk/Ohana/src/libfits/table/F_get_column.c
r38441 r38553 25 25 off_t Nx, Ny; 26 26 int i, N, Nfields, Nval, Nbytes, Nstart, Nv, Nb; 27 char tlabel[ 80], field[80], format[80], tmpline[16];27 char tlabel[256], field[256], format[256], tmpline[64]; 28 28 char *Pin, *Pout, *array; 29 29 double Bscale, Bzero; … … 36 36 if (!gfits_scan (header, "TFIELDS", "%d", 1, &Nfields)) return (NULL); 37 37 for (i = 1; strcasecmp (label, tlabel) && (i < Nfields + 1); i++) { 38 s printf (field, "TTYPE%d", i);38 snprintf (field, 256, "TTYPE%d", i); 39 39 gfits_scan (header, field, "%s", 1, tlabel); 40 40 } … … 46 46 47 47 /* interpret format */ 48 s printf (field, "TSCAL%d", N);48 snprintf (field, 256, "TSCAL%d", N); 49 49 gfits_scan (header, field, "%lf", 1, &Bscale); 50 s printf (field, "TZERO%d", N);50 snprintf (field, 256, "TZERO%d", N); 51 51 gfits_scan (header, field, "%lf", 1, &Bzero); 52 s printf (field, "TFORM%d", N);52 snprintf (field, 256, "TFORM%d", N); 53 53 gfits_scan (header, field, "%s", 1, format); 54 54 … … 62 62 Nstart = 0; 63 63 for (i = 1; i < N; i++) { 64 s printf (field, "TFORM%d", i);64 snprintf (field, 256, "TFORM%d", i); 65 65 gfits_scan (header, field, "%s", 1, format); 66 66 gfits_bintable_format (format, tmpline, &Nv, &Nb); … … 145 145 146 146 int Nbytes; 147 char field[ 80], format[80];147 char field[256], format[256]; 148 148 149 149 assert (N > 0); 150 150 151 s printf (field, "TFORM%d", N);151 snprintf (field, 256, "TFORM%d", N); 152 152 if (!gfits_scan (header, field, "%s", 1, format)) return FALSE; 153 153 if (!gfits_bintable_format (format, type, Nval, &Nbytes)) return (FALSE); … … 159 159 160 160 int i, N, Nfields; 161 char tlabel[ 80], field[80];161 char tlabel[256], field[256]; 162 162 163 163 if (label == (char *) NULL) return (FALSE); … … 168 168 gfits_scan (header, "TFIELDS", "%d", 1, &Nfields); 169 169 for (i = 1; strcasecmp (label, tlabel) && (i < Nfields + 1); i++) { 170 s printf (field, "TTYPE%d", i);170 snprintf (field, 256, "TTYPE%d", i); 171 171 gfits_scan (header, field, "%s", 1, tlabel); 172 172 } … … 181 181 int gfits_get_bintable_column_raw (Header *header, FTable *table, char *label, void **data, char nativeOrder) { 182 182 183 char type[ 16];183 char type[64]; 184 184 off_t Nrow; 185 185 int Ncol; … … 195 195 int gfits_get_bintable_column (Header *header, FTable *table, char *label, void **data) { 196 196 197 char type[ 16];197 char type[64]; 198 198 off_t Nrow; 199 199 int Ncol; … … 229 229 230 230 int i, N, Nfields, Nval, Nbytes; 231 char tlabel[ 80], field[80], format[80];231 char tlabel[256], field[256], format[256]; 232 232 233 233 if (label == (char *) NULL) return (FALSE); … … 238 238 gfits_scan (header, "TFIELDS", "%d", 1, &Nfields); 239 239 for (i = 1; strcasecmp (label, tlabel) && (i < Nfields + 1); i++) { 240 s printf (field, "TTYPE%d", i);240 snprintf (field, 256, "TTYPE%d", i); 241 241 gfits_scan (header, field, "%s", 1, tlabel); 242 242 } … … 245 245 246 246 /* interpret format */ 247 s printf (field, "TFORM%d", N);247 snprintf (field, 256, "TFORM%d", N); 248 248 gfits_scan (header, field, "%s", 1, format); 249 249 … … 257 257 off_t Nx, Ny; 258 258 int i, N, Nfields, Nval, Nbytes, Nstart, Nv, Nb; 259 char tlabel[ 80], field[80], format[80], cformat[80], type[16], tmp[16];259 char tlabel[256], field[256], format[256], cformat[256], type[64], tmp[64]; 260 260 char *array, *Pin, *Pout, *line; 261 261 … … 268 268 gfits_scan (header, "TFIELDS", "%d", 1, &Nfields); 269 269 for (i = 1; strcasecmp (label, tlabel) && (i < Nfields + 1); i++) { 270 s printf (field, "TTYPE%d", i);270 snprintf (field, 256, "TTYPE%d", i); 271 271 gfits_scan (header, field, "%s", 1, tlabel); 272 272 } … … 275 275 276 276 /* interpret format */ 277 s printf (field, "TFORM%d", N);277 snprintf (field, 256, "TFORM%d", N); 278 278 gfits_scan (header, field, "%s", 1, format); 279 279 … … 288 288 Nstart = 0; 289 289 for (i = 1; i < N; i++) { 290 s printf (field, "TFORM%d", i);290 snprintf (field, 256, "TFORM%d", i); 291 291 gfits_scan (header, field, "%s", 1, format); 292 292 gfits_table_format (format, tmp, &Nv, &Nb); -
trunk/Ohana/src/libfits/table/F_set_column.c
r38441 r38553 30 30 int i, N, Nfields; 31 31 int Nval, Nbytes, Nstart, Nv, Nb; 32 char tlabel[ 80], field[80], format[80], type[16], tmpline[16];32 char tlabel[256], field[256], format[256], type[64], tmpline[64]; 33 33 char *Pin, *Pout, *array; 34 34 double Bscale, Bzero; … … 41 41 gfits_scan (header, "TFIELDS", "%d", 1, &Nfields); 42 42 for (i = 1; strcasecmp (label, tlabel) && (i < Nfields + 1); i++) { 43 s printf (field, "TTYPE%d", i);43 snprintf (field, 256, "TTYPE%d", i); 44 44 gfits_scan (header, field, "%s", 1, tlabel); 45 45 } … … 48 48 49 49 /* interpret format */ 50 s printf (field, "TSCAL%d", N);50 snprintf (field, 256, "TSCAL%d", N); 51 51 if (!gfits_scan (header, field, "%lf", 1, &Bscale)) { 52 52 Bscale = 1.0; 53 53 } 54 s printf (field, "TZERO%d", N);54 snprintf (field, 256, "TZERO%d", N); 55 55 if (!gfits_scan (header, field, "%lf", 1, &Bzero)) { 56 56 Bzero = 0.0; 57 57 } 58 s printf (field, "TFORM%d", N);58 snprintf (field, 256, "TFORM%d", N); 59 59 gfits_scan (header, field, "%s", 1, format); 60 60 … … 75 75 Nstart = 0; 76 76 for (i = 1; i < N; i++) { 77 s printf (field, "TFORM%d", i);77 snprintf (field, 256, "TFORM%d", i); 78 78 gfits_scan (header, field, "%s", 1, format); 79 79 gfits_bintable_format (format, tmpline, &Nv, &Nb); … … 190 190 int i, N, Nfields; 191 191 int Nval, NbytesOut, Nstart, Nv, Nb; 192 char tlabel[ 80], field[80], format[80], outtype[16], tmpline[16];192 char tlabel[256], field[256], format[256], outtype[64], tmpline[64]; 193 193 char *Pin, *Pout, *array; 194 194 double Bscale, Bzero; … … 201 201 gfits_scan (header, "TFIELDS", "%d", 1, &Nfields); 202 202 for (i = 1; strcasecmp (label, tlabel) && (i < Nfields + 1); i++) { 203 s printf (field, "TTYPE%d", i);203 snprintf (field, 256, "TTYPE%d", i); 204 204 gfits_scan (header, field, "%s", 1, tlabel); 205 205 } … … 208 208 209 209 /* interpret format */ 210 s printf (field, "TSCAL%d", N);210 snprintf (field, 256, "TSCAL%d", N); 211 211 if (!gfits_scan (header, field, "%lf", 1, &Bscale)) { 212 212 Bscale = 1.0; 213 213 } 214 s printf (field, "TZERO%d", N);214 snprintf (field, 256, "TZERO%d", N); 215 215 if (!gfits_scan (header, field, "%lf", 1, &Bzero)) { 216 216 Bzero = 0.0; 217 217 } 218 s printf (field, "TFORM%d", N);218 snprintf (field, 256, "TFORM%d", N); 219 219 gfits_scan (header, field, "%s", 1, format); 220 220 … … 233 233 Nstart = 0; 234 234 for (i = 1; i < N; i++) { 235 s printf (field, "TFORM%d", i);235 snprintf (field, 256, "TFORM%d", i); 236 236 gfits_scan (header, field, "%s", 1, format); 237 237 gfits_bintable_format (format, tmpline, &Nv, &Nb); … … 780 780 off_t Nx, Ny; 781 781 int i, N, Nfields, Nval, Nbytes, Nstart, Nv, Nb; 782 char tlabel[ 80], field[80], format[80], cformat[80], type[16], tmp[16];782 char tlabel[256], field[256], format[256], cformat[256], type[64], tmp[64]; 783 783 char *array, *Pin, *Pout, *line; 784 784 … … 790 790 gfits_scan (header, "TFIELDS", "%d", 1, &Nfields); 791 791 for (i = 1; strcmp (label, tlabel) && (i < Nfields + 1); i++) { 792 s printf (field, "TTYPE%d", i);792 snprintf (field, 256, "TTYPE%d", i); 793 793 gfits_scan (header, field, "%s", 1, tlabel); 794 794 } … … 797 797 798 798 /* interpret format */ 799 s printf (field, "TFORM%d", N);799 snprintf (field, 256, "TFORM%d", N); 800 800 gfits_scan (header, field, "%s", 1, format); 801 801 … … 815 815 Nstart = 0; 816 816 for (i = 1; i < N; i++) { 817 s printf (field, "TFORM%d", i);817 snprintf (field, 256, "TFORM%d", i); 818 818 gfits_scan (header, field, "%s", 1, format); 819 819 gfits_table_format (format, tmp, &Nv, &Nb); -
trunk/Ohana/src/libfits/table/F_table_column.c
r7054 r38553 6 6 /* we expect one more field: the pointer to the array we read in */ 7 7 8 char string[ 80], this_field[80], form[80], temp[80];8 char string[256], this_field[256], form[256], temp[256]; 9 9 int i, j, N, start, end, width, M; 10 10 va_list argp; … … 18 18 /* find the correct field */ 19 19 for (i = 0; i < table[0].Nfields; i++) { 20 s printf (string, "TTYPE%d\0", i+1);20 snprintf (string, 256, "TTYPE%d\0", i+1); 21 21 gfits_scan (&table[0].header, string, "%s", 1, this_field); 22 22 if (!strcmp (field, this_field)) { … … 32 32 N = i + 1; 33 33 34 s printf (string, "TBCOL%d\0", N);34 snprintf (string, 256, "TBCOL%d\0", N); 35 35 gfits_scan (&table[0].header, string, "%d", 1, &start); 36 s printf (string, "TFORM%d\0", N);36 snprintf (string, 256, "TFORM%d\0", N); 37 37 gfits_scan (&table[0].header, string, "%s", 1, form); 38 38 /* we could use some error checking from the FITS table form, but … … 42 42 end = table[0].Naxis[0]; 43 43 } else { 44 s printf (string, "TBCOL%d\0", N+1);44 snprintf (string, 256, "TBCOL%d\0", N+1); 45 45 gfits_scan (&table[0].header, string, "%d", 1, &end); 46 46 } -
trunk/Ohana/src/libfits/table/F_table_format.c
r38441 r38553 113 113 if (!*Nbytes) { return (FALSE); } 114 114 115 // XXXX : check usage: 116 myAbort ("need to check length"); 115 117 sprintf (format, "%%-%s%c", Size, Type); 116 118 … … 191 193 off_t Nx, off; 192 194 int i, Nchar, Nval, Nbytes, Nfields; 193 char *line, format[64], field[ 16], type[16];195 char *line, format[64], field[64], type[64]; 194 196 va_list argp; 195 197 … … 204 206 for (i = 1; i <= Nfields; i++) { 205 207 206 s printf (field, "TFORM%d", i);208 snprintf (field, 64, "TFORM%d", i); 207 209 gfits_scan (table[0].header, field, "%s", 1, format); /* get field format */ 208 210 gfits_table_format (format, type, &Nval, &Nbytes); /* convert to c-style */ … … 232 234 int i, j, n, Nfields; 233 235 int Nchar, Nval, Nbytes, status; 234 char format[64], field[ 16], type[16];236 char format[64], field[64], type[64]; 235 237 double tzero, tscale; 236 238 char *tmpChar; … … 246 248 247 249 for (i = 1; i <= Nfields; i++) { 248 s printf (field, "TFORM%d", i);250 snprintf (field, 64, "TFORM%d", i); 249 251 gfits_scan (ftable[0].header, field, "%s", 1, format); /* get field format */ 250 252 gfits_bintable_format (format, type, &Nval, &Nbytes); /* convert to c-style */ 251 253 Nchar = Nval * Nbytes; 252 254 253 s printf (field, "TZERO%d", i);255 snprintf (field, 64, "TZERO%d", i); 254 256 status = gfits_scan (ftable[0].header, field, "%lf", 1, &tzero); /* get field format */ 255 257 if (!status) { … … 258 260 } 259 261 260 s printf (field, "TSCAL%d", i);262 snprintf (field, 64, "TSCAL%d", i); 261 263 status = gfits_scan (ftable[0].header, field, "%lf", 1, &tscale); /* get field format */ 262 264 if (!status) { … … 325 327 int i, j, n, Nfields; 326 328 int Nchar, Nval, Nbytes, status; 327 char format[64], field[ 16], type[16];329 char format[64], field[64], type[64]; 328 330 double tzero, tscale; 329 331 char *tmpChar; … … 339 341 340 342 for (i = 1; i <= Nfields; i++) { 341 s printf (field, "TFORM%d", i);343 snprintf (field, 64, "TFORM%d", i); 342 344 gfits_scan (ftable[0].header, field, "%s", 1, format); /* get field format */ 343 345 gfits_bintable_format (format, type, &Nval, &Nbytes); /* convert to c-style */ 344 346 Nchar = Nval * Nbytes; 345 347 346 s printf (field, "TZERO%d", i);348 snprintf (field, 64, "TZERO%d", i); 347 349 status = gfits_scan (ftable[0].header, field, "%lf", 1, &tzero); /* get field format */ 348 350 if (!status) { … … 351 353 } 352 354 353 s printf (field, "TSCAL%d", i);355 snprintf (field, 64, "TSCAL%d", i); 354 356 status = gfits_scan (ftable[0].header, field, "%lf", 1, &tscale); /* get field format */ 355 357 if (!status) { -
trunk/Ohana/src/libfits/table/F_table_varlength.c
r38441 r38553 8 8 int Nv, Nb; 9 9 char *p1, *p2, *p3; 10 char field[ 81];11 char format[ 81];12 char tmpline[ 81];10 char field[256]; 11 char format[256]; 12 char tmpline[256]; 13 13 14 14 // grab the value of TFORMn for this column … … 61 61 def->offset = 0; 62 62 for (i = 1; i < column; i++) { 63 s printf (field, "TFORM%d", i);63 snprintf (field, 256, "TFORM%d", i); 64 64 gfits_scan (ftable->header, field, "%s", 1, format); 65 65 gfits_bintable_format (format, tmpline, &Nv, &Nb); -
trunk/Ohana/src/libfits/table/F_uncompress_T.c
r38471 r38553 78 78 int i; 79 79 80 char keyword[ 81];80 char keyword[256]; 81 81 82 82 char *raw = NULL; 83 83 char *zdata = NULL; 84 TableField *fields = NULL; 84 85 85 86 Header *srcheader = srctable->header; … … 111 112 int offset = 0; 112 113 113 TableField *fields = NULL;114 114 ALLOCATE (fields, TableField, Nfields); 115 115 for (i = 0; i < Nfields; i++) { … … 336 336 free (raw); 337 337 free (zdata); 338 free (fields); 338 339 return (TRUE); 339 340 … … 341 342 FREE (raw); 342 343 FREE (zdata); 344 FREE (fields); 343 345 return FALSE; 344 346 } -
trunk/Ohana/src/libfits/table/F_write_T.c
r38441 r38553 5 5 int gfits_write_table (char *filename, FTable *table) { 6 6 7 FILE *f; 8 int status; 9 10 status = TRUE; 11 12 f = fopen (filename, "a+"); 7 FILE *f = fopen (filename, "a+"); 13 8 if (f == (FILE *) NULL) return (FALSE); 14 9 15 status = fseeko (f, 0LL, SEEK_END); /* write table to end of file! */10 int status = fseeko (f, 0LL, SEEK_END); /* write table to end of file! */ 16 11 if (status) { perror ("fseeko: "); return (FALSE); } 17 12 status = gfits_fwrite_table (f, table); … … 25 20 26 21 off_t Nbytes; 27 22 23 # ifdef OHANA_MEMORY 24 { // check memory before writing: 25 // memblock of supplied pointer 26 OhanaMemblock *myBlock = (OhanaMemblock *) table[0].buffer - 1; 27 myAssert (myBlock->startblock == OHANA_MEMMAGIC, "bad memory"); 28 myAssert (myBlock->endblock == OHANA_MEMMAGIC, "bad memory"); 29 myAssert (myBlock->size >= table[0].datasize, "overflow"); 30 } 31 # endif 32 28 33 Nbytes = fwrite (table[0].buffer, sizeof(char), table[0].datasize, f); 29 if (Nbytes != table[0].datasize) { perror ("fwrite: "); return (FALSE); } 34 if (Nbytes != table[0].datasize) { 35 perror ("fwrite: "); 36 return (FALSE); 37 } 30 38 return (TRUE); 31 39 } -
trunk/Ohana/src/libfits/table/F_write_TH.c
r38441 r38553 5 5 int gfits_write_Theader (char *filename, Header *header) { 6 6 7 FILE *f ;8 i nt status;7 FILE *f = fopen (filename, "a+"); 8 if (!f) return (FALSE); 9 9 10 status = TRUE; 11 12 f = fopen (filename, "a+"); 13 if (f == (FILE *) NULL) return (FALSE); 14 15 status = fseeko (f, 0LL, SEEK_END); /* write header to end of file! */ 10 int status = fseeko (f, 0LL, SEEK_END); /* write header to end of file! */ 16 11 if (status) { perror ("fseeko: "); return (FALSE); } 17 12 status = gfits_fwrite_Theader (f, header); … … 26 21 off_t Nbytes; 27 22 23 # ifdef OHANA_MEMORY 24 { 25 // memblock of supplied pointer 26 OhanaMemblock *myBlock = (OhanaMemblock *) header[0].buffer - 1; 27 myAssert (myBlock->startblock == OHANA_MEMMAGIC, "bad memory"); 28 myAssert (myBlock->endblock == OHANA_MEMMAGIC, "bad memory"); 29 myAssert (myBlock->size >= header[0].datasize, "overflow"); 30 } 31 # endif 32 28 33 Nbytes = fwrite (header[0].buffer, sizeof(char), header[0].datasize, f); 29 if (Nbytes != header[0].datasize) { perror ("fwrite: "); return (FALSE); } 34 if (Nbytes != header[0].datasize) { 35 perror ("fwrite: "); 36 return (FALSE); 37 } 30 38 31 39 return (TRUE); -
trunk/Ohana/src/libfits/test
- Property svn:ignore
-
old new 2 2 ricetest 3 3 tablecomp 4 tcomptiming 4 5 test.cmp.fits 5 6 test.fpk.fits
-
- Property svn:ignore
-
trunk/Ohana/src/libfits/test/imagecomp.c
r38427 r38553 11 11 int bitpix[] = {8, 16, 32, -32, -64, 0}; 12 12 13 // char *cmptype[] = {"GZIP_1", NULL};14 // int bitpix[] = {16, 0};13 // char *cmptype[] = {"NONE", NULL}; 14 // int bitpix[] = {16, 0}; 15 15 16 16 static int NX = 10; … … 31 31 test_compress_fulltile (bitpix[j], cmptype[i]); 32 32 test_compress_fullrange (bitpix[j], cmptype[i]); 33 ok (ohana_memcheck (TRUE), "no memory corruption"); 33 34 } 34 35 } … … 42 43 test_compress_fulltile (bitpix[j], cmptype[i]); 43 44 test_compress_fullrange (bitpix[j], cmptype[i]); 45 ok (ohana_memcheck (TRUE), "no memory corruption"); 44 46 } 45 47 } … … 53 55 test_compress_fulltile (bitpix[j], cmptype[i]); 54 56 test_compress_fullrange (bitpix[j], cmptype[i]); 57 ok (ohana_memcheck (TRUE), "no memory corruption"); 55 58 } 56 59 } -
trunk/Ohana/src/libfits/test/tablecomp.c
r38418 r38553 27 27 test_compress_fullrange (cmptype[i]); 28 28 test_compress_empty (cmptype[i]); 29 ok (ohana_memcheck _func(TRUE), "no memory corruption");29 ok (ohana_memcheck (TRUE), "no memory corruption"); 30 30 } 31 31 -
trunk/Ohana/src/libfits/test/tcomptiming.c
r38429 r38553 29 29 gfits_uncompress_timing(); 30 30 } 31 ok (ohana_memcheck _func(TRUE), "no memory corruption");31 ok (ohana_memcheck (TRUE), "no memory corruption"); 32 32 33 33 return exit_status();
Note:
See TracChangeset
for help on using the changeset viewer.
