diff options
Diffstat (limited to 'src/my/my_result_helper.c')
-rw-r--r-- | src/my/my_result_helper.c | 381 |
1 files changed, 189 insertions, 192 deletions
diff --git a/src/my/my_result_helper.c b/src/my/my_result_helper.c index 2fedc1f19..78f1a1ec0 100644 --- a/src/my/my_result_helper.c +++ b/src/my/my_result_helper.c | |||
@@ -41,11 +41,11 @@ | |||
41 | * #GNUNET_SYSERR if a result was invalid | 41 | * #GNUNET_SYSERR if a result was invalid |
42 | */ | 42 | */ |
43 | static int | 43 | static int |
44 | pre_extract_varsize_blob(void *cls, | 44 | pre_extract_varsize_blob (void *cls, |
45 | struct GNUNET_MY_ResultSpec *rs, | 45 | struct GNUNET_MY_ResultSpec *rs, |
46 | MYSQL_STMT *stmt, | 46 | MYSQL_STMT *stmt, |
47 | unsigned int column, | 47 | unsigned int column, |
48 | MYSQL_BIND *results) | 48 | MYSQL_BIND *results) |
49 | { | 49 | { |
50 | results[0].buffer = NULL; | 50 | results[0].buffer = NULL; |
51 | results[0].buffer_length = 0; | 51 | results[0].buffer_length = 0; |
@@ -70,39 +70,39 @@ pre_extract_varsize_blob(void *cls, | |||
70 | * #GNUNET_SYSERR if a result was invalid | 70 | * #GNUNET_SYSERR if a result was invalid |
71 | */ | 71 | */ |
72 | static int | 72 | static int |
73 | post_extract_varsize_blob(void *cls, | 73 | post_extract_varsize_blob (void *cls, |
74 | struct GNUNET_MY_ResultSpec *rs, | 74 | struct GNUNET_MY_ResultSpec *rs, |
75 | MYSQL_STMT *stmt, | 75 | MYSQL_STMT *stmt, |
76 | unsigned int column, | 76 | unsigned int column, |
77 | MYSQL_BIND *results) | 77 | MYSQL_BIND *results) |
78 | { | 78 | { |
79 | void *buf; | 79 | void *buf; |
80 | size_t size; | 80 | size_t size; |
81 | 81 | ||
82 | if (*results->is_null) | 82 | if (*results->is_null) |
83 | return GNUNET_SYSERR; | 83 | return GNUNET_SYSERR; |
84 | size = (size_t)rs->mysql_bind_output_length; | 84 | size = (size_t) rs->mysql_bind_output_length; |
85 | 85 | ||
86 | if (rs->mysql_bind_output_length != size) | 86 | if (rs->mysql_bind_output_length != size) |
87 | return GNUNET_SYSERR; /* 'unsigned long' does not fit in size_t!? */ | 87 | return GNUNET_SYSERR; /* 'unsigned long' does not fit in size_t!? */ |
88 | 88 | ||
89 | buf = GNUNET_malloc(size); | 89 | buf = GNUNET_malloc (size); |
90 | 90 | ||
91 | results[0].buffer = buf; | 91 | results[0].buffer = buf; |
92 | results[0].buffer_length = size; | 92 | results[0].buffer_length = size; |
93 | results[0].buffer_type = MYSQL_TYPE_BLOB; | 93 | results[0].buffer_type = MYSQL_TYPE_BLOB; |
94 | 94 | ||
95 | if (0 != | 95 | if (0 != |
96 | mysql_stmt_fetch_column(stmt, | 96 | mysql_stmt_fetch_column (stmt, |
97 | results, | 97 | results, |
98 | column, | 98 | column, |
99 | 0)) | 99 | 0)) |
100 | { | 100 | { |
101 | GNUNET_free(buf); | 101 | GNUNET_free (buf); |
102 | return GNUNET_SYSERR; | 102 | return GNUNET_SYSERR; |
103 | } | 103 | } |
104 | 104 | ||
105 | *(void **)rs->dst = buf; | 105 | *(void **) rs->dst = buf; |
106 | *rs->result_size = size; | 106 | *rs->result_size = size; |
107 | 107 | ||
108 | return GNUNET_OK; | 108 | return GNUNET_OK; |
@@ -116,16 +116,16 @@ post_extract_varsize_blob(void *cls, | |||
116 | * @param[in,out] rs | 116 | * @param[in,out] rs |
117 | */ | 117 | */ |
118 | static void | 118 | static void |
119 | cleanup_varsize_blob(void *cls, | 119 | cleanup_varsize_blob (void *cls, |
120 | struct GNUNET_MY_ResultSpec *rs) | 120 | struct GNUNET_MY_ResultSpec *rs) |
121 | { | 121 | { |
122 | void **ptr = (void **)rs->dst; | 122 | void **ptr = (void **) rs->dst; |
123 | 123 | ||
124 | if (NULL != *ptr) | 124 | if (NULL != *ptr) |
125 | { | 125 | { |
126 | GNUNET_free(*ptr); | 126 | GNUNET_free (*ptr); |
127 | *ptr = NULL; | 127 | *ptr = NULL; |
128 | } | 128 | } |
129 | } | 129 | } |
130 | 130 | ||
131 | 131 | ||
@@ -137,15 +137,14 @@ cleanup_varsize_blob(void *cls, | |||
137 | * @return array entru for the result specification to use | 137 | * @return array entru for the result specification to use |
138 | */ | 138 | */ |
139 | struct GNUNET_MY_ResultSpec | 139 | struct GNUNET_MY_ResultSpec |
140 | GNUNET_MY_result_spec_variable_size(void **dst, | 140 | GNUNET_MY_result_spec_variable_size (void **dst, |
141 | size_t *ptr_size) | 141 | size_t *ptr_size) |
142 | { | 142 | { |
143 | struct GNUNET_MY_ResultSpec res = | 143 | struct GNUNET_MY_ResultSpec res = { |
144 | { | ||
145 | .pre_conv = &pre_extract_varsize_blob, | 144 | .pre_conv = &pre_extract_varsize_blob, |
146 | .post_conv = &post_extract_varsize_blob, | 145 | .post_conv = &post_extract_varsize_blob, |
147 | .cleaner = &cleanup_varsize_blob, | 146 | .cleaner = &cleanup_varsize_blob, |
148 | .dst = (void *)(dst), | 147 | .dst = (void *) (dst), |
149 | .result_size = ptr_size, | 148 | .result_size = ptr_size, |
150 | .num_fields = 1 | 149 | .num_fields = 1 |
151 | }; | 150 | }; |
@@ -167,11 +166,11 @@ GNUNET_MY_result_spec_variable_size(void **dst, | |||
167 | * #GNUNET_SYSERR if a result was invalid(non-existing field or NULL) | 166 | * #GNUNET_SYSERR if a result was invalid(non-existing field or NULL) |
168 | */ | 167 | */ |
169 | static int | 168 | static int |
170 | pre_extract_fixed_blob(void *cls, | 169 | pre_extract_fixed_blob (void *cls, |
171 | struct GNUNET_MY_ResultSpec *rs, | 170 | struct GNUNET_MY_ResultSpec *rs, |
172 | MYSQL_STMT *stmt, | 171 | MYSQL_STMT *stmt, |
173 | unsigned int column, | 172 | unsigned int column, |
174 | MYSQL_BIND *results) | 173 | MYSQL_BIND *results) |
175 | { | 174 | { |
176 | results[0].buffer = rs->dst; | 175 | results[0].buffer = rs->dst; |
177 | results[0].buffer_length = rs->dst_size; | 176 | results[0].buffer_length = rs->dst_size; |
@@ -198,11 +197,11 @@ pre_extract_fixed_blob(void *cls, | |||
198 | * #GNUNET_SYSERR if a result was invalid(non-existing field or NULL) | 197 | * #GNUNET_SYSERR if a result was invalid(non-existing field or NULL) |
199 | */ | 198 | */ |
200 | static int | 199 | static int |
201 | post_extract_fixed_blob(void *cls, | 200 | post_extract_fixed_blob (void *cls, |
202 | struct GNUNET_MY_ResultSpec *rs, | 201 | struct GNUNET_MY_ResultSpec *rs, |
203 | MYSQL_STMT *stmt, | 202 | MYSQL_STMT *stmt, |
204 | unsigned int column, | 203 | unsigned int column, |
205 | MYSQL_BIND *results) | 204 | MYSQL_BIND *results) |
206 | { | 205 | { |
207 | if (*results->is_null) | 206 | if (*results->is_null) |
208 | return GNUNET_SYSERR; | 207 | return GNUNET_SYSERR; |
@@ -221,15 +220,14 @@ post_extract_fixed_blob(void *cls, | |||
221 | * @return array entry for the result specification to use | 220 | * @return array entry for the result specification to use |
222 | */ | 221 | */ |
223 | struct GNUNET_MY_ResultSpec | 222 | struct GNUNET_MY_ResultSpec |
224 | GNUNET_MY_result_spec_fixed_size(void *ptr, | 223 | GNUNET_MY_result_spec_fixed_size (void *ptr, |
225 | size_t ptr_size) | 224 | size_t ptr_size) |
226 | { | 225 | { |
227 | struct GNUNET_MY_ResultSpec res = | 226 | struct GNUNET_MY_ResultSpec res = { |
228 | { | ||
229 | .pre_conv = &pre_extract_fixed_blob, | 227 | .pre_conv = &pre_extract_fixed_blob, |
230 | .post_conv = &post_extract_fixed_blob, | 228 | .post_conv = &post_extract_fixed_blob, |
231 | .cleaner = NULL, | 229 | .cleaner = NULL, |
232 | .dst = (void *)(ptr), | 230 | .dst = (void *) (ptr), |
233 | .dst_size = ptr_size, | 231 | .dst_size = ptr_size, |
234 | .num_fields = 1 | 232 | .num_fields = 1 |
235 | }; | 233 | }; |
@@ -251,11 +249,11 @@ GNUNET_MY_result_spec_fixed_size(void *ptr, | |||
251 | * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) | 249 | * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) |
252 | */ | 250 | */ |
253 | static int | 251 | static int |
254 | pre_extract_rsa_public_key(void *cls, | 252 | pre_extract_rsa_public_key (void *cls, |
255 | struct GNUNET_MY_ResultSpec *rs, | 253 | struct GNUNET_MY_ResultSpec *rs, |
256 | MYSQL_STMT *stmt, | 254 | MYSQL_STMT *stmt, |
257 | unsigned int column, | 255 | unsigned int column, |
258 | MYSQL_BIND *results) | 256 | MYSQL_BIND *results) |
259 | { | 257 | { |
260 | results[0].buffer = NULL; | 258 | results[0].buffer = NULL; |
261 | results[0].buffer_length = 0; | 259 | results[0].buffer_length = 0; |
@@ -282,11 +280,11 @@ pre_extract_rsa_public_key(void *cls, | |||
282 | * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) | 280 | * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) |
283 | */ | 281 | */ |
284 | static int | 282 | static int |
285 | post_extract_rsa_public_key(void *cls, | 283 | post_extract_rsa_public_key (void *cls, |
286 | struct GNUNET_MY_ResultSpec *rs, | 284 | struct GNUNET_MY_ResultSpec *rs, |
287 | MYSQL_STMT *stmt, | 285 | MYSQL_STMT *stmt, |
288 | unsigned int column, | 286 | unsigned int column, |
289 | MYSQL_BIND *results) | 287 | MYSQL_BIND *results) |
290 | 288 | ||
291 | { | 289 | { |
292 | struct GNUNET_CRYPTO_RsaPublicKey **pk = rs->dst; | 290 | struct GNUNET_CRYPTO_RsaPublicKey **pk = rs->dst; |
@@ -295,34 +293,34 @@ post_extract_rsa_public_key(void *cls, | |||
295 | 293 | ||
296 | if (*results->is_null) | 294 | if (*results->is_null) |
297 | return GNUNET_SYSERR; | 295 | return GNUNET_SYSERR; |
298 | size = (size_t)rs->mysql_bind_output_length; | 296 | size = (size_t) rs->mysql_bind_output_length; |
299 | 297 | ||
300 | if (rs->mysql_bind_output_length != size) | 298 | if (rs->mysql_bind_output_length != size) |
301 | return GNUNET_SYSERR; /* 'unsigned long' does not fit in size_t!? */ | 299 | return GNUNET_SYSERR; /* 'unsigned long' does not fit in size_t!? */ |
302 | buf = GNUNET_malloc(size); | 300 | buf = GNUNET_malloc (size); |
303 | 301 | ||
304 | results[0].buffer = buf; | 302 | results[0].buffer = buf; |
305 | results[0].buffer_length = size; | 303 | results[0].buffer_length = size; |
306 | results[0].buffer_type = MYSQL_TYPE_BLOB; | 304 | results[0].buffer_type = MYSQL_TYPE_BLOB; |
307 | if (0 != | 305 | if (0 != |
308 | mysql_stmt_fetch_column(stmt, | 306 | mysql_stmt_fetch_column (stmt, |
309 | results, | 307 | results, |
310 | column, | 308 | column, |
311 | 0)) | 309 | 0)) |
312 | { | 310 | { |
313 | GNUNET_free(buf); | 311 | GNUNET_free (buf); |
314 | return GNUNET_SYSERR; | 312 | return GNUNET_SYSERR; |
315 | } | 313 | } |
316 | 314 | ||
317 | *pk = GNUNET_CRYPTO_rsa_public_key_decode(buf, | 315 | *pk = GNUNET_CRYPTO_rsa_public_key_decode (buf, |
318 | size); | 316 | size); |
319 | GNUNET_free(buf); | 317 | GNUNET_free (buf); |
320 | if (NULL == *pk) | 318 | if (NULL == *pk) |
321 | { | 319 | { |
322 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 320 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
323 | "Results contains bogus public key value (fail to decode)\n"); | 321 | "Results contains bogus public key value (fail to decode)\n"); |
324 | return GNUNET_SYSERR; | 322 | return GNUNET_SYSERR; |
325 | } | 323 | } |
326 | 324 | ||
327 | return GNUNET_OK; | 325 | return GNUNET_OK; |
328 | } | 326 | } |
@@ -336,16 +334,16 @@ post_extract_rsa_public_key(void *cls, | |||
336 | * @param rs result data to clean up | 334 | * @param rs result data to clean up |
337 | */ | 335 | */ |
338 | static void | 336 | static void |
339 | clean_rsa_public_key(void *cls, | 337 | clean_rsa_public_key (void *cls, |
340 | struct GNUNET_MY_ResultSpec *rs) | 338 | struct GNUNET_MY_ResultSpec *rs) |
341 | { | 339 | { |
342 | struct GNUNET_CRYPTO_RsaPublicKey **pk = rs->dst; | 340 | struct GNUNET_CRYPTO_RsaPublicKey **pk = rs->dst; |
343 | 341 | ||
344 | if (NULL != *pk) | 342 | if (NULL != *pk) |
345 | { | 343 | { |
346 | GNUNET_CRYPTO_rsa_public_key_free(*pk); | 344 | GNUNET_CRYPTO_rsa_public_key_free (*pk); |
347 | *pk = NULL; | 345 | *pk = NULL; |
348 | } | 346 | } |
349 | } | 347 | } |
350 | 348 | ||
351 | 349 | ||
@@ -357,13 +355,13 @@ clean_rsa_public_key(void *cls, | |||
357 | * @return array entry for the result specification to use | 355 | * @return array entry for the result specification to use |
358 | */ | 356 | */ |
359 | struct GNUNET_MY_ResultSpec | 357 | struct GNUNET_MY_ResultSpec |
360 | GNUNET_MY_result_spec_rsa_public_key(struct GNUNET_CRYPTO_RsaPublicKey **rsa) | 358 | GNUNET_MY_result_spec_rsa_public_key (struct GNUNET_CRYPTO_RsaPublicKey **rsa) |
361 | { | 359 | { |
362 | struct GNUNET_MY_ResultSpec res = { | 360 | struct GNUNET_MY_ResultSpec res = { |
363 | .pre_conv = &pre_extract_rsa_public_key, | 361 | .pre_conv = &pre_extract_rsa_public_key, |
364 | .post_conv = &post_extract_rsa_public_key, | 362 | .post_conv = &post_extract_rsa_public_key, |
365 | .cleaner = &clean_rsa_public_key, | 363 | .cleaner = &clean_rsa_public_key, |
366 | .dst = (void *)rsa, | 364 | .dst = (void *) rsa, |
367 | .dst_size = 0, | 365 | .dst_size = 0, |
368 | .num_fields = 1 | 366 | .num_fields = 1 |
369 | }; | 367 | }; |
@@ -385,11 +383,11 @@ GNUNET_MY_result_spec_rsa_public_key(struct GNUNET_CRYPTO_RsaPublicKey **rsa) | |||
385 | * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) | 383 | * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) |
386 | */ | 384 | */ |
387 | static int | 385 | static int |
388 | pre_extract_rsa_signature(void *cls, | 386 | pre_extract_rsa_signature (void *cls, |
389 | struct GNUNET_MY_ResultSpec *rs, | 387 | struct GNUNET_MY_ResultSpec *rs, |
390 | MYSQL_STMT *stmt, | 388 | MYSQL_STMT *stmt, |
391 | unsigned int column, | 389 | unsigned int column, |
392 | MYSQL_BIND *results) | 390 | MYSQL_BIND *results) |
393 | { | 391 | { |
394 | results[0].buffer = 0; | 392 | results[0].buffer = 0; |
395 | results[0].buffer_length = 0; | 393 | results[0].buffer_length = 0; |
@@ -415,11 +413,11 @@ pre_extract_rsa_signature(void *cls, | |||
415 | * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) | 413 | * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) |
416 | */ | 414 | */ |
417 | static int | 415 | static int |
418 | post_extract_rsa_signature(void *cls, | 416 | post_extract_rsa_signature (void *cls, |
419 | struct GNUNET_MY_ResultSpec *rs, | 417 | struct GNUNET_MY_ResultSpec *rs, |
420 | MYSQL_STMT *stmt, | 418 | MYSQL_STMT *stmt, |
421 | unsigned int column, | 419 | unsigned int column, |
422 | MYSQL_BIND *results) | 420 | MYSQL_BIND *results) |
423 | { | 421 | { |
424 | struct GNUNET_CRYPTO_RsaSignature **sig = rs->dst; | 422 | struct GNUNET_CRYPTO_RsaSignature **sig = rs->dst; |
425 | void *buf; | 423 | void *buf; |
@@ -427,34 +425,34 @@ post_extract_rsa_signature(void *cls, | |||
427 | 425 | ||
428 | if (*results->is_null) | 426 | if (*results->is_null) |
429 | return GNUNET_SYSERR; | 427 | return GNUNET_SYSERR; |
430 | size = (size_t)rs->mysql_bind_output_length; | 428 | size = (size_t) rs->mysql_bind_output_length; |
431 | 429 | ||
432 | if (rs->mysql_bind_output_length != size) | 430 | if (rs->mysql_bind_output_length != size) |
433 | return GNUNET_SYSERR; /* 'unsigned long' does not fit in size_t!? */ | 431 | return GNUNET_SYSERR; /* 'unsigned long' does not fit in size_t!? */ |
434 | buf = GNUNET_malloc(size); | 432 | buf = GNUNET_malloc (size); |
435 | 433 | ||
436 | results[0].buffer = buf; | 434 | results[0].buffer = buf; |
437 | results[0].buffer_length = size; | 435 | results[0].buffer_length = size; |
438 | results[0].buffer_type = MYSQL_TYPE_BLOB; | 436 | results[0].buffer_type = MYSQL_TYPE_BLOB; |
439 | if (0 != | 437 | if (0 != |
440 | mysql_stmt_fetch_column(stmt, | 438 | mysql_stmt_fetch_column (stmt, |
441 | results, | 439 | results, |
442 | column, | 440 | column, |
443 | 0)) | 441 | 0)) |
444 | { | 442 | { |
445 | GNUNET_free(buf); | 443 | GNUNET_free (buf); |
446 | return GNUNET_SYSERR; | 444 | return GNUNET_SYSERR; |
447 | } | 445 | } |
448 | 446 | ||
449 | *sig = GNUNET_CRYPTO_rsa_signature_decode(buf, | 447 | *sig = GNUNET_CRYPTO_rsa_signature_decode (buf, |
450 | size); | 448 | size); |
451 | GNUNET_free(buf); | 449 | GNUNET_free (buf); |
452 | if (NULL == *sig) | 450 | if (NULL == *sig) |
453 | { | 451 | { |
454 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 452 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
455 | "Resuls contains bogus signature value (fails to decode)\n"); | 453 | "Resuls contains bogus signature value (fails to decode)\n"); |
456 | return GNUNET_SYSERR; | 454 | return GNUNET_SYSERR; |
457 | } | 455 | } |
458 | return GNUNET_OK; | 456 | return GNUNET_OK; |
459 | } | 457 | } |
460 | 458 | ||
@@ -467,16 +465,16 @@ post_extract_rsa_signature(void *cls, | |||
467 | * @param rd result data to clean up | 465 | * @param rd result data to clean up |
468 | */ | 466 | */ |
469 | static void | 467 | static void |
470 | clean_rsa_signature(void *cls, | 468 | clean_rsa_signature (void *cls, |
471 | struct GNUNET_MY_ResultSpec *rs) | 469 | struct GNUNET_MY_ResultSpec *rs) |
472 | { | 470 | { |
473 | struct GNUNET_CRYPTO_RsaSignature **sig = rs->dst; | 471 | struct GNUNET_CRYPTO_RsaSignature **sig = rs->dst; |
474 | 472 | ||
475 | if (NULL != *sig) | 473 | if (NULL != *sig) |
476 | { | 474 | { |
477 | GNUNET_CRYPTO_rsa_signature_free(*sig); | 475 | GNUNET_CRYPTO_rsa_signature_free (*sig); |
478 | *sig = NULL; | 476 | *sig = NULL; |
479 | } | 477 | } |
480 | } | 478 | } |
481 | 479 | ||
482 | 480 | ||
@@ -487,14 +485,13 @@ clean_rsa_signature(void *cls, | |||
487 | * @return array entry for the result specification to use | 485 | * @return array entry for the result specification to use |
488 | */ | 486 | */ |
489 | struct GNUNET_MY_ResultSpec | 487 | struct GNUNET_MY_ResultSpec |
490 | GNUNET_MY_result_spec_rsa_signature(struct GNUNET_CRYPTO_RsaSignature **sig) | 488 | GNUNET_MY_result_spec_rsa_signature (struct GNUNET_CRYPTO_RsaSignature **sig) |
491 | { | 489 | { |
492 | struct GNUNET_MY_ResultSpec res = | 490 | struct GNUNET_MY_ResultSpec res = { |
493 | { | ||
494 | .pre_conv = &pre_extract_rsa_signature, | 491 | .pre_conv = &pre_extract_rsa_signature, |
495 | .post_conv = &post_extract_rsa_signature, | 492 | .post_conv = &post_extract_rsa_signature, |
496 | .cleaner = &clean_rsa_signature, | 493 | .cleaner = &clean_rsa_signature, |
497 | .dst = (void *)sig, | 494 | .dst = (void *) sig, |
498 | .dst_size = 0, | 495 | .dst_size = 0, |
499 | .num_fields = 1 | 496 | .num_fields = 1 |
500 | }; | 497 | }; |
@@ -516,11 +513,11 @@ GNUNET_MY_result_spec_rsa_signature(struct GNUNET_CRYPTO_RsaSignature **sig) | |||
516 | * #GNUNET_SYSERR if a result was invalid (non existing field or NULL) | 513 | * #GNUNET_SYSERR if a result was invalid (non existing field or NULL) |
517 | */ | 514 | */ |
518 | static int | 515 | static int |
519 | pre_extract_string(void * cls, | 516 | pre_extract_string (void *cls, |
520 | struct GNUNET_MY_ResultSpec *rs, | 517 | struct GNUNET_MY_ResultSpec *rs, |
521 | MYSQL_STMT *stmt, | 518 | MYSQL_STMT *stmt, |
522 | unsigned int column, | 519 | unsigned int column, |
523 | MYSQL_BIND *results) | 520 | MYSQL_BIND *results) |
524 | { | 521 | { |
525 | results[0].buffer = NULL; | 522 | results[0].buffer = NULL; |
526 | results[0].buffer_length = 0; | 523 | results[0].buffer_length = 0; |
@@ -546,39 +543,39 @@ pre_extract_string(void * cls, | |||
546 | * #GNUNET_SYSERR if a result was invalid (non existing field or NULL) | 543 | * #GNUNET_SYSERR if a result was invalid (non existing field or NULL) |
547 | */ | 544 | */ |
548 | static int | 545 | static int |
549 | post_extract_string(void * cls, | 546 | post_extract_string (void *cls, |
550 | struct GNUNET_MY_ResultSpec *rs, | 547 | struct GNUNET_MY_ResultSpec *rs, |
551 | MYSQL_STMT *stmt, | 548 | MYSQL_STMT *stmt, |
552 | unsigned int column, | 549 | unsigned int column, |
553 | MYSQL_BIND *results) | 550 | MYSQL_BIND *results) |
554 | { | 551 | { |
555 | size_t size = (size_t)rs->mysql_bind_output_length; | 552 | size_t size = (size_t) rs->mysql_bind_output_length; |
556 | char *buf; | 553 | char *buf; |
557 | 554 | ||
558 | if (rs->mysql_bind_output_length != size) | 555 | if (rs->mysql_bind_output_length != size) |
559 | return GNUNET_SYSERR; | 556 | return GNUNET_SYSERR; |
560 | if (*results->is_null) | 557 | if (*results->is_null) |
561 | { | 558 | { |
562 | *(void **)rs->dst = NULL; | 559 | *(void **) rs->dst = NULL; |
563 | return GNUNET_OK; | 560 | return GNUNET_OK; |
564 | } | 561 | } |
565 | 562 | ||
566 | buf = GNUNET_malloc(size); | 563 | buf = GNUNET_malloc (size); |
567 | results[0].buffer = buf; | 564 | results[0].buffer = buf; |
568 | results[0].buffer_length = size; | 565 | results[0].buffer_length = size; |
569 | results[0].buffer_type = MYSQL_TYPE_BLOB; | 566 | results[0].buffer_type = MYSQL_TYPE_BLOB; |
570 | 567 | ||
571 | if (0 != | 568 | if (0 != |
572 | mysql_stmt_fetch_column(stmt, | 569 | mysql_stmt_fetch_column (stmt, |
573 | results, | 570 | results, |
574 | column, | 571 | column, |
575 | 0)) | 572 | 0)) |
576 | { | 573 | { |
577 | GNUNET_free(buf); | 574 | GNUNET_free (buf); |
578 | return GNUNET_SYSERR; | 575 | return GNUNET_SYSERR; |
579 | } | 576 | } |
580 | buf[size] = '\0'; | 577 | buf[size] = '\0'; |
581 | *(void **)rs->dst = buf; | 578 | *(void **) rs->dst = buf; |
582 | return GNUNET_OK; | 579 | return GNUNET_OK; |
583 | } | 580 | } |
584 | 581 | ||
@@ -590,13 +587,13 @@ post_extract_string(void * cls, | |||
590 | * @return array entry for the result specification to use | 587 | * @return array entry for the result specification to use |
591 | */ | 588 | */ |
592 | struct GNUNET_MY_ResultSpec | 589 | struct GNUNET_MY_ResultSpec |
593 | GNUNET_MY_result_spec_string(char **dst) | 590 | GNUNET_MY_result_spec_string (char **dst) |
594 | { | 591 | { |
595 | struct GNUNET_MY_ResultSpec res = { | 592 | struct GNUNET_MY_ResultSpec res = { |
596 | .pre_conv = &pre_extract_string, | 593 | .pre_conv = &pre_extract_string, |
597 | .post_conv = &post_extract_string, | 594 | .post_conv = &post_extract_string, |
598 | .cleaner = NULL, | 595 | .cleaner = NULL, |
599 | .dst = (void *)dst, | 596 | .dst = (void *) dst, |
600 | .dst_size = 0, | 597 | .dst_size = 0, |
601 | .num_fields = 1 | 598 | .num_fields = 1 |
602 | }; | 599 | }; |
@@ -613,9 +610,9 @@ GNUNET_MY_result_spec_string(char **dst) | |||
613 | * @return array entry for the result specification to use | 610 | * @return array entry for the result specification to use |
614 | */ | 611 | */ |
615 | struct GNUNET_MY_ResultSpec | 612 | struct GNUNET_MY_ResultSpec |
616 | GNUNET_MY_result_spec_absolute_time(struct GNUNET_TIME_Absolute *at) | 613 | GNUNET_MY_result_spec_absolute_time (struct GNUNET_TIME_Absolute *at) |
617 | { | 614 | { |
618 | return GNUNET_MY_result_spec_uint64(&at->abs_value_us); | 615 | return GNUNET_MY_result_spec_uint64 (&at->abs_value_us); |
619 | } | 616 | } |
620 | 617 | ||
621 | 618 | ||
@@ -626,10 +623,10 @@ GNUNET_MY_result_spec_absolute_time(struct GNUNET_TIME_Absolute *at) | |||
626 | * @return array entry for the result specification to use | 623 | * @return array entry for the result specification to use |
627 | */ | 624 | */ |
628 | struct GNUNET_MY_ResultSpec | 625 | struct GNUNET_MY_ResultSpec |
629 | GNUNET_MY_result_spec_absolute_time_nbo(struct GNUNET_TIME_AbsoluteNBO *at) | 626 | GNUNET_MY_result_spec_absolute_time_nbo (struct GNUNET_TIME_AbsoluteNBO *at) |
630 | { | 627 | { |
631 | struct GNUNET_MY_ResultSpec res = | 628 | struct GNUNET_MY_ResultSpec res = |
632 | GNUNET_MY_result_spec_auto_from_type(&at->abs_value_us__); | 629 | GNUNET_MY_result_spec_auto_from_type (&at->abs_value_us__); |
633 | 630 | ||
634 | return res; | 631 | return res; |
635 | } | 632 | } |
@@ -648,11 +645,11 @@ GNUNET_MY_result_spec_absolute_time_nbo(struct GNUNET_TIME_AbsoluteNBO *at) | |||
648 | * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) | 645 | * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) |
649 | */ | 646 | */ |
650 | static int | 647 | static int |
651 | pre_extract_uint16(void *cls, | 648 | pre_extract_uint16 (void *cls, |
652 | struct GNUNET_MY_ResultSpec *rs, | 649 | struct GNUNET_MY_ResultSpec *rs, |
653 | MYSQL_STMT *stmt, | 650 | MYSQL_STMT *stmt, |
654 | unsigned int column, | 651 | unsigned int column, |
655 | MYSQL_BIND *results) | 652 | MYSQL_BIND *results) |
656 | { | 653 | { |
657 | results[0].buffer = rs->dst; | 654 | results[0].buffer = rs->dst; |
658 | results[0].buffer_length = rs->dst_size; | 655 | results[0].buffer_length = rs->dst_size; |
@@ -678,11 +675,11 @@ pre_extract_uint16(void *cls, | |||
678 | * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) | 675 | * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) |
679 | */ | 676 | */ |
680 | static int | 677 | static int |
681 | post_extract_uint16(void *cls, | 678 | post_extract_uint16 (void *cls, |
682 | struct GNUNET_MY_ResultSpec *rs, | 679 | struct GNUNET_MY_ResultSpec *rs, |
683 | MYSQL_STMT *stmt, | 680 | MYSQL_STMT *stmt, |
684 | unsigned int column, | 681 | unsigned int column, |
685 | MYSQL_BIND *results) | 682 | MYSQL_BIND *results) |
686 | { | 683 | { |
687 | if (rs->dst_size != rs->mysql_bind_output_length) | 684 | if (rs->dst_size != rs->mysql_bind_output_length) |
688 | return GNUNET_SYSERR; | 685 | return GNUNET_SYSERR; |
@@ -699,13 +696,13 @@ post_extract_uint16(void *cls, | |||
699 | * @return array entry for the result specification to use | 696 | * @return array entry for the result specification to use |
700 | */ | 697 | */ |
701 | struct GNUNET_MY_ResultSpec | 698 | struct GNUNET_MY_ResultSpec |
702 | GNUNET_MY_result_spec_uint16(uint16_t *u16) | 699 | GNUNET_MY_result_spec_uint16 (uint16_t *u16) |
703 | { | 700 | { |
704 | struct GNUNET_MY_ResultSpec res = { | 701 | struct GNUNET_MY_ResultSpec res = { |
705 | .pre_conv = &pre_extract_uint16, | 702 | .pre_conv = &pre_extract_uint16, |
706 | .post_conv = &post_extract_uint16, | 703 | .post_conv = &post_extract_uint16, |
707 | .cleaner = NULL, | 704 | .cleaner = NULL, |
708 | .dst = (void *)u16, | 705 | .dst = (void *) u16, |
709 | .dst_size = sizeof(*u16), | 706 | .dst_size = sizeof(*u16), |
710 | .num_fields = 1 | 707 | .num_fields = 1 |
711 | }; | 708 | }; |
@@ -728,11 +725,11 @@ GNUNET_MY_result_spec_uint16(uint16_t *u16) | |||
728 | * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) | 725 | * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) |
729 | */ | 726 | */ |
730 | static int | 727 | static int |
731 | pre_extract_uint32(void *cls, | 728 | pre_extract_uint32 (void *cls, |
732 | struct GNUNET_MY_ResultSpec *rs, | 729 | struct GNUNET_MY_ResultSpec *rs, |
733 | MYSQL_STMT *stmt, | 730 | MYSQL_STMT *stmt, |
734 | unsigned int column, | 731 | unsigned int column, |
735 | MYSQL_BIND *results) | 732 | MYSQL_BIND *results) |
736 | { | 733 | { |
737 | results[0].buffer = rs->dst; | 734 | results[0].buffer = rs->dst; |
738 | results[0].buffer_length = rs->dst_size; | 735 | results[0].buffer_length = rs->dst_size; |
@@ -759,11 +756,11 @@ pre_extract_uint32(void *cls, | |||
759 | * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) | 756 | * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) |
760 | */ | 757 | */ |
761 | static int | 758 | static int |
762 | post_extract_uint32(void *cls, | 759 | post_extract_uint32 (void *cls, |
763 | struct GNUNET_MY_ResultSpec *rs, | 760 | struct GNUNET_MY_ResultSpec *rs, |
764 | MYSQL_STMT * stmt, | 761 | MYSQL_STMT *stmt, |
765 | unsigned int column, | 762 | unsigned int column, |
766 | MYSQL_BIND *results) | 763 | MYSQL_BIND *results) |
767 | { | 764 | { |
768 | if (rs->dst_size != rs->mysql_bind_output_length) | 765 | if (rs->dst_size != rs->mysql_bind_output_length) |
769 | return GNUNET_SYSERR; | 766 | return GNUNET_SYSERR; |
@@ -780,13 +777,13 @@ post_extract_uint32(void *cls, | |||
780 | * @return array entry for the result specification to use | 777 | * @return array entry for the result specification to use |
781 | */ | 778 | */ |
782 | struct GNUNET_MY_ResultSpec | 779 | struct GNUNET_MY_ResultSpec |
783 | GNUNET_MY_result_spec_uint32(uint32_t *u32) | 780 | GNUNET_MY_result_spec_uint32 (uint32_t *u32) |
784 | { | 781 | { |
785 | struct GNUNET_MY_ResultSpec res = { | 782 | struct GNUNET_MY_ResultSpec res = { |
786 | .pre_conv = &pre_extract_uint32, | 783 | .pre_conv = &pre_extract_uint32, |
787 | .post_conv = &post_extract_uint32, | 784 | .post_conv = &post_extract_uint32, |
788 | .cleaner = NULL, | 785 | .cleaner = NULL, |
789 | .dst = (void *)u32, | 786 | .dst = (void *) u32, |
790 | .dst_size = sizeof(*u32), | 787 | .dst_size = sizeof(*u32), |
791 | .num_fields = 1 | 788 | .num_fields = 1 |
792 | }; | 789 | }; |
@@ -808,11 +805,11 @@ GNUNET_MY_result_spec_uint32(uint32_t *u32) | |||
808 | * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) | 805 | * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) |
809 | */ | 806 | */ |
810 | static int | 807 | static int |
811 | pre_extract_uint64(void *cls, | 808 | pre_extract_uint64 (void *cls, |
812 | struct GNUNET_MY_ResultSpec *rs, | 809 | struct GNUNET_MY_ResultSpec *rs, |
813 | MYSQL_STMT *stmt, | 810 | MYSQL_STMT *stmt, |
814 | unsigned int column, | 811 | unsigned int column, |
815 | MYSQL_BIND *results) | 812 | MYSQL_BIND *results) |
816 | { | 813 | { |
817 | if (sizeof(uint64_t) != rs->dst_size) | 814 | if (sizeof(uint64_t) != rs->dst_size) |
818 | return GNUNET_SYSERR; | 815 | return GNUNET_SYSERR; |
@@ -840,11 +837,11 @@ pre_extract_uint64(void *cls, | |||
840 | * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) | 837 | * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) |
841 | */ | 838 | */ |
842 | static int | 839 | static int |
843 | post_extract_uint64(void *cls, | 840 | post_extract_uint64 (void *cls, |
844 | struct GNUNET_MY_ResultSpec *rs, | 841 | struct GNUNET_MY_ResultSpec *rs, |
845 | MYSQL_STMT *stmt, | 842 | MYSQL_STMT *stmt, |
846 | unsigned int column, | 843 | unsigned int column, |
847 | MYSQL_BIND *results) | 844 | MYSQL_BIND *results) |
848 | { | 845 | { |
849 | if (sizeof(uint64_t) != rs->dst_size) | 846 | if (sizeof(uint64_t) != rs->dst_size) |
850 | return GNUNET_SYSERR; | 847 | return GNUNET_SYSERR; |
@@ -861,13 +858,13 @@ post_extract_uint64(void *cls, | |||
861 | * @return array entry for the result specification to use | 858 | * @return array entry for the result specification to use |
862 | */ | 859 | */ |
863 | struct GNUNET_MY_ResultSpec | 860 | struct GNUNET_MY_ResultSpec |
864 | GNUNET_MY_result_spec_uint64(uint64_t *u64) | 861 | GNUNET_MY_result_spec_uint64 (uint64_t *u64) |
865 | { | 862 | { |
866 | struct GNUNET_MY_ResultSpec res = { | 863 | struct GNUNET_MY_ResultSpec res = { |
867 | .pre_conv = &pre_extract_uint64, | 864 | .pre_conv = &pre_extract_uint64, |
868 | .post_conv = &post_extract_uint64, | 865 | .post_conv = &post_extract_uint64, |
869 | .cleaner = NULL, | 866 | .cleaner = NULL, |
870 | .dst = (void *)u64, | 867 | .dst = (void *) u64, |
871 | .dst_size = sizeof(*u64), | 868 | .dst_size = sizeof(*u64), |
872 | .num_fields = 1 | 869 | .num_fields = 1 |
873 | }; | 870 | }; |