diff options
Diffstat (limited to 'include/argot/table.h')
-rw-r--r-- | include/argot/table.h | 102 |
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 @@ +/* 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 |