diff options
Diffstat (limited to 'src/include/gnunet_my_lib.h')
-rw-r--r-- | src/include/gnunet_my_lib.h | 236 |
1 files changed, 115 insertions, 121 deletions
diff --git a/src/include/gnunet_my_lib.h b/src/include/gnunet_my_lib.h index 744a646f0..1805c2795 100644 --- a/src/include/gnunet_my_lib.h +++ b/src/include/gnunet_my_lib.h | |||
@@ -11,12 +11,12 @@ | |||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 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/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | /** | 20 | /** |
21 | * @author Christian Grothoff | 21 | * @author Christian Grothoff |
22 | * @author Christophe Genevey | 22 | * @author Christophe Genevey |
@@ -62,7 +62,7 @@ struct GNUNET_MY_QueryParam; | |||
62 | */ | 62 | */ |
63 | typedef int | 63 | typedef int |
64 | (*GNUNET_MY_QueryConverter)(void *cls, | 64 | (*GNUNET_MY_QueryConverter)(void *cls, |
65 | const struct GNUNET_MY_QueryParam *qp, | 65 | const struct GNUNET_MY_QueryParam *qp, |
66 | MYSQL_BIND *qbind); | 66 | MYSQL_BIND *qbind); |
67 | 67 | ||
68 | 68 | ||
@@ -74,22 +74,20 @@ typedef int | |||
74 | */ | 74 | */ |
75 | typedef void | 75 | typedef void |
76 | (*GNUNET_MY_QueryCleanup)(void *cls, | 76 | (*GNUNET_MY_QueryCleanup)(void *cls, |
77 | MYSQL_BIND *qbind); | 77 | MYSQL_BIND *qbind); |
78 | /** | 78 | /** |
79 | * Information we pass to #GNUNET_MY_exec_prepared() to | 79 | * Information we pass to #GNUNET_MY_exec_prepared() to |
80 | * initialize the arguments of the prepared statement. | 80 | * initialize the arguments of the prepared statement. |
81 | */ | 81 | */ |
82 | 82 | ||
83 | 83 | ||
84 | struct GNUNET_MY_QueryParam | 84 | struct GNUNET_MY_QueryParam { |
85 | { | ||
86 | |||
87 | /** | 85 | /** |
88 | * Function to call for the type conversion. | 86 | * Function to call for the type conversion. |
89 | */ | 87 | */ |
90 | GNUNET_MY_QueryConverter conv; | 88 | GNUNET_MY_QueryConverter conv; |
91 | 89 | ||
92 | /** | 90 | /** |
93 | * Function to call for cleaning up the query. Can be NULL. | 91 | * Function to call for cleaning up the query. Can be NULL. |
94 | */ | 92 | */ |
95 | GNUNET_MY_QueryCleanup cleaner; | 93 | GNUNET_MY_QueryCleanup cleaner; |
@@ -113,7 +111,6 @@ struct GNUNET_MY_QueryParam | |||
113 | * Information to pass to @e conv. Size of @a data. | 111 | * Information to pass to @e conv. Size of @a data. |
114 | */ | 112 | */ |
115 | unsigned long data_len; | 113 | unsigned long data_len; |
116 | |||
117 | }; | 114 | }; |
118 | 115 | ||
119 | /** | 116 | /** |
@@ -132,8 +129,8 @@ struct GNUNET_MY_QueryParam | |||
132 | * @oaran ptr_size number of bytes in @a ptr | 129 | * @oaran ptr_size number of bytes in @a ptr |
133 | */ | 130 | */ |
134 | struct GNUNET_MY_QueryParam | 131 | struct GNUNET_MY_QueryParam |
135 | GNUNET_MY_query_param_fixed_size (const void *ptr, | 132 | GNUNET_MY_query_param_fixed_size(const void *ptr, |
136 | size_t ptr_size); | 133 | size_t ptr_size); |
137 | 134 | ||
138 | 135 | ||
139 | /** | 136 | /** |
@@ -145,9 +142,9 @@ GNUNET_MY_query_param_fixed_size (const void *ptr, | |||
145 | * @return TBD | 142 | * @return TBD |
146 | */ | 143 | */ |
147 | int | 144 | int |
148 | GNUNET_MY_exec_prepared (struct GNUNET_MYSQL_Context *mc, | 145 | GNUNET_MY_exec_prepared(struct GNUNET_MYSQL_Context *mc, |
149 | struct GNUNET_MYSQL_StatementHandle *sh, | 146 | struct GNUNET_MYSQL_StatementHandle *sh, |
150 | struct GNUNET_MY_QueryParam *params); | 147 | struct GNUNET_MY_QueryParam *params); |
151 | 148 | ||
152 | 149 | ||
153 | /** | 150 | /** |
@@ -194,9 +191,7 @@ typedef void | |||
194 | * Information we pass to #GNUNET_MY_extract_result() to | 191 | * Information we pass to #GNUNET_MY_extract_result() to |
195 | * initialize the arguments of the prepared statement. | 192 | * initialize the arguments of the prepared statement. |
196 | */ | 193 | */ |
197 | struct GNUNET_MY_ResultSpec | 194 | struct GNUNET_MY_ResultSpec { |
198 | { | ||
199 | |||
200 | /** | 195 | /** |
201 | * Function to call to initialize the MYSQL_BIND array. | 196 | * Function to call to initialize the MYSQL_BIND array. |
202 | */ | 197 | */ |
@@ -207,7 +202,7 @@ struct GNUNET_MY_ResultSpec | |||
207 | */ | 202 | */ |
208 | GNUNET_MY_ResultConverter post_conv; | 203 | GNUNET_MY_ResultConverter post_conv; |
209 | 204 | ||
210 | /** | 205 | /** |
211 | * Function to call for cleaning up the result. Can be NULL. | 206 | * Function to call for cleaning up the result. Can be NULL. |
212 | */ | 207 | */ |
213 | GNUNET_MY_ResultCleanup cleaner; | 208 | GNUNET_MY_ResultCleanup cleaner; |
@@ -250,7 +245,6 @@ struct GNUNET_MY_ResultSpec | |||
250 | * Memory for MySQL to notify us about NULL values. | 245 | * Memory for MySQL to notify us about NULL values. |
251 | */ | 246 | */ |
252 | my_bool is_null; | 247 | my_bool is_null; |
253 | |||
254 | }; | 248 | }; |
255 | 249 | ||
256 | 250 | ||
@@ -271,88 +265,88 @@ struct GNUNET_MY_ResultSpec | |||
271 | * @oaran ptr_size number of bytes available at @a ptr | 265 | * @oaran ptr_size number of bytes available at @a ptr |
272 | */ | 266 | */ |
273 | struct GNUNET_MY_ResultSpec | 267 | struct GNUNET_MY_ResultSpec |
274 | GNUNET_MY_result_spec_fixed_size (void *ptr, | 268 | GNUNET_MY_result_spec_fixed_size(void *ptr, |
275 | size_t ptr_size); | 269 | size_t ptr_size); |
276 | 270 | ||
277 | /** | 271 | /** |
278 | * Generate query parameter for a string | 272 | * Generate query parameter for a string |
279 | * | 273 | * |
280 | *@param ptr pointer to the string query parameter to pass | 274 | *@param ptr pointer to the string query parameter to pass |
281 | */ | 275 | */ |
282 | struct GNUNET_MY_QueryParam | 276 | struct GNUNET_MY_QueryParam |
283 | GNUNET_MY_query_param_string (const char *ptr); | 277 | GNUNET_MY_query_param_string(const char *ptr); |
284 | 278 | ||
285 | /** | 279 | /** |
286 | * Generate fixed-size query parameter with size determined | 280 | * Generate fixed-size query parameter with size determined |
287 | * by variable type. | 281 | * by variable type. |
288 | * | 282 | * |
289 | * @param x pointer to the query parameter to pass | 283 | * @param x pointer to the query parameter to pass |
290 | */ | 284 | */ |
291 | #define GNUNET_MY_query_param_auto_from_type(x) GNUNET_MY_query_param_fixed_size ((x), sizeof (*(x))) | 285 | #define GNUNET_MY_query_param_auto_from_type(x) GNUNET_MY_query_param_fixed_size((x), sizeof(*(x))) |
292 | 286 | ||
293 | /** | 287 | /** |
294 | * Generate query parameter for an RSA public key. The | 288 | * Generate query parameter for an RSA public key. The |
295 | * database must contain a BLOB type in the respective position. | 289 | * database must contain a BLOB type in the respective position. |
296 | * | 290 | * |
297 | * @param x the query parameter to pass | 291 | * @param x the query parameter to pass |
298 | * @return array entry for the query parameters to use | 292 | * @return array entry for the query parameters to use |
299 | */ | 293 | */ |
300 | struct GNUNET_MY_QueryParam | 294 | struct GNUNET_MY_QueryParam |
301 | GNUNET_MY_query_param_rsa_public_key (const struct GNUNET_CRYPTO_RsaPublicKey *x); | 295 | GNUNET_MY_query_param_rsa_public_key(const struct GNUNET_CRYPTO_RsaPublicKey *x); |
302 | 296 | ||
303 | /** | 297 | /** |
304 | * Generate query parameter for an RSA signature. The | 298 | * Generate query parameter for an RSA signature. The |
305 | * database must contain a BLOB type in the respective position | 299 | * database must contain a BLOB type in the respective position |
306 | * | 300 | * |
307 | *@param x the query parameter to pass | 301 | *@param x the query parameter to pass |
308 | *@return array entry for the query parameters to use | 302 | *@return array entry for the query parameters to use |
309 | */ | 303 | */ |
310 | struct GNUNET_MY_QueryParam | 304 | struct GNUNET_MY_QueryParam |
311 | GNUNET_MY_query_param_rsa_signature (const struct GNUNET_CRYPTO_RsaSignature *x); | 305 | GNUNET_MY_query_param_rsa_signature(const struct GNUNET_CRYPTO_RsaSignature *x); |
312 | 306 | ||
313 | /** | 307 | /** |
314 | * Generate query parameter for an absolute time value. | 308 | * Generate query parameter for an absolute time value. |
315 | * The database must store a 64-bit integer. | 309 | * The database must store a 64-bit integer. |
316 | * | 310 | * |
317 | *@param x pointer to the query parameter to pass | 311 | *@param x pointer to the query parameter to pass |
318 | *@return array entry for the query parameters to use | 312 | *@return array entry for the query parameters to use |
319 | */ | 313 | */ |
320 | struct GNUNET_MY_QueryParam | 314 | struct GNUNET_MY_QueryParam |
321 | GNUNET_MY_query_param_absolute_time (const struct GNUNET_TIME_Absolute *x); | 315 | GNUNET_MY_query_param_absolute_time(const struct GNUNET_TIME_Absolute *x); |
322 | 316 | ||
323 | 317 | ||
324 | /** | 318 | /** |
325 | * Generate query parameter for an absolute time value. | 319 | * Generate query parameter for an absolute time value. |
326 | * The database must store a 64-bit integer. | 320 | * The database must store a 64-bit integer. |
327 | * | 321 | * |
328 | *@param x pointer to the query parameter to pass | 322 | *@param x pointer to the query parameter to pass |
329 | */ | 323 | */ |
330 | struct GNUNET_MY_QueryParam | 324 | struct GNUNET_MY_QueryParam |
331 | GNUNET_MY_query_param_absolute_time_nbo (const struct GNUNET_TIME_AbsoluteNBO *x); | 325 | GNUNET_MY_query_param_absolute_time_nbo(const struct GNUNET_TIME_AbsoluteNBO *x); |
332 | 326 | ||
333 | /** | 327 | /** |
334 | * Generate query parameter for an uint16_t in host byte order. | 328 | * Generate query parameter for an uint16_t in host byte order. |
335 | * | 329 | * |
336 | * @param x pointer to the query parameter to pass | 330 | * @param x pointer to the query parameter to pass |
337 | */ | 331 | */ |
338 | struct GNUNET_MY_QueryParam | 332 | struct GNUNET_MY_QueryParam |
339 | GNUNET_MY_query_param_uint16 (const uint16_t *x); | 333 | GNUNET_MY_query_param_uint16(const uint16_t *x); |
340 | 334 | ||
341 | /** | 335 | /** |
342 | * Generate query parameter for an uint32_t in host byte order | 336 | * Generate query parameter for an uint32_t in host byte order |
343 | * | 337 | * |
344 | *@param x pointer to the query parameter to pass | 338 | *@param x pointer to the query parameter to pass |
345 | */ | 339 | */ |
346 | struct GNUNET_MY_QueryParam | 340 | struct GNUNET_MY_QueryParam |
347 | GNUNET_MY_query_param_uint32 (const uint32_t *x); | 341 | GNUNET_MY_query_param_uint32(const uint32_t *x); |
348 | 342 | ||
349 | /** | 343 | /** |
350 | * Generate query parameter for an uint64_t in host byte order | 344 | * Generate query parameter for an uint64_t in host byte order |
351 | * | 345 | * |
352 | *@param x pointer to the query parameter to pass | 346 | *@param x pointer to the query parameter to pass |
353 | */ | 347 | */ |
354 | struct GNUNET_MY_QueryParam | 348 | struct GNUNET_MY_QueryParam |
355 | GNUNET_MY_query_param_uint64 (const uint64_t *x); | 349 | GNUNET_MY_query_param_uint64(const uint64_t *x); |
356 | 350 | ||
357 | /** | 351 | /** |
358 | * We expect a fixed-size result, with size determined by the type of `* dst` | 352 | * We expect a fixed-size result, with size determined by the type of `* dst` |
@@ -361,7 +355,7 @@ GNUNET_MY_query_param_uint64 (const uint64_t *x); | |||
361 | * @spec dst point to where to store the result, type fits expected result size | 355 | * @spec dst point to where to store the result, type fits expected result size |
362 | * @return array entry for the result specification to use | 356 | * @return array entry for the result specification to use |
363 | */ | 357 | */ |
364 | #define GNUNET_MY_result_spec_auto_from_type(dst) GNUNET_MY_result_spec_fixed_size ((dst), sizeof (*(dst))) | 358 | #define GNUNET_MY_result_spec_auto_from_type(dst) GNUNET_MY_result_spec_fixed_size((dst), sizeof(*(dst))) |
365 | 359 | ||
366 | 360 | ||
367 | /** | 361 | /** |
@@ -372,8 +366,8 @@ GNUNET_MY_query_param_uint64 (const uint64_t *x); | |||
372 | * @return array entru for the result specification to use | 366 | * @return array entru for the result specification to use |
373 | */ | 367 | */ |
374 | struct GNUNET_MY_ResultSpec | 368 | struct GNUNET_MY_ResultSpec |
375 | GNUNET_MY_result_spec_variable_size (void **dst, | 369 | GNUNET_MY_result_spec_variable_size(void **dst, |
376 | size_t *ptr_size); | 370 | size_t *ptr_size); |
377 | 371 | ||
378 | /** | 372 | /** |
379 | * RSA public key expected | 373 | * RSA public key expected |
@@ -383,7 +377,7 @@ GNUNET_MY_result_spec_variable_size (void **dst, | |||
383 | * @return array entry for the result specification to use | 377 | * @return array entry for the result specification to use |
384 | */ | 378 | */ |
385 | struct GNUNET_MY_ResultSpec | 379 | struct GNUNET_MY_ResultSpec |
386 | GNUNET_MY_result_spec_rsa_public_key (struct GNUNET_CRYPTO_RsaPublicKey **rsa); | 380 | GNUNET_MY_result_spec_rsa_public_key(struct GNUNET_CRYPTO_RsaPublicKey **rsa); |
387 | 381 | ||
388 | 382 | ||
389 | /** | 383 | /** |
@@ -393,62 +387,62 @@ GNUNET_MY_result_spec_rsa_public_key (struct GNUNET_CRYPTO_RsaPublicKey **rsa); | |||
393 | * @return array entry for the result specification to use | 387 | * @return array entry for the result specification to use |
394 | */ | 388 | */ |
395 | struct GNUNET_MY_ResultSpec | 389 | struct GNUNET_MY_ResultSpec |
396 | GNUNET_MY_result_spec_rsa_signature (struct GNUNET_CRYPTO_RsaSignature **sig); | 390 | GNUNET_MY_result_spec_rsa_signature(struct GNUNET_CRYPTO_RsaSignature **sig); |
397 | 391 | ||
398 | /** | 392 | /** |
399 | * 0- terminated string exprected. | 393 | * 0- terminated string exprected. |
400 | * | 394 | * |
401 | * @param[out] dst where to store the result, allocated | 395 | * @param[out] dst where to store the result, allocated |
402 | * @return array entry for the result specification to use | 396 | * @return array entry for the result specification to use |
403 | */ | 397 | */ |
404 | struct GNUNET_MY_ResultSpec | 398 | struct GNUNET_MY_ResultSpec |
405 | GNUNET_MY_result_spec_string (char **dst); | 399 | GNUNET_MY_result_spec_string(char **dst); |
406 | 400 | ||
407 | /** | 401 | /** |
408 | * Absolute time expected | 402 | * Absolute time expected |
409 | * | 403 | * |
410 | * @param name name of the field in the table | 404 | * @param name name of the field in the table |
411 | * @param[out] at where to store the result | 405 | * @param[out] at where to store the result |
412 | * @return array entry for the result specification to use | 406 | * @return array entry for the result specification to use |
413 | */ | 407 | */ |
414 | struct GNUNET_MY_ResultSpec | 408 | struct GNUNET_MY_ResultSpec |
415 | GNUNET_MY_result_spec_absolute_time (struct GNUNET_TIME_Absolute *at); | 409 | GNUNET_MY_result_spec_absolute_time(struct GNUNET_TIME_Absolute *at); |
416 | 410 | ||
417 | /** | 411 | /** |
418 | * Absolute time in network byte order expected | 412 | * Absolute time in network byte order expected |
419 | * | 413 | * |
420 | * @param[out] at where to store the result | 414 | * @param[out] at where to store the result |
421 | * @return array entry for the result specification to use | 415 | * @return array entry for the result specification to use |
422 | */ | 416 | */ |
423 | struct GNUNET_MY_ResultSpec | 417 | struct GNUNET_MY_ResultSpec |
424 | GNUNET_MY_result_spec_absolute_time_nbo (struct GNUNET_TIME_AbsoluteNBO *at); | 418 | GNUNET_MY_result_spec_absolute_time_nbo(struct GNUNET_TIME_AbsoluteNBO *at); |
425 | 419 | ||
426 | /** | 420 | /** |
427 | * uint16_t expected | 421 | * uint16_t expected |
428 | * | 422 | * |
429 | * @param[out] u16 where to store the result | 423 | * @param[out] u16 where to store the result |
430 | * @return array entry for the result specification to use | 424 | * @return array entry for the result specification to use |
431 | */ | 425 | */ |
432 | struct GNUNET_MY_ResultSpec | 426 | struct GNUNET_MY_ResultSpec |
433 | GNUNET_MY_result_spec_uint16 (uint16_t *u16); | 427 | GNUNET_MY_result_spec_uint16(uint16_t *u16); |
434 | 428 | ||
435 | /** | 429 | /** |
436 | * uint32_t expected | 430 | * uint32_t expected |
437 | * | 431 | * |
438 | * @param[out] u32 where to store the result | 432 | * @param[out] u32 where to store the result |
439 | * @return array entry for the result specification to use | 433 | * @return array entry for the result specification to use |
440 | */ | 434 | */ |
441 | struct GNUNET_MY_ResultSpec | 435 | struct GNUNET_MY_ResultSpec |
442 | GNUNET_MY_result_spec_uint32 (uint32_t *u32); | 436 | GNUNET_MY_result_spec_uint32(uint32_t *u32); |
443 | 437 | ||
444 | /** | 438 | /** |
445 | * uint64_t expected. | 439 | * uint64_t expected. |
446 | * | 440 | * |
447 | * @param[out] u64 where to store the result | 441 | * @param[out] u64 where to store the result |
448 | * @return array entry for the result specification to use | 442 | * @return array entry for the result specification to use |
449 | */ | 443 | */ |
450 | struct GNUNET_MY_ResultSpec | 444 | struct GNUNET_MY_ResultSpec |
451 | GNUNET_MY_result_spec_uint64 (uint64_t *u64); | 445 | GNUNET_MY_result_spec_uint64(uint64_t *u64); |
452 | 446 | ||
453 | 447 | ||
454 | /** | 448 | /** |
@@ -463,8 +457,8 @@ GNUNET_MY_result_spec_uint64 (uint64_t *u64); | |||
463 | * #GNUNET_SYSERR if a result was invalid | 457 | * #GNUNET_SYSERR if a result was invalid |
464 | */ | 458 | */ |
465 | int | 459 | int |
466 | GNUNET_MY_extract_result (struct GNUNET_MYSQL_StatementHandle *sh, | 460 | GNUNET_MY_extract_result(struct GNUNET_MYSQL_StatementHandle *sh, |
467 | struct GNUNET_MY_ResultSpec *specs); | 461 | struct GNUNET_MY_ResultSpec *specs); |
468 | 462 | ||
469 | 463 | ||
470 | /** | 464 | /** |
@@ -475,8 +469,8 @@ GNUNET_MY_extract_result (struct GNUNET_MYSQL_StatementHandle *sh, | |||
475 | * @param qbind mysql query | 469 | * @param qbind mysql query |
476 | */ | 470 | */ |
477 | void | 471 | void |
478 | GNUNET_MY_cleanup_query (struct GNUNET_MY_QueryParam *qp, | 472 | GNUNET_MY_cleanup_query(struct GNUNET_MY_QueryParam *qp, |
479 | MYSQL_BIND *qbind); | 473 | MYSQL_BIND *qbind); |
480 | 474 | ||
481 | 475 | ||
482 | /** | 476 | /** |
@@ -486,7 +480,7 @@ GNUNET_MY_cleanup_query (struct GNUNET_MY_QueryParam *qp, | |||
486 | * @param rs reult specification to clean up | 480 | * @param rs reult specification to clean up |
487 | */ | 481 | */ |
488 | void | 482 | void |
489 | GNUNET_MY_cleanup_result (struct GNUNET_MY_ResultSpec *rs); | 483 | GNUNET_MY_cleanup_result(struct GNUNET_MY_ResultSpec *rs); |
490 | 484 | ||
491 | 485 | ||
492 | #if 0 /* keep Emacsens' auto-indent happy */ | 486 | #if 0 /* keep Emacsens' auto-indent happy */ |