6 /******************************************************/
7 /* define the posible lines which contribute to f2k */
8 /******************************************************/
9 #define F2K_MAX_EVENTTYPES 10
10 #define F2K_MAX_LINETYPES 100
12 enum F2K_LINETYPES_T {
46 enum F2K_TAG_SEARCH_T {COMP_STRINGWISE=1, /* stringwise comp */
47 COMP_STRINGWISE_NOTRAIL,
48 COMP_CHARWISE, /* one char should fit */
49 COMP_CHARPUNCT /* same, char is isspunct -> speed */
51 ,COMP_NOTHING /* do not compare at all ->always true */
56 /************** functions to actually parse the lines ****/
59 typedef int (f2k_parser_fun_t)(mcfile *fp, array *a,
61 /* the void pointer misc is a trick to pass anny target to fill */
65 char tag[RDMC_MAXTOKENLENGTH];
66 enum F2K_LINETYPES_T line_id;
67 enum F2K_TAG_SEARCH_T searchtype;
68 f2k_parser_fun_t *parser;
71 /******************************************************/
72 /*** Definitions of f2k blocks ***/
73 /******************************************************/
75 typedef int (f2k_event_reader_fun_t)(mcfile *fp, array *a, mevt *e);
76 typedef int (f2k_event_writer_fun_t)(const mcfile *fp, const array *a, const mevt *e);
80 const f2000_line_t *opener[F2K_MAX_LINETYPES];/* lines that are required to indicate such an event */
81 const f2000_line_t *inner[F2K_MAX_LINETYPES]; /* lines that re alowd within such n event */
82 const f2000_line_t *closer[F2K_MAX_LINETYPES];/* lines that define the end of such an event */
83 f2k_event_reader_fun_t *reader;
84 f2k_event_writer_fun_t *writer;
88 /******************************************************/
89 /**** buffer for decoding f2k ************************/
90 /******************************************************/
91 #define F2K_BUFFERSIZE 32768 /* initial size of the raw text buffer */
92 #define F2K_LINE_BUFFERSIZE 2048 /* initial size of the raw text buffer */
96 typedef struct rdmc_f2k_buffer_s { /* a structure to keep track of raw lines */
97 unsigned long int used; /*length of the buffer (excluding last \0) */
98 unsigned long int ntot; /* number of allocated chars in buff */
99 char *buff; /* this buffers the raw text */
100 /* now the decoding of the lines */
101 unsigned long int lines; /* number of gathered lines in buff */
102 unsigned long int lines_tot; /* number of allocated lines in buff */
103 unsigned long int iline; /* the current line under investigation */
104 const f2000_line_t **type_def; /* pointer to the global array definition */
105 char **line_pt; /* pointer to each line in buffer */
107 /* the last element of line_pt is always set to NULL */
110 /* **************************************************** */
111 /* now this are all known event functions */
112 /* *****************************************************/
114 // the different formats differe only in the events
115 extern const f2000_event_t f2000_preamble_1x1; /* works for 1.1, 1.2, 2004.1*/
116 extern const f2000_event_t f2000_mhead_1x1; /* works for 1.1, 1.2, 2004.1*/
117 extern const f2000_event_t f2000_mfoot_1x1;
119 extern const f2000_event_t *f2000_events_1x1[];
120 extern const f2000_event_t *f2000_events_1x2[];
121 extern const f2000_event_t *f2000_events_2004x1[];
124 /* ******************************************************************* */
125 /* Functions in f2k_utl.c */
126 /* ******************************************************************* */
130 /* functions that convert special strings to rdmc values and vice versa */
131 f2k_parser_fun_t rdmc_f2k_dummy_parser;
132 f2k_event_writer_fun_t rdmc_f2k_dummy_event_writer;
134 void rdmc_push_f2k_buffer(rdmc_f2k_buffer_t *b, char *s, const f2000_line_t * type_def);
135 void rdmc_init_f2k_buffer(rdmc_f2k_buffer_t *b);
136 void rdmc_reset_f2k_buffer(rdmc_f2k_buffer_t *b);
137 void rdmc_unlink_f2k_buffer(rdmc_f2k_buffer_t *b);
138 void rdmc_clear_f2k_buffer(rdmc_f2k_buffer_t *b);
140 char ** rdmc_f2k_tokenize(char *line, int *nargs);
142 /* stores specific error information int f2k file pointer for print */
143 void rdmc_f2k_errorlog(mcfile *fp);
145 /* parser routines to catch ?, *, N, NaN, -inf, +inf, na */
146 int rdmc_amanda_strtoi(const char *str, int default_nan);
147 double rdmc_amanda_strtof(char *str, double default_nan);
148 char * rdmc_amanda_itostr(int val, int default_nan);
149 char * rdmc_amanda_ftostr(double val, double default_nan);
151 /* parser to catch some non float values in special blocks */
152 double rdmc_amanda_sptof(char *str);
154 /* parses the status flags at the end of the HT line */
155 int rdmc_amanda_mhit_stat(mhit_stat_t *hstat,char *stat_s);
157 /* return the rdmc value for "up" and "dn" .. and vice versa */
158 float rdmc_amanda_fori(char *ori);
159 char * rdmc_amanda_sori(float ori);
161 /* en/decode the time in a sec.ns fomat */
162 int rdmc_amanda_strtimetoi(const char *stime, int *sec, int *nsec); /* returns 0 on succes */
163 char * rdmc_amanda_itimetostr(int sec, int nsec);
165 /* create a string the USES lines for itoken */
166 char * rdmc_amanda_uses_to_str(int n_uses, mevt_uses_t *uses, int id);
168 /* tries to patches any year to avoid y2k problems returns corrected year */
169 int rdmc_f2k_y2k(int year);
170 /* ******************************************************************* */
171 /* ******************************************************************* */
172 /* Functions in f2k_YxZ.c */
175 f2k_event_reader_fun_t rdmc_rhd_f2k_1x1;
176 f2k_event_reader_fun_t rdmc_mhead_f2k_1x1;
177 f2k_event_reader_fun_t rdmc_mevt_f2k_1x1;
178 f2k_event_reader_fun_t rdmc_mfoot_f2k_1x1;
181 f2k_parser_fun_t rdmc_amanda_HI_1x1;
182 f2k_parser_fun_t rdmc_amanda_ARRAY_1x1;
183 f2k_parser_fun_t rdmc_amanda_FIT_DEF_1x1;
184 f2k_parser_fun_t rdmc_amanda_STAT_DEF_1x1;
185 f2k_parser_fun_t rdmc_amanda_USER_DEF_1x1;
186 f2k_parser_fun_t rdmc_amanda_TRIG_DEF_1x1;
187 f2k_parser_fun_t rdmc_amanda_TRIG_PAR_1x1;
188 f2k_parser_fun_t rdmc_amanda_OM_1x1;
189 f2k_parser_fun_t rdmc_amanda_KH_1x1;
190 f2k_parser_fun_t rdmc_amanda_KADC_1x1;
191 f2k_parser_fun_t rdmc_amanda_KTDC_1x1;
192 f2k_parser_fun_t rdmc_amanda_KTOT_1x1;
193 f2k_parser_fun_t rdmc_amanda_KUTC_1x1;
194 f2k_parser_fun_t rdmc_amanda_TBEGIN_1x1;
195 f2k_parser_fun_t rdmc_amanda_EM_1x1;
196 f2k_parser_fun_t rdmc_amanda_TR_1x1;
197 f2k_parser_fun_t rdmc_amanda_CH_1x1;
198 f2k_parser_fun_t rdmc_amanda_HT_1x1;
199 f2k_parser_fun_t rdmc_amanda_US_1x1;
200 f2k_parser_fun_t rdmc_amanda_STATUS_1x1;
201 f2k_parser_fun_t rdmc_amanda_trigblock_1x1;
202 f2k_parser_fun_t rdmc_amanda_TRIG_1x1;
203 f2k_parser_fun_t rdmc_amanda_fitblock_1x1;
204 f2k_parser_fun_t rdmc_amanda_FIT_1x1;
205 f2k_parser_fun_t rdmc_amanda_FRESULT_1x1;
206 f2k_parser_fun_t rdmc_amanda_USES_1x1;
208 f2k_parser_fun_t rdmc_amanda_HT_1x2;
209 f2k_parser_fun_t rdmc_amanda_WF_1x2;
211 f2k_parser_fun_t rdmc_amanda_WF_2004x1;
213 /* ******************************************************************* */
214 /* write functions */
215 /* ******************************************************************* */
216 /* Functions in f2k_YxZ.c */
219 /* functions handle all writing of 1.1 and 1.2 and 2004.1 */
220 f2k_event_writer_fun_t rdmc_whead_f2k_1x1_2;
221 f2k_event_writer_fun_t rdmc_wfoot_f2k_1x1_2;
222 f2k_event_writer_fun_t rdmc_wevt_f2k_1x1_2;
224 int rdmc_wrhist_f2k_1x1(const mcfile *fp, const char *s, const char *pre);
225 int rdmc_wrcomment_f2k_1x1(const mcfile *fp, const char *s);
228 /* ******************************************************************* */
230 /* ******************************************************************* */
232 extern const f2000_line_t V_line_1x1;
233 extern const f2000_line_t COMMENT_line_1x1;
234 extern const f2000_line_t HI_line_1x1;
235 extern const f2000_line_t ARRAY_line_1x1;
236 extern const f2000_line_t TRIG_DEF_line_1x1;
237 extern const f2000_line_t TRIG_PAR_line_1x1;
238 extern const f2000_line_t FIT_DEF_line_1x1;
239 extern const f2000_line_t STAT_DEF_line_1x1;
240 extern const f2000_line_t USER_DEF_line_1x1;
241 extern const f2000_line_t KH_line_1x1;
242 extern const f2000_line_t OM_line_1x1;
243 extern const f2000_line_t KADC_line_1x1;
244 extern const f2000_line_t KTDC_line_1x1;
245 extern const f2000_line_t KTOT_line_1x1;
246 extern const f2000_line_t KUTC_line_1x1;
247 extern const f2000_line_t TBEGIN_line_1x1;
248 extern const f2000_line_t EM_line_1x1;
249 extern const f2000_line_t TR_line_1x1;
250 extern const f2000_line_t CH_line_1x1;
251 extern const f2000_line_t HT_line_1x1;
252 extern const f2000_line_t US_line_1x1;
253 extern const f2000_line_t STATUS_line_1x1;
254 extern const f2000_line_t FIT_block_1x1;
255 extern const f2000_line_t TRIG_block_1x1;
256 extern const f2000_line_t TRIG_line_1x1;
257 extern const f2000_line_t FIT_line_1x1;
258 extern const f2000_line_t FRESULT_line_1x1;
259 extern const f2000_line_t USES_line_1x1;
260 extern const f2000_line_t EE_line_1x1;
261 extern const f2000_line_t TEND_line_1x1;
262 extern const f2000_line_t END_line_1x1;
264 extern const f2000_line_t HT_line_1x2;
265 extern const f2000_line_t WF_line_1x2;
267 extern const f2000_line_t WF_line_2004x1;