1 #line 2 "conf-file.c"
2
3 #line 4 "conf-file.c"
4
5 #define YY_INT_ALIGNED short int
6
7 /* A lexical scanner generated by flex */
8
9 #define FLEX_SCANNER
10 #define YY_FLEX_MAJOR_VERSION 2
11 #define YY_FLEX_MINOR_VERSION 6
12 #define YY_FLEX_SUBMINOR_VERSION 4
13 #if YY_FLEX_SUBMINOR_VERSION > 0
14 #define FLEX_BETA
15 #endif
16
17 /* First, we deal with platform-specific or compiler-specific issues. */
18
19 /* begin standard C headers. */
20 #include <stdio.h>
21 #include <string.h>
22 #include <errno.h>
23 #include <stdlib.h>
24
25 /* end standard C headers. */
26
27 /* flex integer type definitions */
28
29 #ifndef FLEXINT_H
30 #define FLEXINT_H
31
32 /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
33
34 #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
35
36 /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
37 * if you want the limit (max/min) macros for int types.
38 */
39 #ifndef __STDC_LIMIT_MACROS
40 #define __STDC_LIMIT_MACROS 1
41 #endif
42
43 #include <inttypes.h>
44 typedef int8_t flex_int8_t;
45 typedef uint8_t flex_uint8_t;
46 typedef int16_t flex_int16_t;
47 typedef uint16_t flex_uint16_t;
48 typedef int32_t flex_int32_t;
49 typedef uint32_t flex_uint32_t;
50 #else
51 typedef signed char flex_int8_t;
52 typedef short int flex_int16_t;
53 typedef int flex_int32_t;
54 typedef unsigned char flex_uint8_t;
55 typedef unsigned short int flex_uint16_t;
56 typedef unsigned int flex_uint32_t;
57
58 /* Limits of integral types. */
59 #ifndef INT8_MIN
60 #define INT8_MIN (-128)
61 #endif
62 #ifndef INT16_MIN
63 #define INT16_MIN (-32767-1)
64 #endif
65 #ifndef INT32_MIN
66 #define INT32_MIN (-2147483647-1)
67 #endif
68 #ifndef INT8_MAX
69 #define INT8_MAX (127)
70 #endif
71 #ifndef INT16_MAX
72 #define INT16_MAX (32767)
73 #endif
74 #ifndef INT32_MAX
75 #define INT32_MAX (2147483647)
76 #endif
77 #ifndef UINT8_MAX
78 #define UINT8_MAX (255U)
79 #endif
80 #ifndef UINT16_MAX
81 #define UINT16_MAX (65535U)
82 #endif
83 #ifndef UINT32_MAX
84 #define UINT32_MAX (4294967295U)
85 #endif
86
87 #ifndef SIZE_MAX
88 #define SIZE_MAX (~(size_t)0)
89 #endif
90
91 #endif /* ! C99 */
92
93 #endif /* ! FLEXINT_H */
94
95 /* begin standard C++ headers. */
96
97 /* TODO: this is always defined, so inline it */
98 #define yyconst const
99
100 #if defined(__GNUC__) && __GNUC__ >= 3
101 #define yynoreturn __attribute__((__noreturn__))
102 #else
103 #define yynoreturn
104 #endif
105
106 /* Returned upon end-of-file. */
107 #define YY_NULL 0
108
109 /* Promotes a possibly negative, possibly signed char to an
110 * integer in range [0..255] for use as an array index.
111 */
112 #define YY_SC_TO_UI(c) ((YY_CHAR) (c))
113
114 /* Enter a start condition. This macro really ought to take a parameter,
115 * but we do it the disgusting crufty way forced on us by the ()-less
116 * definition of BEGIN.
117 */
118 #define BEGIN (yy_start) = 1 + 2 *
119 /* Translate the current start state into a value that can be later handed
120 * to BEGIN to return to the state. The YYSTATE alias is for lex
121 * compatibility.
122 */
123 #define YY_START (((yy_start) - 1) / 2)
124 #define YYSTATE YY_START
125 /* Action number for EOF rule of a given start state. */
126 #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
127 /* Special action meaning "start processing a new file". */
128 #define YY_NEW_FILE yyrestart( yyin )
129 #define YY_END_OF_BUFFER_CHAR 0
130
131 /* Size of default input buffer. */
132 #ifndef YY_BUF_SIZE
133 #ifdef __ia64__
134 /* On IA-64, the buffer size is 16k, not 8k.
135 * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
136 * Ditto for the __ia64__ case accordingly.
137 */
138 #define YY_BUF_SIZE 32768
139 #else
140 #define YY_BUF_SIZE 16384
141 #endif /* __ia64__ */
142 #endif
143
144 /* The state buf must be large enough to hold one state per character in the main buffer.
145 */
146 #define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
147
148 #ifndef YY_TYPEDEF_YY_BUFFER_STATE
149 #define YY_TYPEDEF_YY_BUFFER_STATE
150 typedef struct yy_buffer_state *YY_BUFFER_STATE;
151 #endif
152
153 #ifndef YY_TYPEDEF_YY_SIZE_T
154 #define YY_TYPEDEF_YY_SIZE_T
155 typedef size_t yy_size_t;
156 #endif
157
158 extern int yyleng;
159
160 extern FILE *yyin, *yyout;
161
162 #define EOB_ACT_CONTINUE_SCAN 0
163 #define EOB_ACT_END_OF_FILE 1
164 #define EOB_ACT_LAST_MATCH 2
165
166 #define YY_LESS_LINENO(n)
167 #define YY_LINENO_REWIND_TO(ptr)
168
169 /* Return all but the first "n" matched characters back to the input stream. */
170 #define yyless(n) \
171 do \
172 { \
173 /* Undo effects of setting up yytext. */ \
174 int yyless_macro_arg = (n); \
175 YY_LESS_LINENO(yyless_macro_arg);\
176 *yy_cp = (yy_hold_char); \
177 YY_RESTORE_YY_MORE_OFFSET \
178 (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
179 YY_DO_BEFORE_ACTION; /* set up yytext again */ \
180 } \
181 while ( 0 )
182 #define unput(c) yyunput( c, (yytext_ptr) )
183
184 #ifndef YY_STRUCT_YY_BUFFER_STATE
185 #define YY_STRUCT_YY_BUFFER_STATE
186 struct yy_buffer_state
187 {
188 FILE *yy_input_file;
189
190 char *yy_ch_buf; /* input buffer */
191 char *yy_buf_pos; /* current position in input buffer */
192
193 /* Size of input buffer in bytes, not including room for EOB
194 * characters.
195 */
196 int yy_buf_size;
197
198 /* Number of characters read into yy_ch_buf, not including EOB
199 * characters.
200 */
201 int yy_n_chars;
202
203 /* Whether we "own" the buffer - i.e., we know we created it,
204 * and can realloc() it to grow it, and should free() it to
205 * delete it.
206 */
207 int yy_is_our_buffer;
208
209 /* Whether this is an "interactive" input source; if so, and
210 * if we're using stdio for input, then we want to use getc()
211 * instead of fread(), to make sure we stop fetching input after
212 * each newline.
213 */
214 int yy_is_interactive;
215
216 /* Whether we're considered to be at the beginning of a line.
217 * If so, '^' rules will be active on the next match, otherwise
218 * not.
219 */
220 int yy_at_bol;
221
222 int yy_bs_lineno; /**< The line count. */
223 int yy_bs_column; /**< The column count. */
224
225 /* Whether to try to fill the input buffer when we reach the
226 * end of it.
227 */
228 int yy_fill_buffer;
229
230 int yy_buffer_status;
231
232 #define YY_BUFFER_NEW 0
233 #define YY_BUFFER_NORMAL 1
234 /* When an EOF's been seen but there's still some text to process
235 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
236 * shouldn't try reading from the input source any more. We might
237 * still have a bunch of tokens to match, though, because of
238 * possible backing-up.
239 *
240 * When we actually see the EOF, we change the status to "new"
241 * (via yyrestart()), so that the user can continue scanning by
242 * just pointing yyin at a new input file.
243 */
244 #define YY_BUFFER_EOF_PENDING 2
245
246 };
247 #endif /* !YY_STRUCT_YY_BUFFER_STATE */
248
249 /* Stack of input buffers. */
250 static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
251 static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
252 static YY_BUFFER_STATE * yy_buffer_stack = NULL; /**< Stack as an array. */
253
254 /* We provide macros for accessing buffer states in case in the
255 * future we want to put the buffer states in a more general
256 * "scanner state".
257 *
258 * Returns the top of the stack, or NULL.
259 */
260 #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
261 ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
262 : NULL)
263 /* Same as previous macro, but useful when we know that the buffer stack is not
264 * NULL or when we need an lvalue. For internal use only.
265 */
266 #define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
267
268 /* yy_hold_char holds the character lost when yytext is formed. */
269 static char yy_hold_char;
270 static int yy_n_chars; /* number of characters read into yy_ch_buf */
271 int yyleng;
272
273 /* Points to current character in buffer. */
274 static char *yy_c_buf_p = NULL;
275 static int yy_init = 0; /* whether we need to initialize */
276 static int yy_start = 0; /* start state number */
277
278 /* Flag which is used to allow yywrap()'s to do buffer switches
279 * instead of setting up a fresh yyin. A bit of a hack ...
280 */
281 static int yy_did_buffer_switch_on_eof;
282
283 void yyrestart ( FILE *input_file );
284 void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer );
285 YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size );
286 void yy_delete_buffer ( YY_BUFFER_STATE b );
287 void yy_flush_buffer ( YY_BUFFER_STATE b );
288 void yypush_buffer_state ( YY_BUFFER_STATE new_buffer );
289 void yypop_buffer_state ( void );
290
291 static void yyensure_buffer_stack ( void );
292 static void yy_load_buffer_state ( void );
293 static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file );
294 #define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER )
295
296 YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size );
297 YY_BUFFER_STATE yy_scan_string ( const char *yy_str );
298 YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len );
299
300 void *yyalloc ( yy_size_t );
301 void *yyrealloc ( void *, yy_size_t );
302 void yyfree ( void * );
303
304 #define yy_new_buffer yy_create_buffer
305 #define yy_set_interactive(is_interactive) \
306 { \
307 if ( ! YY_CURRENT_BUFFER ){ \
308 yyensure_buffer_stack (); \
309 YY_CURRENT_BUFFER_LVALUE = \
310 yy_create_buffer( yyin, YY_BUF_SIZE ); \
311 } \
312 YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
313 }
314 #define yy_set_bol(at_bol) \
315 { \
316 if ( ! YY_CURRENT_BUFFER ){\
317 yyensure_buffer_stack (); \
318 YY_CURRENT_BUFFER_LVALUE = \
319 yy_create_buffer( yyin, YY_BUF_SIZE ); \
320 } \
321 YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
322 }
323 #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
324
325 /* Begin user sect3 */
326
327 #define yywrap() (/*CONSTCOND*/1)
328 #define YY_SKIP_YYWRAP
329 typedef flex_uint8_t YY_CHAR;
330
331 FILE *yyin = NULL, *yyout = NULL;
332
333 typedef int yy_state_type;
334
335 extern int yylineno;
336 int yylineno = 1;
337
338 extern char *yytext;
339 #ifdef yytext_ptr
340 #undef yytext_ptr
341 #endif
342 #define yytext_ptr yytext
343
344 static yy_state_type yy_get_previous_state ( void );
345 static yy_state_type yy_try_NUL_trans ( yy_state_type current_state );
346 static int yy_get_next_buffer ( void );
347 static void yynoreturn yy_fatal_error ( const char* msg );
348
349 /* Done after the current pattern has been matched and before the
350 * corresponding action - sets up yytext.
351 */
352 #define YY_DO_BEFORE_ACTION \
353 (yytext_ptr) = yy_bp; \
354 yyleng = (int) (yy_cp - yy_bp); \
355 (yy_hold_char) = *yy_cp; \
356 *yy_cp = '\0'; \
357 (yy_c_buf_p) = yy_cp;
358 #define YY_NUM_RULES 13
359 #define YY_END_OF_BUFFER 14
360 /* This struct is not used in this scanner,
361 but its presence is necessary. */
362 struct yy_trans_info
363 {
364 flex_int32_t yy_verify;
365 flex_int32_t yy_nxt;
366 };
367 static const flex_int16_t yy_accept[49] =
368 { 0,
369 0, 0, 14, 12, 2, 1, 12, 3, 12, 12,
370 10, 9, 9, 11, 4, 2, 0, 8, 0, 3,
371 0, 6, 0, 10, 9, 9, 10, 0, 0, 7,
372 7, 4, 4, 0, 8, 0, 0, 6, 0, 0,
373 10, 9, 7, 5, 5, 5, 5, 0
374 } ;
375
376 static const YY_CHAR yy_ec[256] =
377 { 0,
378 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
379 1, 1, 2, 1, 1, 1, 1, 1, 1, 1,
380 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
381 1, 2, 1, 4, 5, 1, 1, 1, 6, 1,
382 1, 1, 7, 1, 8, 9, 10, 11, 12, 12,
383 12, 12, 12, 12, 12, 12, 12, 10, 1, 1,
384 13, 1, 1, 1, 14, 14, 14, 14, 15, 14,
385 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
386 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
387 1, 17, 1, 1, 18, 1, 14, 14, 14, 14,
388
389 15, 14, 16, 16, 16, 16, 16, 16, 16, 16,
390 16, 16, 16, 16, 16, 16, 16, 16, 16, 19,
391 16, 16, 1, 1, 1, 1, 1, 16, 16, 16,
392 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
393 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
394 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
395 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
396 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
397 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
398 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
399
400 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
401 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
402 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
403 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
404 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
405 16, 16, 16, 16, 16
406 } ;
407
408 static const YY_CHAR yy_meta[20] =
409 { 0,
410 1, 1, 2, 1, 1, 1, 1, 3, 3, 3,
411 4, 4, 1, 5, 4, 3, 1, 3, 3
412 } ;
413
414 static const flex_int16_t yy_base[59] =
415 { 0,
416 0, 0, 75, 141, 72, 141, 16, 0, 15, 25,
417 58, 11, 61, 141, 30, 51, 24, 141, 25, 0,
418 18, 141, 37, 37, 0, 0, 0, 48, 0, 29,
419 47, 59, 0, 27, 41, 47, 40, 64, 65, 14,
420 38, 0, 9, 75, 86, 0, 0, 141, 104, 109,
421 114, 19, 117, 122, 127, 129, 132, 135
422 } ;
423
424 static const flex_int16_t yy_def[59] =
425 { 0,
426 48, 1, 48, 48, 48, 48, 49, 50, 51, 48,
427 52, 10, 10, 48, 53, 48, 49, 48, 54, 50,
428 51, 48, 55, 52, 12, 13, 24, 48, 56, 57,
429 57, 53, 32, 49, 49, 54, 51, 51, 55, 48,
430 48, 56, 57, 58, 58, 45, 45, 0, 48, 48,
431 48, 48, 48, 48, 48, 48, 48, 48
432 } ;
433
434 static const flex_int16_t yy_nxt[161] =
435 { 0,
436 4, 5, 6, 7, 8, 9, 10, 10, 11, 4,
437 12, 13, 14, 15, 15, 15, 4, 15, 15, 18,
438 22, 26, 27, 22, 41, 41, 43, 18, 35, 29,
439 18, 23, 19, 24, 23, 25, 26, 30, 31, 30,
440 19, 36, 38, 19, 18, 22, 43, 33, 41, 41,
441 35, 28, 16, 39, 40, 40, 23, 19, 41, 41,
442 44, 44, 44, 36, 45, 44, 30, 31, 30, 22,
443 38, 26, 28, 16, 48, 48, 33, 48, 48, 48,
444 23, 39, 30, 30, 30, 48, 48, 48, 48, 48,
445 48, 48, 47, 30, 30, 30, 48, 48, 48, 48,
446
447 48, 48, 48, 47, 17, 48, 17, 17, 17, 20,
448 48, 20, 20, 20, 21, 48, 21, 21, 21, 32,
449 32, 32, 34, 48, 34, 34, 34, 37, 48, 37,
450 37, 37, 42, 42, 30, 30, 30, 46, 46, 46,
451 3, 48, 48, 48, 48, 48, 48, 48, 48, 48,
452 48, 48, 48, 48, 48, 48, 48, 48, 48, 48
453 } ;
454
455 static const flex_int16_t yy_chk[161] =
456 { 0,
457 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
458 1, 1, 1, 1, 1, 1, 1, 1, 1, 7,
459 9, 12, 52, 21, 40, 40, 43, 17, 19, 12,
460 34, 9, 7, 10, 21, 10, 10, 15, 15, 15,
461 17, 19, 23, 34, 35, 37, 30, 15, 41, 41,
462 36, 24, 16, 23, 28, 28, 37, 35, 28, 28,
463 31, 31, 31, 36, 31, 31, 32, 32, 32, 38,
464 39, 13, 11, 5, 3, 0, 32, 0, 0, 0,
465 38, 39, 44, 44, 44, 0, 0, 0, 0, 0,
466 0, 0, 44, 45, 45, 45, 0, 0, 0, 0,
467
468 0, 0, 0, 45, 49, 0, 49, 49, 49, 50,
469 0, 50, 50, 50, 51, 0, 51, 51, 51, 53,
470 53, 53, 54, 0, 54, 54, 54, 55, 0, 55,
471 55, 55, 56, 56, 57, 57, 57, 58, 58, 58,
472 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
473 48, 48, 48, 48, 48, 48, 48, 48, 48, 48
474 } ;
475
476 static yy_state_type yy_last_accepting_state;
477 static char *yy_last_accepting_cpos;
478
479 extern int yy_flex_debug;
480 int yy_flex_debug = 0;
481
482 /* The intent behind this definition is that it'll catch
483 * any uses of REJECT which flex missed.
484 */
485 #define REJECT reject_used_but_not_detected
486 #define yymore() yymore_used_but_not_detected
487 #define YY_MORE_ADJ 0
488 #define YY_RESTORE_YY_MORE_OFFSET
489 char *yytext;
490 #line 1 "conf-file.l"
491 /* Scanner for slon config file */
492 #line 4 "conf-file.l"
493 #include <sys/stat.h>
494 #include <errno.h>
495 #include <ctype.h>
496 #include <pthread.h>
497
498 #include <stdio.h>
499 #include <stdlib.h>
500 #include <string.h>
501 #include <sys/types.h>
502
503 #ifndef WIN32
504 #include <unistd.h>
505 #endif
506
507 #include "slon.h"
508
509
510 #define CONFIG_FILENAME "./slon.conf"
511
512 static unsigned ConfigFileLineno;
513
514 enum {
515 SLON_ID = 1,
516 SLON_STRING = 2,
517 SLON_INTEGER = 3,
518 SLON_REAL = 4,
519 SLON_EQUALS = 5,
520 SLON_UNQUOTED_STRING = 6,
521 SLON_QUALIFIED_ID = 7,
522 SLON_ESCAPED_STRING = 8,
523 SLON_EOL = 99,
524 SLON_FERROR = 100
525 };
526
527 #define YY_USER_INIT (ConfigFileLineno = 1)
528
529 /* prototype, so compiler is happy with our high warnings setting */
530 int SLON_yylex(void);
531 char *SLON_scanstr(char *);
532 #line 533 "conf-file.c"
533 #line 534 "conf-file.c"
534
535 #define INITIAL 0
536
537 #ifndef YY_NO_UNISTD_H
538 /* Special case for "unistd.h", since it is non-ANSI. We include it way
539 * down here because we want the user's section 1 to have been scanned first.
540 * The user has a chance to override it with an option.
541 */
542 #include <unistd.h>
543 #endif
544
545 #ifndef YY_EXTRA_TYPE
546 #define YY_EXTRA_TYPE void *
547 #endif
548
549 static int yy_init_globals ( void );
550
551 /* Accessor methods to globals.
552 These are made visible to non-reentrant scanners for convenience. */
553
554 int yylex_destroy ( void );
555
556 int yyget_debug ( void );
557
558 void yyset_debug ( int debug_flag );
559
560 YY_EXTRA_TYPE yyget_extra ( void );
561
562 void yyset_extra ( YY_EXTRA_TYPE user_defined );
563
564 FILE *yyget_in ( void );
565
566 void yyset_in ( FILE * _in_str );
567
568 FILE *yyget_out ( void );
569
570 void yyset_out ( FILE * _out_str );
571
572 int yyget_leng ( void );
573
574 char *yyget_text ( void );
575
576 int yyget_lineno ( void );
577
578 void yyset_lineno ( int _line_number );
579
580 /* Macros after this point can all be overridden by user definitions in
581 * section 1.
582 */
583
584 #ifndef YY_SKIP_YYWRAP
585 #ifdef __cplusplus
586 extern "C" int yywrap ( void );
587 #else
588 extern int yywrap ( void );
589 #endif
590 #endif
591
592 #ifndef YY_NO_UNPUT
593
594 #endif
595
596 #ifndef yytext_ptr
597 static void yy_flex_strncpy ( char *, const char *, int );
598 #endif
599
600 #ifdef YY_NEED_STRLEN
601 static int yy_flex_strlen ( const char * );
602 #endif
603
604 #ifndef YY_NO_INPUT
605 #ifdef __cplusplus
606 static int yyinput ( void );
607 #else
608 static int input ( void );
609 #endif
610
611 #endif
612
613 /* Amount of stuff to slurp up with each read. */
614 #ifndef YY_READ_BUF_SIZE
615 #ifdef __ia64__
616 /* On IA-64, the buffer size is 16k, not 8k */
617 #define YY_READ_BUF_SIZE 16384
618 #else
619 #define YY_READ_BUF_SIZE 8192
620 #endif /* __ia64__ */
621 #endif
622
623 /* Copy whatever the last rule matched to the standard output. */
624 #ifndef ECHO
625 /* This used to be an fputs(), but since the string might contain NUL's,
626 * we now use fwrite().
627 */
628 #define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0)
629 #endif
630
631 /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
632 * is returned in "result".
633 */
634 #ifndef YY_INPUT
635 #define YY_INPUT(buf,result,max_size) \
636 if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
637 { \
638 int c = '*'; \
639 int n; \
640 for ( n = 0; n < max_size && \
641 (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
642 buf[n] = (char) c; \
643 if ( c == '\n' ) \
644 buf[n++] = (char) c; \
645 if ( c == EOF && ferror( yyin ) ) \
646 YY_FATAL_ERROR( "input in flex scanner failed" ); \
647 result = n; \
648 } \
649 else \
650 { \
651 errno=0; \
652 while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \
653 { \
654 if( errno != EINTR) \
655 { \
656 YY_FATAL_ERROR( "input in flex scanner failed" ); \
657 break; \
658 } \
659 errno=0; \
660 clearerr(yyin); \
661 } \
662 }\
663 \
664
665 #endif
666
667 /* No semi-colon after return; correct usage is to write "yyterminate();" -
668 * we don't want an extra ';' after the "return" because that will cause
669 * some compilers to complain about unreachable statements.
670 */
671 #ifndef yyterminate
672 #define yyterminate() return YY_NULL
673 #endif
674
675 /* Number of entries by which start-condition stack grows. */
676 #ifndef YY_START_STACK_INCR
677 #define YY_START_STACK_INCR 25
678 #endif
679
680 /* Report a fatal error. */
681 #ifndef YY_FATAL_ERROR
682 #define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
683 #endif
684
685 /* end tables serialization structures and prototypes */
686
687 /* Default declaration of generated scanner - a define so the user can
688 * easily add parameters.
689 */
690 #ifndef YY_DECL
691 #define YY_DECL_IS_OURS 1
692
693 extern int yylex (void);
694
695 #define YY_DECL int yylex (void)
696 #endif /* !YY_DECL */
697
698 /* Code executed at the beginning of each rule, after yytext and yyleng
699 * have been set up.
700 */
701 #ifndef YY_USER_ACTION
702 #define YY_USER_ACTION
703 #endif
704
705 /* Code executed at the end of each rule. */
706 #ifndef YY_BREAK
707 #define YY_BREAK /*LINTED*/break;
708 #endif
709
710 #define YY_RULE_SETUP \
711 YY_USER_ACTION
712
713 /** The main scanner function which does all the work.
714 */
715 YY_DECL
716 {
717 yy_state_type yy_current_state;
718 char *yy_cp, *yy_bp;
719 int yy_act;
720
721 if ( !(yy_init) )
722 {
723 (yy_init) = 1;
724
725 #ifdef YY_USER_INIT
726 YY_USER_INIT;
727 #endif
728
729 if ( ! (yy_start) )
730 (yy_start) = 1; /* first start state */
731
732 if ( ! yyin )
733 yyin = stdin;
734
735 if ( ! yyout )
736 yyout = stdout;
737
738 if ( ! YY_CURRENT_BUFFER ) {
739 yyensure_buffer_stack ();
740 YY_CURRENT_BUFFER_LVALUE =
741 yy_create_buffer( yyin, YY_BUF_SIZE );
742 }
743
744 yy_load_buffer_state( );
745 }
746
747 {
748 #line 69 "conf-file.l"
749
750
751 #line 752 "conf-file.c"
752
753 while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */
754 {
755 yy_cp = (yy_c_buf_p);
756
757 /* Support of yytext. */
758 *yy_cp = (yy_hold_char);
759
760 /* yy_bp points to the position in yy_ch_buf of the start of
761 * the current run.
762 */
763 yy_bp = yy_cp;
764
765 yy_current_state = (yy_start);
766 yy_match:
767 do
768 {
769 YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ;
770 if ( yy_accept[yy_current_state] )
771 {
772 (yy_last_accepting_state) = yy_current_state;
773 (yy_last_accepting_cpos) = yy_cp;
774 }
775 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
776 {
777 yy_current_state = (int) yy_def[yy_current_state];
778 if ( yy_current_state >= 49 )
779 yy_c = yy_meta[yy_c];
780 }
781 yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
782 ++yy_cp;
783 }
784 while ( yy_current_state != 48 );
785 yy_cp = (yy_last_accepting_cpos);
786 yy_current_state = (yy_last_accepting_state);
787
788 yy_find_action:
789 yy_act = yy_accept[yy_current_state];
790
791 YY_DO_BEFORE_ACTION;
792
793 do_action: /* This label is used only to access EOF actions. */
794
795 switch ( yy_act )
796 { /* beginning of action switch */
797 case 0: /* must back up */
798 /* undo the effects of YY_DO_BEFORE_ACTION */
799 *yy_cp = (yy_hold_char);
800 yy_cp = (yy_last_accepting_cpos);
801 yy_current_state = (yy_last_accepting_state);
802 goto yy_find_action;
803
804 case 1:
805 /* rule 1 can match eol */
806 YY_RULE_SETUP
807 #line 71 "conf-file.l"
808 ConfigFileLineno++; return SLON_EOL;
809 YY_BREAK
810 case 2:
811 YY_RULE_SETUP
812 #line 72 "conf-file.l"
813 /* eat whitespace */
814 YY_BREAK
815 case 3:
816 YY_RULE_SETUP
817 #line 73 "conf-file.l"
818 /* eat comment */
819 YY_BREAK
820 case 4:
821 YY_RULE_SETUP
822 #line 75 "conf-file.l"
823 return SLON_ID;
824 YY_BREAK
825 case 5:
826 YY_RULE_SETUP
827 #line 76 "conf-file.l"
828 return SLON_QUALIFIED_ID;
829 YY_BREAK
830 case 6:
831 YY_RULE_SETUP
832 #line 77 "conf-file.l"
833 return SLON_STRING;
834 YY_BREAK
835 case 7:
836 YY_RULE_SETUP
837 #line 78 "conf-file.l"
838 return SLON_UNQUOTED_STRING;
839 YY_BREAK
840 case 8:
841 YY_RULE_SETUP
842 #line 79 "conf-file.l"
843 return SLON_ESCAPED_STRING;
844 YY_BREAK
845 case 9:
846 YY_RULE_SETUP
847 #line 80 "conf-file.l"
848 return SLON_INTEGER;
849 YY_BREAK
850 case 10:
851 YY_RULE_SETUP
852 #line 81 "conf-file.l"
853 return SLON_REAL;
854 YY_BREAK
855 case 11:
856 YY_RULE_SETUP
857 #line 82 "conf-file.l"
858 return SLON_EQUALS;
859 YY_BREAK
860 case 12:
861 YY_RULE_SETUP
862 #line 84 "conf-file.l"
863 return SLON_FERROR;
864 YY_BREAK
865 case 13:
866 YY_RULE_SETUP
867 #line 86 "conf-file.l"
868 YY_FATAL_ERROR( "flex scanner jammed" );
869 YY_BREAK
870 #line 871 "conf-file.c"
871 case YY_STATE_EOF(INITIAL):
872 yyterminate();
873
874 case YY_END_OF_BUFFER:
875 {
876 /* Amount of text matched not including the EOB char. */
877 int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
878
879 /* Undo the effects of YY_DO_BEFORE_ACTION. */
880 *yy_cp = (yy_hold_char);
881 YY_RESTORE_YY_MORE_OFFSET
882
883 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
884 {
885 /* We're scanning a new file or input source. It's
886 * possible that this happened because the user
887 * just pointed yyin at a new source and called
888 * yylex(). If so, then we have to assure
889 * consistency between YY_CURRENT_BUFFER and our
890 * globals. Here is the right place to do so, because
891 * this is the first action (other than possibly a
892 * back-up) that will match for the new input source.
893 */
894 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
895 YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
896 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
897 }
898
899 /* Note that here we test for yy_c_buf_p "<=" to the position
900 * of the first EOB in the buffer, since yy_c_buf_p will
901 * already have been incremented past the NUL character
902 * (since all states make transitions on EOB to the
903 * end-of-buffer state). Contrast this with the test
904 * in input().
905 */
906 if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
907 { /* This was really a NUL. */
908 yy_state_type yy_next_state;
909
910 (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
911
912 yy_current_state = yy_get_previous_state( );
913
914 /* Okay, we're now positioned to make the NUL
915 * transition. We couldn't have
916 * yy_get_previous_state() go ahead and do it
917 * for us because it doesn't know how to deal
918 * with the possibility of jamming (and we don't
919 * want to build jamming into it because then it
920 * will run more slowly).
921 */
922
923 yy_next_state = yy_try_NUL_trans( yy_current_state );
924
925 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
926
927 if ( yy_next_state )
928 {
929 /* Consume the NUL. */
930 yy_cp = ++(yy_c_buf_p);
931 yy_current_state = yy_next_state;
932 goto yy_match;
933 }
934
935 else
936 {
937 yy_cp = (yy_last_accepting_cpos);
938 yy_current_state = (yy_last_accepting_state);
939 goto yy_find_action;
940 }
941 }
942
943 else switch ( yy_get_next_buffer( ) )
944 {
945 case EOB_ACT_END_OF_FILE:
946 {
947 (yy_did_buffer_switch_on_eof) = 0;
948
949 if ( yywrap( ) )
950 {
951 /* Note: because we've taken care in
952 * yy_get_next_buffer() to have set up
953 * yytext, we can now set up
954 * yy_c_buf_p so that if some total
955 * hoser (like flex itself) wants to
956 * call the scanner after we return the
957 * YY_NULL, it'll still work - another
958 * YY_NULL will get returned.
959 */
960 (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
961
962 yy_act = YY_STATE_EOF(YY_START);
963 goto do_action;
964 }
965
966 else
967 {
968 if ( ! (yy_did_buffer_switch_on_eof) )
969 YY_NEW_FILE;
970 }
971 break;
972 }
973
974 case EOB_ACT_CONTINUE_SCAN:
975 (yy_c_buf_p) =
976 (yytext_ptr) + yy_amount_of_matched_text;
977
978 yy_current_state = yy_get_previous_state( );
979
980 yy_cp = (yy_c_buf_p);
981 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
982 goto yy_match;
983
984 case EOB_ACT_LAST_MATCH:
985 (yy_c_buf_p) =
986 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
987
988 yy_current_state = yy_get_previous_state( );
989
990 yy_cp = (yy_c_buf_p);
991 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
992 goto yy_find_action;
993 }
994 break;
995 }
996
997 default:
998 YY_FATAL_ERROR(
999 "fatal flex scanner internal error--no action found" );
1000 } /* end of action switch */
1001 } /* end of scanning one token */
1002 } /* end of user's declarations */
1003 } /* end of yylex */
1004
1005 /* yy_get_next_buffer - try to read in a new buffer
1006 *
1007 * Returns a code representing an action:
1008 * EOB_ACT_LAST_MATCH -
1009 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1010 * EOB_ACT_END_OF_FILE - end of file
1011 */
yy_get_next_buffer(void)1012 static int yy_get_next_buffer (void)
1013 {
1014 char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
1015 char *source = (yytext_ptr);
1016 int number_to_move, i;
1017 int ret_val;
1018
1019 if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
1020 YY_FATAL_ERROR(
1021 "fatal flex scanner internal error--end of buffer missed" );
1022
1023 if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
1024 { /* Don't try to fill the buffer, so this is an EOF. */
1025 if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
1026 {
1027 /* We matched a single character, the EOB, so
1028 * treat this as a final EOF.
1029 */
1030 return EOB_ACT_END_OF_FILE;
1031 }
1032
1033 else
1034 {
1035 /* We matched some text prior to the EOB, first
1036 * process it.
1037 */
1038 return EOB_ACT_LAST_MATCH;
1039 }
1040 }
1041
1042 /* Try to read more data. */
1043
1044 /* First move last chars to start of buffer. */
1045 number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr) - 1);
1046
1047 for ( i = 0; i < number_to_move; ++i )
1048 *(dest++) = *(source++);
1049
1050 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
1051 /* don't do the read, it's not guaranteed to return an EOF,
1052 * just force an EOF
1053 */
1054 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
1055
1056 else
1057 {
1058 int num_to_read =
1059 YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
1060
1061 while ( num_to_read <= 0 )
1062 { /* Not enough room in the buffer - grow it. */
1063
1064 /* just a shorter name for the current buffer */
1065 YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE;
1066
1067 int yy_c_buf_p_offset =
1068 (int) ((yy_c_buf_p) - b->yy_ch_buf);
1069
1070 if ( b->yy_is_our_buffer )
1071 {
1072 int new_size = b->yy_buf_size * 2;
1073
1074 if ( new_size <= 0 )
1075 b->yy_buf_size += b->yy_buf_size / 8;
1076 else
1077 b->yy_buf_size *= 2;
1078
1079 b->yy_ch_buf = (char *)
1080 /* Include room in for 2 EOB chars. */
1081 yyrealloc( (void *) b->yy_ch_buf,
1082 (yy_size_t) (b->yy_buf_size + 2) );
1083 }
1084 else
1085 /* Can't grow it, we don't own it. */
1086 b->yy_ch_buf = NULL;
1087
1088 if ( ! b->yy_ch_buf )
1089 YY_FATAL_ERROR(
1090 "fatal error - scanner input buffer overflow" );
1091
1092 (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
1093
1094 num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
1095 number_to_move - 1;
1096
1097 }
1098
1099 if ( num_to_read > YY_READ_BUF_SIZE )
1100 num_to_read = YY_READ_BUF_SIZE;
1101
1102 /* Read in more data. */
1103 YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
1104 (yy_n_chars), num_to_read );
1105
1106 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1107 }
1108
1109 if ( (yy_n_chars) == 0 )
1110 {
1111 if ( number_to_move == YY_MORE_ADJ )
1112 {
1113 ret_val = EOB_ACT_END_OF_FILE;
1114 yyrestart( yyin );
1115 }
1116
1117 else
1118 {
1119 ret_val = EOB_ACT_LAST_MATCH;
1120 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
1121 YY_BUFFER_EOF_PENDING;
1122 }
1123 }
1124
1125 else
1126 ret_val = EOB_ACT_CONTINUE_SCAN;
1127
1128 if (((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
1129 /* Extend the array by 50%, plus the number we really need. */
1130 int new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
1131 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc(
1132 (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size );
1133 if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1134 YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
1135 /* "- 2" to take care of EOB's */
1136 YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2);
1137 }
1138
1139 (yy_n_chars) += number_to_move;
1140 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
1141 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
1142
1143 (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
1144
1145 return ret_val;
1146 }
1147
1148 /* yy_get_previous_state - get the state just before the EOB char was reached */
1149
yy_get_previous_state(void)1150 static yy_state_type yy_get_previous_state (void)
1151 {
1152 yy_state_type yy_current_state;
1153 char *yy_cp;
1154
1155 yy_current_state = (yy_start);
1156
1157 for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
1158 {
1159 YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
1160 if ( yy_accept[yy_current_state] )
1161 {
1162 (yy_last_accepting_state) = yy_current_state;
1163 (yy_last_accepting_cpos) = yy_cp;
1164 }
1165 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1166 {
1167 yy_current_state = (int) yy_def[yy_current_state];
1168 if ( yy_current_state >= 49 )
1169 yy_c = yy_meta[yy_c];
1170 }
1171 yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
1172 }
1173
1174 return yy_current_state;
1175 }
1176
1177 /* yy_try_NUL_trans - try to make a transition on the NUL character
1178 *
1179 * synopsis
1180 * next_state = yy_try_NUL_trans( current_state );
1181 */
yy_try_NUL_trans(yy_state_type yy_current_state)1182 static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
1183 {
1184 int yy_is_jam;
1185 char *yy_cp = (yy_c_buf_p);
1186
1187 YY_CHAR yy_c = 1;
1188 if ( yy_accept[yy_current_state] )
1189 {
1190 (yy_last_accepting_state) = yy_current_state;
1191 (yy_last_accepting_cpos) = yy_cp;
1192 }
1193 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1194 {
1195 yy_current_state = (int) yy_def[yy_current_state];
1196 if ( yy_current_state >= 49 )
1197 yy_c = yy_meta[yy_c];
1198 }
1199 yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
1200 yy_is_jam = (yy_current_state == 48);
1201
1202 return yy_is_jam ? 0 : yy_current_state;
1203 }
1204
1205 #ifndef YY_NO_UNPUT
1206
1207 #endif
1208
1209 #ifndef YY_NO_INPUT
1210 #ifdef __cplusplus
yyinput(void)1211 static int yyinput (void)
1212 #else
1213 static int input (void)
1214 #endif
1215
1216 {
1217 int c;
1218
1219 *(yy_c_buf_p) = (yy_hold_char);
1220
1221 if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
1222 {
1223 /* yy_c_buf_p now points to the character we want to return.
1224 * If this occurs *before* the EOB characters, then it's a
1225 * valid NUL; if not, then we've hit the end of the buffer.
1226 */
1227 if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
1228 /* This was really a NUL. */
1229 *(yy_c_buf_p) = '\0';
1230
1231 else
1232 { /* need more input */
1233 int offset = (int) ((yy_c_buf_p) - (yytext_ptr));
1234 ++(yy_c_buf_p);
1235
1236 switch ( yy_get_next_buffer( ) )
1237 {
1238 case EOB_ACT_LAST_MATCH:
1239 /* This happens because yy_g_n_b()
1240 * sees that we've accumulated a
1241 * token and flags that we need to
1242 * try matching the token before
1243 * proceeding. But for input(),
1244 * there's no matching to consider.
1245 * So convert the EOB_ACT_LAST_MATCH
1246 * to EOB_ACT_END_OF_FILE.
1247 */
1248
1249 /* Reset buffer status. */
1250 yyrestart( yyin );
1251
1252 /*FALLTHROUGH*/
1253
1254 case EOB_ACT_END_OF_FILE:
1255 {
1256 if ( yywrap( ) )
1257 return 0;
1258
1259 if ( ! (yy_did_buffer_switch_on_eof) )
1260 YY_NEW_FILE;
1261 #ifdef __cplusplus
1262 return yyinput();
1263 #else
1264 return input();
1265 #endif
1266 }
1267
1268 case EOB_ACT_CONTINUE_SCAN:
1269 (yy_c_buf_p) = (yytext_ptr) + offset;
1270 break;
1271 }
1272 }
1273 }
1274
1275 c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */
1276 *(yy_c_buf_p) = '\0'; /* preserve yytext */
1277 (yy_hold_char) = *++(yy_c_buf_p);
1278
1279 return c;
1280 }
1281 #endif /* ifndef YY_NO_INPUT */
1282
1283 /** Immediately switch to a different input stream.
1284 * @param input_file A readable stream.
1285 *
1286 * @note This function does not reset the start condition to @c INITIAL .
1287 */
yyrestart(FILE * input_file)1288 void yyrestart (FILE * input_file )
1289 {
1290
1291 if ( ! YY_CURRENT_BUFFER ){
1292 yyensure_buffer_stack ();
1293 YY_CURRENT_BUFFER_LVALUE =
1294 yy_create_buffer( yyin, YY_BUF_SIZE );
1295 }
1296
1297 yy_init_buffer( YY_CURRENT_BUFFER, input_file );
1298 yy_load_buffer_state( );
1299 }
1300
1301 /** Switch to a different input buffer.
1302 * @param new_buffer The new input buffer.
1303 *
1304 */
yy_switch_to_buffer(YY_BUFFER_STATE new_buffer)1305 void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer )
1306 {
1307
1308 /* TODO. We should be able to replace this entire function body
1309 * with
1310 * yypop_buffer_state();
1311 * yypush_buffer_state(new_buffer);
1312 */
1313 yyensure_buffer_stack ();
1314 if ( YY_CURRENT_BUFFER == new_buffer )
1315 return;
1316
1317 if ( YY_CURRENT_BUFFER )
1318 {
1319 /* Flush out information for old buffer. */
1320 *(yy_c_buf_p) = (yy_hold_char);
1321 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1322 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1323 }
1324
1325 YY_CURRENT_BUFFER_LVALUE = new_buffer;
1326 yy_load_buffer_state( );
1327
1328 /* We don't actually know whether we did this switch during
1329 * EOF (yywrap()) processing, but the only time this flag
1330 * is looked at is after yywrap() is called, so it's safe
1331 * to go ahead and always set it.
1332 */
1333 (yy_did_buffer_switch_on_eof) = 1;
1334 }
1335
yy_load_buffer_state(void)1336 static void yy_load_buffer_state (void)
1337 {
1338 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1339 (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
1340 yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
1341 (yy_hold_char) = *(yy_c_buf_p);
1342 }
1343
1344 /** Allocate and initialize an input buffer state.
1345 * @param file A readable stream.
1346 * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
1347 *
1348 * @return the allocated buffer state.
1349 */
yy_create_buffer(FILE * file,int size)1350 YY_BUFFER_STATE yy_create_buffer (FILE * file, int size )
1351 {
1352 YY_BUFFER_STATE b;
1353
1354 b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) );
1355 if ( ! b )
1356 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1357
1358 b->yy_buf_size = size;
1359
1360 /* yy_ch_buf has to be 2 characters longer than the size given because
1361 * we need to put in 2 end-of-buffer characters.
1362 */
1363 b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) );
1364 if ( ! b->yy_ch_buf )
1365 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1366
1367 b->yy_is_our_buffer = 1;
1368
1369 yy_init_buffer( b, file );
1370
1371 return b;
1372 }
1373
1374 /** Destroy the buffer.
1375 * @param b a buffer created with yy_create_buffer()
1376 *
1377 */
yy_delete_buffer(YY_BUFFER_STATE b)1378 void yy_delete_buffer (YY_BUFFER_STATE b )
1379 {
1380
1381 if ( ! b )
1382 return;
1383
1384 if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
1385 YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
1386
1387 if ( b->yy_is_our_buffer )
1388 yyfree( (void *) b->yy_ch_buf );
1389
1390 yyfree( (void *) b );
1391 }
1392
1393 /* Initializes or reinitializes a buffer.
1394 * This function is sometimes called more than once on the same buffer,
1395 * such as during a yyrestart() or at EOF.
1396 */
yy_init_buffer(YY_BUFFER_STATE b,FILE * file)1397 static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file )
1398
1399 {
1400 int oerrno = errno;
1401
1402 yy_flush_buffer( b );
1403
1404 b->yy_input_file = file;
1405 b->yy_fill_buffer = 1;
1406
1407 /* If b is the current buffer, then yy_init_buffer was _probably_
1408 * called from yyrestart() or through yy_get_next_buffer.
1409 * In that case, we don't want to reset the lineno or column.
1410 */
1411 if (b != YY_CURRENT_BUFFER){
1412 b->yy_bs_lineno = 1;
1413 b->yy_bs_column = 0;
1414 }
1415
1416 b->yy_is_interactive = 0;
1417
1418 errno = oerrno;
1419 }
1420
1421 /** Discard all buffered characters. On the next scan, YY_INPUT will be called.
1422 * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
1423 *
1424 */
yy_flush_buffer(YY_BUFFER_STATE b)1425 void yy_flush_buffer (YY_BUFFER_STATE b )
1426 {
1427 if ( ! b )
1428 return;
1429
1430 b->yy_n_chars = 0;
1431
1432 /* We always need two end-of-buffer characters. The first causes
1433 * a transition to the end-of-buffer state. The second causes
1434 * a jam in that state.
1435 */
1436 b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
1437 b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
1438
1439 b->yy_buf_pos = &b->yy_ch_buf[0];
1440
1441 b->yy_at_bol = 1;
1442 b->yy_buffer_status = YY_BUFFER_NEW;
1443
1444 if ( b == YY_CURRENT_BUFFER )
1445 yy_load_buffer_state( );
1446 }
1447
1448 /** Pushes the new state onto the stack. The new state becomes
1449 * the current state. This function will allocate the stack
1450 * if necessary.
1451 * @param new_buffer The new state.
1452 *
1453 */
yypush_buffer_state(YY_BUFFER_STATE new_buffer)1454 void yypush_buffer_state (YY_BUFFER_STATE new_buffer )
1455 {
1456 if (new_buffer == NULL)
1457 return;
1458
1459 yyensure_buffer_stack();
1460
1461 /* This block is copied from yy_switch_to_buffer. */
1462 if ( YY_CURRENT_BUFFER )
1463 {
1464 /* Flush out information for old buffer. */
1465 *(yy_c_buf_p) = (yy_hold_char);
1466 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1467 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1468 }
1469
1470 /* Only push if top exists. Otherwise, replace top. */
1471 if (YY_CURRENT_BUFFER)
1472 (yy_buffer_stack_top)++;
1473 YY_CURRENT_BUFFER_LVALUE = new_buffer;
1474
1475 /* copied from yy_switch_to_buffer. */
1476 yy_load_buffer_state( );
1477 (yy_did_buffer_switch_on_eof) = 1;
1478 }
1479
1480 /** Removes and deletes the top of the stack, if present.
1481 * The next element becomes the new top.
1482 *
1483 */
yypop_buffer_state(void)1484 void yypop_buffer_state (void)
1485 {
1486 if (!YY_CURRENT_BUFFER)
1487 return;
1488
1489 yy_delete_buffer(YY_CURRENT_BUFFER );
1490 YY_CURRENT_BUFFER_LVALUE = NULL;
1491 if ((yy_buffer_stack_top) > 0)
1492 --(yy_buffer_stack_top);
1493
1494 if (YY_CURRENT_BUFFER) {
1495 yy_load_buffer_state( );
1496 (yy_did_buffer_switch_on_eof) = 1;
1497 }
1498 }
1499
1500 /* Allocates the stack if it does not exist.
1501 * Guarantees space for at least one push.
1502 */
yyensure_buffer_stack(void)1503 static void yyensure_buffer_stack (void)
1504 {
1505 yy_size_t num_to_alloc;
1506
1507 if (!(yy_buffer_stack)) {
1508
1509 /* First allocation is just for 2 elements, since we don't know if this
1510 * scanner will even need a stack. We use 2 instead of 1 to avoid an
1511 * immediate realloc on the next call.
1512 */
1513 num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */
1514 (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc
1515 (num_to_alloc * sizeof(struct yy_buffer_state*)
1516 );
1517 if ( ! (yy_buffer_stack) )
1518 YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
1519
1520 memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
1521
1522 (yy_buffer_stack_max) = num_to_alloc;
1523 (yy_buffer_stack_top) = 0;
1524 return;
1525 }
1526
1527 if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
1528
1529 /* Increase the buffer to prepare for a possible push. */
1530 yy_size_t grow_size = 8 /* arbitrary grow size */;
1531
1532 num_to_alloc = (yy_buffer_stack_max) + grow_size;
1533 (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc
1534 ((yy_buffer_stack),
1535 num_to_alloc * sizeof(struct yy_buffer_state*)
1536 );
1537 if ( ! (yy_buffer_stack) )
1538 YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
1539
1540 /* zero only the new slots.*/
1541 memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
1542 (yy_buffer_stack_max) = num_to_alloc;
1543 }
1544 }
1545
1546 /** Setup the input buffer state to scan directly from a user-specified character buffer.
1547 * @param base the character buffer
1548 * @param size the size in bytes of the character buffer
1549 *
1550 * @return the newly allocated buffer state object.
1551 */
yy_scan_buffer(char * base,yy_size_t size)1552 YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size )
1553 {
1554 YY_BUFFER_STATE b;
1555
1556 if ( size < 2 ||
1557 base[size-2] != YY_END_OF_BUFFER_CHAR ||
1558 base[size-1] != YY_END_OF_BUFFER_CHAR )
1559 /* They forgot to leave room for the EOB's. */
1560 return NULL;
1561
1562 b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) );
1563 if ( ! b )
1564 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
1565
1566 b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */
1567 b->yy_buf_pos = b->yy_ch_buf = base;
1568 b->yy_is_our_buffer = 0;
1569 b->yy_input_file = NULL;
1570 b->yy_n_chars = b->yy_buf_size;
1571 b->yy_is_interactive = 0;
1572 b->yy_at_bol = 1;
1573 b->yy_fill_buffer = 0;
1574 b->yy_buffer_status = YY_BUFFER_NEW;
1575
1576 yy_switch_to_buffer( b );
1577
1578 return b;
1579 }
1580
1581 /** Setup the input buffer state to scan a string. The next call to yylex() will
1582 * scan from a @e copy of @a str.
1583 * @param yystr a NUL-terminated string to scan
1584 *
1585 * @return the newly allocated buffer state object.
1586 * @note If you want to scan bytes that may contain NUL values, then use
1587 * yy_scan_bytes() instead.
1588 */
yy_scan_string(const char * yystr)1589 YY_BUFFER_STATE yy_scan_string (const char * yystr )
1590 {
1591
1592 return yy_scan_bytes( yystr, (int) strlen(yystr) );
1593 }
1594
1595 /** Setup the input buffer state to scan the given bytes. The next call to yylex() will
1596 * scan from a @e copy of @a bytes.
1597 * @param yybytes the byte buffer to scan
1598 * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
1599 *
1600 * @return the newly allocated buffer state object.
1601 */
yy_scan_bytes(const char * yybytes,int _yybytes_len)1602 YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len )
1603 {
1604 YY_BUFFER_STATE b;
1605 char *buf;
1606 yy_size_t n;
1607 int i;
1608
1609 /* Get memory for full buffer, including space for trailing EOB's. */
1610 n = (yy_size_t) (_yybytes_len + 2);
1611 buf = (char *) yyalloc( n );
1612 if ( ! buf )
1613 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
1614
1615 for ( i = 0; i < _yybytes_len; ++i )
1616 buf[i] = yybytes[i];
1617
1618 buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
1619
1620 b = yy_scan_buffer( buf, n );
1621 if ( ! b )
1622 YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
1623
1624 /* It's okay to grow etc. this buffer, and we should throw it
1625 * away when we're done.
1626 */
1627 b->yy_is_our_buffer = 1;
1628
1629 return b;
1630 }
1631
1632 #ifndef YY_EXIT_FAILURE
1633 #define YY_EXIT_FAILURE 2
1634 #endif
1635
yy_fatal_error(const char * msg)1636 static void yynoreturn yy_fatal_error (const char* msg )
1637 {
1638 fprintf( stderr, "%s\n", msg );
1639 exit( YY_EXIT_FAILURE );
1640 }
1641
1642 /* Redefine yyless() so it works in section 3 code. */
1643
1644 #undef yyless
1645 #define yyless(n) \
1646 do \
1647 { \
1648 /* Undo effects of setting up yytext. */ \
1649 int yyless_macro_arg = (n); \
1650 YY_LESS_LINENO(yyless_macro_arg);\
1651 yytext[yyleng] = (yy_hold_char); \
1652 (yy_c_buf_p) = yytext + yyless_macro_arg; \
1653 (yy_hold_char) = *(yy_c_buf_p); \
1654 *(yy_c_buf_p) = '\0'; \
1655 yyleng = yyless_macro_arg; \
1656 } \
1657 while ( 0 )
1658
1659 /* Accessor methods (get/set functions) to struct members. */
1660
1661 /** Get the current line number.
1662 *
1663 */
yyget_lineno(void)1664 int yyget_lineno (void)
1665 {
1666
1667 return yylineno;
1668 }
1669
1670 /** Get the input stream.
1671 *
1672 */
yyget_in(void)1673 FILE *yyget_in (void)
1674 {
1675 return yyin;
1676 }
1677
1678 /** Get the output stream.
1679 *
1680 */
yyget_out(void)1681 FILE *yyget_out (void)
1682 {
1683 return yyout;
1684 }
1685
1686 /** Get the length of the current token.
1687 *
1688 */
yyget_leng(void)1689 int yyget_leng (void)
1690 {
1691 return yyleng;
1692 }
1693
1694 /** Get the current token.
1695 *
1696 */
1697
yyget_text(void)1698 char *yyget_text (void)
1699 {
1700 return yytext;
1701 }
1702
1703 /** Set the current line number.
1704 * @param _line_number line number
1705 *
1706 */
yyset_lineno(int _line_number)1707 void yyset_lineno (int _line_number )
1708 {
1709
1710 yylineno = _line_number;
1711 }
1712
1713 /** Set the input stream. This does not discard the current
1714 * input buffer.
1715 * @param _in_str A readable stream.
1716 *
1717 * @see yy_switch_to_buffer
1718 */
yyset_in(FILE * _in_str)1719 void yyset_in (FILE * _in_str )
1720 {
1721 yyin = _in_str ;
1722 }
1723
yyset_out(FILE * _out_str)1724 void yyset_out (FILE * _out_str )
1725 {
1726 yyout = _out_str ;
1727 }
1728
yyget_debug(void)1729 int yyget_debug (void)
1730 {
1731 return yy_flex_debug;
1732 }
1733
yyset_debug(int _bdebug)1734 void yyset_debug (int _bdebug )
1735 {
1736 yy_flex_debug = _bdebug ;
1737 }
1738
yy_init_globals(void)1739 static int yy_init_globals (void)
1740 {
1741 /* Initialization is the same as for the non-reentrant scanner.
1742 * This function is called from yylex_destroy(), so don't allocate here.
1743 */
1744
1745 (yy_buffer_stack) = NULL;
1746 (yy_buffer_stack_top) = 0;
1747 (yy_buffer_stack_max) = 0;
1748 (yy_c_buf_p) = NULL;
1749 (yy_init) = 0;
1750 (yy_start) = 0;
1751
1752 /* Defined in main.c */
1753 #ifdef YY_STDINIT
1754 yyin = stdin;
1755 yyout = stdout;
1756 #else
1757 yyin = NULL;
1758 yyout = NULL;
1759 #endif
1760
1761 /* For future reference: Set errno on error, since we are called by
1762 * yylex_init()
1763 */
1764 return 0;
1765 }
1766
1767 /* yylex_destroy is for both reentrant and non-reentrant scanners. */
yylex_destroy(void)1768 int yylex_destroy (void)
1769 {
1770
1771 /* Pop the buffer stack, destroying each element. */
1772 while(YY_CURRENT_BUFFER){
1773 yy_delete_buffer( YY_CURRENT_BUFFER );
1774 YY_CURRENT_BUFFER_LVALUE = NULL;
1775 yypop_buffer_state();
1776 }
1777
1778 /* Destroy the stack itself. */
1779 yyfree((yy_buffer_stack) );
1780 (yy_buffer_stack) = NULL;
1781
1782 /* Reset the globals. This is important in a non-reentrant scanner so the next time
1783 * yylex() is called, initialization will occur. */
1784 yy_init_globals( );
1785
1786 return 0;
1787 }
1788
1789 /*
1790 * Internal utility routines.
1791 */
1792
1793 #ifndef yytext_ptr
yy_flex_strncpy(char * s1,const char * s2,int n)1794 static void yy_flex_strncpy (char* s1, const char * s2, int n )
1795 {
1796
1797 int i;
1798 for ( i = 0; i < n; ++i )
1799 s1[i] = s2[i];
1800 }
1801 #endif
1802
1803 #ifdef YY_NEED_STRLEN
yy_flex_strlen(const char * s)1804 static int yy_flex_strlen (const char * s )
1805 {
1806 int n;
1807 for ( n = 0; s[n]; ++n )
1808 ;
1809
1810 return n;
1811 }
1812 #endif
1813
yyalloc(yy_size_t size)1814 void *yyalloc (yy_size_t size )
1815 {
1816 return malloc(size);
1817 }
1818
yyrealloc(void * ptr,yy_size_t size)1819 void *yyrealloc (void * ptr, yy_size_t size )
1820 {
1821
1822 /* The cast to (char *) in the following accommodates both
1823 * implementations that use char* generic pointers, and those
1824 * that use void* generic pointers. It works with the latter
1825 * because both ANSI C and C++ allow castless assignment from
1826 * any pointer type to void*, and deal with argument conversions
1827 * as though doing an assignment.
1828 */
1829 return realloc(ptr, size);
1830 }
1831
yyfree(void * ptr)1832 void yyfree (void * ptr )
1833 {
1834 free( (char *) ptr ); /* see yyrealloc() for (char *) cast */
1835 }
1836
1837 #define YYTABLES_NAME "yytables"
1838
1839 #line 86 "conf-file.l"
1840
1841
1842 struct name_value_pair
1843 {
1844 char *name;
1845 char *value;
1846 struct name_value_pair *next;
1847 };
1848
1849 /*
1850 * Free a list of name/value pairs, including the names and the values
1851 */
1852 static void
free_name_value_list(struct name_value_pair * list)1853 free_name_value_list(struct name_value_pair * list)
1854 {
1855 struct name_value_pair *item;
1856
1857 item = list;
1858 while (item)
1859 {
1860 struct name_value_pair *save;
1861
1862 save = item->next;
1863 free(item->name);
1864 free(item->value);
1865 free(item);
1866 item = save;
1867 }
1868 }
1869
ProcessConfigFile(const char * filename)1870 void ProcessConfigFile(const char *filename)
1871 {
1872 int token, parse_state;
1873 char *opt_name, *opt_value;
1874 int elevel;
1875 struct name_value_pair *item, *head, *tail;
1876 FILE * fp;
1877
1878 elevel = SLON_ERROR;
1879
1880 /*
1881 * Open the conf file
1882 */
1883 if (filename == NULL)
1884 {
1885 fp = fopen(CONFIG_FILENAME, "r");
1886 }
1887 else
1888 {
1889 fp = fopen(filename, "r");
1890 }
1891 if (!fp)
1892 {
1893 /* File not found is fine */
1894 if (errno != ENOENT)
1895 {
1896 slon_log(elevel,"could not open configuration file \"%s\"\n", filename);
1897
1898 }
1899 return;
1900 }
1901
1902 /* Ok we have the file, lets parse it */
1903
1904 yyin = fp;
1905 parse_state = 0;
1906 head = NULL;
1907 tail = head;
1908 opt_name = NULL;
1909 opt_value = opt_name;
1910
1911 while ( (token = yylex()) )
1912 {
1913 switch(parse_state)
1914 {
1915 case 0:
1916 if (token == SLON_EOL) /* empty line */
1917 {
1918 continue;
1919 }
1920 if (token != SLON_ID && token != SLON_QUALIFIED_ID)
1921 {
1922 goto parse_error;
1923 }
1924 opt_name = strdup(yytext);
1925 parse_state = 1;
1926 break;
1927 case 1:
1928 /* ignore equals sign */
1929 if (token == SLON_EQUALS)
1930 {
1931 token = yylex();
1932 }
1933 if (token != SLON_ID && token != SLON_STRING && token != SLON_INTEGER && token != SLON_REAL && token != SLON_UNQUOTED_STRING && token != SLON_ESCAPED_STRING)
1934 {
1935 goto parse_error;
1936 }
1937 opt_value = strdup(yytext);
1938 if (token == SLON_STRING || token == SLON_ESCAPED_STRING)
1939 {
1940 memmove(opt_value,opt_value+1,strlen(opt_value)-1);
1941 opt_value[strlen(opt_value)-2]='\0';
1942 opt_value=SLON_scanstr(opt_value);
1943 }
1944 parse_state = 2;
1945 break;
1946 case 2: /* OEL ? */
1947 if (token != SLON_EOL)
1948 {
1949 goto parse_error;
1950 }
1951 item = malloc(sizeof *item);
1952 item->name = opt_name;
1953 item->value = opt_value;
1954
1955 if (strcmp(opt_name, "custom_variable_classes") == 0)
1956 {
1957 item->next = head;
1958 head = item;
1959 if (!tail)
1960 {
1961 tail = item;
1962 }
1963 }
1964 else
1965 {
1966 /* append to list */
1967 item->next = NULL;
1968 if (!head)
1969 {
1970 head = item;
1971 }
1972 else
1973 {
1974 tail->next = item;
1975 }
1976 tail = item;
1977 }
1978 parse_state = 0;
1979 break;
1980 }
1981 }
1982 /*
1983 * If we encountered an EOF after we've already
1984 * reached parse_state of 2, we already have a complete
1985 * configuration line, it's just terminated with EOF
1986 * instead of EOL. Store that config option.
1987 */
1988 if(parse_state == 2)
1989 {
1990 item = malloc(sizeof *item);
1991 item->name = opt_name;
1992 item->value = opt_value;
1993 if (strcmp(opt_name, "custom_variable_classes") == 0)
1994 {
1995 item->next = head;
1996 head = item;
1997 if (!tail)
1998 {
1999 tail = item;
2000 }
2001 }
2002 else
2003 {
2004 /* append to list */
2005 item->next = NULL;
2006 if (!head)
2007 {
2008 head = item;
2009 }
2010 else
2011 {
2012 tail->next = item;
2013 }
2014 tail = item;
2015 }
2016 parse_state = 0;
2017 }
2018
2019 fclose(fp);
2020
2021 for(item = head; item; item=item->next)
2022 {
2023 set_config_option(item->name, item->value);
2024 }
2025
2026 cleanup_exit:
2027 free_name_value_list(head);
2028 return;
2029
2030 parse_error:
2031 fclose(fp);
2032 free_name_value_list(head);
2033 if (token == SLON_EOL)
2034 {
2035 slon_log(elevel, "syntax error in file \"%s\" line %u, near end of line\n", filename, ConfigFileLineno - 1);
2036 }
2037
2038 else
2039 {
2040 slon_log(elevel, "syntax error in file \"%s\" line %u, near end of line\n", filename, ConfigFileLineno - 1);
2041 }
2042 }
2043
2044
2045
2046
2047
2048
2049
SLON_scanstr(char * s)2050 char *SLON_scanstr(char *s)
2051 {
2052 char *newStr;
2053 int len,
2054 i,
2055 j;
2056
2057 if (s == NULL || s[0] == '\0')
2058 {
2059 if (s != NULL)
2060 free(s);
2061 return strdup("");
2062 }
2063 len = strlen(s);
2064
2065 newStr = malloc(len + 1); /* string cannot get longer */
2066 if (newStr == NULL)
2067 slon_log(SLON_FATAL, "out of memory\n");
2068
2069 for (i = 0, j = 0; i < len; i++)
2070 {
2071 if (s[i] == '\\')
2072 {
2073 i++;
2074 switch (s[i])
2075 {
2076 case 'b':
2077 newStr[j] = '\b';
2078 break;
2079 case 'f':
2080 newStr[j] = '\f';
2081 break;
2082 case 'n':
2083 newStr[j] = '\n';
2084 break;
2085 case 'r':
2086 newStr[j] = '\r';
2087 break;
2088 case 't':
2089 newStr[j] = '\t';
2090 break;
2091 case '0':
2092 case '1':
2093 case '2':
2094 case '3':
2095 case '4':
2096 case '5':
2097 case '6':
2098 case '7':
2099 {
2100 int k;
2101 long octVal = 0;
2102
2103 for (k = 0;
2104 s[i + k] >= '0' && s[i
2105 + k] <= '7' && k < 3;
2106 k++)
2107 octVal = (octVal << 3) +
2108 (s[i + k] - '0');
2109 i += k - 1;
2110 newStr[j] = ((char) octVal);
2111 }
2112 break;
2113 default:
2114 newStr[j] = s[i];
2115 break;
2116 }
2117 } /* switch */
2118 else
2119 newStr[j] = s[i];
2120 j++;
2121 }
2122 newStr[j] = '\0';
2123 free(s);
2124 return newStr;
2125 }
2126
2127 /*
2128 * Local Variables:
2129 * tab-width: 4
2130 * c-indent-level: 4
2131 * c-basic-offset: 4
2132 * End:
2133 */
2134
2135