1
/* T E M P L A T E P A R S E R H E A D E R F I L E
2
=====================================================
4
by Jerzy.Borkowski@obs.unige.ch
6
Integral Science Data Center
11
14-Oct-98: initial release
12
16-Oct-98: reference to fitsio.h removed, also removed strings after #endif
13
directives to make gcc -Wall not to complain
14
20-Oct-98: added declarations NGP_XTENSION_SIMPLE and NGP_XTENSION_FIRST
15
24-Oct-98: prototype of ngp_read_line() function updated.
16
22-Jan-99: prototype for ngp_set_extver() function added.
17
20-Jun-2002 Wm Pence, added support for the HIERARCH keyword convention
18
(changed NGP_MAX_NAME from (20) to FLEN_KEYWORD)
21
#ifndef GRPARSER_H_INCLUDED
22
#define GRPARSER_H_INCLUDED
28
/* error codes - now defined in fitsio.h */
30
/* common constants definitions */
32
#define NGP_ALLOCCHUNK (1000)
33
#define NGP_MAX_INCLUDE (10) /* include file nesting limit */
34
#define NGP_MAX_COMMENT (80) /* max size for comment */
35
#define NGP_MAX_NAME FLEN_KEYWORD /* max size for KEYWORD (FITS limits it to 8 chars) */
36
/* except HIERARCH can have longer effective keyword names */
37
#define NGP_MAX_STRING (80) /* max size for various strings */
38
#define NGP_MAX_ARRAY_DIM (999) /* max. number of dimensions in array */
39
#define NGP_MAX_FNAME (1000) /* max size of combined path+fname */
40
#define NGP_MAX_ENVFILES (10000) /* max size of CFITSIO_INCLUDE_FILES env. variable */
42
#define NGP_TOKEN_UNKNOWN (-1) /* token type unknown */
43
#define NGP_TOKEN_INCLUDE (0) /* \INCLUDE token */
44
#define NGP_TOKEN_GROUP (1) /* \GROUP token */
45
#define NGP_TOKEN_END (2) /* \END token */
46
#define NGP_TOKEN_XTENSION (3) /* XTENSION token */
47
#define NGP_TOKEN_SIMPLE (4) /* SIMPLE token */
48
#define NGP_TOKEN_EOF (5) /* End Of File pseudo token */
50
#define NGP_TTYPE_UNKNOWN (0) /* undef (yet) token type - invalid to print/write to disk */
51
#define NGP_TTYPE_BOOL (1) /* boolean, it is 'T' or 'F' */
52
#define NGP_TTYPE_STRING (2) /* something withing "" or starting with letter */
53
#define NGP_TTYPE_INT (3) /* starting with digit and not with '.' */
54
#define NGP_TTYPE_REAL (4) /* digits + '.' */
55
#define NGP_TTYPE_COMPLEX (5) /* 2 reals, separated with ',' */
56
#define NGP_TTYPE_NULL (6) /* NULL token, format is : NAME = / comment */
57
#define NGP_TTYPE_RAW (7) /* HISTORY/COMMENT/8SPACES + comment string without / */
59
#define NGP_FOUND_EQUAL_SIGN (1) /* line contains '=' after keyword name */
61
#define NGP_FORMAT_OK (0) /* line format OK */
62
#define NGP_FORMAT_ERROR (1) /* line format error */
64
#define NGP_NODE_INVALID (0) /* default node type - invalid (to catch errors) */
65
#define NGP_NODE_IMAGE (1) /* IMAGE type */
66
#define NGP_NODE_ATABLE (2) /* ASCII table type */
67
#define NGP_NODE_BTABLE (3) /* BINARY table type */
69
#define NGP_NON_SYSTEM_ONLY (0) /* save all keywords except NAXIS,BITPIX,etc.. */
70
#define NGP_REALLY_ALL (1) /* save really all keywords */
72
#define NGP_XTENSION_SIMPLE (1) /* HDU defined with SIMPLE T */
73
#define NGP_XTENSION_FIRST (2) /* this is first extension in template */
75
#define NGP_LINE_REREAD (1) /* reread line */
77
#define NGP_BITPIX_INVALID (-12345) /* default BITPIX (to catch errors) */
79
/* common macro definitions */
81
#ifdef NGP_PARSER_DEBUG_MALLOC
83
#define ngp_alloc(x) dal_malloc(x)
84
#define ngp_free(x) dal_free(x)
85
#define ngp_realloc(x,y) dal_realloc(x,y)
89
#define ngp_alloc(x) malloc(x)
90
#define ngp_free(x) free(x)
91
#define ngp_realloc(x,y) realloc(x,y)
95
/* type definitions */
97
typedef struct NGP_RAW_LINE_STRUCT
108
typedef union NGP_TOKVAL_UNION
109
{ char *s; /* space allocated separately, be careful !!! */
113
struct NGP_COMPLEX_STRUCT
116
} c; /* complex value */
120
typedef struct NGP_TOKEN_STRUCT
122
char name[NGP_MAX_NAME];
124
char comment[NGP_MAX_COMMENT];
128
typedef struct NGP_HDU_STRUCT
134
typedef struct NGP_TKDEF_STRUCT
140
typedef struct NGP_EXTVER_TAB_STRUCT
146
/* globally visible variables declarations */
148
extern NGP_RAW_LINE ngp_curline;
149
extern NGP_RAW_LINE ngp_prevline;
151
extern int ngp_extver_tab_size;
152
extern NGP_EXTVER_TAB *ngp_extver_tab;
155
/* globally visible functions declarations */
157
int ngp_get_extver(char *extname, int *version);
158
int ngp_set_extver(char *extname, int version);
159
int ngp_delete_extver_tab(void);
160
int ngp_strcasecmp(char *p1, char *p2);
161
int ngp_strcasencmp(char *p1, char *p2, int n);
162
int ngp_line_from_file(FILE *fp, char **p);
163
int ngp_free_line(void);
164
int ngp_free_prevline(void);
165
int ngp_read_line_buffered(FILE *fp);
166
int ngp_unread_line(void);
167
int ngp_extract_tokens(NGP_RAW_LINE *cl);
168
int ngp_include_file(char *fname);
169
int ngp_read_line(int ignore_blank_lines);
170
int ngp_keyword_is_write(NGP_TOKEN *ngp_tok);
171
int ngp_keyword_all_write(NGP_HDU *ngph, fitsfile *ffp, int mode);
172
int ngp_hdu_init(NGP_HDU *ngph);
173
int ngp_hdu_clear(NGP_HDU *ngph);
174
int ngp_hdu_insert_token(NGP_HDU *ngph, NGP_TOKEN *newtok);
175
int ngp_append_columns(fitsfile *ff, NGP_HDU *ngph, int aftercol);
176
int ngp_read_xtension(fitsfile *ff, int parent_hn, int simple_mode);
177
int ngp_read_group(fitsfile *ff, char *grpname, int parent_hn);
179
/* top level API function - now defined in fitsio.h */