diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-06-07 11:47:47 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-06-07 11:47:47 +0000 |
commit | 1893283990d3c128c67da900fde4b8c71b1939a7 (patch) | |
tree | 288ff80a631e6c169340b4ba3508c387c146f220 /src/my | |
parent | f1a8e79f1cff6a135297cf4eabb6db4733456ad5 (diff) | |
download | gnunet-1893283990d3c128c67da900fde4b8c71b1939a7.tar.gz gnunet-1893283990d3c128c67da900fde4b8c71b1939a7.zip |
-fix misc issues
Diffstat (limited to 'src/my')
-rw-r--r-- | src/my/my.c | 21 | ||||
-rw-r--r-- | src/my/my_query_helper.c | 46 | ||||
-rw-r--r-- | src/my/my_result_helper.c | 99 | ||||
-rw-r--r-- | src/my/test_my.c | 63 |
4 files changed, 120 insertions, 109 deletions
diff --git a/src/my/my.c b/src/my/my.c index 93b0a05b4..841ef28a4 100644 --- a/src/my/my.c +++ b/src/my/my.c | |||
@@ -39,7 +39,6 @@ | |||
39 | #GNUNET_YES if we can prepare all statement | 39 | #GNUNET_YES if we can prepare all statement |
40 | #GNUNET_SYSERR if we can't prepare all statement | 40 | #GNUNET_SYSERR if we can't prepare all statement |
41 | */ | 41 | */ |
42 | |||
43 | int | 42 | int |
44 | GNUNET_MY_exec_prepared (struct GNUNET_MYSQL_Context *mc, | 43 | GNUNET_MY_exec_prepared (struct GNUNET_MYSQL_Context *mc, |
45 | struct GNUNET_MYSQL_StatementHandle *sh, | 44 | struct GNUNET_MYSQL_StatementHandle *sh, |
@@ -82,15 +81,15 @@ GNUNET_MY_exec_prepared (struct GNUNET_MYSQL_Context *mc, | |||
82 | return GNUNET_SYSERR; | 81 | return GNUNET_SYSERR; |
83 | } | 82 | } |
84 | 83 | ||
85 | } | 84 | if (mysql_stmt_execute (stmt)) |
86 | if (mysql_stmt_execute (stmt)) | 85 | { |
87 | { | 86 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "mysql", |
88 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "mysql", | 87 | _("`%s' failed at %s:%d with error: %s\n"), |
89 | _("`%s' failed at %s:%d with error: %s\n"), | 88 | "mysql_stmt_execute", __FILE__, __LINE__, |
90 | "mysql_stmt_execute", __FILE__, __LINE__, | 89 | mysql_stmt_error (stmt)); |
91 | mysql_stmt_error (stmt)); | 90 | GNUNET_MYSQL_statements_invalidate (mc); |
92 | GNUNET_MYSQL_statements_invalidate (mc); | 91 | return GNUNET_SYSERR; |
93 | return GNUNET_SYSERR; | 92 | } |
94 | } | 93 | } |
95 | 94 | ||
96 | return GNUNET_OK; | 95 | return GNUNET_OK; |
@@ -175,7 +174,7 @@ GNUNET_MY_extract_result (struct GNUNET_MYSQL_StatementHandle *sh, | |||
175 | } | 174 | } |
176 | 175 | ||
177 | ret = mysql_stmt_fetch (stmt); | 176 | ret = mysql_stmt_fetch (stmt); |
178 | 177 | ||
179 | if (MYSQL_NO_DATA == ret) | 178 | if (MYSQL_NO_DATA == ret) |
180 | return GNUNET_NO; | 179 | return GNUNET_NO; |
181 | if ((0 != ret ) & (MYSQL_DATA_TRUNCATED != ret)) | 180 | if ((0 != ret ) & (MYSQL_DATA_TRUNCATED != ret)) |
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 | */ |
94 | static int | 94 | static int |
95 | my_conv_uint16 (void *cls, | 95 | my_conv_uint16 (void *cls, |
@@ -124,7 +124,7 @@ my_conv_uint16 (void *cls, | |||
124 | struct GNUNET_MY_QueryParam | 124 | struct GNUNET_MY_QueryParam |
125 | GNUNET_MY_query_param_uint16 (const uint16_t *x) | 125 | GNUNET_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 | */ |
146 | static int | 146 | static int |
147 | my_conv_uint32 (void *cls, | 147 | my_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 | */ |
194 | static int | 194 | static int |
195 | my_conv_uint64 (void *cls, | 195 | my_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 | */ |
242 | static int | 242 | static int |
243 | my_conv_rsa_public_key (void *cls, | 243 | my_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 | */ |
291 | static int | 293 | static int |
292 | my_conv_rsa_signature (void *cls, | 294 | my_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 */ |
diff --git a/src/my/my_result_helper.c b/src/my/my_result_helper.c index 2d2c18cec..9cfd373c7 100644 --- a/src/my/my_result_helper.c +++ b/src/my/my_result_helper.c | |||
@@ -1,12 +1,15 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet | 2 | This file is part of GNUnet |
3 | Copyright (C) 2014, 2015, 2016 GNUnet e.V. | 3 | Copyright (C) 2014, 2015, 2016 GNUnet e.V. |
4 | |||
4 | GNUnet is free software; you can redistribute it and/or modify it under the | 5 | GNUnet is free software; you can redistribute it and/or modify it under the |
5 | terms of the GNU General Public License as published by the Free Software | 6 | terms of the GNU General Public License as published by the Free Software |
6 | Foundation; either version 3, or (at your option) any later version. | 7 | Foundation; either version 3, or (at your option) any later version. |
8 | |||
7 | GNUnet is distributed in the hope that it will be useful, but WITHOUT ANY | 9 | GNUnet is distributed in the hope that it will be useful, but WITHOUT ANY |
8 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR | 10 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
9 | A PARTICULAR PURPOSE. See the GNU General Public License for more details. | 11 | A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
12 | |||
10 | You should have received a copy of the GNU General Public License along with | 13 | You should have received a copy of the GNU General Public License along with |
11 | GNUnet; see the file COPYING. If not, If not, see <http://www.gnu.org/licenses/> | 14 | GNUnet; see the file COPYING. If not, If not, see <http://www.gnu.org/licenses/> |
12 | */ | 15 | */ |
@@ -225,6 +228,7 @@ GNUNET_MY_result_spec_fixed_size (void *ptr, | |||
225 | return res; | 228 | return res; |
226 | } | 229 | } |
227 | 230 | ||
231 | |||
228 | /** | 232 | /** |
229 | * Extract data from a Mysql database @a result at row @a row | 233 | * Extract data from a Mysql database @a result at row @a row |
230 | * | 234 | * |
@@ -239,12 +243,11 @@ GNUNET_MY_result_spec_fixed_size (void *ptr, | |||
239 | * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) | 243 | * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) |
240 | */ | 244 | */ |
241 | static int | 245 | static int |
242 | pre_extract_rsa_public_key (void *cls, | 246 | pre_extract_rsa_public_key (void *cls, |
243 | struct GNUNET_MY_ResultSpec *rs, | 247 | struct GNUNET_MY_ResultSpec *rs, |
244 | MYSQL_STMT *stmt, | 248 | MYSQL_STMT *stmt, |
245 | unsigned int column, | 249 | unsigned int column, |
246 | MYSQL_BIND *results) | 250 | MYSQL_BIND *results) |
247 | |||
248 | { | 251 | { |
249 | results[0].buffer = NULL; | 252 | results[0].buffer = NULL; |
250 | results[0].buffer_length = 0; | 253 | results[0].buffer_length = 0; |
@@ -271,35 +274,41 @@ pre_extract_rsa_public_key (void *cls, | |||
271 | */ | 274 | */ |
272 | static int | 275 | static int |
273 | post_extract_rsa_public_key (void *cls, | 276 | post_extract_rsa_public_key (void *cls, |
274 | struct GNUNET_MY_ResultSpec *rs, | 277 | struct GNUNET_MY_ResultSpec *rs, |
275 | MYSQL_STMT *stmt, | 278 | MYSQL_STMT *stmt, |
276 | unsigned int column, | 279 | unsigned int column, |
277 | MYSQL_BIND *results) | 280 | MYSQL_BIND *results) |
278 | 281 | ||
279 | { | 282 | { |
280 | struct GNUNET_CRYPTO_RsaPublicKey **pk = rs->dst; | 283 | struct GNUNET_CRYPTO_RsaPublicKey **pk = rs->dst; |
281 | 284 | void *buf; | |
282 | size_t size; | 285 | size_t size; |
283 | char *res; | ||
284 | 286 | ||
285 | results[0].buffer = res; | 287 | size = (size_t) rs->mysql_bind_output_length; |
286 | results[0].buffer_length = size; | 288 | |
289 | if (rs->mysql_bind_output_length != size) | ||
290 | return GNUNET_SYSERR; /* 'unsigned long' does not fit in size_t!? */ | ||
291 | buf = GNUNET_malloc (size); | ||
287 | 292 | ||
288 | if (0 != | 293 | results[0].buffer = buf; |
289 | mysql_stmt_fetch_column (stmt, | 294 | results[0].buffer_length = size; |
290 | results, | 295 | results[0].buffer_type = MYSQL_TYPE_BLOB; |
291 | column, | 296 | if (0 != |
292 | 0)) | 297 | mysql_stmt_fetch_column (stmt, |
298 | results, | ||
299 | column, | ||
300 | 0)) | ||
293 | { | 301 | { |
294 | return GNUNET_SYSERR; | 302 | GNUNET_free (buf); |
303 | return GNUNET_SYSERR; | ||
295 | } | 304 | } |
296 | 305 | *pk = GNUNET_CRYPTO_rsa_public_key_decode (buf, | |
297 | *pk = GNUNET_CRYPTO_rsa_public_key_decode (res, | 306 | size); |
298 | size); | 307 | GNUNET_free (buf); |
299 | if (NULL == *pk) | 308 | if (NULL == *pk) |
300 | { | 309 | { |
301 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 310 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
302 | "Results contains bogus value (fail to decode)\n"); | 311 | "Results contains bogus public key value (fail to decode)\n"); |
303 | return GNUNET_SYSERR; | 312 | return GNUNET_SYSERR; |
304 | } | 313 | } |
305 | 314 | ||
@@ -324,7 +333,6 @@ clean_rsa_public_key (void *cls, | |||
324 | { | 333 | { |
325 | GNUNET_CRYPTO_rsa_public_key_free (*pk); | 334 | GNUNET_CRYPTO_rsa_public_key_free (*pk); |
326 | *pk = NULL; | 335 | *pk = NULL; |
327 | *rs->result_size = 0; | ||
328 | } | 336 | } |
329 | } | 337 | } |
330 | 338 | ||
@@ -378,6 +386,8 @@ pre_extract_rsa_signature (void *cls, | |||
378 | 386 | ||
379 | return GNUNET_OK; | 387 | return GNUNET_OK; |
380 | } | 388 | } |
389 | |||
390 | |||
381 | /** | 391 | /** |
382 | * Extract data from a Mysql database @a result at row @a row. | 392 | * Extract data from a Mysql database @a result at row @a row. |
383 | * | 393 | * |
@@ -399,31 +409,37 @@ post_extract_rsa_signature (void *cls, | |||
399 | MYSQL_BIND *results) | 409 | MYSQL_BIND *results) |
400 | { | 410 | { |
401 | struct GNUNET_CRYPTO_RsaSignature **sig = rs->dst; | 411 | struct GNUNET_CRYPTO_RsaSignature **sig = rs->dst; |
402 | size_t size = 0 ; | 412 | void *buf; |
403 | char *res = NULL; | 413 | size_t size; |
404 | 414 | ||
405 | results[0].buffer = res; | 415 | size = (size_t) rs->mysql_bind_output_length; |
406 | results[0].buffer_length = size; | 416 | |
417 | if (rs->mysql_bind_output_length != size) | ||
418 | return GNUNET_SYSERR; /* 'unsigned long' does not fit in size_t!? */ | ||
419 | buf = GNUNET_malloc (size); | ||
407 | 420 | ||
408 | if (0 != | 421 | results[0].buffer = buf; |
422 | results[0].buffer_length = size; | ||
423 | results[0].buffer_type = MYSQL_TYPE_BLOB; | ||
424 | if (0 != | ||
409 | mysql_stmt_fetch_column (stmt, | 425 | mysql_stmt_fetch_column (stmt, |
410 | results, | 426 | results, |
411 | column, | 427 | column, |
412 | 0)) | 428 | 0)) |
413 | { | 429 | { |
430 | GNUNET_free (buf); | ||
414 | return GNUNET_SYSERR; | 431 | return GNUNET_SYSERR; |
415 | } | 432 | } |
416 | 433 | ||
417 | *sig = GNUNET_CRYPTO_rsa_signature_decode (res, | 434 | *sig = GNUNET_CRYPTO_rsa_signature_decode (buf, |
418 | size); | 435 | size); |
419 | 436 | GNUNET_free (buf); | |
420 | if (NULL != *sig) | 437 | if (NULL == *sig) |
421 | { | 438 | { |
422 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 439 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
423 | "Resuls contains bogus value (fails to decode)\n"); | 440 | "Resuls contains bogus signature value (fails to decode)\n"); |
424 | return GNUNET_SYSERR; | 441 | return GNUNET_SYSERR; |
425 | } | 442 | } |
426 | |||
427 | return GNUNET_OK; | 443 | return GNUNET_OK; |
428 | } | 444 | } |
429 | 445 | ||
@@ -445,7 +461,6 @@ clean_rsa_signature (void *cls, | |||
445 | { | 461 | { |
446 | GNUNET_CRYPTO_rsa_signature_free (*sig); | 462 | GNUNET_CRYPTO_rsa_signature_free (*sig); |
447 | *sig = NULL; | 463 | *sig = NULL; |
448 | rs->result_size = 0; | ||
449 | } | 464 | } |
450 | } | 465 | } |
451 | 466 | ||
@@ -523,7 +538,7 @@ pre_extract_string (void * cls, | |||
523 | 538 | ||
524 | 539 | ||
525 | /** | 540 | /** |
526 | * Check size of extracted fixed size data from a Mysql database @a | 541 | * Check size of extracted fixed size data from a Mysql database @a |
527 | * | 542 | * |
528 | * @param cls closure | 543 | * @param cls closure |
529 | * @param result where to extract data from | 544 | * @param result where to extract data from |
@@ -545,7 +560,7 @@ post_extract_string (void * cls, | |||
545 | if (rs->dst_size != rs->mysql_bind_output_length) | 560 | if (rs->dst_size != rs->mysql_bind_output_length) |
546 | return GNUNET_SYSERR; | 561 | return GNUNET_SYSERR; |
547 | return GNUNET_OK; | 562 | return GNUNET_OK; |
548 | /* | 563 | /* |
549 | char **str = rs->dst; | 564 | char **str = rs->dst; |
550 | size_t len; | 565 | size_t len; |
551 | const char *res; | 566 | const char *res; |
diff --git a/src/my/test_my.c b/src/my/test_my.c index b8b5faf33..f0766ac2c 100644 --- a/src/my/test_my.c +++ b/src/my/test_my.c | |||
@@ -37,7 +37,7 @@ | |||
37 | static int | 37 | static int |
38 | run_queries (struct GNUNET_MYSQL_Context *context) | 38 | run_queries (struct GNUNET_MYSQL_Context *context) |
39 | { | 39 | { |
40 | struct GNUNET_CRYPTO_RsaPublicKey *pub; | 40 | struct GNUNET_CRYPTO_RsaPublicKey *pub; |
41 | struct GNUNET_CRYPTO_RsaPublicKey *pub2 = NULL; | 41 | struct GNUNET_CRYPTO_RsaPublicKey *pub2 = NULL; |
42 | struct GNUNET_CRYPTO_RsaSignature *sig; | 42 | struct GNUNET_CRYPTO_RsaSignature *sig; |
43 | struct GNUNET_CRYPTO_RsaSignature *sig2 = NULL; | 43 | struct GNUNET_CRYPTO_RsaSignature *sig2 = NULL; |
@@ -154,12 +154,12 @@ run_queries (struct GNUNET_MYSQL_Context *context) | |||
154 | " ORDER BY abs_time DESC " | 154 | " ORDER BY abs_time DESC " |
155 | " LIMIT 1;"); | 155 | " LIMIT 1;"); |
156 | 156 | ||
157 | */ | 157 | */ |
158 | statements_handle_select = GNUNET_MYSQL_statement_prepare (context, | 158 | statements_handle_select = GNUNET_MYSQL_statement_prepare (context, |
159 | "SELECT" | 159 | "SELECT" |
160 | //" pub" | 160 | " pub" |
161 | //" sig" | 161 | ",sig" |
162 | " abs_time" | 162 | ",abs_time" |
163 | ",forever" | 163 | ",forever" |
164 | ",hash" | 164 | ",hash" |
165 | ",vsize" | 165 | ",vsize" |
@@ -201,8 +201,8 @@ run_queries (struct GNUNET_MYSQL_Context *context) | |||
201 | }; | 201 | }; |
202 | */ | 202 | */ |
203 | struct GNUNET_MY_ResultSpec results_select[] = { | 203 | struct GNUNET_MY_ResultSpec results_select[] = { |
204 | //GNUNET_MY_result_spec_rsa_public_key (&pub2), | 204 | GNUNET_MY_result_spec_rsa_public_key (&pub2), |
205 | //GNUNET_MY_result_spec_rsa_signature (&sig2), | 205 | GNUNET_MY_result_spec_rsa_signature (&sig2), |
206 | GNUNET_MY_result_spec_absolute_time (&abs_time2), | 206 | GNUNET_MY_result_spec_absolute_time (&abs_time2), |
207 | GNUNET_MY_result_spec_absolute_time (&forever2), | 207 | GNUNET_MY_result_spec_absolute_time (&forever2), |
208 | GNUNET_MY_result_spec_auto_from_type (&hc2), | 208 | GNUNET_MY_result_spec_auto_from_type (&hc2), |
@@ -244,12 +244,11 @@ run_queries (struct GNUNET_MYSQL_Context *context) | |||
244 | } | 244 | } |
245 | 245 | ||
246 | 246 | ||
247 | int | 247 | int |
248 | main (int argc, const char * const argv[]) | 248 | main (int argc, const char * const argv[]) |
249 | { | 249 | { |
250 | struct GNUNET_CONFIGURATION_Handle *config; | 250 | struct GNUNET_CONFIGURATION_Handle *config; |
251 | struct GNUNET_MYSQL_Context *context; | 251 | struct GNUNET_MYSQL_Context *context; |
252 | |||
253 | int ret; | 252 | int ret; |
254 | 253 | ||
255 | GNUNET_log_setup ( "test-my", | 254 | GNUNET_log_setup ( "test-my", |
@@ -257,19 +256,13 @@ main (int argc, const char * const argv[]) | |||
257 | NULL); | 256 | NULL); |
258 | 257 | ||
259 | config = GNUNET_CONFIGURATION_create (); | 258 | config = GNUNET_CONFIGURATION_create (); |
260 | if (NULL == config) | ||
261 | { | ||
262 | fprintf (stderr, "Failed to create a configuration\n"); | ||
263 | return 1; | ||
264 | } | ||
265 | |||
266 | if (GNUNET_OK != GNUNET_CONFIGURATION_parse (config, "test_my.conf")) | 259 | if (GNUNET_OK != GNUNET_CONFIGURATION_parse (config, "test_my.conf")) |
267 | { | 260 | { |
268 | fprintf (stderr, "Failed to parse configuaration\n"); | 261 | fprintf (stderr, "Failed to parse configuaration\n"); |
269 | return 1; | 262 | return 1; |
270 | } | 263 | } |
271 | 264 | ||
272 | context = GNUNET_MYSQL_context_create (config, | 265 | context = GNUNET_MYSQL_context_create (config, |
273 | "datastore-mysql"); | 266 | "datastore-mysql"); |
274 | if (NULL == context) | 267 | if (NULL == context) |
275 | { | 268 | { |
@@ -277,24 +270,26 @@ main (int argc, const char * const argv[]) | |||
277 | return 77; | 270 | return 77; |
278 | } | 271 | } |
279 | 272 | ||
273 | (void) GNUNET_MYSQL_statement_run (context, | ||
274 | "DROP TABLE test_my2;"); | ||
280 | if (GNUNET_OK != GNUNET_MYSQL_statement_run (context, | 275 | if (GNUNET_OK != GNUNET_MYSQL_statement_run (context, |
281 | "CREATE TABLE test_my2(" | 276 | "CREATE TABLE IF NOT EXISTS test_my2(" |
282 | "pub BLOB NOT NULL" | 277 | " pub BLOB NOT NULL" |
283 | ", sig BLOB NOT NULL" | 278 | ",sig BLOB NOT NULL" |
284 | ", abs_time BIGINT NOT NULL" | 279 | ",abs_time BIGINT NOT NULL" |
285 | ", forever BIGINT NOT NULL" | 280 | ",forever BIGINT NOT NULL" |
286 | ", hash BLOB NOT NULL CHECK(LENGTH(hash)=64)" | 281 | ",hash BLOB NOT NULL CHECK(LENGTH(hash)=64)" |
287 | ", vsize BLOB NOT NULL" | 282 | ",vsize BLOB NOT NULL" |
288 | ", u16 SMALLINT NOT NULL" | 283 | ",u16 SMALLINT NOT NULL" |
289 | ", u32 INT NOT NULL" | 284 | ",u32 INT NOT NULL" |
290 | ", u64 BIGINT NOT NULL" | 285 | ",u64 BIGINT NOT NULL" |
291 | ")")) | 286 | ")")) |
292 | { | 287 | { |
293 | fprintf (stderr, | 288 | fprintf (stderr, |
294 | "Failed to create table \n"); | 289 | "Failed to create table \n"); |
295 | GNUNET_MYSQL_statements_invalidate (context); | 290 | GNUNET_MYSQL_statements_invalidate (context); |
296 | GNUNET_MYSQL_context_destroy (context); | 291 | GNUNET_MYSQL_context_destroy (context); |
297 | 292 | ||
298 | return 1; | 293 | return 1; |
299 | } | 294 | } |
300 | 295 | ||
@@ -308,11 +303,11 @@ main (int argc, const char * const argv[]) | |||
308 | ", u64 BIGINT NOT NULL" | 303 | ", u64 BIGINT NOT NULL" |
309 | ")")) | 304 | ")")) |
310 | { | 305 | { |
311 | fprintf (stderr, | 306 | fprintf (stderr, |
312 | "Failed to create table \n"); | 307 | "Failed to create table \n"); |
313 | GNUNET_MYSQL_statements_invalidate (context); | 308 | GNUNET_MYSQL_statements_invalidate (context); |
314 | GNUNET_MYSQL_context_destroy (context); | 309 | GNUNET_MYSQL_context_destroy (context); |
315 | 310 | ||
316 | return 1; | 311 | return 1; |
317 | } | 312 | } |
318 | */ | 313 | */ |