next up previous contents
Next: 2. Using `idx' Sorting Up: CFHT FITS Handling Library Previous: Contents   Contents

1. Summary of All Functions

NOTE: In this table, hu is a type HeaderUnit that was returned from a previous call to fh_create() or fh_ehu(), fd is an open file descriptor (type int) returned by a previous call to open(), and idx is a double floating point sorting number used internally by the library. Finally, where-ever name and comment are found, these are ASCII character strings (type char*). They must contain only those characters allowed by the FITS standard.


Table 1: Functions to Open, Lock, Close, or create new FITS files
Return Function Parameters Description
HeaderUnit fh_create No parameters Allocate a table to store FITS cards.
HeaderUnit fh_copy_hu (HeaderUnit hu) Allocate a table to store FITS cards and copy an initial set from `hu'.
fh_result fh_destroy (HeaderUnit hu) Free memory associated with `hu'. Check return!
fh_result fh_read (HeaderUnit hu, int fd, double idx) Read header from an open file descriptor.
fh_result fh_reindex (HeaderUnit hu) Restore fh_registry.h indices to the cards in `hu'.
fh_result fh_file (HeaderUnit hu, const* filespec, fh_mode) Open and read header from a file or extension.
int fh_file_desc (HeaderUnit hu) Get the file descriptor used by fh_file
fh_result(??) fh_reserve (hu, int n) Reserve at least n cards slots for downstream use.
fh_result fh_validate (hu) Test if `hu' is complete and valid (fh_validate.c)
fh_result fh_count_cards (hu) Put library in special mode to count cards
fh_result fh_write (hu, fd) Write header, padding, and END to an open file.
fh_result fh_write_padding (hu, fd) Write padding to go after the IMAGE.
fh_result fh_write_padded_image (hu, fd, void* data, size, typesize) Write `size' image bytes of `data' plus padding.
fh_result fh_read_padded_image (hu, fd, void* data, size, typesize) Read `size' bytes into user allocated `data'.
fh_result fh_copy_padded_image (hu, fd_out, fd_in) Copy image and padding from another open file.
fh_result fh_rewrite (hu) Write the header back to the original file, if possible.


Table 2: Functions for Looking at Extensions and Image data
Return Function Parameters Description
int fh_extensions (hu) Reads NEXTEND to determine number of extensions.
int fh_image_bytes (hu) Reads BITPIX and NAXIS* to find (unpadded) image size.
int fh_image_blocks (hu) Converts fh_image_bytes to size in 2880-byte blocks.
int fh_header_blocks (hu) Returns size required for header in 2880-byte blocks.
HeaderUnit fh_ehu (hu, int number) Seek to extension by its offset in the file (caution!)
HeaderUnit fh_ehu_by_imageid (hu, int imageid) Seek to extension with matching IMAGEID keyword.
HeaderUnit fh_ehu_by_extname (hu, char* extname) Seek by EXTNAME (e.g. ``im07'' or ``chip03b'')


Table 3: Functions for Looking at Keywords
Return Function Parameters Description
fh_result fh_get_bool (hu, char* name, fh_bool* value) *value gets FH_TRUE or FH_FALSE
fh_result fh_get_int (hu, char* name, int* value) *value gets integer value of `name'
fh_result fh_get_flt (hu, char* name, double* value) *value gets double-float value of `name'
fh_result fh_get_str (hu, char* name, char* value, maxlen) *value gets string value of `name'
const char* fh_first (hu) Returns the first 80 character record (or NULL)
const char* fh_next (hu) Returns the next 80 character record (or NULL)
double fh_idx (hu) Return the index for the card last returned by fh_next .
fh_result fh_search (hu, char* name, double* idx) Returns FH_SUCCESS if found (and *idx if !NULL)
fh_result fh_show (hu) Display a list on stdout (for debugging).
double fh_idx_after (hu, char* name) Get `idx' for a new card after `name'
double fh_idx_before (hu, char* name) Get `idx' for new card before `name'


Table 4: Functions for Changing Keywords
Return Function Parameters Description
fh_result fh_remove (hu, char* name) Removes a card from the header unit in memory. It will disappear from the file on the next fh_rewrite()
fh_result fh_set_all_units (hu) Overrides default behavior of fh_set*() functions so they change extensions too.
void fh_set_com (hu, idx, char* name, char* comment) Creates new comment card containing up to 72 ASCII characters. ``name'' should be ``HISTORY'' or ``COMMENT''.
void fh_set_bool (hu, idx,name, fh_bool value, comment) Changes or adds the card `name' with new value of 'T' if value is non-zero, and sets comment field if comment is not empty.
void fh_set_int (hu, idx, name, int value, comment) Changes or adds keyword `name' with new integer value and comment fields.
void fh_set_flt (hu, idx, name, double value, double flt, double prec, comment) Changes or adds keyword `name' with new floating-point value.
void fh_set_str (hu, idx, name, char* value, comment) Changes or adds keyword `name' with new string value and comment fields.
void fh_set_val (hu, idx, name, char* value, comment) Changes or adds keyword `name' with new pre-formatted value and comment fields. (Use typed functions above instead.)
fh_result fh_merge (target_hu, source_hu) Merges all cards from one list into another. Final order depends on the sorting numbers in both lists.


Table 5: Redirecting Error Messages
Return Function Parameters Description
void fh_log_warning (fh_logger_t log_function) Set warning log handler
void fh_log_error (fh_logger_t log_function) Set error log handler
void fh_log_perror (fh_logger_t log_function) Set system error log handler (check errno)


next up previous contents
Next: 2. Using `idx' Sorting Up: CFHT FITS Handling Library Previous: Contents   Contents
Jim Thomas
2013-12-19