This allows plugins to handle custom options in the <Query> blocks.
{
oconfig_item_t *child = ci->children + i;
if (strcasecmp ("Query", child->key) == 0)
- udb_query_create (&queries, &queries_num, child);
+ udb_query_create (&queries, &queries_num, child,
+ /* callback = */ NULL);
else if (strcasecmp ("Database", child->key) == 0)
cdbi_config_add_database (child);
else
{
oconfig_item_t *child = ci->children + i;
if (strcasecmp ("Query", child->key) == 0)
- udb_query_create (&queries, &queries_num, child);
+ udb_query_create (&queries, &queries_num, child,
+ /* callback = */ NULL);
else if (strcasecmp ("Database", child->key) == 0)
o_config_add_database (child);
else
* Query public functions
*/
int udb_query_create (udb_query_t ***ret_query_list, /* {{{ */
- size_t *ret_query_list_len, oconfig_item_t *ci)
+ size_t *ret_query_list_len, oconfig_item_t *ci,
+ udb_query_create_callback_t cb)
{
udb_query_t **query_list;
size_t query_list_len;
q->name);
status = udb_config_set_uint (&q->max_version, child);
}
+ else if (cb != NULL)
+ {
+ status = (*cb) (q, child);
+ if (status != 0)
+ {
+ WARNING ("db query utils: The configuration callback failed "
+ "to handle `%s'.", child->key);
+ }
+ }
else
{
WARNING ("db query utils: Query `%s': Option `%s' not allowed here.",
struct udb_query_s;
typedef struct udb_query_s udb_query_t;
+typedef int (*udb_query_create_callback_t) (udb_query_t *q,
+ oconfig_item_t *ci);
+
/*
* Public functions
*/
int udb_query_create (udb_query_t ***ret_query_list,
- size_t *ret_query_list_len, oconfig_item_t *ci);
+ size_t *ret_query_list_len, oconfig_item_t *ci,
+ udb_query_create_callback_t cb);
void udb_query_free (udb_query_t **query_list, size_t query_list_len);
int udb_query_pick_from_list (oconfig_item_t *ci,