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

Return to:

Send suggestions and report system problems to the System administrator.