aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_mysql_lib.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/gnunet_mysql_lib.h')
-rw-r--r--src/include/gnunet_mysql_lib.h151
1 files changed, 0 insertions, 151 deletions
diff --git a/src/include/gnunet_mysql_lib.h b/src/include/gnunet_mysql_lib.h
deleted file mode 100644
index 52be3ff11..000000000
--- a/src/include/gnunet_mysql_lib.h
+++ /dev/null
@@ -1,151 +0,0 @@
1/*
2 This file is part of GNUnet
3 Copyright (C) 2012 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20/**
21 * @author Christian Grothoff
22 *
23 * @file
24 * Helper library to access a MySQL database
25 *
26 * @defgroup mysql MySQL library
27 * Helper library to access a MySQL database.
28 * @{
29 */
30#ifndef GNUNET_MYSQL_LIB_H
31#define GNUNET_MYSQL_LIB_H
32
33
34#include "gnunet_util_lib.h"
35#include <mysql/mysql.h>
36
37#ifdef __cplusplus
38extern "C"
39{
40#if 0 /* keep Emacsens' auto-indent happy */
41}
42#endif
43#endif
44
45/**
46 * Mysql context.
47 */
48struct GNUNET_MYSQL_Context;
49
50
51/**
52 * Handle for a prepared statement.
53 */
54struct GNUNET_MYSQL_StatementHandle;
55
56
57/**
58 * Type of a callback that will be called for each
59 * data set returned from MySQL.
60 *
61 * @param cls user-defined argument
62 * @param num_values number of elements in values
63 * @param values values returned by MySQL
64 * @return #GNUNET_OK to continue iterating, #GNUNET_SYSERR to abort
65 */
66typedef int
67(*GNUNET_MYSQL_DataProcessor) (void *cls,
68 unsigned int num_values,
69 MYSQL_BIND *values);
70
71
72/**
73 * Create a mysql context.
74 *
75 * @param cfg configuration
76 * @param section configuration section to use to get MySQL configuration options
77 * @return the mysql context
78 */
79struct GNUNET_MYSQL_Context *
80GNUNET_MYSQL_context_create (const struct GNUNET_CONFIGURATION_Handle *cfg,
81 const char *section);
82
83
84/**
85 * Destroy a mysql context. Also frees all associated prepared statements.
86 *
87 * @param mc context to destroy
88 */
89void
90GNUNET_MYSQL_context_destroy (struct GNUNET_MYSQL_Context *mc);
91
92
93/**
94 * Close database connection and all prepared statements (we got a DB
95 * error). The connection will automatically be re-opened and
96 * statements will be re-prepared if they are needed again later.
97 *
98 * @param mc mysql context
99 */
100void
101GNUNET_MYSQL_statements_invalidate (struct GNUNET_MYSQL_Context *mc);
102
103
104/**
105 * Get internal handle for a prepared statement. This function should rarely
106 * be used, and if, with caution! On failures during the interaction with
107 * the handle, you must call #GNUNET_MYSQL_statements_invalidate()!
108 *
109 * @param sh prepared statement to introspect
110 * @return MySQL statement handle, NULL on error
111 */
112MYSQL_STMT *
113GNUNET_MYSQL_statement_get_stmt (struct GNUNET_MYSQL_StatementHandle *sh);
114
115
116/**
117 * Prepare a statement. Prepared statements are automatically discarded
118 * when the MySQL context is destroyed.
119 *
120 * @param mc mysql context
121 * @param query query text
122 * @return prepared statement, NULL on error
123 */
124struct GNUNET_MYSQL_StatementHandle *
125GNUNET_MYSQL_statement_prepare (struct GNUNET_MYSQL_Context *mc,
126 const char *query);
127
128
129/**
130 * Run a SQL statement.
131 *
132 * @param mc mysql context
133 * @param sql SQL statement to run
134 * @return #GNUNET_OK on success
135 * #GNUNET_SYSERR if there was a problem
136 */
137int
138GNUNET_MYSQL_statement_run (struct GNUNET_MYSQL_Context *mc,
139 const char *sql);
140
141
142#if 0 /* keep Emacsens' auto-indent happy */
143{
144#endif
145#ifdef __cplusplus
146}
147#endif
148
149#endif
150
151/** @} */ /* end of group */