#include "wcsconfig.h"
Go to the source code of this file.
Data Structures | |
struct | fitskeyid |
Keyword indexing. More... | |
struct | fitskey |
Keyword/value information. More... | |
Defines | |
#define | FITSHDR_KEYWORD 0x01 |
Flag bit indicating illegal keyword syntax. | |
#define | FITSHDR_KEYVALUE 0x02 |
Flag bit indicating illegal keyvalue syntax. | |
#define | FITSHDR_COMMENT 0x04 |
Flag bit indicating illegal keycomment syntax. | |
#define | FITSHDR_KEYREC 0x08 |
Flag bit indicating illegal keyrecord. | |
#define | FITSHDR_CARD 0x08 |
Deprecated. | |
#define | FITSHDR_TRAILER 0x10 |
Flag bit indicating keyrecord following a valid END keyrecord. | |
#define | KEYIDLEN (sizeof(struct fitskeyid)/sizeof(int)) |
#define | KEYLEN (sizeof(struct fitskey)/sizeof(int)) |
Typedefs | |
typedef int | int64 [3] |
64-bit signed integer data type. | |
Functions | |
int | fitshdr (const char header[], int nkeyrec, int nkeyids, struct fitskeyid keyids[], int *nreject, struct fitskey **keys) |
FITS header parser routine. | |
Variables | |
const char * | fitshdr_errmsg [] |
Status return messages. |
#define FITSHDR_KEYWORD 0x01 |
Bit mask for the status flag bit-vector returned by fitshdr() indicating illegal keyword syntax.
#define FITSHDR_KEYVALUE 0x02 |
Bit mask for the status flag bit-vector returned by fitshdr() indicating illegal keyvalue syntax.
#define FITSHDR_COMMENT 0x04 |
Bit mask for the status flag bit-vector returned by fitshdr() indicating illegal keycomment syntax.
#define FITSHDR_KEYREC 0x08 |
Bit mask for the status flag bit-vector returned by fitshdr() indicating an illegal keyrecord, e.g. an END keyrecord with trailing text.
#define FITSHDR_CARD 0x08 |
#define FITSHDR_TRAILER 0x10 |
Bit mask for the status flag bit-vector returned by fitshdr() indicating a keyrecord following a valid END keyrecord.
#define KEYIDLEN (sizeof(struct fitskeyid)/sizeof(int)) |
#define KEYLEN (sizeof(struct fitskey)/sizeof(int)) |
64-bit signed integer data type defined via preprocessor macro WCSLIB_INT64 which may be defined in wcsconfig.h. For example
#define WCSLIB_INT64 long long int
This is typedef'd in fitshdr.h as
See fitskey::type.
int fitshdr | ( | const char | header[], | |
int | nkeyrec, | |||
int | nkeyids, | |||
struct fitskeyid | keyids[], | |||
int * | nreject, | |||
struct fitskey ** | keys | |||
) |
fitshdr() parses a character array containing a FITS header, extracting all keywords and their values into an array of fitskey structs.
[in] | header | Character array containing the (entire) FITS header, for example, as might be obtained conveniently via the CFITSIO routine fits_hdr2str(). Each header "keyrecord" (formerly "card image") consists of exactly 80 7-bit ASCII printing characters in the range 0x20 to 0x7e (which excludes NUL, BS, TAB, LF, FF and CR) especially noting that the keyrecords are NOT null-terminated. |
[in] | nkeyrec | Number of keyrecords in header[]. |
[in] | nkeyids | Number of entries in keyids[]. |
[in,out] | keyids | While all keywords are extracted from the header, keyids[] provides a convienient way of indexing them. The fitskeyid struct contains three members; fitskeyid::name must be set by the user while fitskeyid::count and fitskeyid::name are returned by fitshdr(). All matched keywords will have their fitskey::keyno member negated. |
[out] | nreject | Number of header keyrecords rejected for syntax errors. |
[out] | keys | Pointer to an array of nkeyrec fitskey structs containing all keywords and keyvalues extracted from the header. Memory for the array is allocated by fitshdr() and this must be freed by the user by invoking free() on the array. |
ABCDEFGHJKLMNOPQRSTUVWXYZ0123456789-_
fitshdr() accepts any characters in columns 1-8 but flags keywords that do not conform to standard syntax.
=
'' occurring in columns 9 and 10. If these are absent then the keyword has no value and columns 9-80 may contain any ASCII text (but see note 2 for CONTINUE
keyrecords). This is copied to the comment member of the fitskey struct.
Sect. 5.2.1 also states that a quote character ('
) in a string value is to be represented by two successive quote characters and the parser removes the repeated quote.
END
not followed by 77 blanks is not considered to be a legitimate end keyrecord.
CONTINUE
,
=
',
CONTINUE
keyrecord. If any of these conditions is violated, the keyrecord is considered in isolation.
Syntax errors in keycomments in a continued string are treated more permissively than usual; the '/
' delimiter may be omitted provided that parsing of the string keyvalue is not compromised. However, the FITSHDR_COMMENT status bit will be set for the keyrecord (see fitskey::status).
As for normal strings, trailing blanks in a continued string are not significant.
In the OGIP convention "the '&
' character is used as the last non-blank character of the string to indicate that the string is (probably) continued on the following keyword". This additional syntax is not required by fitshdr(), but if '&
' does occur as the last non-blank character of a continued string keyvalue then it will be removed, along with any trailing blanks. However, blanks that occur before the '&
' will be preserved.
const char * fitshdr_errmsg[] |
Error messages to match the status value returned from each function.