mirror of
https://github.com/servalproject/serval-dna.git
synced 2024-12-18 20:57:56 +00:00
Refactor configuration schema code
Replace 'parsefunc' (cf_opt_foo) function arguments in schema declarations with 'repr' (foo) names, which are used to declare cf_opt_foo and cf_fmt_foo.
This commit is contained in:
parent
5518859b66
commit
14ce5af688
133
conf.h
133
conf.h
@ -303,15 +303,15 @@ struct pattern_list {
|
||||
// Generate config struct definitions, struct config_NAME.
|
||||
#define STRUCT(__name, __validator...) \
|
||||
struct config_##__name {
|
||||
#define NODE(__type, __element, __default, __parser, __flags, __comment) \
|
||||
#define NODE(__type, __element, __default, __repr, __flags, __comment) \
|
||||
__type __element;
|
||||
#define ATOM(__type, __element, __default, __parser, __flags, __comment) \
|
||||
#define ATOM(__type, __element, __default, __repr, __flags, __comment) \
|
||||
__type __element;
|
||||
#define STRING(__size, __element, __default, __parser, __flags, __comment) \
|
||||
#define STRING(__size, __element, __default, __repr, __flags, __comment) \
|
||||
char __element[__size + 1];
|
||||
#define SUB_STRUCT(__name, __element, __flags) \
|
||||
struct config_##__name __element;
|
||||
#define NODE_STRUCT(__name, __element, __parser, __flags) \
|
||||
#define NODE_STRUCT(__name, __element, __repr, __flags) \
|
||||
struct config_##__name __element;
|
||||
#define END_STRUCT \
|
||||
};
|
||||
@ -319,19 +319,19 @@ struct pattern_list {
|
||||
struct config_##__name { \
|
||||
unsigned ac; \
|
||||
struct config_##__name##__element {
|
||||
#define KEY_ATOM(__type, __eltparser, __cmpfunc...) \
|
||||
#define KEY_ATOM(__type, __keyrepr, __cmpfunc...) \
|
||||
__type key;
|
||||
#define KEY_STRING(__strsize, __eltparser, __cmpfunc...) \
|
||||
#define KEY_STRING(__strsize, __keyrepr, __cmpfunc...) \
|
||||
char key[(__strsize) + 1];
|
||||
#define VALUE_ATOM(__type, __eltparser) \
|
||||
#define VALUE_ATOM(__type, __eltrepr) \
|
||||
__type value;
|
||||
#define VALUE_STRING(__strsize, __eltparser) \
|
||||
#define VALUE_STRING(__strsize, __eltrepr) \
|
||||
char value[(__strsize) + 1];
|
||||
#define VALUE_NODE(__type, __eltparser) \
|
||||
#define VALUE_NODE(__type, __eltrepr) \
|
||||
__type value;
|
||||
#define VALUE_SUB_STRUCT(__structname) \
|
||||
struct config_##__structname value;
|
||||
#define VALUE_NODE_STRUCT(__structname, __eltparser) \
|
||||
#define VALUE_NODE_STRUCT(__structname, __eltrepr) \
|
||||
struct config_##__structname value;
|
||||
#define END_ARRAY(__size) \
|
||||
} av[(__size)]; \
|
||||
@ -358,22 +358,22 @@ struct pattern_list {
|
||||
#define STRUCT(__name, __validator...) \
|
||||
int cf_dfl_config_##__name(struct config_##__name *s); \
|
||||
int cf_sch_config_##__name(struct cf_om_node **parentp);
|
||||
#define NODE(__type, __element, __default, __parser, __flags, __comment)
|
||||
#define ATOM(__type, __element, __default, __parser, __flags, __comment)
|
||||
#define STRING(__size, __element, __default, __parser, __flags, __comment)
|
||||
#define NODE(__type, __element, __default, __repr, __flags, __comment)
|
||||
#define ATOM(__type, __element, __default, __repr, __flags, __comment)
|
||||
#define STRING(__size, __element, __default, __repr, __flags, __comment)
|
||||
#define SUB_STRUCT(__name, __element, __flags)
|
||||
#define NODE_STRUCT(__name, __element, __parser, __flags)
|
||||
#define NODE_STRUCT(__name, __element, __repr, __flags)
|
||||
#define END_STRUCT
|
||||
#define ARRAY(__name, __flags, __validator...) \
|
||||
int cf_dfl_config_##__name(struct config_##__name *a); \
|
||||
int cf_sch_config_##__name(struct cf_om_node **parentp);
|
||||
#define KEY_ATOM(__type, __eltparser, __cmpfunc...)
|
||||
#define KEY_STRING(__strsize, __eltparser, __cmpfunc...)
|
||||
#define VALUE_ATOM(__type, __eltparser)
|
||||
#define VALUE_STRING(__strsize, __eltparser)
|
||||
#define VALUE_NODE(__type, __eltparser)
|
||||
#define KEY_ATOM(__type, __keyrepr, __cmpfunc...)
|
||||
#define KEY_STRING(__strsize, __keyrepr, __cmpfunc...)
|
||||
#define VALUE_ATOM(__type, __eltrepr)
|
||||
#define VALUE_STRING(__strsize, __eltrepr)
|
||||
#define VALUE_NODE(__type, __eltrepr)
|
||||
#define VALUE_SUB_STRUCT(__structname)
|
||||
#define VALUE_NODE_STRUCT(__structname, __eltparser)
|
||||
#define VALUE_NODE_STRUCT(__structname, __eltrepr)
|
||||
#define END_ARRAY(__size)
|
||||
#include "conf_schema.h"
|
||||
#undef STRUCT
|
||||
@ -400,34 +400,39 @@ struct pattern_list {
|
||||
#define STRUCT(__name, __validator...) \
|
||||
int cf_opt_config_##__name(struct config_##__name *, const struct cf_om_node *); \
|
||||
__VALIDATOR(__name, ##__validator)
|
||||
#define NODE(__type, __element, __default, __parser, __flags, __comment) \
|
||||
int __parser(__type *, const struct cf_om_node *);
|
||||
#define ATOM(__type, __element, __default, __parser, __flags, __comment) \
|
||||
int __parser(__type *, const char *);
|
||||
#define STRING(__size, __element, __default, __parser, __flags, __comment) \
|
||||
int __parser(char *, size_t, const char *);
|
||||
#define NODE(__type, __element, __default, __repr, __flags, __comment) \
|
||||
int cf_opt_##__repr(__type *, const struct cf_om_node *); \
|
||||
char * cf_fmt_##__repr(const __type *);
|
||||
#define ATOM(__type, __element, __default, __repr, __flags, __comment) \
|
||||
int cf_opt_##__repr(__type *, const char *); \
|
||||
char * cf_fmt_##__repr(const __type *);
|
||||
#define STRING(__size, __element, __default, __repr, __flags, __comment) \
|
||||
int cf_opt_##__repr(char *, size_t, const char *); \
|
||||
char * cf_fmt_##__repr(const char *);
|
||||
#define SUB_STRUCT(__name, __element, __flags) \
|
||||
int cf_opt_config_##__name(struct config_##__name *, const struct cf_om_node *);
|
||||
#define NODE_STRUCT(__name, __element, __parser, __flags) \
|
||||
int __parser(struct config_##__name *, const struct cf_om_node *);
|
||||
int cf_opt_config_##__name(struct config_##__name *, const struct cf_om_node *); \
|
||||
struct cf_om_node * cf_fmt_config_##__name(struct config_##__name *);
|
||||
#define NODE_STRUCT(__name, __element, __repr, __flags) \
|
||||
int cf_opt_##__repr(struct config_##__name *, const struct cf_om_node *); \
|
||||
struct cf_om_node * cf_fmt_##__repr(struct config_##__name *);
|
||||
#define END_STRUCT
|
||||
#define ARRAY(__name, __flags, __validator...) \
|
||||
int cf_opt_config_##__name(struct config_##__name *, const struct cf_om_node *); \
|
||||
__VALIDATOR(__name, ##__validator)
|
||||
#define KEY_ATOM(__type, __eltparser, __cmpfunc...) \
|
||||
int __eltparser(__type *, const char *);
|
||||
#define KEY_STRING(__strsize, __eltparser, __cmpfunc...) \
|
||||
int __eltparser(char *, size_t, const char *);
|
||||
#define VALUE_ATOM(__type, __eltparser) \
|
||||
int __eltparser(__type *, const char *);
|
||||
#define VALUE_STRING(__strsize, __eltparser) \
|
||||
int __eltparser(char *, size_t, const char *);
|
||||
#define VALUE_NODE(__type, __eltparser) \
|
||||
int __eltparser(__type *, const struct cf_om_node *);
|
||||
#define KEY_ATOM(__type, __keyrepr, __cmpfunc...) \
|
||||
int cf_opt_##__keyrepr(__type *, const char *);
|
||||
#define KEY_STRING(__strsize, __keyrepr, __cmpfunc...) \
|
||||
int cf_opt_##__keyrepr(char *, size_t, const char *);
|
||||
#define VALUE_ATOM(__type, __eltrepr) \
|
||||
int cf_opt_##__eltrepr(__type *, const char *);
|
||||
#define VALUE_STRING(__strsize, __eltrepr) \
|
||||
int cf_opt_##__eltrepr(char *, size_t, const char *);
|
||||
#define VALUE_NODE(__type, __eltrepr) \
|
||||
int cf_opt_##__eltrepr(__type *, const struct cf_om_node *);
|
||||
#define VALUE_SUB_STRUCT(__structname) \
|
||||
int cf_opt_config_##__structname(struct config_##__structname *, const struct cf_om_node *);
|
||||
#define VALUE_NODE_STRUCT(__structname, __eltparser) \
|
||||
int __eltparser(struct config_##__structname *, const struct cf_om_node *);
|
||||
#define VALUE_NODE_STRUCT(__structname, __eltrepr) \
|
||||
int cf_opt_##__eltrepr(struct config_##__structname *, const struct cf_om_node *);
|
||||
#define END_ARRAY(__size)
|
||||
#include "conf_schema.h"
|
||||
#undef __VALIDATOR
|
||||
@ -450,23 +455,23 @@ struct pattern_list {
|
||||
|
||||
// Generate config array key comparison function prototypes.
|
||||
#define STRUCT(__name, __validator...)
|
||||
#define NODE(__type, __element, __default, __parser, __flags, __comment)
|
||||
#define ATOM(__type, __element, __default, __parser, __flags, __comment)
|
||||
#define STRING(__size, __element, __default, __parser, __flags, __comment)
|
||||
#define NODE(__type, __element, __default, __repr, __flags, __comment)
|
||||
#define ATOM(__type, __element, __default, __repr, __flags, __comment)
|
||||
#define STRING(__size, __element, __default, __repr, __flags, __comment)
|
||||
#define SUB_STRUCT(__name, __element, __flags)
|
||||
#define NODE_STRUCT(__name, __element, __parser, __flags)
|
||||
#define NODE_STRUCT(__name, __element, __repr, __flags)
|
||||
#define END_STRUCT
|
||||
#define ARRAY(__name, __flags, __validator...) \
|
||||
typedef int __compare_func__config_##__name##__t
|
||||
#define KEY_ATOM(__type, __eltparser, __cmpfunc...) \
|
||||
#define KEY_ATOM(__type, __keyrepr, __cmpfunc...) \
|
||||
(const __type *, const __type *);
|
||||
#define KEY_STRING(__strsize, __eltparser, __cmpfunc...) \
|
||||
#define KEY_STRING(__strsize, __keyrepr, __cmpfunc...) \
|
||||
(const char *, const char *);
|
||||
#define VALUE_ATOM(__type, __eltparser)
|
||||
#define VALUE_STRING(__strsize, __eltparser)
|
||||
#define VALUE_NODE(__type, __eltparser)
|
||||
#define VALUE_ATOM(__type, __eltrepr)
|
||||
#define VALUE_STRING(__strsize, __eltrepr)
|
||||
#define VALUE_NODE(__type, __eltrepr)
|
||||
#define VALUE_SUB_STRUCT(__structname)
|
||||
#define VALUE_NODE_STRUCT(__structname, __eltparser)
|
||||
#define VALUE_NODE_STRUCT(__structname, __eltrepr)
|
||||
#define END_ARRAY(__size)
|
||||
#include "conf_schema.h"
|
||||
#undef ARRAY
|
||||
@ -474,9 +479,9 @@ struct pattern_list {
|
||||
#undef KEY_STRING
|
||||
#define ARRAY(__name, __flags, __validator...) \
|
||||
__compare_func__config_##__name##__t __dummy__compare_func__config_##__name
|
||||
#define KEY_ATOM(__type, __eltparser, __cmpfunc...) \
|
||||
#define KEY_ATOM(__type, __keyrepr, __cmpfunc...) \
|
||||
,##__cmpfunc;
|
||||
#define KEY_STRING(__strsize, __eltparser, __cmpfunc...) \
|
||||
#define KEY_STRING(__strsize, __keyrepr, __cmpfunc...) \
|
||||
,##__cmpfunc;
|
||||
#include "conf_schema.h"
|
||||
#undef STRUCT
|
||||
@ -498,23 +503,23 @@ struct pattern_list {
|
||||
|
||||
// Generate config array search-by-key function prototypes.
|
||||
#define STRUCT(__name, __validator...)
|
||||
#define NODE(__type, __element, __default, __parser, __flags, __comment)
|
||||
#define ATOM(__type, __element, __default, __parser, __flags, __comment)
|
||||
#define STRING(__size, __element, __default, __parser, __flags, __comment)
|
||||
#define NODE(__type, __element, __default, __repr, __flags, __comment)
|
||||
#define ATOM(__type, __element, __default, __repr, __flags, __comment)
|
||||
#define STRING(__size, __element, __default, __repr, __flags, __comment)
|
||||
#define SUB_STRUCT(__name, __element, __flags)
|
||||
#define NODE_STRUCT(__name, __element, __parser, __flags)
|
||||
#define NODE_STRUCT(__name, __element, __repr, __flags)
|
||||
#define END_STRUCT
|
||||
#define ARRAY(__name, __flags, __validator...) \
|
||||
int config_##__name##__get(const struct config_##__name *,
|
||||
#define KEY_ATOM(__type, __eltparser, __cmpfunc...) \
|
||||
#define KEY_ATOM(__type, __keyrepr, __cmpfunc...) \
|
||||
const __type *);
|
||||
#define KEY_STRING(__strsize, __eltparser, __cmpfunc...) \
|
||||
#define KEY_STRING(__strsize, __keyrepr, __cmpfunc...) \
|
||||
const char *);
|
||||
#define VALUE_ATOM(__type, __eltparser)
|
||||
#define VALUE_STRING(__strsize, __eltparser)
|
||||
#define VALUE_NODE(__type, __eltparser)
|
||||
#define VALUE_ATOM(__type, __eltrepr)
|
||||
#define VALUE_STRING(__strsize, __eltrepr)
|
||||
#define VALUE_NODE(__type, __eltrepr)
|
||||
#define VALUE_SUB_STRUCT(__structname)
|
||||
#define VALUE_NODE_STRUCT(__structname, __eltparser)
|
||||
#define VALUE_NODE_STRUCT(__structname, __eltrepr)
|
||||
#define END_ARRAY(__size)
|
||||
#include "conf_schema.h"
|
||||
#undef STRUCT
|
||||
@ -555,6 +560,8 @@ int cf_opt_interface_type(short *typep, const char *text);
|
||||
int cf_opt_pattern_list(struct pattern_list *listp, const char *text);
|
||||
int cf_opt_network_interface(struct config_network_interface *nifp, const struct cf_om_node *node);
|
||||
int cf_opt_interface_list(struct config_interface_list *listp, const struct cf_om_node *node);
|
||||
int cf_opt_socket_type(int *typep, const char *text);
|
||||
int cf_opt_encapsulation(int *typep, const char *text);
|
||||
|
||||
extern int cf_limbo;
|
||||
extern struct config_main config;
|
||||
|
148
conf_parse.c
148
conf_parse.c
@ -24,15 +24,15 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
// Generate config set-default function definitions, cf_dfl_config_NAME().
|
||||
#define STRUCT(__name, __validator...) \
|
||||
int cf_dfl_config_##__name(struct config_##__name *s) {
|
||||
#define NODE(__type, __element, __default, __parser, __flags, __comment) \
|
||||
#define NODE(__type, __element, __default, __repr, __flags, __comment) \
|
||||
s->__element = (__default);
|
||||
#define ATOM(__type, __element, __default, __parser, __flags, __comment) \
|
||||
#define ATOM(__type, __element, __default, __repr, __flags, __comment) \
|
||||
s->__element = (__default);
|
||||
#define STRING(__size, __element, __default, __parser, __flags, __comment) \
|
||||
#define STRING(__size, __element, __default, __repr, __flags, __comment) \
|
||||
strncpy(s->__element, (__default), (__size))[(__size)] = '\0';
|
||||
#define SUB_STRUCT(__name, __element, __flags) \
|
||||
cf_dfl_config_##__name(&s->__element);
|
||||
#define NODE_STRUCT(__name, __element, __parser, __flags) \
|
||||
#define NODE_STRUCT(__name, __element, __repr, __flags) \
|
||||
cf_dfl_config_##__name(&s->__element);
|
||||
#define END_STRUCT \
|
||||
return CFOK; \
|
||||
@ -42,13 +42,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
a->ac = 0; \
|
||||
return CFOK; \
|
||||
}
|
||||
#define KEY_ATOM(__type, __keyparser, __cmpfunc...)
|
||||
#define KEY_STRING(__strsize, __keyparser, __cmpfunc...)
|
||||
#define VALUE_ATOM(__type, __eltparser)
|
||||
#define VALUE_STRING(__strsize, __eltparser)
|
||||
#define VALUE_NODE(__type, __eltparser)
|
||||
#define KEY_ATOM(__type, __keyrepr, __cmpfunc...)
|
||||
#define KEY_STRING(__strsize, __keyrepr, __cmpfunc...)
|
||||
#define VALUE_ATOM(__type, __eltrepr)
|
||||
#define VALUE_STRING(__strsize, __eltrepr)
|
||||
#define VALUE_NODE(__type, __eltrepr)
|
||||
#define VALUE_SUB_STRUCT(__structname)
|
||||
#define VALUE_NODE_STRUCT(__structname, __eltparser)
|
||||
#define VALUE_NODE_STRUCT(__structname, __eltrepr)
|
||||
#define END_ARRAY(__size)
|
||||
#include "conf_schema.h"
|
||||
#undef STRUCT
|
||||
@ -70,26 +70,26 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
// Generate array element comparison functions.
|
||||
#define STRUCT(__name, __validator...)
|
||||
#define NODE(__type, __element, __default, __parser, __flags, __comment)
|
||||
#define ATOM(__type, __element, __default, __parser, __flags, __comment)
|
||||
#define STRING(__size, __element, __default, __parser, __flags, __comment)
|
||||
#define NODE(__type, __element, __default, __repr, __flags, __comment)
|
||||
#define ATOM(__type, __element, __default, __repr, __flags, __comment)
|
||||
#define STRING(__size, __element, __default, __repr, __flags, __comment)
|
||||
#define SUB_STRUCT(__name, __element, __flags)
|
||||
#define NODE_STRUCT(__name, __element, __parser, __flags)
|
||||
#define NODE_STRUCT(__name, __element, __repr, __flags)
|
||||
#define END_STRUCT
|
||||
#define ARRAY(__name, __flags, __validator...) \
|
||||
static int __cmp_config_##__name(const struct config_##__name##__element *a, const struct config_##__name##__element *b) { \
|
||||
__compare_func__config_##__name##__t *cmp = (NULL
|
||||
#define KEY_ATOM(__type, __keyparser, __cmpfunc...) \
|
||||
#define KEY_ATOM(__type, __keyrepr, __cmpfunc...) \
|
||||
,##__cmpfunc); \
|
||||
return cmp ? (*cmp)(&a->key, &b->key) : memcmp(&a->key, &b->key, sizeof a->key);
|
||||
#define KEY_STRING(__strsize, __keyparser, __cmpfunc...) \
|
||||
#define KEY_STRING(__strsize, __keyrepr, __cmpfunc...) \
|
||||
,##__cmpfunc); \
|
||||
return cmp ? (*cmp)(a->key, b->key) : strcmp(a->key, b->key);
|
||||
#define VALUE_ATOM(__type, __eltparser)
|
||||
#define VALUE_STRING(__strsize, __eltparser)
|
||||
#define VALUE_NODE(__type, __eltparser)
|
||||
#define VALUE_ATOM(__type, __eltrepr)
|
||||
#define VALUE_STRING(__strsize, __eltrepr)
|
||||
#define VALUE_NODE(__type, __eltrepr)
|
||||
#define VALUE_SUB_STRUCT(__structname)
|
||||
#define VALUE_NODE_STRUCT(__structname, __eltparser)
|
||||
#define VALUE_NODE_STRUCT(__structname, __eltrepr)
|
||||
#define END_ARRAY(__size) \
|
||||
}
|
||||
#include "conf_schema.h"
|
||||
@ -157,16 +157,16 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
result |= CFSUB(ret); \
|
||||
} \
|
||||
}
|
||||
#define NODE(__type, __element, __default, __parser, __flags, __comment) \
|
||||
__ITEM(__element, 0 __flags, __parser(&strct->__element, child))
|
||||
#define ATOM(__type, __element, __default, __parser, __flags, __comment) \
|
||||
__ITEM(__element, ((0 __flags)|__TEXT)&~__CHILDREN, child->text ? __parser(&strct->__element, child->text) : CFEMPTY)
|
||||
#define STRING(__size, __element, __default, __parser, __flags, __comment) \
|
||||
__ITEM(__element, ((0 __flags)|__TEXT)&~__CHILDREN, child->text ? __parser(strct->__element, (__size) + 1, child->text) : CFEMPTY)
|
||||
#define NODE(__type, __element, __default, __repr, __flags, __comment) \
|
||||
__ITEM(__element, 0 __flags, cf_opt_##__repr(&strct->__element, child))
|
||||
#define ATOM(__type, __element, __default, __repr, __flags, __comment) \
|
||||
__ITEM(__element, ((0 __flags)|__TEXT)&~__CHILDREN, child->text ? cf_opt_##__repr(&strct->__element, child->text) : CFEMPTY)
|
||||
#define STRING(__size, __element, __default, __repr, __flags, __comment) \
|
||||
__ITEM(__element, ((0 __flags)|__TEXT)&~__CHILDREN, child->text ? cf_opt_##__repr(strct->__element, (__size) + 1, child->text) : CFEMPTY)
|
||||
#define SUB_STRUCT(__name, __element, __flags) \
|
||||
__ITEM(__element, (0 __flags)|__CHILDREN, cf_opt_config_##__name(&strct->__element, child))
|
||||
#define NODE_STRUCT(__name, __element, __parser, __flags) \
|
||||
__ITEM(__element, (0 __flags)|__TEXT|__CHILDREN, __parser(&strct->__element, child))
|
||||
#define NODE_STRUCT(__name, __element, __repr, __flags) \
|
||||
__ITEM(__element, (0 __flags)|__TEXT|__CHILDREN, cf_opt_##__repr(&strct->__element, child))
|
||||
#define END_STRUCT \
|
||||
{ \
|
||||
int i; \
|
||||
@ -249,20 +249,20 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
result |= CFEMPTY; \
|
||||
return result; \
|
||||
}
|
||||
#define KEY_ATOM(__type, __keyparser, __cmpfunc...) \
|
||||
__ARRAY_KEY(__keyparser(&array->av[n].key, child->key), ##__cmpfunc)
|
||||
#define KEY_STRING(__strsize, __keyparser, __cmpfunc...) \
|
||||
__ARRAY_KEY(__keyparser(array->av[n].key, sizeof array->av[n].key, child->key), ##__cmpfunc)
|
||||
#define VALUE_ATOM(__type, __eltparser) \
|
||||
__ARRAY_VALUE(CFOK, child->text ? __eltparser(&array->av[n].value, child->text) : CFEMPTY)
|
||||
#define VALUE_STRING(__strsize, __eltparser) \
|
||||
__ARRAY_VALUE(CFOK, child->text ? __eltparser(array->av[n].value, sizeof array->av[n].value, child->text) : CFEMPTY)
|
||||
#define VALUE_NODE(__type, __eltparser) \
|
||||
__ARRAY_VALUE(CFOK, __eltparser(&array->av[n].value, child))
|
||||
#define KEY_ATOM(__type, __keyrepr, __cmpfunc...) \
|
||||
__ARRAY_KEY(cf_opt_##__keyrepr(&array->av[n].key, child->key), ##__cmpfunc)
|
||||
#define KEY_STRING(__strsize, __keyrepr, __cmpfunc...) \
|
||||
__ARRAY_KEY(cf_opt_##__keyrepr(array->av[n].key, sizeof array->av[n].key, child->key), ##__cmpfunc)
|
||||
#define VALUE_ATOM(__type, __eltrepr) \
|
||||
__ARRAY_VALUE(CFOK, child->text ? cf_opt_##__eltrepr(&array->av[n].value, child->text) : CFEMPTY)
|
||||
#define VALUE_STRING(__strsize, __eltrepr) \
|
||||
__ARRAY_VALUE(CFOK, child->text ? cf_opt_##__eltrepr(array->av[n].value, sizeof array->av[n].value, child->text) : CFEMPTY)
|
||||
#define VALUE_NODE(__type, __eltrepr) \
|
||||
__ARRAY_VALUE(CFOK, cf_opt_##__eltrepr(&array->av[n].value, child))
|
||||
#define VALUE_SUB_STRUCT(__structname) \
|
||||
__ARRAY_VALUE(cf_dfl_config_##__structname(&array->av[n].value), cf_opt_config_##__structname(&array->av[n].value, child))
|
||||
#define VALUE_NODE_STRUCT(__structname, __eltparser) \
|
||||
__ARRAY_VALUE(cf_dfl_config_##__structname(&array->av[n].value), __eltparser(&array->av[n].value, child))
|
||||
#define VALUE_NODE_STRUCT(__structname, __eltrepr) \
|
||||
__ARRAY_VALUE(cf_dfl_config_##__structname(&array->av[n].value), cf_opt_##__eltrepr(&array->av[n].value, child))
|
||||
#include "conf_schema.h"
|
||||
#undef STRUCT
|
||||
#undef NODE
|
||||
@ -283,15 +283,15 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
// Generate config array search-by-key functions.
|
||||
#define STRUCT(__name, __validator...)
|
||||
#define NODE(__type, __element, __default, __parser, __flags, __comment)
|
||||
#define ATOM(__type, __element, __default, __parser, __flags, __comment)
|
||||
#define STRING(__size, __element, __default, __parser, __flags, __comment)
|
||||
#define NODE(__type, __element, __default, __repr, __flags, __comment)
|
||||
#define ATOM(__type, __element, __default, __repr, __flags, __comment)
|
||||
#define STRING(__size, __element, __default, __repr, __flags, __comment)
|
||||
#define SUB_STRUCT(__name, __element, __flags)
|
||||
#define NODE_STRUCT(__name, __element, __parser, __flags)
|
||||
#define NODE_STRUCT(__name, __element, __repr, __flags)
|
||||
#define END_STRUCT
|
||||
#define ARRAY(__name, __flags, __validator...) \
|
||||
int config_##__name##__get(const struct config_##__name *array,
|
||||
#define KEY_ATOM(__type, __keyparser, __cmpfunc...) \
|
||||
#define KEY_ATOM(__type, __keyrepr, __cmpfunc...) \
|
||||
const __type *key) { \
|
||||
int (*cmp)(const __type *, const __type *) = (NULL, ##__cmpfunc); \
|
||||
int i; \
|
||||
@ -300,7 +300,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
return i; \
|
||||
return -1; \
|
||||
}
|
||||
#define KEY_STRING(__strsize, __keyparser, __cmpfunc...) \
|
||||
#define KEY_STRING(__strsize, __keyrepr, __cmpfunc...) \
|
||||
const char *key) { \
|
||||
int (*cmp)(const char *, const char *) = (NULL, ##__cmpfunc); \
|
||||
int i; \
|
||||
@ -309,11 +309,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
return i; \
|
||||
return -1; \
|
||||
}
|
||||
#define VALUE_ATOM(__type, __eltparser)
|
||||
#define VALUE_STRING(__strsize, __eltparser)
|
||||
#define VALUE_NODE(__type, __eltparser)
|
||||
#define VALUE_ATOM(__type, __eltrepr)
|
||||
#define VALUE_STRING(__strsize, __eltrepr)
|
||||
#define VALUE_NODE(__type, __eltrepr)
|
||||
#define VALUE_SUB_STRUCT(__structname)
|
||||
#define VALUE_NODE_STRUCT(__structname, __eltparser)
|
||||
#define VALUE_NODE_STRUCT(__structname, __eltrepr)
|
||||
#define END_ARRAY(__size)
|
||||
#include "conf_schema.h"
|
||||
#undef STRUCT
|
||||
@ -348,23 +348,23 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#define __STRUCT(nodep, __structname) \
|
||||
if (cf_sch_config_##__structname(nodep) == -1) \
|
||||
return -1;
|
||||
#define NODE(__type, __element, __default, __parser, __flags, __comment) \
|
||||
#define NODE(__type, __element, __default, __repr, __flags, __comment) \
|
||||
__ADD_CHILD(rootp, #__element) \
|
||||
__ATOM(childp, "(" #__parser ")") \
|
||||
__ADD_CHILD(childp, "(" #__parser ")") \
|
||||
__ATOM(childp, "(" #__parser ")")
|
||||
#define ATOM(__type, __element, __default, __parser, __flags, __comment) \
|
||||
__ATOM(childp, "(" #__repr ")") \
|
||||
__ADD_CHILD(childp, "(" #__repr ")") \
|
||||
__ATOM(childp, "(" #__repr ")")
|
||||
#define ATOM(__type, __element, __default, __repr, __flags, __comment) \
|
||||
__ADD_CHILD(rootp, #__element) \
|
||||
__ATOM(childp, "(" #__parser ")")
|
||||
#define STRING(__size, __element, __default, __parser, __flags, __comment) \
|
||||
__ATOM(childp, "(" #__repr ")")
|
||||
#define STRING(__size, __element, __default, __repr, __flags, __comment) \
|
||||
__ADD_CHILD(rootp, #__element) \
|
||||
__ATOM(childp, "(" #__parser ")")
|
||||
__ATOM(childp, "(" #__repr ")")
|
||||
#define SUB_STRUCT(__structname, __element, __flags) \
|
||||
__ADD_CHILD(rootp, #__element) \
|
||||
__STRUCT(childp, __structname)
|
||||
#define NODE_STRUCT(__structname, __element, __parser, __flags) \
|
||||
#define NODE_STRUCT(__structname, __element, __repr, __flags) \
|
||||
__ADD_CHILD(rootp, #__element) \
|
||||
__ATOM(childp, "(" #__parser ")") \
|
||||
__ATOM(childp, "(" #__repr ")") \
|
||||
__STRUCT(childp, __structname)
|
||||
#define END_STRUCT \
|
||||
return 0; \
|
||||
@ -373,22 +373,22 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
int cf_sch_config_##__name(struct cf_om_node **rootp) { \
|
||||
int i; \
|
||||
struct cf_om_node **childp;
|
||||
#define KEY_ATOM(__type, __keyparser, __cmpfunc...) \
|
||||
__ADD_CHILD(rootp, "[" #__keyparser "]")
|
||||
#define KEY_STRING(__strsize, __keyparser, __cmpfunc...) \
|
||||
__ADD_CHILD(rootp, "[" #__keyparser "]")
|
||||
#define VALUE_ATOM(__type, __eltparser) \
|
||||
__ATOM(childp, "(" #__eltparser ")")
|
||||
#define VALUE_STRING(__strsize, __eltparser) \
|
||||
__ATOM(childp, "(" #__eltparser ")")
|
||||
#define VALUE_NODE(__type, __eltparser) \
|
||||
__ATOM(childp, "(" #__eltparser ")") \
|
||||
__ADD_CHILD(childp, "(" #__eltparser ")") \
|
||||
__ATOM(childp, "(" #__eltparser ")")
|
||||
#define KEY_ATOM(__type, __keyrepr, __cmpfunc...) \
|
||||
__ADD_CHILD(rootp, "[" #__keyrepr "]")
|
||||
#define KEY_STRING(__strsize, __keyrepr, __cmpfunc...) \
|
||||
__ADD_CHILD(rootp, "[" #__keyrepr "]")
|
||||
#define VALUE_ATOM(__type, __eltrepr) \
|
||||
__ATOM(childp, "(" #__eltrepr ")")
|
||||
#define VALUE_STRING(__strsize, __eltrepr) \
|
||||
__ATOM(childp, "(" #__eltrepr ")")
|
||||
#define VALUE_NODE(__type, __eltrepr) \
|
||||
__ATOM(childp, "(" #__eltrepr ")") \
|
||||
__ADD_CHILD(childp, "(" #__eltrepr ")") \
|
||||
__ATOM(childp, "(" #__eltrepr ")")
|
||||
#define VALUE_SUB_STRUCT(__structname) \
|
||||
__STRUCT(childp, __structname)
|
||||
#define VALUE_NODE_STRUCT(__structname, __eltparser) \
|
||||
__ATOM(childp, "(" #__eltparser ")") \
|
||||
#define VALUE_NODE_STRUCT(__structname, __eltrepr) \
|
||||
__ATOM(childp, "(" #__eltrepr ")") \
|
||||
__STRUCT(childp, __structname)
|
||||
|
||||
#define END_ARRAY(__size) \
|
||||
|
253
conf_schema.h
253
conf_schema.h
@ -46,12 +46,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
* the following schema would do:
|
||||
*
|
||||
* STRUCT(happy)
|
||||
* ATOM(int32_t, element1, 0, cf_opt_int32_nonnegative,, "An integer >= 0")
|
||||
* STRING(80, element2, "boo!", cf_opt_str_nonempty, MANDATORY, "A non-empty string")
|
||||
* ATOM(int32_t, element1, 0, int32_nonnegative,, "An integer >= 0")
|
||||
* STRING(80, element2, "boo!", str_nonempty, MANDATORY, "A non-empty string")
|
||||
* END_STRUCT
|
||||
*
|
||||
* ARRAY(joy,)
|
||||
* KEY_STRING(3, happy, cf_opt_str)
|
||||
* KEY_STRING(3, happy, str)
|
||||
* VALUE_SUB_STRUCT(happy)
|
||||
* END_ARRAY(16)
|
||||
*
|
||||
@ -62,7 +62,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* STRUCT(main)
|
||||
* SUB_STRUCT(love, some,)
|
||||
* STRING(128, another_thing, "", cf_opt_uri,, "URL; protocol://hostname[:port][/path]")
|
||||
* STRING(128, another_thing, "", uri,, "URL; protocol://hostname[:port][/path]")
|
||||
* END_STRUCT
|
||||
*
|
||||
* which would produce an API based on the following definitions (see "config.h" for more
|
||||
@ -98,11 +98,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* where each element-declaration is one of:
|
||||
*
|
||||
* ATOM(type, element, default, parsefunc, flags, comment)
|
||||
* NODE(type, element, default, parsefunc, flags, comment)
|
||||
* STRING(strlen, element, default, parsefunc, flags, comment)
|
||||
* ATOM(type, element, default, repr, flags, comment)
|
||||
* NODE(type, element, default, repr, flags, comment)
|
||||
* STRING(strlen, element, default, repr, flags, comment)
|
||||
* SUB_STRUCT(structname, element, flags)
|
||||
* NODE_STRUCT(structname, element, parsefunc, flags)
|
||||
* NODE_STRUCT(structname, element, repr, flags)
|
||||
*
|
||||
* ARRAY(name, flags[, validatorfunc])
|
||||
* key-declaration
|
||||
@ -111,16 +111,16 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* where key-declaration is one of:
|
||||
*
|
||||
* KEY_ATOM(type, parsefunc[, comparefunc])
|
||||
* KEY_STRING(strlen, parsefunc[, comparefunc])
|
||||
* KEY_ATOM(type, repr[, comparefunc])
|
||||
* KEY_STRING(strlen, repr[, comparefunc])
|
||||
*
|
||||
* and value-declaration is one of:
|
||||
*
|
||||
* VALUE_ATOM(type, parsefunc)
|
||||
* VALUE_STRING(strlen, parsefunc)
|
||||
* VALUE_NODE(type, parsefunc)
|
||||
* VALUE_ATOM(type, repr)
|
||||
* VALUE_STRING(strlen, repr)
|
||||
* VALUE_NODE(type, repr)
|
||||
* VALUE_SUB_STRUCT(structname)
|
||||
* VALUE_NODE_STRUCT(structname, parsefunc)
|
||||
* VALUE_NODE_STRUCT(structname, repr)
|
||||
*
|
||||
* The meanings of the parameters are:
|
||||
*
|
||||
@ -135,7 +135,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
* For all ARRAYs, gives the maximum size of the array.
|
||||
* 'type'
|
||||
* Used for ATOM, NODE, LABEL_ATOM, VALUE_ATOM and VALUE_NODE declarations. Gives the C type
|
||||
* of the element. For STRING, KEY_STRING and VALUE_STRING this is implicitly a char[].
|
||||
* of the element. For STRING, KEY_STRING and VALUE_STRING this is implicitly char[strlen+1].
|
||||
* 'structname'
|
||||
* Only used for SUB_STRUCT, NODE_STRUCT, VALUE_SUB_STRUCT and VALUE_NODE_STRUCT declarations.
|
||||
* Identifies a sub- structure by 'name' to nest in the enclosing struct or array.
|
||||
@ -148,13 +148,22 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
* 'default'
|
||||
* Only used for ATOM and NODE struct elements. Gives the default value for the element if
|
||||
* absent from the config file.
|
||||
* 'parsefunc'
|
||||
* The function used to parse a VALUE from the config file for a STRUCT element, or a KEY or
|
||||
* VALUE for an array element. Parse functions for ATOM, STRING, KEY_ATOM, KEY_STRING,
|
||||
* VALUE_ATOM and VALUE_STRING all take a string argument (const char *) which is a
|
||||
* nul-terminated text. The parse functions for NODE, NODE_STRUCT, VALUE_NODE and
|
||||
* VALUE_NODE_STRUCT take a pointer to a COM node (const struct cf_om_node *), and are
|
||||
* responsible for parsing the node's text and all of its descendents (children).
|
||||
* 'repr'
|
||||
* The string representation. This name specifies a pair of functions, <repr> and
|
||||
* cf_fmt_<repr> that convert the given 'type' from and to a string respectively:
|
||||
* - The <repr> functions for ATOM, STRING, KEY_ATOM, KEY_STRING, VALUE_ATOM and
|
||||
* VALUE_STRING take a (const char *) argument pointing to nul-terminated text. The
|
||||
* <repr> functions for NODE and VALUE_NODE take a pointer to a COM node (const
|
||||
* struct cf_om_node *), and are responsible for parsing the node's text and all of its
|
||||
* descendents (children).
|
||||
* - Each cf_fmt_<repr> function is the inverse of <repr>. The cf_fmt_<repr>
|
||||
* functions for ATOM, STRING, KEY_ATOM, KEY_STRING, VALUE_ATOM and VALUE_STRING all take a
|
||||
* pointer to a const 'type', and return a malloc()ed nul-terminated string which, if passed
|
||||
* to <repr>(), would produce the same original value. If the value is invalid
|
||||
* (outside the legal range) or malloc() fails, then cf_fmt_<repr> returns NULL. The
|
||||
* cf_fmt_<repr> functions for NODE and VALUE_NODE take a pointer to a const 'type' and
|
||||
* return a pointer to a malloc()ed COM node (struct cf_om_node *) which, if passed to
|
||||
* <repr> would produce the same original value.
|
||||
* 'comparefunc'
|
||||
* A function used to sort an array after all elements have been parsed, and before being
|
||||
* validated (see below).
|
||||
@ -179,88 +188,88 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
STRUCT(debug)
|
||||
ATOM(char, verbose, 0, cf_opt_char_boolean,, "")
|
||||
ATOM(char, dnaresponses, 0, cf_opt_char_boolean,, "")
|
||||
ATOM(char, dnahelper, 0, cf_opt_char_boolean,, "")
|
||||
ATOM(char, queues, 0, cf_opt_char_boolean,, "")
|
||||
ATOM(char, timing, 0, cf_opt_char_boolean,, "")
|
||||
ATOM(char, io, 0, cf_opt_char_boolean,, "")
|
||||
ATOM(char, verbose_io, 0, cf_opt_char_boolean,, "")
|
||||
ATOM(char, packetformats, 0, cf_opt_char_boolean,, "")
|
||||
ATOM(char, gateway, 0, cf_opt_char_boolean,, "")
|
||||
ATOM(char, keyring, 0, cf_opt_char_boolean,, "")
|
||||
ATOM(char, security, 0, cf_opt_char_boolean,, "")
|
||||
ATOM(char, mdprequests, 0, cf_opt_char_boolean,, "")
|
||||
ATOM(char, peers, 0, cf_opt_char_boolean,, "")
|
||||
ATOM(char, overlayframes, 0, cf_opt_char_boolean,, "")
|
||||
ATOM(char, overlayabbreviations, 0, cf_opt_char_boolean,, "")
|
||||
ATOM(char, overlayrouting, 0, cf_opt_char_boolean,, "")
|
||||
ATOM(char, overlayroutemonitor, 0, cf_opt_char_boolean,, "")
|
||||
ATOM(char, overlayinterfaces, 0, cf_opt_char_boolean,, "")
|
||||
ATOM(char, broadcasts, 0, cf_opt_char_boolean,, "")
|
||||
ATOM(char, packettx, 0, cf_opt_char_boolean,, "")
|
||||
ATOM(char, packetrx, 0, cf_opt_char_boolean,, "")
|
||||
ATOM(char, packetradio, 0, cf_opt_char_boolean,, "")
|
||||
ATOM(char, rejecteddata, 0, cf_opt_char_boolean,, "")
|
||||
ATOM(char, slip, 0, cf_opt_char_boolean,, "")
|
||||
ATOM(char, slipdecode, 0, cf_opt_char_boolean,, "")
|
||||
ATOM(char, packetconstruction, 0, cf_opt_char_boolean,, "")
|
||||
ATOM(char, rhizome, 0, cf_opt_char_boolean,, "")
|
||||
ATOM(char, rhizome_tx, 0, cf_opt_char_boolean,, "")
|
||||
ATOM(char, rhizome_rx, 0, cf_opt_char_boolean,, "")
|
||||
ATOM(char, rhizome_ads, 0, cf_opt_char_boolean,, "")
|
||||
ATOM(char, manifests, 0, cf_opt_char_boolean,, "")
|
||||
ATOM(char, vomp, 0, cf_opt_char_boolean,, "")
|
||||
ATOM(char, trace, 0, cf_opt_char_boolean,, "")
|
||||
ATOM(char, profiling, 0, cf_opt_char_boolean,, "")
|
||||
ATOM(char, externalblobs, 0, cf_opt_char_boolean,, "")
|
||||
ATOM(char, verbose, 0, char_boolean,, "")
|
||||
ATOM(char, dnaresponses, 0, char_boolean,, "")
|
||||
ATOM(char, dnahelper, 0, char_boolean,, "")
|
||||
ATOM(char, queues, 0, char_boolean,, "")
|
||||
ATOM(char, timing, 0, char_boolean,, "")
|
||||
ATOM(char, io, 0, char_boolean,, "")
|
||||
ATOM(char, verbose_io, 0, char_boolean,, "")
|
||||
ATOM(char, packetformats, 0, char_boolean,, "")
|
||||
ATOM(char, gateway, 0, char_boolean,, "")
|
||||
ATOM(char, keyring, 0, char_boolean,, "")
|
||||
ATOM(char, security, 0, char_boolean,, "")
|
||||
ATOM(char, mdprequests, 0, char_boolean,, "")
|
||||
ATOM(char, peers, 0, char_boolean,, "")
|
||||
ATOM(char, overlayframes, 0, char_boolean,, "")
|
||||
ATOM(char, overlayabbreviations, 0, char_boolean,, "")
|
||||
ATOM(char, overlayrouting, 0, char_boolean,, "")
|
||||
ATOM(char, overlayroutemonitor, 0, char_boolean,, "")
|
||||
ATOM(char, overlayinterfaces, 0, char_boolean,, "")
|
||||
ATOM(char, broadcasts, 0, char_boolean,, "")
|
||||
ATOM(char, packettx, 0, char_boolean,, "")
|
||||
ATOM(char, packetrx, 0, char_boolean,, "")
|
||||
ATOM(char, packetradio, 0, char_boolean,, "")
|
||||
ATOM(char, rejecteddata, 0, char_boolean,, "")
|
||||
ATOM(char, slip, 0, char_boolean,, "")
|
||||
ATOM(char, slipdecode, 0, char_boolean,, "")
|
||||
ATOM(char, packetconstruction, 0, char_boolean,, "")
|
||||
ATOM(char, rhizome, 0, char_boolean,, "")
|
||||
ATOM(char, rhizome_tx, 0, char_boolean,, "")
|
||||
ATOM(char, rhizome_rx, 0, char_boolean,, "")
|
||||
ATOM(char, rhizome_ads, 0, char_boolean,, "")
|
||||
ATOM(char, manifests, 0, char_boolean,, "")
|
||||
ATOM(char, vomp, 0, char_boolean,, "")
|
||||
ATOM(char, trace, 0, char_boolean,, "")
|
||||
ATOM(char, profiling, 0, char_boolean,, "")
|
||||
ATOM(char, externalblobs, 0, char_boolean,, "")
|
||||
END_STRUCT
|
||||
|
||||
STRUCT(log)
|
||||
STRING(256, file, "", cf_opt_str_nonempty,, "Path of log file, either absolute or relative to instance directory")
|
||||
ATOM(int, show_pid, 1, cf_opt_int_boolean,, "If true, all log lines contain PID of logging process")
|
||||
ATOM(int, show_time, 1, cf_opt_int_boolean,, "If true, all log lines contain time stamp")
|
||||
STRING(256, file, "", str_nonempty,, "Path of log file, either absolute or relative to instance directory")
|
||||
ATOM(int, show_pid, 1, int_boolean,, "If true, all log lines contain PID of logging process")
|
||||
ATOM(int, show_time, 1, int_boolean,, "If true, all log lines contain time stamp")
|
||||
END_STRUCT
|
||||
|
||||
STRUCT(server)
|
||||
STRING(256, chdir, "/", cf_opt_absolute_path,, "Absolute path of chdir(2) for server process")
|
||||
STRING(256, interface_path, "", cf_opt_str_nonempty,, "Path of directory containing interface files, either absolute or relative to instance directory")
|
||||
ATOM(int, respawn_on_crash, 0, cf_opt_int_boolean,, "If true, server will exec(2) itself on fatal signals, eg SEGV")
|
||||
STRING(256, chdir, "/", absolute_path,, "Absolute path of chdir(2) for server process")
|
||||
STRING(256, interface_path, "", str_nonempty,, "Path of directory containing interface files, either absolute or relative to instance directory")
|
||||
ATOM(int, respawn_on_crash, 0, int_boolean,, "If true, server will exec(2) itself on fatal signals, eg SEGV")
|
||||
END_STRUCT
|
||||
|
||||
STRUCT(monitor)
|
||||
STRING(256, socket, DEFAULT_MONITOR_SOCKET_NAME, cf_opt_str_nonempty,, "Name of socket for monitor interface")
|
||||
ATOM(int, uid, -1, cf_opt_int,, "Allowed UID for monitor socket client")
|
||||
STRING(256, socket, DEFAULT_MONITOR_SOCKET_NAME, str_nonempty,, "Name of socket for monitor interface")
|
||||
ATOM(int, uid, -1, int,, "Allowed UID for monitor socket client")
|
||||
END_STRUCT
|
||||
|
||||
STRUCT(mdp_iftype)
|
||||
ATOM(uint32_t, tick_ms, -1, cf_opt_uint32_nonzero,, "Tick interval for this interface type")
|
||||
ATOM(int, packet_interval, -1, cf_opt_int,, "Minimum interval between packets in microseconds")
|
||||
ATOM(uint32_t, tick_ms, -1, uint32_nonzero,, "Tick interval for this interface type")
|
||||
ATOM(int, packet_interval, -1, int,, "Minimum interval between packets in microseconds")
|
||||
END_STRUCT
|
||||
|
||||
ARRAY(mdp_iftypelist, NO_DUPLICATES)
|
||||
KEY_ATOM(short, cf_opt_interface_type, cmp_short)
|
||||
KEY_ATOM(short, interface_type, cmp_short)
|
||||
VALUE_SUB_STRUCT(mdp_iftype)
|
||||
END_ARRAY(5)
|
||||
|
||||
STRUCT(mdp)
|
||||
STRING(256, socket, DEFAULT_MDP_SOCKET_NAME, cf_opt_str_nonempty,, "Name of socket for MDP client interface")
|
||||
STRING(256, socket, DEFAULT_MDP_SOCKET_NAME, str_nonempty,, "Name of socket for MDP client interface")
|
||||
SUB_STRUCT(mdp_iftypelist, iftype,)
|
||||
END_STRUCT
|
||||
|
||||
STRUCT(olsr)
|
||||
ATOM(int, enable, 1, cf_opt_int_boolean,, "If true, OLSR is used for mesh routing")
|
||||
ATOM(uint16_t, remote_port,4130, cf_opt_uint16_nonzero,, "Remote port number")
|
||||
ATOM(uint16_t, local_port, 4131, cf_opt_uint16_nonzero,, "Local port number")
|
||||
ATOM(int, enable, 1, int_boolean,, "If true, OLSR is used for mesh routing")
|
||||
ATOM(uint16_t, remote_port,4130, uint16_nonzero,, "Remote port number")
|
||||
ATOM(uint16_t, local_port, 4131, uint16_nonzero,, "Local port number")
|
||||
END_STRUCT
|
||||
|
||||
ARRAY(argv, SORTED NO_DUPLICATES, vld_argv)
|
||||
KEY_ATOM(unsigned short, cf_opt_ushort_nonzero, cmp_ushort)
|
||||
VALUE_STRING(128, cf_opt_str)
|
||||
KEY_ATOM(unsigned short, ushort_nonzero, cmp_ushort)
|
||||
VALUE_STRING(128, str)
|
||||
END_ARRAY(16)
|
||||
|
||||
STRUCT(executable)
|
||||
STRING(256, executable, "", cf_opt_absolute_path, MANDATORY, "Absolute path of dna helper executable")
|
||||
STRING(256, executable, "", absolute_path, MANDATORY, "Absolute path of dna helper executable")
|
||||
SUB_STRUCT(argv, argv,)
|
||||
END_STRUCT
|
||||
|
||||
@ -269,14 +278,14 @@ SUB_STRUCT(executable, helper,)
|
||||
END_STRUCT
|
||||
|
||||
STRUCT(rhizome_peer)
|
||||
STRING(25, protocol, "http", cf_opt_protocol,, "Protocol name")
|
||||
STRING(256, host, "", cf_opt_str_nonempty, MANDATORY, "Host name or IP address")
|
||||
ATOM(uint16_t, port, RHIZOME_HTTP_PORT, cf_opt_uint16_nonzero,, "Port number")
|
||||
STRING(25, protocol, "http", protocol,, "Protocol name")
|
||||
STRING(256, host, "", str_nonempty, MANDATORY, "Host name or IP address")
|
||||
ATOM(uint16_t, port, RHIZOME_HTTP_PORT, uint16_nonzero,, "Port number")
|
||||
END_STRUCT
|
||||
|
||||
ARRAY(peerlist,)
|
||||
KEY_STRING(15, cf_opt_str)
|
||||
VALUE_NODE_STRUCT(rhizome_peer, cf_opt_rhizome_peer)
|
||||
KEY_STRING(15, str)
|
||||
VALUE_NODE_STRUCT(rhizome_peer, rhizome_peer)
|
||||
END_ARRAY(10)
|
||||
|
||||
STRUCT(rhizome_direct)
|
||||
@ -284,11 +293,11 @@ SUB_STRUCT(peerlist, peer,)
|
||||
END_STRUCT
|
||||
|
||||
STRUCT(rhizome_api_addfile)
|
||||
STRING(64, uri_path, "", cf_opt_absolute_path,, "URI path for HTTP add-file request")
|
||||
ATOM(struct in_addr, allow_host, hton_in_addr(INADDR_LOOPBACK), cf_opt_in_addr,, "IP address of host allowed to make HTTP add-file request")
|
||||
STRING(256, manifest_template_file, "", cf_opt_str_nonempty,, "Path of manifest template file, either absolute or relative to instance directory")
|
||||
ATOM(sid_t, default_author, SID_ANY, cf_opt_sid,, "Author of add-file bundle if sender not given")
|
||||
ATOM(rhizome_bk_t, bundle_secret_key, RHIZOME_BK_NONE, cf_opt_rhizome_bk,, "Secret key of add-file bundle to try if sender not given")
|
||||
STRING(64, uri_path, "", absolute_path,, "URI path for HTTP add-file request")
|
||||
ATOM(struct in_addr, allow_host, hton_in_addr(INADDR_LOOPBACK), in_addr,, "IP address of host allowed to make HTTP add-file request")
|
||||
STRING(256, manifest_template_file, "", str_nonempty,, "Path of manifest template file, either absolute or relative to instance directory")
|
||||
ATOM(sid_t, default_author, SID_ANY, sid,, "Author of add-file bundle if sender not given")
|
||||
ATOM(rhizome_bk_t, bundle_secret_key, RHIZOME_BK_NONE, rhizome_bk,, "Secret key of add-file bundle to try if sender not given")
|
||||
END_STRUCT
|
||||
|
||||
STRUCT(rhizome_api)
|
||||
@ -296,28 +305,28 @@ SUB_STRUCT(rhizome_api_addfile, addfile,)
|
||||
END_STRUCT
|
||||
|
||||
STRUCT(rhizome_http)
|
||||
ATOM(int, enable, 1, cf_opt_int_boolean,, "If true, Rhizome HTTP server is started")
|
||||
ATOM(int, enable, 1, int_boolean,, "If true, Rhizome HTTP server is started")
|
||||
END_STRUCT
|
||||
|
||||
STRUCT(rhizome_mdp)
|
||||
ATOM(int, enable, 1, cf_opt_int_boolean,, "If true, Rhizome MDP server is started")
|
||||
ATOM(int, enable, 1, int_boolean,, "If true, Rhizome MDP server is started")
|
||||
END_STRUCT
|
||||
|
||||
STRUCT(rhizome_advertise)
|
||||
ATOM(int, enable, 1, cf_opt_int_boolean,, "If true, Rhizome advertisements are sent")
|
||||
ATOM(uint32_t, interval, 500, cf_opt_uint32_nonzero,, "Interval between Rhizome advertisements")
|
||||
ATOM(int, enable, 1, int_boolean,, "If true, Rhizome advertisements are sent")
|
||||
ATOM(uint32_t, interval, 500, uint32_nonzero,, "Interval between Rhizome advertisements")
|
||||
END_STRUCT
|
||||
|
||||
STRUCT(rhizome)
|
||||
ATOM(int, enable, 1, cf_opt_int_boolean,, "If true, server opens Rhizome database when starting")
|
||||
ATOM(int, clean_on_open, 1, cf_opt_int_boolean,, "If true, Rhizome database is cleaned at start of every command")
|
||||
STRING(256, datastore_path, "", cf_opt_absolute_path,, "Path of rhizome storage directory, absolute or relative to instance directory")
|
||||
ATOM(uint64_t, database_size, 1000000, cf_opt_uint64_scaled,, "Size of database in bytes")
|
||||
ATOM(char, external_blobs, 0, cf_opt_char_boolean,, "Store rhizome bundles as separate files.")
|
||||
ATOM(int, enable, 1, int_boolean,, "If true, server opens Rhizome database when starting")
|
||||
ATOM(int, clean_on_open, 1, int_boolean,, "If true, Rhizome database is cleaned at start of every command")
|
||||
STRING(256, datastore_path, "", absolute_path,, "Path of rhizome storage directory, absolute or relative to instance directory")
|
||||
ATOM(uint64_t, database_size, 1000000, uint64_scaled,, "Size of database in bytes")
|
||||
ATOM(char, external_blobs, 0, char_boolean,, "Store rhizome bundles as separate files.")
|
||||
|
||||
ATOM(uint64_t, rhizome_mdp_block_size, 512, cf_opt_uint64_scaled,, "Rhizome MDP block size.")
|
||||
ATOM(uint64_t, idle_timeout, RHIZOME_IDLE_TIMEOUT, cf_opt_uint64_scaled,, "Rhizome transfer timeout if no data received.")
|
||||
ATOM(uint32_t, fetch_delay_ms, 50, cf_opt_uint32_nonzero,, "Delay from receiving first bundle advert to initiating fetch")
|
||||
ATOM(uint64_t, rhizome_mdp_block_size, 512, uint64_scaled,, "Rhizome MDP block size.")
|
||||
ATOM(uint64_t, idle_timeout, RHIZOME_IDLE_TIMEOUT, uint64_scaled,, "Rhizome transfer timeout if no data received.")
|
||||
ATOM(uint32_t, fetch_delay_ms, 50, uint32_nonzero,, "Delay from receiving first bundle advert to initiating fetch")
|
||||
SUB_STRUCT(rhizome_direct, direct,)
|
||||
SUB_STRUCT(rhizome_api, api,)
|
||||
SUB_STRUCT(rhizome_http, http,)
|
||||
@ -326,48 +335,48 @@ SUB_STRUCT(rhizome_advertise, advertise,)
|
||||
END_STRUCT
|
||||
|
||||
STRUCT(directory)
|
||||
ATOM(sid_t, service, SID_ANY, cf_opt_sid,, "Subscriber ID of Serval Directory Service")
|
||||
ATOM(sid_t, service, SID_ANY, sid,, "Subscriber ID of Serval Directory Service")
|
||||
END_STRUCT
|
||||
|
||||
STRUCT(host)
|
||||
STRING(INTERFACE_NAME_STRLEN, interface, "", cf_opt_str_nonempty,, "Interface name")
|
||||
STRING(256, host, "", cf_opt_str_nonempty,, "Host Name")
|
||||
ATOM(struct in_addr, address, hton_in_addr(INADDR_NONE), cf_opt_in_addr,, "Host IP address")
|
||||
ATOM(uint16_t, port, PORT_DNA, cf_opt_uint16_nonzero,, "Port number")
|
||||
STRING(INTERFACE_NAME_STRLEN, interface, "", str_nonempty,, "Interface name")
|
||||
STRING(256, host, "", str_nonempty,, "Host Name")
|
||||
ATOM(struct in_addr, address, hton_in_addr(INADDR_NONE), in_addr,, "Host IP address")
|
||||
ATOM(uint16_t, port, PORT_DNA, uint16_nonzero,, "Port number")
|
||||
END_STRUCT
|
||||
|
||||
ARRAY(host_list, NO_DUPLICATES)
|
||||
KEY_ATOM(sid_t, cf_opt_sid, cmp_sid)
|
||||
KEY_ATOM(sid_t, sid, cmp_sid)
|
||||
VALUE_SUB_STRUCT(host)
|
||||
END_ARRAY(32)
|
||||
|
||||
STRUCT(network_interface, vld_network_interface)
|
||||
ATOM(int, exclude, 0, cf_opt_int_boolean,, "If true, do not use matching interfaces")
|
||||
ATOM(struct pattern_list, match, PATTERN_LIST_EMPTY, cf_opt_pattern_list,, "Names that match network interface")
|
||||
ATOM(int, socket_type, SOCK_UNSPECIFIED, cf_opt_socket_type,, "Type of network socket")
|
||||
ATOM(int, encapsulation, ENCAP_OVERLAY, cf_opt_encapsulation,, "Type of packet encapsulation")
|
||||
STRING(256, file, "", cf_opt_str_nonempty,, "Path of interface file, absolute or relative to server.interface_path")
|
||||
ATOM(struct in_addr, dummy_address, hton_in_addr(INADDR_LOOPBACK), cf_opt_in_addr,, "Dummy interface address")
|
||||
ATOM(struct in_addr, dummy_netmask, hton_in_addr(0xFFFFFF00), cf_opt_in_addr,, "Dummy interface netmask")
|
||||
ATOM(uint16_t, port, PORT_DNA, cf_opt_uint16_nonzero,, "Port number for network interface")
|
||||
ATOM(char, drop_broadcasts, 0, cf_opt_char_boolean,, "If true, drop all incoming broadcast packets")
|
||||
ATOM(char, drop_unicasts, 0, cf_opt_char_boolean,, "If true, drop all incoming unicast packets")
|
||||
ATOM(short, type, OVERLAY_INTERFACE_WIFI, cf_opt_interface_type,, "Type of network interface")
|
||||
ATOM(int, packet_interval, -1, cf_opt_int,, "Minimum interval between packets in microseconds")
|
||||
ATOM(int, mdp_tick_ms, -1, cf_opt_int32_nonneg,, "Override MDP tick interval for this interface")
|
||||
ATOM(char, send_broadcasts, 1, cf_opt_char_boolean,, "If false, don't send any broadcast packets")
|
||||
ATOM(char, default_route, 0, cf_opt_char_boolean,, "If true, use this interface as a default route")
|
||||
ATOM(char, prefer_unicast, 0, cf_opt_char_boolean,, "If true, send unicast data as unicast IP packets if available")
|
||||
ATOM(int, exclude, 0, int_boolean,, "If true, do not use matching interfaces")
|
||||
ATOM(struct pattern_list, match, PATTERN_LIST_EMPTY, pattern_list,, "Names that match network interface")
|
||||
ATOM(int, socket_type, SOCK_UNSPECIFIED, socket_type,, "Type of network socket")
|
||||
ATOM(int, encapsulation, ENCAP_OVERLAY, encapsulation,, "Type of packet encapsulation")
|
||||
STRING(256, file, "", str_nonempty,, "Path of interface file, absolute or relative to server.interface_path")
|
||||
ATOM(struct in_addr, dummy_address, hton_in_addr(INADDR_LOOPBACK), in_addr,, "Dummy interface address")
|
||||
ATOM(struct in_addr, dummy_netmask, hton_in_addr(0xFFFFFF00), in_addr,, "Dummy interface netmask")
|
||||
ATOM(uint16_t, port, PORT_DNA, uint16_nonzero,, "Port number for network interface")
|
||||
ATOM(char, drop_broadcasts, 0, char_boolean,, "If true, drop all incoming broadcast packets")
|
||||
ATOM(char, drop_unicasts, 0, char_boolean,, "If true, drop all incoming unicast packets")
|
||||
ATOM(short, type, OVERLAY_INTERFACE_WIFI, interface_type,, "Type of network interface")
|
||||
ATOM(int, packet_interval, -1, int,, "Minimum interval between packets in microseconds")
|
||||
ATOM(int, mdp_tick_ms, -1, int32_nonneg,, "Override MDP tick interval for this interface")
|
||||
ATOM(char, send_broadcasts, 1, char_boolean,, "If false, don't send any broadcast packets")
|
||||
ATOM(char, default_route, 0, char_boolean,, "If true, use this interface as a default route")
|
||||
ATOM(char, prefer_unicast, 0, char_boolean,, "If true, send unicast data as unicast IP packets if available")
|
||||
END_STRUCT
|
||||
|
||||
ARRAY(interface_list, SORTED NO_DUPLICATES)
|
||||
KEY_ATOM(unsigned, cf_opt_uint)
|
||||
VALUE_NODE_STRUCT(network_interface, cf_opt_network_interface)
|
||||
KEY_ATOM(unsigned, uint)
|
||||
VALUE_NODE_STRUCT(network_interface, network_interface)
|
||||
END_ARRAY(10)
|
||||
|
||||
// The top level.
|
||||
STRUCT(main)
|
||||
NODE_STRUCT(interface_list, interfaces, cf_opt_interface_list,)
|
||||
NODE_STRUCT(interface_list, interfaces, interface_list,)
|
||||
SUB_STRUCT(log, log,)
|
||||
SUB_STRUCT(server, server,)
|
||||
SUB_STRUCT(monitor, monitor,)
|
||||
|
Loading…
Reference in New Issue
Block a user