My Project
 All Classes Files Functions Variables Enumerations Enumerator Friends Macros Pages
grparser.h
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  =====================================================
3 
4  by Jerzy.Borkowski@obs.unige.ch
5 
6  Integral Science Data Center
7  ch. d'Ecogia 16
8  1290 Versoix
9  Switzerland
10 
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 */
18 
19 #ifndef GRPARSER_H_INCLUDED
20 #define GRPARSER_H_INCLUDED
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26  /* error codes - now defined in fitsio.h */
27 
28  /* common constants definitions */
29 
30 #define NGP_ALLOCCHUNK (1000)
31 #define NGP_MAX_INCLUDE (10) /* include file nesting limit */
32 #define NGP_MAX_COMMENT (80) /* max size for comment */
33 #define NGP_MAX_NAME (20) /* max size for KEYWORD (FITS limits it to 8 chars) */
34 #define NGP_MAX_STRING (80) /* max size for various strings */
35 #define NGP_MAX_ARRAY_DIM (999) /* max. number of dimensions in array */
36 #define NGP_MAX_FNAME (1000) /* max size of combined path+fname */
37 #define NGP_MAX_ENVFILES (10000) /* max size of CFITSIO_INCLUDE_FILES env. variable */
38 
39 #define NGP_TOKEN_UNKNOWN (-1) /* token type unknown */
40 #define NGP_TOKEN_INCLUDE (0) /* \INCLUDE token */
41 #define NGP_TOKEN_GROUP (1) /* \GROUP token */
42 #define NGP_TOKEN_END (2) /* \END token */
43 #define NGP_TOKEN_XTENSION (3) /* XTENSION token */
44 #define NGP_TOKEN_SIMPLE (4) /* SIMPLE token */
45 #define NGP_TOKEN_EOF (5) /* End Of File pseudo token */
46 
47 #define NGP_TTYPE_UNKNOWN (0) /* undef (yet) token type - invalid to print/write to disk */
48 #define NGP_TTYPE_BOOL (1) /* boolean, it is 'T' or 'F' */
49 #define NGP_TTYPE_STRING (2) /* something withing "" or starting with letter */
50 #define NGP_TTYPE_INT (3) /* starting with digit and not with '.' */
51 #define NGP_TTYPE_REAL (4) /* digits + '.' */
52 #define NGP_TTYPE_COMPLEX (5) /* 2 reals, separated with ',' */
53 #define NGP_TTYPE_NULL (6) /* NULL token, format is : NAME = / comment */
54 #define NGP_TTYPE_RAW (7) /* HISTORY/COMMENT/8SPACES + comment string without / */
55 
56 #define NGP_FOUND_EQUAL_SIGN (1) /* line contains '=' after keyword name */
57 
58 #define NGP_FORMAT_OK (0) /* line format OK */
59 #define NGP_FORMAT_ERROR (1) /* line format error */
60 
61 #define NGP_NODE_INVALID (0) /* default node type - invalid (to catch errors) */
62 #define NGP_NODE_IMAGE (1) /* IMAGE type */
63 #define NGP_NODE_ATABLE (2) /* ASCII table type */
64 #define NGP_NODE_BTABLE (3) /* BINARY table type */
65 
66 #define NGP_NON_SYSTEM_ONLY (0) /* save all keywords except NAXIS,BITPIX,etc.. */
67 #define NGP_REALLY_ALL (1) /* save really all keywords */
68 
69 #define NGP_XTENSION_SIMPLE (1) /* HDU defined with SIMPLE T */
70 #define NGP_XTENSION_FIRST (2) /* this is first extension in template */
71 
72 #define NGP_LINE_REREAD (1) /* reread line */
73 
74 #define NGP_BITPIX_INVALID (-12345) /* default BITPIX (to catch errors) */
75 
76  /* common macro definitions */
77 
78 #ifdef NGP_PARSER_DEBUG_MALLOC
79 
80 #define ngp_alloc(x) dal_malloc(x)
81 #define ngp_free(x) dal_free(x)
82 #define ngp_realloc(x,y) dal_realloc(x,y)
83 
84 #else
85 
86 #define ngp_alloc(x) malloc(x)
87 #define ngp_free(x) free(x)
88 #define ngp_realloc(x,y) realloc(x,y)
89 
90 #endif
91 
92  /* type definitions */
93 
94 typedef struct NGP_RAW_LINE_STRUCT
95  { char *line;
96  char *name;
97  char *value;
98  int type;
99  char *comment;
100  int format;
101  int flags;
102  } NGP_RAW_LINE;
103 
104 
105 typedef union NGP_TOKVAL_UNION
106  { char *s; /* space allocated separately, be careful !!! */
107  char b;
108  int i;
109  double d;
111  { double re;
112  double im;
113  } c; /* complex value */
114  } NGP_TOKVAL;
115 
116 
117 typedef struct NGP_TOKEN_STRUCT
118  { int type;
119  char name[NGP_MAX_NAME];
120  NGP_TOKVAL value;
121  char comment[NGP_MAX_COMMENT];
122  } NGP_TOKEN;
123 
124 
125 typedef struct NGP_HDU_STRUCT
126  { int tokcnt;
127  NGP_TOKEN *tok;
128  } NGP_HDU;
129 
130 
131 typedef struct NGP_TKDEF_STRUCT
132  { char *name;
133  int code;
134  } NGP_TKDEF;
135 
136 
137 typedef struct NGP_EXTVER_TAB_STRUCT
138  { char *extname;
139  int version;
140  } NGP_EXTVER_TAB;
141 
142 
143  /* globally visible variables declarations */
144 
145 extern NGP_RAW_LINE ngp_curline;
146 extern NGP_RAW_LINE ngp_prevline;
147 
148 extern int ngp_extver_tab_size;
149 extern NGP_EXTVER_TAB *ngp_extver_tab;
150 
151 
152  /* globally visible functions declarations */
153 
154 int ngp_get_extver(char *extname, int *version);
155 int ngp_set_extver(char *extname, int version);
156 int ngp_delete_extver_tab(void);
157 int ngp_strcasecmp(char *p1, char *p2);
158 int ngp_line_from_file(FILE *fp, char **p);
159 int ngp_free_line(void);
160 int ngp_free_prevline(void);
161 int ngp_read_line_buffered(FILE *fp);
162 int ngp_unread_line(void);
163 int ngp_extract_tokens(NGP_RAW_LINE *cl);
164 int ngp_include_file(char *fname);
165 int ngp_read_line(int ignore_blank_lines);
166 int ngp_keyword_is_write(NGP_TOKEN *ngp_tok);
167 int ngp_keyword_all_write(NGP_HDU *ngph, fitsfile *ffp, int mode);
168 int ngp_hdu_init(NGP_HDU *ngph);
169 int ngp_hdu_clear(NGP_HDU *ngph);
170 int ngp_hdu_insert_token(NGP_HDU *ngph, NGP_TOKEN *newtok);
171 int ngp_append_columns(fitsfile *ff, NGP_HDU *ngph, int aftercol);
172 int ngp_read_xtension(fitsfile *ff, int parent_hn, int simple_mode);
173 int ngp_read_group(fitsfile *ff, char *grpname, int parent_hn);
174 
175  /* top level API function - now defined in fitsio.h */
176 
177 #ifdef __cplusplus
178 }
179 #endif
180 
181 #endif
Definition: grparser.h:117
Definition: grparser.h:131
Definition: grparser.h:137
Definition: grparser.h:110
Definition: grparser.h:94
Definition: grparser.h:105
Definition: grparser.h:125
Definition: fitsio.h:248