1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
/* argot - Gray's Extensible Configuration System -*- c -*-
Copyright (C) 2007-2016 Sergey Poznyakoff
Grecs is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version.
Grecs is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with Grecs. If not, see <http://www.gnu.org/licenses/>. */
#ifndef _ARGOT_TABLE_H
#define _ARGOT_TABLE_H
#include <argot/node.h>
enum argot_data_type {
argot_type_void,
argot_type_string,
argot_type_short,
argot_type_ushort,
argot_type_int,
argot_type_uint,
argot_type_long,
argot_type_ulong,
argot_type_size,
/* argot_type_off,*/
argot_type_time,
argot_type_bool,
argot_type_ipv4,
argot_type_cidr,
argot_type_host,
argot_type_sockaddr,
argot_type_section,
argot_type_null
};
#define ARGOT_DFLT 0x00 /* Default keyword flags */
#define ARGOT_AGGR 0x01 /* Multiple entries aggregate */
#define ARGOT_MULT 0x02 /* Statement can appear multiple times */
#define ARGOT_INAC 0x04 /* Inactive keyword */
#define ARGOT_LIST 0x08 /* Value is a list of declared type */
#define ARGOT_HIDDEN 0x10 /* Hidden keyword: don't display in help output */
#define ARGOT_CONST 0x20 /* For string types: initial value is constant,
don't try to free it before assigning new value.
This flag is cleared after the first assignment.
*/
enum argot_callback_command {
argot_callback_section_begin,
argot_callback_section_end,
argot_callback_set_value
};
typedef int (*argot_callback_fn)(
#if ARGOT_TREE_API
enum argot_callback_command cmd,
argot_node_t * /* node */,
void * /* varptr */,
void * /* cb_data */
#else
enum argot_callback_command cmd,
argot_locus_t * /* locus */,
void * /* varptr */,
argot_value_t * /* value */,
void * /* cb_data */
#endif
);
struct argot_keyword {
const char *ident;
const char *argname;
const char *docstring;
enum argot_data_type type;
int flags;
void *varptr;
size_t offset;
argot_callback_fn callback;
void *callback_data;
struct argot_keyword *kwd;
};
extern int argot_string_convert(void *target, enum argot_data_type type,
const char *string,
argot_locus_t const *locus);
extern void argot_process_ident(struct argot_keyword *kwp,
argot_value_t *value,
void *base,
argot_locus_t *locus);
const char *argot_data_type_string(enum argot_data_type type);
int argot_tree_process(struct argot_node *node, struct argot_keyword *kwd);
int argot_tree_reduce(struct argot_node *node, struct argot_keyword *kwd,
int flags);
#endif
|