aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_my_lib.h
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-05-19 11:48:46 +0000
committerChristian Grothoff <christian@grothoff.org>2016-05-19 11:48:46 +0000
commitfaf7c575d400f0623c5244944852e256c33d0f6e (patch)
treef69b306b04e7798d4f487f42a8ee8f119c94b954 /src/include/gnunet_my_lib.h
parentc68f44aa5797f1e765e6119a5b895c1746e8c958 (diff)
downloadgnunet-faf7c575d400f0623c5244944852e256c33d0f6e.tar.gz
gnunet-faf7c575d400f0623c5244944852e256c33d0f6e.zip
forgot file
Diffstat (limited to 'src/include/gnunet_my_lib.h')
-rw-r--r--src/include/gnunet_my_lib.h148
1 files changed, 148 insertions, 0 deletions
diff --git a/src/include/gnunet_my_lib.h b/src/include/gnunet_my_lib.h
new file mode 100644
index 000000000..3ac544ece
--- /dev/null
+++ b/src/include/gnunet_my_lib.h
@@ -0,0 +1,148 @@
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
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 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 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
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_MY_LIB_H
31#define GNUNET_MY_LIB_H
32
33#include "gnunet_util_lib.h"
34#include "gnunet_mysql_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
47/**
48 * Information we pass to #GNUNET_MY_exec_prepared() to
49 * initialize the arguments of the prepared statement.
50 */
51struct GNUNET_MY_QueryParam;
52
53
54/**
55 * Function called to convert input argument into SQL parameters.
56 *
57 * @param cls closure
58 * @param pq data about the query
59 * @param qbind array of parameters to initialize
60 * @return -1 on error
61 */
62typedef int
63(*GNUNET_MY_QueryConverter)(void *cls,
64 const struct GNUNET_MY_QueryParam *qp,
65 MYSQL_BIND *qbind);
66
67
68
69/**
70 * Information we pass to #GNUNET_MY_exec_prepared() to
71 * initialize the arguments of the prepared statement.
72 */
73struct GNUNET_MY_QueryParam
74{
75
76 /**
77 * Function to call for the type conversion.
78 */
79 GNUNET_MY_QueryConverter conv;
80
81 /**
82 * Closure for @e conv.
83 */
84 void *conv_cls;
85
86 /**
87 * Number of arguments the @a conv converter expects to initialize.
88 */
89 unsigned int num_params;
90
91 /**
92 * Information to pass to @e conv.
93 */
94 const void *data;
95
96 /**
97 * Information to pass to @e conv. Size of @a data.
98 */
99 unsigned long data_len;
100
101};
102
103
104/**
105 * End of result parameter specification.
106 *
107 * @return array last entry for the result specification to use
108 */
109#define GNUNET_MY_query_param_end { NULL, NULL, 0, NULL, 0 }
110
111
112
113/**
114 * Generate query parameter for a buffer @a ptr of
115 * @a ptr_size bytes.
116 *
117 * @param ptr pointer to the query parameter to pass
118 * @oaran ptr_size number of bytes in @a ptr
119 */
120struct GNUNET_MY_QueryParam
121GNUNET_MY_query_param_fixed_size (const void *ptr,
122 size_t ptr_size);
123
124
125/**
126 * Run a prepared SELECT statement.
127 *
128 * @param mc mysql context
129 * @param sh handle to SELECT statment
130 * @param params parameters to the statement
131 * @return TBD
132 */
133int
134GNUNET_MY_exec_prepared (struct GNUNET_MYSQL_Context *mc,
135 struct GNUNET_MYSQL_StatementHandle *sh,
136 const struct GNUNET_MY_QueryParam *params);
137
138
139#if 0 /* keep Emacsens' auto-indent happy */
140{
141#endif
142#ifdef __cplusplus
143}
144#endif
145
146#endif
147
148/** @} */ /* end of group */