diff options
Diffstat (limited to 'src/sq/sq_result_helper.c')
-rw-r--r-- | src/sq/sq_result_helper.c | 550 |
1 files changed, 275 insertions, 275 deletions
diff --git a/src/sq/sq_result_helper.c b/src/sq/sq_result_helper.c index aba1eaea5..6cef94326 100644 --- a/src/sq/sq_result_helper.c +++ b/src/sq/sq_result_helper.c | |||
@@ -1,23 +1,23 @@ | |||
1 | 1 | ||
2 | /* | 2 | /* |
3 | This file is part of GNUnet | 3 | This file is part of GNUnet |
4 | Copyright (C) 2017 GNUnet e.V. | 4 | Copyright (C) 2017 GNUnet e.V. |
5 | 5 | ||
6 | GNUnet is free software: you can redistribute it and/or modify it | 6 | GNUnet is free software: you can redistribute it and/or modify it |
7 | under the terms of the GNU Affero General Public License as published | 7 | under the terms of the GNU Affero General Public License as published |
8 | by the Free Software Foundation, either version 3 of the License, | 8 | by the Free Software Foundation, either version 3 of the License, |
9 | or (at your option) any later version. | 9 | or (at your option) any later version. |
10 | 10 | ||
11 | GNUnet is distributed in the hope that it will be useful, but | 11 | GNUnet is distributed in the hope that it will be useful, but |
12 | WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Affero General Public License for more details. | 14 | Affero General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Affero General Public License | 16 | You should have received a copy of the GNU Affero General Public License |
17 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 17 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
18 | 18 | ||
19 | SPDX-License-Identifier: AGPL3.0-or-later | 19 | SPDX-License-Identifier: AGPL3.0-or-later |
20 | */ | 20 | */ |
21 | /** | 21 | /** |
22 | * @file sq/sq_result_helper.c | 22 | * @file sq/sq_result_helper.c |
23 | * @brief helper functions for queries | 23 | * @brief helper functions for queries |
@@ -40,53 +40,53 @@ | |||
40 | * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) | 40 | * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) |
41 | */ | 41 | */ |
42 | static int | 42 | static int |
43 | extract_var_blob (void *cls, | 43 | extract_var_blob(void *cls, |
44 | sqlite3_stmt *result, | 44 | sqlite3_stmt *result, |
45 | unsigned int column, | 45 | unsigned int column, |
46 | size_t *dst_size, | 46 | size_t *dst_size, |
47 | void *dst) | 47 | void *dst) |
48 | { | 48 | { |
49 | int have; | 49 | int have; |
50 | const void *ret; | 50 | const void *ret; |
51 | void **rdst = (void **) dst; | 51 | void **rdst = (void **)dst; |
52 | 52 | ||
53 | if (SQLITE_NULL == | 53 | if (SQLITE_NULL == |
54 | sqlite3_column_type (result, | 54 | sqlite3_column_type(result, |
55 | column)) | 55 | column)) |
56 | { | 56 | { |
57 | *rdst = NULL; | 57 | *rdst = NULL; |
58 | *dst_size = 0; | 58 | *dst_size = 0; |
59 | return GNUNET_YES; | 59 | return GNUNET_YES; |
60 | } | 60 | } |
61 | 61 | ||
62 | if (SQLITE_BLOB != | 62 | if (SQLITE_BLOB != |
63 | sqlite3_column_type (result, | 63 | sqlite3_column_type(result, |
64 | column)) | 64 | column)) |
65 | { | 65 | { |
66 | GNUNET_break (0); | 66 | GNUNET_break(0); |
67 | return GNUNET_SYSERR; | 67 | return GNUNET_SYSERR; |
68 | } | 68 | } |
69 | /* sqlite manual says to invoke 'sqlite3_column_blob()' | 69 | /* sqlite manual says to invoke 'sqlite3_column_blob()' |
70 | before calling sqlite3_column_bytes() */ | 70 | before calling sqlite3_column_bytes() */ |
71 | ret = sqlite3_column_blob (result, | 71 | ret = sqlite3_column_blob(result, |
72 | column); | 72 | column); |
73 | have = sqlite3_column_bytes (result, | 73 | have = sqlite3_column_bytes(result, |
74 | column); | 74 | column); |
75 | if (have < 0) | 75 | if (have < 0) |
76 | { | 76 | { |
77 | GNUNET_break (0); | 77 | GNUNET_break(0); |
78 | return GNUNET_SYSERR; | 78 | return GNUNET_SYSERR; |
79 | } | 79 | } |
80 | *dst_size = have; | 80 | *dst_size = have; |
81 | if (0 == have) | 81 | if (0 == have) |
82 | { | 82 | { |
83 | *rdst = NULL; | 83 | *rdst = NULL; |
84 | return GNUNET_OK; | 84 | return GNUNET_OK; |
85 | } | 85 | } |
86 | *rdst = GNUNET_malloc (have); | 86 | *rdst = GNUNET_malloc(have); |
87 | GNUNET_memcpy (*rdst, | 87 | GNUNET_memcpy(*rdst, |
88 | ret, | 88 | ret, |
89 | have); | 89 | have); |
90 | return GNUNET_OK; | 90 | return GNUNET_OK; |
91 | } | 91 | } |
92 | 92 | ||
@@ -97,15 +97,15 @@ extract_var_blob (void *cls, | |||
97 | * @param cls pointer to pointer of allocation | 97 | * @param cls pointer to pointer of allocation |
98 | */ | 98 | */ |
99 | static void | 99 | static void |
100 | clean_var_blob (void *cls) | 100 | clean_var_blob(void *cls) |
101 | { | 101 | { |
102 | void **dptr = (void **) cls; | 102 | void **dptr = (void **)cls; |
103 | 103 | ||
104 | if (NULL != *dptr) | 104 | if (NULL != *dptr) |
105 | { | 105 | { |
106 | GNUNET_free (*dptr); | 106 | GNUNET_free(*dptr); |
107 | *dptr = NULL; | 107 | *dptr = NULL; |
108 | } | 108 | } |
109 | } | 109 | } |
110 | 110 | ||
111 | 111 | ||
@@ -117,8 +117,8 @@ clean_var_blob (void *cls) | |||
117 | * @return array entry for the result specification to use | 117 | * @return array entry for the result specification to use |
118 | */ | 118 | */ |
119 | struct GNUNET_SQ_ResultSpec | 119 | struct GNUNET_SQ_ResultSpec |
120 | GNUNET_SQ_result_spec_variable_size (void **dst, | 120 | GNUNET_SQ_result_spec_variable_size(void **dst, |
121 | size_t *sptr) | 121 | size_t *sptr) |
122 | { | 122 | { |
123 | struct GNUNET_SQ_ResultSpec rs = { | 123 | struct GNUNET_SQ_ResultSpec rs = { |
124 | .conv = &extract_var_blob, | 124 | .conv = &extract_var_blob, |
@@ -146,44 +146,44 @@ GNUNET_SQ_result_spec_variable_size (void **dst, | |||
146 | * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) | 146 | * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) |
147 | */ | 147 | */ |
148 | static int | 148 | static int |
149 | extract_fixed_blob (void *cls, | 149 | extract_fixed_blob(void *cls, |
150 | sqlite3_stmt *result, | 150 | sqlite3_stmt *result, |
151 | unsigned int column, | 151 | unsigned int column, |
152 | size_t *dst_size, | 152 | size_t *dst_size, |
153 | void *dst) | 153 | void *dst) |
154 | { | 154 | { |
155 | int have; | 155 | int have; |
156 | const void *ret; | 156 | const void *ret; |
157 | 157 | ||
158 | if ( (0 == *dst_size) && | 158 | if ((0 == *dst_size) && |
159 | (SQLITE_NULL == | 159 | (SQLITE_NULL == |
160 | sqlite3_column_type (result, | 160 | sqlite3_column_type(result, |
161 | column)) ) | 161 | column))) |
162 | { | 162 | { |
163 | return GNUNET_YES; | 163 | return GNUNET_YES; |
164 | } | 164 | } |
165 | 165 | ||
166 | if (SQLITE_BLOB != | 166 | if (SQLITE_BLOB != |
167 | sqlite3_column_type (result, | 167 | sqlite3_column_type(result, |
168 | column)) | 168 | column)) |
169 | { | 169 | { |
170 | GNUNET_break (0); | 170 | GNUNET_break(0); |
171 | return GNUNET_SYSERR; | 171 | return GNUNET_SYSERR; |
172 | } | 172 | } |
173 | /* sqlite manual says to invoke 'sqlite3_column_blob()' | 173 | /* sqlite manual says to invoke 'sqlite3_column_blob()' |
174 | before calling sqlite3_column_bytes() */ | 174 | before calling sqlite3_column_bytes() */ |
175 | ret = sqlite3_column_blob (result, | 175 | ret = sqlite3_column_blob(result, |
176 | column); | 176 | column); |
177 | have = sqlite3_column_bytes (result, | 177 | have = sqlite3_column_bytes(result, |
178 | column); | 178 | column); |
179 | if (*dst_size != have) | 179 | if (*dst_size != have) |
180 | { | 180 | { |
181 | GNUNET_break (0); | 181 | GNUNET_break(0); |
182 | return GNUNET_SYSERR; | 182 | return GNUNET_SYSERR; |
183 | } | 183 | } |
184 | GNUNET_memcpy (dst, | 184 | GNUNET_memcpy(dst, |
185 | ret, | 185 | ret, |
186 | have); | 186 | have); |
187 | return GNUNET_OK; | 187 | return GNUNET_OK; |
188 | } | 188 | } |
189 | 189 | ||
@@ -196,8 +196,8 @@ extract_fixed_blob (void *cls, | |||
196 | * @return array entry for the result specification to use | 196 | * @return array entry for the result specification to use |
197 | */ | 197 | */ |
198 | struct GNUNET_SQ_ResultSpec | 198 | struct GNUNET_SQ_ResultSpec |
199 | GNUNET_SQ_result_spec_fixed_size (void *dst, | 199 | GNUNET_SQ_result_spec_fixed_size(void *dst, |
200 | size_t dst_size) | 200 | size_t dst_size) |
201 | { | 201 | { |
202 | struct GNUNET_SQ_ResultSpec rs = { | 202 | struct GNUNET_SQ_ResultSpec rs = { |
203 | .conv = &extract_fixed_blob, | 203 | .conv = &extract_fixed_blob, |
@@ -223,40 +223,40 @@ GNUNET_SQ_result_spec_fixed_size (void *dst, | |||
223 | * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) | 223 | * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) |
224 | */ | 224 | */ |
225 | static int | 225 | static int |
226 | extract_utf8_string (void *cls, | 226 | extract_utf8_string(void *cls, |
227 | sqlite3_stmt *result, | 227 | sqlite3_stmt *result, |
228 | unsigned int column, | 228 | unsigned int column, |
229 | size_t *dst_size, | 229 | size_t *dst_size, |
230 | void *dst) | 230 | void *dst) |
231 | { | 231 | { |
232 | const char *text; | 232 | const char *text; |
233 | char **rdst = dst; | 233 | char **rdst = dst; |
234 | 234 | ||
235 | if (SQLITE_NULL == | 235 | if (SQLITE_NULL == |
236 | sqlite3_column_type (result, | 236 | sqlite3_column_type(result, |
237 | column)) | 237 | column)) |
238 | { | 238 | { |
239 | *rdst = NULL; | 239 | *rdst = NULL; |
240 | return GNUNET_OK; | 240 | return GNUNET_OK; |
241 | } | 241 | } |
242 | if (SQLITE_TEXT != | 242 | if (SQLITE_TEXT != |
243 | sqlite3_column_type (result, | 243 | sqlite3_column_type(result, |
244 | column)) | 244 | column)) |
245 | { | 245 | { |
246 | GNUNET_break (0); | 246 | GNUNET_break(0); |
247 | return GNUNET_SYSERR; | 247 | return GNUNET_SYSERR; |
248 | } | 248 | } |
249 | /* sqlite manual guarantees that 'sqlite3_column_text()' | 249 | /* sqlite manual guarantees that 'sqlite3_column_text()' |
250 | is 0-terminated */ | 250 | is 0-terminated */ |
251 | text = (const char *) sqlite3_column_text (result, | 251 | text = (const char *)sqlite3_column_text(result, |
252 | column); | 252 | column); |
253 | if (NULL == text) | 253 | if (NULL == text) |
254 | { | 254 | { |
255 | GNUNET_break (0); | 255 | GNUNET_break(0); |
256 | return GNUNET_SYSERR; | 256 | return GNUNET_SYSERR; |
257 | } | 257 | } |
258 | *dst_size = strlen (text) + 1; | 258 | *dst_size = strlen(text) + 1; |
259 | *rdst = GNUNET_strdup (text); | 259 | *rdst = GNUNET_strdup(text); |
260 | return GNUNET_OK; | 260 | return GNUNET_OK; |
261 | } | 261 | } |
262 | 262 | ||
@@ -267,15 +267,15 @@ extract_utf8_string (void *cls, | |||
267 | * @param cls pointer to pointer of allocation | 267 | * @param cls pointer to pointer of allocation |
268 | */ | 268 | */ |
269 | static void | 269 | static void |
270 | clean_utf8_string (void *cls) | 270 | clean_utf8_string(void *cls) |
271 | { | 271 | { |
272 | char **dptr = (char **) cls; | 272 | char **dptr = (char **)cls; |
273 | 273 | ||
274 | if (NULL != *dptr) | 274 | if (NULL != *dptr) |
275 | { | 275 | { |
276 | GNUNET_free (*dptr); | 276 | GNUNET_free(*dptr); |
277 | *dptr = NULL; | 277 | *dptr = NULL; |
278 | } | 278 | } |
279 | } | 279 | } |
280 | 280 | ||
281 | 281 | ||
@@ -286,7 +286,7 @@ clean_utf8_string (void *cls) | |||
286 | * @return array entry for the result specification to use | 286 | * @return array entry for the result specification to use |
287 | */ | 287 | */ |
288 | struct GNUNET_SQ_ResultSpec | 288 | struct GNUNET_SQ_ResultSpec |
289 | GNUNET_SQ_result_spec_string (char **dst) | 289 | GNUNET_SQ_result_spec_string(char **dst) |
290 | { | 290 | { |
291 | struct GNUNET_SQ_ResultSpec rs = { | 291 | struct GNUNET_SQ_ResultSpec rs = { |
292 | .conv = &extract_utf8_string, | 292 | .conv = &extract_utf8_string, |
@@ -313,42 +313,42 @@ GNUNET_SQ_result_spec_string (char **dst) | |||
313 | * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) | 313 | * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) |
314 | */ | 314 | */ |
315 | static int | 315 | static int |
316 | extract_rsa_pub (void *cls, | 316 | extract_rsa_pub(void *cls, |
317 | sqlite3_stmt *result, | 317 | sqlite3_stmt *result, |
318 | unsigned int column, | 318 | unsigned int column, |
319 | size_t *dst_size, | 319 | size_t *dst_size, |
320 | void *dst) | 320 | void *dst) |
321 | { | 321 | { |
322 | struct GNUNET_CRYPTO_RsaPublicKey **pk = dst; | 322 | struct GNUNET_CRYPTO_RsaPublicKey **pk = dst; |
323 | int have; | 323 | int have; |
324 | const void *ret; | 324 | const void *ret; |
325 | 325 | ||
326 | if (SQLITE_BLOB != | 326 | if (SQLITE_BLOB != |
327 | sqlite3_column_type (result, | 327 | sqlite3_column_type(result, |
328 | column)) | 328 | column)) |
329 | { | 329 | { |
330 | GNUNET_break (0); | 330 | GNUNET_break(0); |
331 | return GNUNET_SYSERR; | 331 | return GNUNET_SYSERR; |
332 | } | 332 | } |
333 | /* sqlite manual says to invoke 'sqlite3_column_blob()' | 333 | /* sqlite manual says to invoke 'sqlite3_column_blob()' |
334 | before calling sqlite3_column_bytes() */ | 334 | before calling sqlite3_column_bytes() */ |
335 | ret = sqlite3_column_blob (result, | 335 | ret = sqlite3_column_blob(result, |
336 | column); | 336 | column); |
337 | have = sqlite3_column_bytes (result, | 337 | have = sqlite3_column_bytes(result, |
338 | column); | 338 | column); |
339 | if (have < 0) | 339 | if (have < 0) |
340 | { | 340 | { |
341 | GNUNET_break (0); | 341 | GNUNET_break(0); |
342 | return GNUNET_SYSERR; | 342 | return GNUNET_SYSERR; |
343 | } | 343 | } |
344 | 344 | ||
345 | *pk = GNUNET_CRYPTO_rsa_public_key_decode (ret, | 345 | *pk = GNUNET_CRYPTO_rsa_public_key_decode(ret, |
346 | have); | 346 | have); |
347 | if (NULL == *pk) | 347 | if (NULL == *pk) |
348 | { | 348 | { |
349 | GNUNET_break (0); | 349 | GNUNET_break(0); |
350 | return GNUNET_SYSERR; | 350 | return GNUNET_SYSERR; |
351 | } | 351 | } |
352 | return GNUNET_OK; | 352 | return GNUNET_OK; |
353 | } | 353 | } |
354 | 354 | ||
@@ -360,15 +360,15 @@ extract_rsa_pub (void *cls, | |||
360 | * @param cls closure | 360 | * @param cls closure |
361 | */ | 361 | */ |
362 | static void | 362 | static void |
363 | clean_rsa_pub (void *cls) | 363 | clean_rsa_pub(void *cls) |
364 | { | 364 | { |
365 | struct GNUNET_CRYPTO_RsaPublicKey **pk = cls; | 365 | struct GNUNET_CRYPTO_RsaPublicKey **pk = cls; |
366 | 366 | ||
367 | if (NULL != *pk) | 367 | if (NULL != *pk) |
368 | { | 368 | { |
369 | GNUNET_CRYPTO_rsa_public_key_free (*pk); | 369 | GNUNET_CRYPTO_rsa_public_key_free(*pk); |
370 | *pk = NULL; | 370 | *pk = NULL; |
371 | } | 371 | } |
372 | } | 372 | } |
373 | 373 | ||
374 | 374 | ||
@@ -379,7 +379,7 @@ clean_rsa_pub (void *cls) | |||
379 | * @return array entry for the result specification to use | 379 | * @return array entry for the result specification to use |
380 | */ | 380 | */ |
381 | struct GNUNET_SQ_ResultSpec | 381 | struct GNUNET_SQ_ResultSpec |
382 | GNUNET_SQ_result_spec_rsa_public_key (struct GNUNET_CRYPTO_RsaPublicKey **rsa) | 382 | GNUNET_SQ_result_spec_rsa_public_key(struct GNUNET_CRYPTO_RsaPublicKey **rsa) |
383 | { | 383 | { |
384 | struct GNUNET_SQ_ResultSpec rs = { | 384 | struct GNUNET_SQ_ResultSpec rs = { |
385 | .conv = &extract_rsa_pub, | 385 | .conv = &extract_rsa_pub, |
@@ -406,42 +406,42 @@ GNUNET_SQ_result_spec_rsa_public_key (struct GNUNET_CRYPTO_RsaPublicKey **rsa) | |||
406 | * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) | 406 | * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) |
407 | */ | 407 | */ |
408 | static int | 408 | static int |
409 | extract_rsa_sig (void *cls, | 409 | extract_rsa_sig(void *cls, |
410 | sqlite3_stmt *result, | 410 | sqlite3_stmt *result, |
411 | unsigned int column, | 411 | unsigned int column, |
412 | size_t *dst_size, | 412 | size_t *dst_size, |
413 | void *dst) | 413 | void *dst) |
414 | { | 414 | { |
415 | struct GNUNET_CRYPTO_RsaSignature **sig = dst; | 415 | struct GNUNET_CRYPTO_RsaSignature **sig = dst; |
416 | int have; | 416 | int have; |
417 | const void *ret; | 417 | const void *ret; |
418 | 418 | ||
419 | if (SQLITE_BLOB != | 419 | if (SQLITE_BLOB != |
420 | sqlite3_column_type (result, | 420 | sqlite3_column_type(result, |
421 | column)) | 421 | column)) |
422 | { | 422 | { |
423 | GNUNET_break (0); | 423 | GNUNET_break(0); |
424 | return GNUNET_SYSERR; | 424 | return GNUNET_SYSERR; |
425 | } | 425 | } |
426 | /* sqlite manual says to invoke 'sqlite3_column_blob()' | 426 | /* sqlite manual says to invoke 'sqlite3_column_blob()' |
427 | before calling sqlite3_column_bytes() */ | 427 | before calling sqlite3_column_bytes() */ |
428 | ret = sqlite3_column_blob (result, | 428 | ret = sqlite3_column_blob(result, |
429 | column); | 429 | column); |
430 | have = sqlite3_column_bytes (result, | 430 | have = sqlite3_column_bytes(result, |
431 | column); | 431 | column); |
432 | if (have < 0) | 432 | if (have < 0) |
433 | { | 433 | { |
434 | GNUNET_break (0); | 434 | GNUNET_break(0); |
435 | return GNUNET_SYSERR; | 435 | return GNUNET_SYSERR; |
436 | } | 436 | } |
437 | 437 | ||
438 | *sig = GNUNET_CRYPTO_rsa_signature_decode (ret, | 438 | *sig = GNUNET_CRYPTO_rsa_signature_decode(ret, |
439 | have); | 439 | have); |
440 | if (NULL == *sig) | 440 | if (NULL == *sig) |
441 | { | 441 | { |
442 | GNUNET_break (0); | 442 | GNUNET_break(0); |
443 | return GNUNET_SYSERR; | 443 | return GNUNET_SYSERR; |
444 | } | 444 | } |
445 | return GNUNET_OK; | 445 | return GNUNET_OK; |
446 | } | 446 | } |
447 | 447 | ||
@@ -453,15 +453,15 @@ extract_rsa_sig (void *cls, | |||
453 | * @param cls result data to clean up | 453 | * @param cls result data to clean up |
454 | */ | 454 | */ |
455 | static void | 455 | static void |
456 | clean_rsa_sig (void *cls) | 456 | clean_rsa_sig(void *cls) |
457 | { | 457 | { |
458 | struct GNUNET_CRYPTO_RsaSignature **sig = cls; | 458 | struct GNUNET_CRYPTO_RsaSignature **sig = cls; |
459 | 459 | ||
460 | if (NULL != *sig) | 460 | if (NULL != *sig) |
461 | { | 461 | { |
462 | GNUNET_CRYPTO_rsa_signature_free (*sig); | 462 | GNUNET_CRYPTO_rsa_signature_free(*sig); |
463 | *sig = NULL; | 463 | *sig = NULL; |
464 | } | 464 | } |
465 | } | 465 | } |
466 | 466 | ||
467 | 467 | ||
@@ -472,7 +472,7 @@ clean_rsa_sig (void *cls) | |||
472 | * @return array entry for the result specification to use | 472 | * @return array entry for the result specification to use |
473 | */ | 473 | */ |
474 | struct GNUNET_SQ_ResultSpec | 474 | struct GNUNET_SQ_ResultSpec |
475 | GNUNET_SQ_result_spec_rsa_signature (struct GNUNET_CRYPTO_RsaSignature **sig) | 475 | GNUNET_SQ_result_spec_rsa_signature(struct GNUNET_CRYPTO_RsaSignature **sig) |
476 | { | 476 | { |
477 | struct GNUNET_SQ_ResultSpec rs = { | 477 | struct GNUNET_SQ_ResultSpec rs = { |
478 | .conv = &extract_rsa_sig, | 478 | .conv = &extract_rsa_sig, |
@@ -499,25 +499,25 @@ GNUNET_SQ_result_spec_rsa_signature (struct GNUNET_CRYPTO_RsaSignature **sig) | |||
499 | * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) | 499 | * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) |
500 | */ | 500 | */ |
501 | static int | 501 | static int |
502 | extract_abs_time (void *cls, | 502 | extract_abs_time(void *cls, |
503 | sqlite3_stmt *result, | 503 | sqlite3_stmt *result, |
504 | unsigned int column, | 504 | unsigned int column, |
505 | size_t *dst_size, | 505 | size_t *dst_size, |
506 | void *dst) | 506 | void *dst) |
507 | { | 507 | { |
508 | struct GNUNET_TIME_Absolute *u = dst; | 508 | struct GNUNET_TIME_Absolute *u = dst; |
509 | struct GNUNET_TIME_Absolute t; | 509 | struct GNUNET_TIME_Absolute t; |
510 | 510 | ||
511 | GNUNET_assert (sizeof (uint64_t) == *dst_size); | 511 | GNUNET_assert(sizeof(uint64_t) == *dst_size); |
512 | if (SQLITE_INTEGER != | 512 | if (SQLITE_INTEGER != |
513 | sqlite3_column_type (result, | 513 | sqlite3_column_type(result, |
514 | column)) | 514 | column)) |
515 | { | 515 | { |
516 | GNUNET_break (0); | 516 | GNUNET_break(0); |
517 | return GNUNET_SYSERR; | 517 | return GNUNET_SYSERR; |
518 | } | 518 | } |
519 | t.abs_value_us = (uint64_t) sqlite3_column_int64 (result, | 519 | t.abs_value_us = (uint64_t)sqlite3_column_int64(result, |
520 | column); | 520 | column); |
521 | if (INT64_MAX == t.abs_value_us) | 521 | if (INT64_MAX == t.abs_value_us) |
522 | t = GNUNET_TIME_UNIT_FOREVER_ABS; | 522 | t = GNUNET_TIME_UNIT_FOREVER_ABS; |
523 | *u = t; | 523 | *u = t; |
@@ -532,12 +532,12 @@ extract_abs_time (void *cls, | |||
532 | * @return array entry for the result specification to use | 532 | * @return array entry for the result specification to use |
533 | */ | 533 | */ |
534 | struct GNUNET_SQ_ResultSpec | 534 | struct GNUNET_SQ_ResultSpec |
535 | GNUNET_SQ_result_spec_absolute_time (struct GNUNET_TIME_Absolute *at) | 535 | GNUNET_SQ_result_spec_absolute_time(struct GNUNET_TIME_Absolute *at) |
536 | { | 536 | { |
537 | struct GNUNET_SQ_ResultSpec rs = { | 537 | struct GNUNET_SQ_ResultSpec rs = { |
538 | .conv = &extract_abs_time, | 538 | .conv = &extract_abs_time, |
539 | .dst = at, | 539 | .dst = at, |
540 | .dst_size = sizeof (struct GNUNET_TIME_Absolute), | 540 | .dst_size = sizeof(struct GNUNET_TIME_Absolute), |
541 | .num_params = 1 | 541 | .num_params = 1 |
542 | }; | 542 | }; |
543 | 543 | ||
@@ -558,28 +558,28 @@ GNUNET_SQ_result_spec_absolute_time (struct GNUNET_TIME_Absolute *at) | |||
558 | * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) | 558 | * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) |
559 | */ | 559 | */ |
560 | static int | 560 | static int |
561 | extract_abs_time_nbo (void *cls, | 561 | extract_abs_time_nbo(void *cls, |
562 | sqlite3_stmt *result, | 562 | sqlite3_stmt *result, |
563 | unsigned int column, | 563 | unsigned int column, |
564 | size_t *dst_size, | 564 | size_t *dst_size, |
565 | void *dst) | 565 | void *dst) |
566 | { | 566 | { |
567 | struct GNUNET_TIME_AbsoluteNBO *u = dst; | 567 | struct GNUNET_TIME_AbsoluteNBO *u = dst; |
568 | struct GNUNET_TIME_Absolute t; | 568 | struct GNUNET_TIME_Absolute t; |
569 | 569 | ||
570 | GNUNET_assert (sizeof (uint64_t) == *dst_size); | 570 | GNUNET_assert(sizeof(uint64_t) == *dst_size); |
571 | if (SQLITE_INTEGER != | 571 | if (SQLITE_INTEGER != |
572 | sqlite3_column_type (result, | 572 | sqlite3_column_type(result, |
573 | column)) | 573 | column)) |
574 | { | 574 | { |
575 | GNUNET_break (0); | 575 | GNUNET_break(0); |
576 | return GNUNET_SYSERR; | 576 | return GNUNET_SYSERR; |
577 | } | 577 | } |
578 | t.abs_value_us = (uint64_t) sqlite3_column_int64 (result, | 578 | t.abs_value_us = (uint64_t)sqlite3_column_int64(result, |
579 | column); | 579 | column); |
580 | if (INT64_MAX == t.abs_value_us) | 580 | if (INT64_MAX == t.abs_value_us) |
581 | t = GNUNET_TIME_UNIT_FOREVER_ABS; | 581 | t = GNUNET_TIME_UNIT_FOREVER_ABS; |
582 | *u = GNUNET_TIME_absolute_hton (t); | 582 | *u = GNUNET_TIME_absolute_hton(t); |
583 | return GNUNET_OK; | 583 | return GNUNET_OK; |
584 | } | 584 | } |
585 | 585 | ||
@@ -591,12 +591,12 @@ extract_abs_time_nbo (void *cls, | |||
591 | * @return array entry for the result specification to use | 591 | * @return array entry for the result specification to use |
592 | */ | 592 | */ |
593 | struct GNUNET_SQ_ResultSpec | 593 | struct GNUNET_SQ_ResultSpec |
594 | GNUNET_SQ_result_spec_absolute_time_nbo (struct GNUNET_TIME_AbsoluteNBO *at) | 594 | GNUNET_SQ_result_spec_absolute_time_nbo(struct GNUNET_TIME_AbsoluteNBO *at) |
595 | { | 595 | { |
596 | struct GNUNET_SQ_ResultSpec rs = { | 596 | struct GNUNET_SQ_ResultSpec rs = { |
597 | .conv = &extract_abs_time_nbo, | 597 | .conv = &extract_abs_time_nbo, |
598 | .dst = at, | 598 | .dst = at, |
599 | .dst_size = sizeof (struct GNUNET_TIME_AbsoluteNBO), | 599 | .dst_size = sizeof(struct GNUNET_TIME_AbsoluteNBO), |
600 | .num_params = 1 | 600 | .num_params = 1 |
601 | }; | 601 | }; |
602 | 602 | ||
@@ -617,31 +617,31 @@ GNUNET_SQ_result_spec_absolute_time_nbo (struct GNUNET_TIME_AbsoluteNBO *at) | |||
617 | * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) | 617 | * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) |
618 | */ | 618 | */ |
619 | static int | 619 | static int |
620 | extract_uint16 (void *cls, | 620 | extract_uint16(void *cls, |
621 | sqlite3_stmt *result, | 621 | sqlite3_stmt *result, |
622 | unsigned int column, | 622 | unsigned int column, |
623 | size_t *dst_size, | 623 | size_t *dst_size, |
624 | void *dst) | 624 | void *dst) |
625 | { | 625 | { |
626 | uint64_t v; | 626 | uint64_t v; |
627 | uint16_t *u = dst; | 627 | uint16_t *u = dst; |
628 | 628 | ||
629 | GNUNET_assert (sizeof (uint16_t) == *dst_size); | 629 | GNUNET_assert(sizeof(uint16_t) == *dst_size); |
630 | if (SQLITE_INTEGER != | 630 | if (SQLITE_INTEGER != |
631 | sqlite3_column_type (result, | 631 | sqlite3_column_type(result, |
632 | column)) | 632 | column)) |
633 | { | 633 | { |
634 | GNUNET_break (0); | 634 | GNUNET_break(0); |
635 | return GNUNET_SYSERR; | 635 | return GNUNET_SYSERR; |
636 | } | 636 | } |
637 | v = (uint64_t) sqlite3_column_int64 (result, | 637 | v = (uint64_t)sqlite3_column_int64(result, |
638 | column); | 638 | column); |
639 | if (v > UINT16_MAX) | 639 | if (v > UINT16_MAX) |
640 | { | 640 | { |
641 | GNUNET_break (0); | 641 | GNUNET_break(0); |
642 | return GNUNET_SYSERR; | 642 | return GNUNET_SYSERR; |
643 | } | 643 | } |
644 | *u = (uint16_t) v; | 644 | *u = (uint16_t)v; |
645 | return GNUNET_OK; | 645 | return GNUNET_OK; |
646 | } | 646 | } |
647 | 647 | ||
@@ -653,12 +653,12 @@ extract_uint16 (void *cls, | |||
653 | * @return array entry for the result specification to use | 653 | * @return array entry for the result specification to use |
654 | */ | 654 | */ |
655 | struct GNUNET_SQ_ResultSpec | 655 | struct GNUNET_SQ_ResultSpec |
656 | GNUNET_SQ_result_spec_uint16 (uint16_t *u16) | 656 | GNUNET_SQ_result_spec_uint16(uint16_t *u16) |
657 | { | 657 | { |
658 | struct GNUNET_SQ_ResultSpec rs = { | 658 | struct GNUNET_SQ_ResultSpec rs = { |
659 | .conv = &extract_uint16, | 659 | .conv = &extract_uint16, |
660 | .dst = u16, | 660 | .dst = u16, |
661 | .dst_size = sizeof (uint16_t), | 661 | .dst_size = sizeof(uint16_t), |
662 | .num_params = 1 | 662 | .num_params = 1 |
663 | }; | 663 | }; |
664 | 664 | ||
@@ -679,31 +679,31 @@ GNUNET_SQ_result_spec_uint16 (uint16_t *u16) | |||
679 | * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) | 679 | * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) |
680 | */ | 680 | */ |
681 | static int | 681 | static int |
682 | extract_uint32 (void *cls, | 682 | extract_uint32(void *cls, |
683 | sqlite3_stmt *result, | 683 | sqlite3_stmt *result, |
684 | unsigned int column, | 684 | unsigned int column, |
685 | size_t *dst_size, | 685 | size_t *dst_size, |
686 | void *dst) | 686 | void *dst) |
687 | { | 687 | { |
688 | uint64_t v; | 688 | uint64_t v; |
689 | uint32_t *u = dst; | 689 | uint32_t *u = dst; |
690 | 690 | ||
691 | GNUNET_assert (sizeof (uint32_t) == *dst_size); | 691 | GNUNET_assert(sizeof(uint32_t) == *dst_size); |
692 | if (SQLITE_INTEGER != | 692 | if (SQLITE_INTEGER != |
693 | sqlite3_column_type (result, | 693 | sqlite3_column_type(result, |
694 | column)) | 694 | column)) |
695 | { | 695 | { |
696 | GNUNET_break (0); | 696 | GNUNET_break(0); |
697 | return GNUNET_SYSERR; | 697 | return GNUNET_SYSERR; |
698 | } | 698 | } |
699 | v = (uint64_t) sqlite3_column_int64 (result, | 699 | v = (uint64_t)sqlite3_column_int64(result, |
700 | column); | 700 | column); |
701 | if (v > UINT32_MAX) | 701 | if (v > UINT32_MAX) |
702 | { | 702 | { |
703 | GNUNET_break (0); | 703 | GNUNET_break(0); |
704 | return GNUNET_SYSERR; | 704 | return GNUNET_SYSERR; |
705 | } | 705 | } |
706 | *u = (uint32_t) v; | 706 | *u = (uint32_t)v; |
707 | return GNUNET_OK; | 707 | return GNUNET_OK; |
708 | } | 708 | } |
709 | 709 | ||
@@ -715,12 +715,12 @@ extract_uint32 (void *cls, | |||
715 | * @return array entry for the result specification to use | 715 | * @return array entry for the result specification to use |
716 | */ | 716 | */ |
717 | struct GNUNET_SQ_ResultSpec | 717 | struct GNUNET_SQ_ResultSpec |
718 | GNUNET_SQ_result_spec_uint32 (uint32_t *u32) | 718 | GNUNET_SQ_result_spec_uint32(uint32_t *u32) |
719 | { | 719 | { |
720 | struct GNUNET_SQ_ResultSpec rs = { | 720 | struct GNUNET_SQ_ResultSpec rs = { |
721 | .conv = &extract_uint32, | 721 | .conv = &extract_uint32, |
722 | .dst = u32, | 722 | .dst = u32, |
723 | .dst_size = sizeof (uint32_t), | 723 | .dst_size = sizeof(uint32_t), |
724 | .num_params = 1 | 724 | .num_params = 1 |
725 | }; | 725 | }; |
726 | 726 | ||
@@ -741,24 +741,24 @@ GNUNET_SQ_result_spec_uint32 (uint32_t *u32) | |||
741 | * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) | 741 | * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) |
742 | */ | 742 | */ |
743 | static int | 743 | static int |
744 | extract_uint64 (void *cls, | 744 | extract_uint64(void *cls, |
745 | sqlite3_stmt *result, | 745 | sqlite3_stmt *result, |
746 | unsigned int column, | 746 | unsigned int column, |
747 | size_t *dst_size, | 747 | size_t *dst_size, |
748 | void *dst) | 748 | void *dst) |
749 | { | 749 | { |
750 | uint64_t *u = dst; | 750 | uint64_t *u = dst; |
751 | 751 | ||
752 | GNUNET_assert (sizeof (uint64_t) == *dst_size); | 752 | GNUNET_assert(sizeof(uint64_t) == *dst_size); |
753 | if (SQLITE_INTEGER != | 753 | if (SQLITE_INTEGER != |
754 | sqlite3_column_type (result, | 754 | sqlite3_column_type(result, |
755 | column)) | 755 | column)) |
756 | { | 756 | { |
757 | GNUNET_break (0); | 757 | GNUNET_break(0); |
758 | return GNUNET_SYSERR; | 758 | return GNUNET_SYSERR; |
759 | } | 759 | } |
760 | *u = (uint64_t) sqlite3_column_int64 (result, | 760 | *u = (uint64_t)sqlite3_column_int64(result, |
761 | column); | 761 | column); |
762 | return GNUNET_OK; | 762 | return GNUNET_OK; |
763 | } | 763 | } |
764 | 764 | ||
@@ -770,12 +770,12 @@ extract_uint64 (void *cls, | |||
770 | * @return array entry for the result specification to use | 770 | * @return array entry for the result specification to use |
771 | */ | 771 | */ |
772 | struct GNUNET_SQ_ResultSpec | 772 | struct GNUNET_SQ_ResultSpec |
773 | GNUNET_SQ_result_spec_uint64 (uint64_t *u64) | 773 | GNUNET_SQ_result_spec_uint64(uint64_t *u64) |
774 | { | 774 | { |
775 | struct GNUNET_SQ_ResultSpec rs = { | 775 | struct GNUNET_SQ_ResultSpec rs = { |
776 | .conv = &extract_uint64, | 776 | .conv = &extract_uint64, |
777 | .dst = u64, | 777 | .dst = u64, |
778 | .dst_size = sizeof (uint64_t), | 778 | .dst_size = sizeof(uint64_t), |
779 | .num_params = 1 | 779 | .num_params = 1 |
780 | }; | 780 | }; |
781 | 781 | ||