libt3config
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
config_internal.h
1 /* Copyright (C) 2011-2012 G.P. Halkes
2  This program is free software: you can redistribute it and/or modify
3  it under the terms of the GNU General Public License version 3, as
4  published by the Free Software Foundation.
5 
6  This program is distributed in the hope that it will be useful,
7  but WITHOUT ANY WARRANTY; without even the implied warranty of
8  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9  GNU General Public License for more details.
10 
11  You should have received a copy of the GNU General Public License
12  along with this program. If not, see <http://www.gnu.org/licenses/>.
13 */
14 #ifndef T3_CONFIG_INTERNAL_H
15 #define T3_CONFIG_INTERNAL_H
16 #include "config.h"
17 
18 #include "expression.h"
19 
20 typedef struct {
21  char *file_name;
22  int count;
23 } file_name_t;
24 
25 struct t3_config_t {
26  t3_config_type_t type;
27  int line_number;
28  struct t3_config_t *next;
29  char *name;
30  file_name_t *file_name;
31  union {
32  const void *ptr; /* First member can be assigned. */
33  char *string;
34  int integer;
35  double number;
36  struct t3_config_t *list;
37  t3_bool boolean;
38  expr_node_t *expr;
39  } value;
40 };
41 
42 enum {
43  T3_CONFIG_SCHEMA = 128,
44  T3_CONFIG_EXPRESSION,
45  T3_CONFIG_ANY
46 };
47 
48 #ifndef YY_TYPEDEF_YY_SCANNER_T
49 #define YY_TYPEDEF_YY_SCANNER_T
50 typedef void* yyscan_t;
51 #endif
52 
53 #define SCAN_FILE 0
54 #define SCAN_BUFFER 1
55 
56 typedef struct {
57  yyscan_t scanner;
58  void *result;
59 
60  int scan_type;
61  FILE *file;
62  const char *buffer;
63  size_t buffer_size,
64  buffer_idx;
65 
66  int line_number;
67  void *LLthis;
68  t3_bool constraint_parser;
69  const t3_config_opts_t *opts;
70  char *error_extra;
71 
72  t3_config_t *current_section; /* Used only for including files, to hold the current section. */
73  t3_config_t *included; /* Holds a list of included files (strings). */
74 } parse_context_t;
75 
76 T3_CONFIG_LOCAL char *_t3_config_get_text(yyscan_t scanner);
77 T3_CONFIG_LOCAL parse_context_t *_t3_config_get_extra(yyscan_t scanner);
78 T3_CONFIG_LOCAL void _t3_config_set_extra(parse_context_t *extra, yyscan_t scanner);
79 T3_CONFIG_LOCAL int _t3_config_lex(yyscan_t scanner);
80 T3_CONFIG_LOCAL int _t3_config_lex_init(yyscan_t *scanner);
81 T3_CONFIG_LOCAL int _t3_config_lex_init_extra(parse_context_t *extra, yyscan_t *scanner);
82 T3_CONFIG_LOCAL int _t3_config_lex_destroy(yyscan_t scanner);
83 T3_CONFIG_LOCAL void _t3_config_set_in(FILE *in_str, yyscan_t scanner);
84 #endif