aboutsummaryrefslogtreecommitdiff
path: root/src/my/my_query_helper.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-06-07 11:47:47 +0000
committerChristian Grothoff <christian@grothoff.org>2016-06-07 11:47:47 +0000
commit1893283990d3c128c67da900fde4b8c71b1939a7 (patch)
tree288ff80a631e6c169340b4ba3508c387c146f220 /src/my/my_query_helper.c
parentf1a8e79f1cff6a135297cf4eabb6db4733456ad5 (diff)
downloadgnunet-1893283990d3c128c67da900fde4b8c71b1939a7.tar.gz
gnunet-1893283990d3c128c67da900fde4b8c71b1939a7.zip
-fix misc issues
Diffstat (limited to 'src/my/my_query_helper.c')
-rw-r--r--src/my/my_query_helper.c46
1 files changed, 24 insertions, 22 deletions
diff --git a/src/my/my_query_helper.c b/src/my/my_query_helper.c
index 07eb2481d..99bb4a5e4 100644
--- a/src/my/my_query_helper.c
+++ b/src/my/my_query_helper.c
@@ -89,7 +89,7 @@ GNUNET_MY_query_param_string (const char *ptr)
89 *@param cls closure 89 *@param cls closure
90 *@param pq data about the query 90 *@param pq data about the query
91 * @param qbind array of parameters to initialize 91 * @param qbind array of parameters to initialize
92 *@return -1 on error 92 *@return -1 on error
93 */ 93 */
94static int 94static int
95my_conv_uint16 (void *cls, 95my_conv_uint16 (void *cls,
@@ -124,7 +124,7 @@ my_conv_uint16 (void *cls,
124struct GNUNET_MY_QueryParam 124struct GNUNET_MY_QueryParam
125GNUNET_MY_query_param_uint16 (const uint16_t *x) 125GNUNET_MY_query_param_uint16 (const uint16_t *x)
126{ 126{
127 struct GNUNET_MY_QueryParam res = { 127 struct GNUNET_MY_QueryParam res = {
128 .conv = &my_conv_uint16, 128 .conv = &my_conv_uint16,
129 .conv_cls = NULL, 129 .conv_cls = NULL,
130 .num_params = 1, 130 .num_params = 1,
@@ -141,9 +141,9 @@ GNUNET_MY_query_param_uint16 (const uint16_t *x)
141 *@param cls closure 141 *@param cls closure
142 *@param pq data about the query 142 *@param pq data about the query
143 * @param qbind array of parameters to initialize 143 * @param qbind array of parameters to initialize
144 *@return -1 on error 144 *@return -1 on error
145 */ 145 */
146static int 146static int
147my_conv_uint32 (void *cls, 147my_conv_uint32 (void *cls,
148 const struct GNUNET_MY_QueryParam *qp, 148 const struct GNUNET_MY_QueryParam *qp,
149 MYSQL_BIND *qbind) 149 MYSQL_BIND *qbind)
@@ -176,10 +176,10 @@ GNUNET_MY_query_param_uint32 (const uint32_t *x)
176 .conv = &my_conv_uint32, 176 .conv = &my_conv_uint32,
177 .conv_cls = NULL, 177 .conv_cls = NULL,
178 .num_params = 1, 178 .num_params = 1,
179 .data = x, 179 .data = x,
180 .data_len = sizeof (*x) 180 .data_len = sizeof (*x)
181 }; 181 };
182 182
183 return res; 183 return res;
184} 184}
185 185
@@ -189,7 +189,7 @@ GNUNET_MY_query_param_uint32 (const uint32_t *x)
189 *@param cls closure 189 *@param cls closure
190 *@param pq data about the query 190 *@param pq data about the query
191 * @param qbind array of parameters to initialize 191 * @param qbind array of parameters to initialize
192 *@return -1 on error 192 *@return -1 on error
193 */ 193 */
194static int 194static int
195my_conv_uint64 (void *cls, 195my_conv_uint64 (void *cls,
@@ -209,7 +209,7 @@ my_conv_uint64 (void *cls,
209 qbind->buffer_length = sizeof (uint64_t); 209 qbind->buffer_length = sizeof (uint64_t);
210 qbind->buffer_type = MYSQL_TYPE_LONGLONG; 210 qbind->buffer_type = MYSQL_TYPE_LONGLONG;
211 211
212 return 1; 212 return 1;
213} 213}
214 214
215/** 215/**
@@ -237,7 +237,7 @@ GNUNET_MY_query_param_uint64 (const uint64_t *x)
237 *@param cls closure 237 *@param cls closure
238 *@param pq data about the query 238 *@param pq data about the query
239 * @param qbind array of parameters to initialize 239 * @param qbind array of parameters to initialize
240 *@return -1 on error 240 *@return -1 on error
241 */ 241 */
242static int 242static int
243my_conv_rsa_public_key (void *cls, 243my_conv_rsa_public_key (void *cls,
@@ -249,16 +249,17 @@ my_conv_rsa_public_key (void *cls,
249 size_t buf_size; 249 size_t buf_size;
250 250
251 GNUNET_assert(1 == qp->num_params); 251 GNUNET_assert(1 == qp->num_params);
252 252 // FIXME: this leaks memory right now...
253 buf_size = GNUNET_CRYPTO_rsa_public_key_encode (rsa, &buf); 253 buf_size = GNUNET_CRYPTO_rsa_public_key_encode (rsa, &buf);
254 254
255 qbind->buffer = (void *)buf; 255 qbind->buffer = (void *) buf;
256 qbind->buffer_length = buf_size-1; 256 qbind->buffer_length = buf_size;
257 qbind->buffer_type = MYSQL_TYPE_BLOB; 257 qbind->buffer_type = MYSQL_TYPE_BLOB;
258 258
259 return 1; 259 return 1;
260 } 260 }
261 261
262
262 /** 263 /**
263 * Generate query parameter for an RSA public key. The 264 * Generate query parameter for an RSA public key. The
264 * database must contain a BLOB type in the respective position. 265 * database must contain a BLOB type in the respective position.
@@ -280,18 +281,19 @@ GNUNET_MY_query_param_rsa_public_key (const struct GNUNET_CRYPTO_RsaPublicKey *x
280 return res; 281 return res;
281} 282}
282 283
284
283/** 285/**
284 * Function called to convert input argument into SQL parameters 286 * Function called to convert input argument into SQL parameters
285 * 287 *
286 *@param cls closure 288 *@param cls closure
287 *@param pq data about the query 289 *@param pq data about the query
288 * @param qbind array of parameters to initialize 290 * @param qbind array of parameters to initialize
289 *@return -1 on error 291 *@return -1 on error
290 */ 292 */
291static int 293static int
292my_conv_rsa_signature (void *cls, 294my_conv_rsa_signature (void *cls,
293 const struct GNUNET_MY_QueryParam *qp, 295 const struct GNUNET_MY_QueryParam *qp,
294 MYSQL_BIND * qbind) 296 MYSQL_BIND *qbind)
295{ 297{
296 const struct GNUNET_CRYPTO_RsaSignature *sig = qp->data; 298 const struct GNUNET_CRYPTO_RsaSignature *sig = qp->data;
297 char *buf; 299 char *buf;
@@ -299,16 +301,16 @@ my_conv_rsa_signature (void *cls,
299 301
300 GNUNET_assert(1 == qp->num_params); 302 GNUNET_assert(1 == qp->num_params);
301 303
302 buf_size = GNUNET_CRYPTO_rsa_signature_encode(sig, 304 buf_size = GNUNET_CRYPTO_rsa_signature_encode (sig,
303 &buf); 305 &buf);
304 306 qbind->buffer = (void *) buf;
305 qbind->buffer = (void *)buf; 307 qbind->buffer_length = buf_size;
306 qbind->buffer_length = buf_size-1;
307 qbind->buffer_type = MYSQL_TYPE_BLOB; 308 qbind->buffer_type = MYSQL_TYPE_BLOB;
308 309
309 return 1; 310 return 1;
310} 311}
311 312
313
312/** 314/**
313 * Generate query parameter for an RSA signature. The 315 * Generate query parameter for an RSA signature. The
314 * database must contain a BLOB type in the respective position 316 * database must contain a BLOB type in the respective position
@@ -354,4 +356,4 @@ GNUNET_MY_query_param_absolute_time_nbo (const struct GNUNET_TIME_AbsoluteNBO *x
354 return GNUNET_MY_query_param_auto_from_type (&x->abs_value_us__); 356 return GNUNET_MY_query_param_auto_from_type (&x->abs_value_us__);
355} 357}
356 358
357/* end of my_query_helper.c */ \ No newline at end of file 359/* end of my_query_helper.c */