summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8490780)
raw | patch | inline | side by side (parent: 8490780)
author | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Thu, 5 Feb 2009 19:21:20 +0000 (20:21 +0100) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Thu, 5 Feb 2009 19:21:20 +0000 (20:21 +0100) |
This allows plugins to handle custom options in the <Query> blocks.
src/dbi.c | patch | blob | history | |
src/oracle.c | patch | blob | history | |
src/utils_db_query.c | patch | blob | history | |
src/utils_db_query.h | patch | blob | history |
diff --git a/src/dbi.c b/src/dbi.c
index a542df32ed37cf9cd710353be64cf5c858330d0e..d970938e0fff0d616c93eeaa435a09a3805d45e5 100644 (file)
--- a/src/dbi.c
+++ b/src/dbi.c
{
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
diff --git a/src/oracle.c b/src/oracle.c
index accaee35045d815f9e1b29b19694a4bf6a9a7c82..b008e5c52c06a6a8a81cdbfb644fc72ca90a2a2a 100644 (file)
--- a/src/oracle.c
+++ b/src/oracle.c
{
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
diff --git a/src/utils_db_query.c b/src/utils_db_query.c
index 868b53bf5c92e68fb24c0aaf7ae42612dd22c645..3229d64e1b2aae6c89ba598ab29b583f584db986 100644 (file)
--- a/src/utils_db_query.c
+++ b/src/utils_db_query.c
* 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.",
diff --git a/src/utils_db_query.h b/src/utils_db_query.h
index 4e12cedd0b7d99e487ce99ad03c02d73951c2eeb..3959e88246222d875d731080b603b28d7fa3a9b2 100644 (file)
--- a/src/utils_db_query.h
+++ b/src/utils_db_query.h
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,