diff options
Diffstat (limited to 'src/my/my_query_helper.c')
-rw-r--r-- | src/my/my_query_helper.c | 130 |
1 files changed, 66 insertions, 64 deletions
diff --git a/src/my/my_query_helper.c b/src/my/my_query_helper.c index 764021057..526e57b8b 100644 --- a/src/my/my_query_helper.c +++ b/src/my/my_query_helper.c | |||
@@ -36,11 +36,11 @@ | |||
36 | * @param qbind array of parameter to clean up | 36 | * @param qbind array of parameter to clean up |
37 | */ | 37 | */ |
38 | static void | 38 | static void |
39 | my_clean_query(void *cls, | 39 | my_clean_query (void *cls, |
40 | MYSQL_BIND *qbind) | 40 | MYSQL_BIND *qbind) |
41 | { | 41 | { |
42 | (void)cls; | 42 | (void) cls; |
43 | GNUNET_free(qbind[0].buffer); | 43 | GNUNET_free (qbind[0].buffer); |
44 | } | 44 | } |
45 | 45 | ||
46 | 46 | ||
@@ -53,13 +53,13 @@ my_clean_query(void *cls, | |||
53 | * @return -1 on error | 53 | * @return -1 on error |
54 | */ | 54 | */ |
55 | static int | 55 | static int |
56 | my_conv_fixed_size(void *cls, | 56 | my_conv_fixed_size (void *cls, |
57 | const struct GNUNET_MY_QueryParam *qp, | 57 | const struct GNUNET_MY_QueryParam *qp, |
58 | MYSQL_BIND *qbind) | 58 | MYSQL_BIND *qbind) |
59 | { | 59 | { |
60 | (void)cls; | 60 | (void) cls; |
61 | GNUNET_assert(1 == qp->num_params); | 61 | GNUNET_assert (1 == qp->num_params); |
62 | qbind->buffer = (void *)qp->data; | 62 | qbind->buffer = (void *) qp->data; |
63 | qbind->buffer_length = qp->data_len; | 63 | qbind->buffer_length = qp->data_len; |
64 | qbind->buffer_type = MYSQL_TYPE_BLOB; | 64 | qbind->buffer_type = MYSQL_TYPE_BLOB; |
65 | 65 | ||
@@ -75,8 +75,8 @@ my_conv_fixed_size(void *cls, | |||
75 | * @param ptr_size number of bytes in @a ptr | 75 | * @param ptr_size number of bytes in @a ptr |
76 | */ | 76 | */ |
77 | struct GNUNET_MY_QueryParam | 77 | struct GNUNET_MY_QueryParam |
78 | GNUNET_MY_query_param_fixed_size(const void *ptr, | 78 | GNUNET_MY_query_param_fixed_size (const void *ptr, |
79 | size_t ptr_size) | 79 | size_t ptr_size) |
80 | { | 80 | { |
81 | struct GNUNET_MY_QueryParam qp = { | 81 | struct GNUNET_MY_QueryParam qp = { |
82 | .conv = &my_conv_fixed_size, | 82 | .conv = &my_conv_fixed_size, |
@@ -84,7 +84,7 @@ GNUNET_MY_query_param_fixed_size(const void *ptr, | |||
84 | .conv_cls = NULL, | 84 | .conv_cls = NULL, |
85 | .num_params = 1, | 85 | .num_params = 1, |
86 | .data = ptr, | 86 | .data = ptr, |
87 | .data_len = (unsigned long)ptr_size | 87 | .data_len = (unsigned long) ptr_size |
88 | }; | 88 | }; |
89 | 89 | ||
90 | return qp; | 90 | return qp; |
@@ -100,13 +100,13 @@ GNUNET_MY_query_param_fixed_size(const void *ptr, | |||
100 | * @return -1 on error | 100 | * @return -1 on error |
101 | */ | 101 | */ |
102 | static int | 102 | static int |
103 | my_conv_string(void *cls, | 103 | my_conv_string (void *cls, |
104 | const struct GNUNET_MY_QueryParam *qp, | 104 | const struct GNUNET_MY_QueryParam *qp, |
105 | MYSQL_BIND *qbind) | 105 | MYSQL_BIND *qbind) |
106 | { | 106 | { |
107 | (void)cls; | 107 | (void) cls; |
108 | GNUNET_assert(1 == qp->num_params); | 108 | GNUNET_assert (1 == qp->num_params); |
109 | qbind->buffer = (void *)qp->data; | 109 | qbind->buffer = (void *) qp->data; |
110 | qbind->buffer_length = qp->data_len; | 110 | qbind->buffer_length = qp->data_len; |
111 | qbind->buffer_type = MYSQL_TYPE_STRING; | 111 | qbind->buffer_type = MYSQL_TYPE_STRING; |
112 | return 1; | 112 | return 1; |
@@ -119,7 +119,7 @@ my_conv_string(void *cls, | |||
119 | * @param ptr pointer to the string query parameter to pass | 119 | * @param ptr pointer to the string query parameter to pass |
120 | */ | 120 | */ |
121 | struct GNUNET_MY_QueryParam | 121 | struct GNUNET_MY_QueryParam |
122 | GNUNET_MY_query_param_string(const char *ptr) | 122 | GNUNET_MY_query_param_string (const char *ptr) |
123 | { | 123 | { |
124 | struct GNUNET_MY_QueryParam qp = { | 124 | struct GNUNET_MY_QueryParam qp = { |
125 | .conv = &my_conv_string, | 125 | .conv = &my_conv_string, |
@@ -127,7 +127,7 @@ GNUNET_MY_query_param_string(const char *ptr) | |||
127 | .conv_cls = NULL, | 127 | .conv_cls = NULL, |
128 | .num_params = 1, | 128 | .num_params = 1, |
129 | .data = ptr, | 129 | .data = ptr, |
130 | .data_len = strlen(ptr) | 130 | .data_len = strlen (ptr) |
131 | }; | 131 | }; |
132 | 132 | ||
133 | return qp; | 133 | return qp; |
@@ -143,13 +143,13 @@ GNUNET_MY_query_param_string(const char *ptr) | |||
143 | * @return -1 on error | 143 | * @return -1 on error |
144 | */ | 144 | */ |
145 | static int | 145 | static int |
146 | my_conv_uint16(void *cls, | 146 | my_conv_uint16 (void *cls, |
147 | const struct GNUNET_MY_QueryParam *qp, | 147 | const struct GNUNET_MY_QueryParam *qp, |
148 | MYSQL_BIND *qbind) | 148 | MYSQL_BIND *qbind) |
149 | { | 149 | { |
150 | (void)cls; | 150 | (void) cls; |
151 | GNUNET_assert(1 == qp->num_params); | 151 | GNUNET_assert (1 == qp->num_params); |
152 | qbind->buffer = (void *)qp->data; | 152 | qbind->buffer = (void *) qp->data; |
153 | qbind->buffer_length = sizeof(uint16_t); | 153 | qbind->buffer_length = sizeof(uint16_t); |
154 | qbind->buffer_type = MYSQL_TYPE_SHORT; | 154 | qbind->buffer_type = MYSQL_TYPE_SHORT; |
155 | qbind->is_unsigned = 1; | 155 | qbind->is_unsigned = 1; |
@@ -163,7 +163,7 @@ my_conv_uint16(void *cls, | |||
163 | * @param x pointer to the query parameter to pass | 163 | * @param x pointer to the query parameter to pass |
164 | */ | 164 | */ |
165 | struct GNUNET_MY_QueryParam | 165 | struct GNUNET_MY_QueryParam |
166 | GNUNET_MY_query_param_uint16(const uint16_t *x) | 166 | GNUNET_MY_query_param_uint16 (const uint16_t *x) |
167 | { | 167 | { |
168 | struct GNUNET_MY_QueryParam res = { | 168 | struct GNUNET_MY_QueryParam res = { |
169 | .conv = &my_conv_uint16, | 169 | .conv = &my_conv_uint16, |
@@ -187,13 +187,13 @@ GNUNET_MY_query_param_uint16(const uint16_t *x) | |||
187 | * @return -1 on error | 187 | * @return -1 on error |
188 | */ | 188 | */ |
189 | static int | 189 | static int |
190 | my_conv_uint32(void *cls, | 190 | my_conv_uint32 (void *cls, |
191 | const struct GNUNET_MY_QueryParam *qp, | 191 | const struct GNUNET_MY_QueryParam *qp, |
192 | MYSQL_BIND *qbind) | 192 | MYSQL_BIND *qbind) |
193 | { | 193 | { |
194 | (void)cls; | 194 | (void) cls; |
195 | GNUNET_assert(1 == qp->num_params); | 195 | GNUNET_assert (1 == qp->num_params); |
196 | qbind->buffer = (void *)qp->data; | 196 | qbind->buffer = (void *) qp->data; |
197 | qbind->buffer_length = sizeof(uint32_t); | 197 | qbind->buffer_length = sizeof(uint32_t); |
198 | qbind->buffer_type = MYSQL_TYPE_LONG; | 198 | qbind->buffer_type = MYSQL_TYPE_LONG; |
199 | qbind->is_unsigned = 1; | 199 | qbind->is_unsigned = 1; |
@@ -207,7 +207,7 @@ my_conv_uint32(void *cls, | |||
207 | * @param x pointer to the query parameter to pass | 207 | * @param x pointer to the query parameter to pass |
208 | */ | 208 | */ |
209 | struct GNUNET_MY_QueryParam | 209 | struct GNUNET_MY_QueryParam |
210 | GNUNET_MY_query_param_uint32(const uint32_t *x) | 210 | GNUNET_MY_query_param_uint32 (const uint32_t *x) |
211 | { | 211 | { |
212 | struct GNUNET_MY_QueryParam res = { | 212 | struct GNUNET_MY_QueryParam res = { |
213 | .conv = &my_conv_uint32, | 213 | .conv = &my_conv_uint32, |
@@ -231,13 +231,13 @@ GNUNET_MY_query_param_uint32(const uint32_t *x) | |||
231 | * @return -1 on error | 231 | * @return -1 on error |
232 | */ | 232 | */ |
233 | static int | 233 | static int |
234 | my_conv_uint64(void *cls, | 234 | my_conv_uint64 (void *cls, |
235 | const struct GNUNET_MY_QueryParam *qp, | 235 | const struct GNUNET_MY_QueryParam *qp, |
236 | MYSQL_BIND * qbind) | 236 | MYSQL_BIND *qbind) |
237 | { | 237 | { |
238 | (void)cls; | 238 | (void) cls; |
239 | GNUNET_assert(1 == qp->num_params); | 239 | GNUNET_assert (1 == qp->num_params); |
240 | qbind->buffer = (void *)qp->data; | 240 | qbind->buffer = (void *) qp->data; |
241 | qbind->buffer_length = sizeof(uint64_t); | 241 | qbind->buffer_length = sizeof(uint64_t); |
242 | qbind->buffer_type = MYSQL_TYPE_LONGLONG; | 242 | qbind->buffer_type = MYSQL_TYPE_LONGLONG; |
243 | qbind->is_unsigned = 1; | 243 | qbind->is_unsigned = 1; |
@@ -251,7 +251,7 @@ my_conv_uint64(void *cls, | |||
251 | * @param x pointer to the query parameter to pass | 251 | * @param x pointer to the query parameter to pass |
252 | */ | 252 | */ |
253 | struct GNUNET_MY_QueryParam | 253 | struct GNUNET_MY_QueryParam |
254 | GNUNET_MY_query_param_uint64(const uint64_t *x) | 254 | GNUNET_MY_query_param_uint64 (const uint64_t *x) |
255 | { | 255 | { |
256 | struct GNUNET_MY_QueryParam res = { | 256 | struct GNUNET_MY_QueryParam res = { |
257 | .conv = &my_conv_uint64, | 257 | .conv = &my_conv_uint64, |
@@ -275,19 +275,19 @@ GNUNET_MY_query_param_uint64(const uint64_t *x) | |||
275 | * @return -1 on error | 275 | * @return -1 on error |
276 | */ | 276 | */ |
277 | static int | 277 | static int |
278 | my_conv_rsa_public_key(void *cls, | 278 | my_conv_rsa_public_key (void *cls, |
279 | const struct GNUNET_MY_QueryParam *qp, | 279 | const struct GNUNET_MY_QueryParam *qp, |
280 | MYSQL_BIND * qbind) | 280 | MYSQL_BIND *qbind) |
281 | { | 281 | { |
282 | const struct GNUNET_CRYPTO_RsaPublicKey *rsa = qp->data; | 282 | const struct GNUNET_CRYPTO_RsaPublicKey *rsa = qp->data; |
283 | char *buf; | 283 | char *buf; |
284 | size_t buf_size; | 284 | size_t buf_size; |
285 | 285 | ||
286 | (void)cls; | 286 | (void) cls; |
287 | GNUNET_assert(1 == qp->num_params); | 287 | GNUNET_assert (1 == qp->num_params); |
288 | buf_size = GNUNET_CRYPTO_rsa_public_key_encode(rsa, | 288 | buf_size = GNUNET_CRYPTO_rsa_public_key_encode (rsa, |
289 | &buf); | 289 | &buf); |
290 | qbind->buffer = (void *)buf; | 290 | qbind->buffer = (void *) buf; |
291 | qbind->buffer_length = buf_size; | 291 | qbind->buffer_length = buf_size; |
292 | qbind->buffer_type = MYSQL_TYPE_BLOB; | 292 | qbind->buffer_type = MYSQL_TYPE_BLOB; |
293 | return 1; | 293 | return 1; |
@@ -302,7 +302,8 @@ my_conv_rsa_public_key(void *cls, | |||
302 | * @return array entry for the query parameters to use | 302 | * @return array entry for the query parameters to use |
303 | */ | 303 | */ |
304 | struct GNUNET_MY_QueryParam | 304 | struct GNUNET_MY_QueryParam |
305 | GNUNET_MY_query_param_rsa_public_key(const struct GNUNET_CRYPTO_RsaPublicKey *x) | 305 | GNUNET_MY_query_param_rsa_public_key (const struct |
306 | GNUNET_CRYPTO_RsaPublicKey *x) | ||
306 | { | 307 | { |
307 | struct GNUNET_MY_QueryParam res = { | 308 | struct GNUNET_MY_QueryParam res = { |
308 | .conv = &my_conv_rsa_public_key, | 309 | .conv = &my_conv_rsa_public_key, |
@@ -326,19 +327,19 @@ GNUNET_MY_query_param_rsa_public_key(const struct GNUNET_CRYPTO_RsaPublicKey *x) | |||
326 | *@return -1 on error | 327 | *@return -1 on error |
327 | */ | 328 | */ |
328 | static int | 329 | static int |
329 | my_conv_rsa_signature(void *cls, | 330 | my_conv_rsa_signature (void *cls, |
330 | const struct GNUNET_MY_QueryParam *qp, | 331 | const struct GNUNET_MY_QueryParam *qp, |
331 | MYSQL_BIND *qbind) | 332 | MYSQL_BIND *qbind) |
332 | { | 333 | { |
333 | const struct GNUNET_CRYPTO_RsaSignature *sig = qp->data; | 334 | const struct GNUNET_CRYPTO_RsaSignature *sig = qp->data; |
334 | char *buf; | 335 | char *buf; |
335 | size_t buf_size; | 336 | size_t buf_size; |
336 | 337 | ||
337 | (void)cls; | 338 | (void) cls; |
338 | GNUNET_assert(1 == qp->num_params); | 339 | GNUNET_assert (1 == qp->num_params); |
339 | buf_size = GNUNET_CRYPTO_rsa_signature_encode(sig, | 340 | buf_size = GNUNET_CRYPTO_rsa_signature_encode (sig, |
340 | &buf); | 341 | &buf); |
341 | qbind->buffer = (void *)buf; | 342 | qbind->buffer = (void *) buf; |
342 | qbind->buffer_length = buf_size; | 343 | qbind->buffer_length = buf_size; |
343 | qbind->buffer_type = MYSQL_TYPE_BLOB; | 344 | qbind->buffer_type = MYSQL_TYPE_BLOB; |
344 | return 1; | 345 | return 1; |
@@ -353,7 +354,7 @@ my_conv_rsa_signature(void *cls, | |||
353 | * @return array entry for the query parameters to use | 354 | * @return array entry for the query parameters to use |
354 | */ | 355 | */ |
355 | struct GNUNET_MY_QueryParam | 356 | struct GNUNET_MY_QueryParam |
356 | GNUNET_MY_query_param_rsa_signature(const struct GNUNET_CRYPTO_RsaSignature *x) | 357 | GNUNET_MY_query_param_rsa_signature (const struct GNUNET_CRYPTO_RsaSignature *x) |
357 | { | 358 | { |
358 | struct GNUNET_MY_QueryParam res = { | 359 | struct GNUNET_MY_QueryParam res = { |
359 | .conv = &my_conv_rsa_signature, | 360 | .conv = &my_conv_rsa_signature, |
@@ -376,9 +377,9 @@ GNUNET_MY_query_param_rsa_signature(const struct GNUNET_CRYPTO_RsaSignature *x) | |||
376 | * @return array entry for the query parameters to use | 377 | * @return array entry for the query parameters to use |
377 | */ | 378 | */ |
378 | struct GNUNET_MY_QueryParam | 379 | struct GNUNET_MY_QueryParam |
379 | GNUNET_MY_query_param_absolute_time(const struct GNUNET_TIME_Absolute *x) | 380 | GNUNET_MY_query_param_absolute_time (const struct GNUNET_TIME_Absolute *x) |
380 | { | 381 | { |
381 | return GNUNET_MY_query_param_uint64(&x->abs_value_us); | 382 | return GNUNET_MY_query_param_uint64 (&x->abs_value_us); |
382 | } | 383 | } |
383 | 384 | ||
384 | 385 | ||
@@ -389,9 +390,10 @@ GNUNET_MY_query_param_absolute_time(const struct GNUNET_TIME_Absolute *x) | |||
389 | * @param x pointer to the query parameter to pass | 390 | * @param x pointer to the query parameter to pass |
390 | */ | 391 | */ |
391 | struct GNUNET_MY_QueryParam | 392 | struct GNUNET_MY_QueryParam |
392 | GNUNET_MY_query_param_absolute_time_nbo(const struct GNUNET_TIME_AbsoluteNBO *x) | 393 | GNUNET_MY_query_param_absolute_time_nbo (const struct |
394 | GNUNET_TIME_AbsoluteNBO *x) | ||
393 | { | 395 | { |
394 | return GNUNET_MY_query_param_auto_from_type(&x->abs_value_us__); | 396 | return GNUNET_MY_query_param_auto_from_type (&x->abs_value_us__); |
395 | } | 397 | } |
396 | 398 | ||
397 | 399 | ||