Changeset 23924 for trunk/extsrc/gpcsw/gpcsrc/fits/libfh/fh.h
- Timestamp:
- Apr 18, 2009, 11:11:15 AM (17 years ago)
- File:
-
- 1 edited
-
trunk/extsrc/gpcsw/gpcsrc/fits/libfh/fh.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/extsrc/gpcsw/gpcsrc/fits/libfh/fh.h
r23490 r23924 36 36 #define FH_COUNT_CARDS "@FH_COUNT_CARDS@" /* See also: fh_count_cards() */ 37 37 38 /* Size of buffer in fhTableCol structure for format string. */ 39 #define FH_TABLE_FORMAT_STR_LEN 20 40 38 41 typedef enum /* fh_result -- Result Code for most functions in this library: */ 39 42 { FH_SUCCESS = 0, … … 64 67 } fh_bool; /* Value for "logical" FITS cards */ 65 68 69 /* The possible field formats in an ASCII table extension. */ 70 typedef enum 71 { 72 FH_TABLE_FORMAT_CHAR = 'A', /* Designates a string field. */ 73 FH_TABLE_FORMAT_INT = 'I', /* Integer field. */ 74 FH_TABLE_FORMAT_FLOAT = 'F', /* Float field. */ 75 FH_TABLE_FORMAT_DOUBLE = 'D' /* Double field. */ 76 } fhTableFormat; 77 78 typedef struct 79 { 80 char * name; /* Short string identifying this column's data. */ 81 char * comment; /* Longer blurb about this column's data. */ 82 char * units; /* Units for column's data. */ 83 fhTableFormat format; /* Type of data held in this column. */ 84 int width; /* Width of this column's data, in characters. */ 85 int dec_places; /* For doubles, etc, the number of decimal places to write. */ 86 /* Everything below this line is generated by fh_table_init(). These 87 * do not need to be filled out by hand. */ 88 int first_char_pos; /* Position of first character in this column. Calculated on the fly. */ 89 char format_string[FH_TABLE_FORMAT_STR_LEN]; /* Format string for printf. */ 90 } fhTableCol; 91 92 /* Describes the layout of an ASCII table. */ 93 typedef struct 94 { 95 char * extname; /* Name of table extension. */ 96 int num_cols; /* Number of rows in table. */ 97 int num_rows; /* Number of columns in table. */ 98 fhTableCol * cols; /* Array of cols columns. */ 99 /* Everything below this line is generated by fh_table_init(). These 100 * do not need to be filled out by hand. */ 101 int widest_col; /* Width of widest column. */ 102 char * strbuf; /* Will point to buf of widest_col + 1 chars. */ 103 int row_width; /* Number of characters in a table tow. */ 104 int table_size; /* Total size of table data, in bytes. */ 105 } fhTable; 106 66 107 typedef void* HeaderUnit; /* Handle to a list of FITS cards allocated by fh_create. */ 67 108 … … 345 386 double fh_idx(HeaderUnit hu); /* idx of the last card returned by fh_next */ 346 387 fh_result fh_merge(HeaderUnit hu, const HeaderUnit source); /* source unchanged */ 388 389 /* --------------------------------------------------------- 390 * Reading and writing tables 391 * --------------------------------------------------------- 392 */ 393 394 fh_result 395 fh_table_init(fhTable * table); 396 /* Call once to initialise information about a given table. This will 397 * walk through all of the columns and fill out starting character 398 * positions and so forth, and will calculate the size of each row 399 * and the size of the table as a whole, and so forth. */ 400 401 fh_result 402 fh_table_populate_header(HeaderUnit hu, fhTable * table); 403 /* Sets up keywords for a table extension header, including all 404 * of the column information, etc. This will initialise the table 405 * structure if necessary. This does not include any fh_write... 406 * calls to write the header to the file. */ 407 408 fh_result 409 fh_reserve_padded_table(HeaderUnit hu, int fd); 410 /* Analogous to fh_reserve_padded_image() for tables. This reserves 411 * space for the table based on the information in the passed extension 412 * header at the current location in the file. The header must therefore 413 * be populated prior to calling this function (use 414 * fh_table_populate_header() to build a header from a table structure. 415 */ 416 417 fh_result 418 fh_map_table(HeaderUnit hu, void** data, int size); 419 fh_result 420 fh_munmap_table(HeaderUnit hu); 421 /* Analogous to fh_map_raw_image() and fh_munmap_image() for tables. 422 * These calls give the calling program access to a memory mapped pointer 423 * to the data in the FITS file. The data format is equivalent to what 424 * would be produced by fh_read_image() with typesize=FH_TYPESIZE_RAW. 425 * Whether or not the file can be modified through the memory-mapped 426 * pointer depends on whether fh_mode=FH_FILE_RDONLY or FH_FILE_RDWR 427 * in the call to fh_file() that opened the file. Be sure to use 428 * fh_munmap_table() when done. 429 * 430 * `size' must match the exact number bytes of data which should be in 431 * the file, according to its NAXIS and BITPIX values, excluding padding. 432 * 433 * %%% TODO: FH_FILE_RDWR is completely unimplemented! 434 * 435 * %%% TODO: File locking is not handled properly yet. For now, use 436 * FH_FILE_RDONLY_NOLOCK and FH_FILE_RDWR_NOLOCK, especially on MEF 437 * files where the locks are left in place until the file is closed 438 * otherwise! 439 */ 440 441 fh_result 442 fh_table_read_value(fhTable * table, void * data, 443 int row, int col, void * value); 444 /* Reads a single value from an existing table at (row, column). 445 * The table field is interpreted based on the format of that 446 * column in the table structure, and is passed back via the 447 * 'value' pointer. It is the caller's responsibility to ensure 448 * that 'value' points to a location with sufficient space for 449 * the data in the field, and that any casting to & from a void 450 * pointer is done correctly. 451 */ 452 453 fh_result 454 fh_table_write_value(fhTable * table, void * data, 455 int row, int col, void * value); 456 /* Similar to read_value() above, this function overwrites a field 457 * in a table at the given location. The caller is repsonsible 458 * for casting the location of the stored data to a void pointer. 459 */ 460 461 347 462 #endif /* _INCLUDED_fh */
Note:
See TracChangeset
for help on using the changeset viewer.
