2 * collectd - src/utils_db_query.h
3 * Copyright (C) 2008,2009 Florian octo Forster
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; only version 2 of the License is applicable.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 * Florian octo Forster <octo at verplant.org>
22 #ifndef UTILS_DB_QUERY_H
23 #define UTILS_DB_QUERY_H 1
25 #include "configfile.h"
31 typedef struct udb_query_s udb_query_t;
33 typedef int (*udb_query_create_callback_t) (udb_query_t *q,
39 int udb_query_create (udb_query_t ***ret_query_list,
40 size_t *ret_query_list_len, oconfig_item_t *ci,
41 udb_query_create_callback_t cb, int legacy_mode);
42 void udb_query_free (udb_query_t **query_list, size_t query_list_len);
44 int udb_query_pick_from_list_by_name (const char *name,
45 udb_query_t **src_list, size_t src_list_len,
46 udb_query_t ***dst_list, size_t *dst_list_len);
47 int udb_query_pick_from_list (oconfig_item_t *ci,
48 udb_query_t **src_list, size_t src_list_len,
49 udb_query_t ***dst_list, size_t *dst_list_len);
51 const char *udb_query_get_name (udb_query_t *q);
52 const char *udb_query_get_statement (udb_query_t *q);
54 void udb_query_set_user_data (udb_query_t *q, void *user_data);
55 void *udb_query_get_user_data (udb_query_t *q);
58 * udb_query_check_version
60 * Returns 0 if the query is NOT suitable for `version' and >0 if the
63 int udb_query_check_version (udb_query_t *q, unsigned int version);
65 int udb_query_prepare_result (udb_query_t *q,
66 const char *host, const char *plugin, const char *db_name,
67 char **column_names, size_t column_num);
68 int udb_query_handle_result (udb_query_t *q, char **column_values);
69 void udb_query_finish_result (udb_query_t *q);
71 #endif /* UTILS_DB_QUERY_H */
72 /* vim: set sw=2 sts=2 et : */