summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 0bd2ee0)
raw | patch | inline | side by side (parent: 0bd2ee0)
author | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Sat, 14 Feb 2009 16:09:40 +0000 (17:09 +0100) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Sat, 14 Feb 2009 16:09:40 +0000 (17:09 +0100) |
src/utils_db_query.c | patch | blob | history | |
src/utils_db_query.h | patch | blob | history |
diff --git a/src/utils_db_query.c b/src/utils_db_query.c
index e1ed7e6de6535b1e59cc7c91fae1474738b8bb4d..9389db65d8fb86b6fe3eedf5ddb72ccbf0b338b5 100644 (file)
--- a/src/utils_db_query.c
+++ b/src/utils_db_query.c
@@ -918,32 +918,23 @@ void udb_query_free (udb_query_t **query_list, size_t query_list_len) /* {{{ */
sfree (query_list);
} /* }}} void udb_query_free */
-int udb_query_pick_from_list (oconfig_item_t *ci, /* {{{ */
+int udb_query_pick_from_list_by_name (const char *name, /* {{{ */
udb_query_t **src_list, size_t src_list_len,
udb_query_t ***dst_list, size_t *dst_list_len)
{
- const char *name;
udb_query_t *q;
udb_query_t **tmp_list;
size_t tmp_list_len;
size_t i;
- if ((ci == NULL) || (src_list == NULL) || (dst_list == NULL)
+ if ((name == NULL) || (src_list == NULL) || (dst_list == NULL)
|| (dst_list_len == NULL))
{
- ERROR ("db query utils: Invalid argument.");
+ ERROR ("db query utils: udb_query_pick_from_list_by_name: "
+ "Invalid argument.");
return (-EINVAL);
}
- if ((ci->values_num != 1)
- || (ci->values[0].type != OCONFIG_TYPE_STRING))
- {
- ERROR ("db query utils: The `%s' config option "
- "needs exactly one string argument.", ci->key);
- return (-1);
- }
- name = ci->values[0].value.string;
-
q = NULL;
for (i = 0; i < src_list_len; i++)
if (strcasecmp (name, src_list[i]->name) == 0)
if (q == NULL)
{
- ERROR ("db query utils: Cannot find query `%s'. Make sure the <%s> "
+ ERROR ("db query utils: Cannot find query `%s'. Make sure the <Query> "
"block is above the database definition!",
- name, ci->key);
+ name);
return (-ENOENT);
}
*dst_list_len = tmp_list_len;
return (0);
+} /* }}} int udb_query_pick_from_list_by_name */
+
+int udb_query_pick_from_list (oconfig_item_t *ci, /* {{{ */
+ udb_query_t **src_list, size_t src_list_len,
+ udb_query_t ***dst_list, size_t *dst_list_len)
+{
+ const char *name;
+
+ if ((ci == NULL) || (src_list == NULL) || (dst_list == NULL)
+ || (dst_list_len == NULL))
+ {
+ ERROR ("db query utils: udb_query_pick_from_list: "
+ "Invalid argument.");
+ return (-EINVAL);
+ }
+
+ if ((ci->values_num != 1)
+ || (ci->values[0].type != OCONFIG_TYPE_STRING))
+ {
+ ERROR ("db query utils: The `%s' config option "
+ "needs exactly one string argument.", ci->key);
+ return (-1);
+ }
+ name = ci->values[0].value.string;
+
+ return (udb_query_pick_from_list_by_name (name,
+ src_list, src_list_len,
+ dst_list, dst_list_len));
} /* }}} int udb_query_pick_from_list */
const char *udb_query_get_name (udb_query_t *q) /* {{{ */
diff --git a/src/utils_db_query.h b/src/utils_db_query.h
index 36da9e3dde854a846aa80204b491f47eb09bda1b..0551310573dfe608c45d5a67efea8d221b96fd54 100644 (file)
--- a/src/utils_db_query.h
+++ b/src/utils_db_query.h
udb_query_create_callback_t cb, int legacy_mode);
void udb_query_free (udb_query_t **query_list, size_t query_list_len);
+int udb_query_pick_from_list_by_name (const char *name,
+ udb_query_t **src_list, size_t src_list_len,
+ udb_query_t ***dst_list, size_t *dst_list_len);
int udb_query_pick_from_list (oconfig_item_t *ci,
udb_query_t **src_list, size_t src_list_len,
udb_query_t ***dst_list, size_t *dst_list_len);