diff options
author | Christian Grothoff <christian@grothoff.org> | 2019-10-05 15:09:28 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2019-10-05 15:09:28 +0200 |
commit | c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207 (patch) | |
tree | cac3ce030d77b4cbe7c7dc62ed58cfe6d24f73e1 /src/my | |
parent | fbb71d527c7d6babf269a8fefce1db291b9f7068 (diff) | |
download | gnunet-c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207.tar.gz gnunet-c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207.zip |
global reindent, now with uncrustify hook enabled
Diffstat (limited to 'src/my')
-rw-r--r-- | src/my/my.c | 252 | ||||
-rw-r--r-- | src/my/my_query_helper.c | 130 | ||||
-rw-r--r-- | src/my/my_result_helper.c | 381 | ||||
-rw-r--r-- | src/my/test_my.c | 359 |
4 files changed, 561 insertions, 561 deletions
diff --git a/src/my/my.c b/src/my/my.c index bee18145d..41d280d5e 100644 --- a/src/my/my.c +++ b/src/my/my.c | |||
@@ -39,9 +39,9 @@ | |||
39 | #GNUNET_SYSERR if we can't prepare all statement | 39 | #GNUNET_SYSERR if we can't prepare all statement |
40 | */ | 40 | */ |
41 | int | 41 | int |
42 | GNUNET_MY_exec_prepared(struct GNUNET_MYSQL_Context *mc, | 42 | GNUNET_MY_exec_prepared (struct GNUNET_MYSQL_Context *mc, |
43 | struct GNUNET_MYSQL_StatementHandle *sh, | 43 | struct GNUNET_MYSQL_StatementHandle *sh, |
44 | struct GNUNET_MY_QueryParam *params) | 44 | struct GNUNET_MY_QueryParam *params) |
45 | { | 45 | { |
46 | const struct GNUNET_MY_QueryParam *p; | 46 | const struct GNUNET_MY_QueryParam *p; |
47 | unsigned int num; | 47 | unsigned int num; |
@@ -54,50 +54,50 @@ GNUNET_MY_exec_prepared(struct GNUNET_MYSQL_Context *mc, | |||
54 | MYSQL_BIND qbind[num]; | 54 | MYSQL_BIND qbind[num]; |
55 | unsigned int off; | 55 | unsigned int off; |
56 | 56 | ||
57 | memset(qbind, | 57 | memset (qbind, |
58 | 0, | 58 | 0, |
59 | sizeof(qbind)); | 59 | sizeof(qbind)); |
60 | off = 0; | 60 | off = 0; |
61 | for (unsigned int i = 0; NULL != (p = ¶ms[i])->conv; i++) | 61 | for (unsigned int i = 0; NULL != (p = ¶ms[i])->conv; i++) |
62 | { | ||
63 | if (GNUNET_OK != | ||
64 | p->conv (p->conv_cls, | ||
65 | p, | ||
66 | &qbind[off])) | ||
62 | { | 67 | { |
63 | if (GNUNET_OK != | 68 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
64 | p->conv(p->conv_cls, | 69 | "Conversion for MySQL query failed at offset %u\n", |
65 | p, | 70 | i); |
66 | &qbind[off])) | ||
67 | { | ||
68 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | ||
69 | "Conversion for MySQL query failed at offset %u\n", | ||
70 | i); | ||
71 | return GNUNET_SYSERR; | ||
72 | } | ||
73 | off += p->num_params; | ||
74 | } | ||
75 | stmt = GNUNET_MYSQL_statement_get_stmt(sh); | ||
76 | if (mysql_stmt_bind_param(stmt, | ||
77 | qbind)) | ||
78 | { | ||
79 | GNUNET_log_from(GNUNET_ERROR_TYPE_ERROR, | ||
80 | "my", | ||
81 | _("`%s' failed at %s:%d with error: %s\n"), | ||
82 | "mysql_stmt_bind_param", | ||
83 | __FILE__, __LINE__, | ||
84 | mysql_stmt_error(stmt)); | ||
85 | GNUNET_MYSQL_statements_invalidate(mc); | ||
86 | return GNUNET_SYSERR; | 71 | return GNUNET_SYSERR; |
87 | } | 72 | } |
73 | off += p->num_params; | ||
74 | } | ||
75 | stmt = GNUNET_MYSQL_statement_get_stmt (sh); | ||
76 | if (mysql_stmt_bind_param (stmt, | ||
77 | qbind)) | ||
78 | { | ||
79 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, | ||
80 | "my", | ||
81 | _ ("`%s' failed at %s:%d with error: %s\n"), | ||
82 | "mysql_stmt_bind_param", | ||
83 | __FILE__, __LINE__, | ||
84 | mysql_stmt_error (stmt)); | ||
85 | GNUNET_MYSQL_statements_invalidate (mc); | ||
86 | return GNUNET_SYSERR; | ||
87 | } | ||
88 | 88 | ||
89 | if (mysql_stmt_execute(stmt)) | 89 | if (mysql_stmt_execute (stmt)) |
90 | { | 90 | { |
91 | GNUNET_log_from(GNUNET_ERROR_TYPE_ERROR, | 91 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, |
92 | "my", | 92 | "my", |
93 | _("`%s' failed at %s:%d with error: %s\n"), | 93 | _ ("`%s' failed at %s:%d with error: %s\n"), |
94 | "mysql_stmt_execute", __FILE__, __LINE__, | 94 | "mysql_stmt_execute", __FILE__, __LINE__, |
95 | mysql_stmt_error(stmt)); | 95 | mysql_stmt_error (stmt)); |
96 | GNUNET_MYSQL_statements_invalidate(mc); | 96 | GNUNET_MYSQL_statements_invalidate (mc); |
97 | return GNUNET_SYSERR; | 97 | return GNUNET_SYSERR; |
98 | } | 98 | } |
99 | GNUNET_MY_cleanup_query(params, | 99 | GNUNET_MY_cleanup_query (params, |
100 | qbind); | 100 | qbind); |
101 | } | 101 | } |
102 | return GNUNET_OK; | 102 | return GNUNET_OK; |
103 | } | 103 | } |
@@ -111,13 +111,13 @@ GNUNET_MY_exec_prepared(struct GNUNET_MYSQL_Context *mc, | |||
111 | * @param qbind array of parameter to clean up | 111 | * @param qbind array of parameter to clean up |
112 | */ | 112 | */ |
113 | void | 113 | void |
114 | GNUNET_MY_cleanup_query(struct GNUNET_MY_QueryParam *qp, | 114 | GNUNET_MY_cleanup_query (struct GNUNET_MY_QueryParam *qp, |
115 | MYSQL_BIND *qbind) | 115 | MYSQL_BIND *qbind) |
116 | { | 116 | { |
117 | for (unsigned int i = 0; NULL != qp[i].conv; i++) | 117 | for (unsigned int i = 0; NULL != qp[i].conv; i++) |
118 | if (NULL != qp[i].cleaner) | 118 | if (NULL != qp[i].cleaner) |
119 | qp[i].cleaner(qp[i].conv_cls, | 119 | qp[i].cleaner (qp[i].conv_cls, |
120 | &qbind[i]); | 120 | &qbind[i]); |
121 | } | 121 | } |
122 | 122 | ||
123 | 123 | ||
@@ -133,115 +133,115 @@ GNUNET_MY_cleanup_query(struct GNUNET_MY_QueryParam *qp, | |||
133 | * #GNUNET_SYSERR if a result was invalid | 133 | * #GNUNET_SYSERR if a result was invalid |
134 | */ | 134 | */ |
135 | int | 135 | int |
136 | GNUNET_MY_extract_result(struct GNUNET_MYSQL_StatementHandle *sh, | 136 | GNUNET_MY_extract_result (struct GNUNET_MYSQL_StatementHandle *sh, |
137 | struct GNUNET_MY_ResultSpec *rs) | 137 | struct GNUNET_MY_ResultSpec *rs) |
138 | { | 138 | { |
139 | unsigned int num_fields; | 139 | unsigned int num_fields; |
140 | int ret; | 140 | int ret; |
141 | MYSQL_STMT *stmt; | 141 | MYSQL_STMT *stmt; |
142 | 142 | ||
143 | stmt = GNUNET_MYSQL_statement_get_stmt(sh); | 143 | stmt = GNUNET_MYSQL_statement_get_stmt (sh); |
144 | if (NULL == stmt) | 144 | if (NULL == stmt) |
145 | { | 145 | { |
146 | GNUNET_break(0); | 146 | GNUNET_break (0); |
147 | return GNUNET_SYSERR; | 147 | return GNUNET_SYSERR; |
148 | } | 148 | } |
149 | if (NULL == rs) | 149 | if (NULL == rs) |
150 | { | 150 | { |
151 | mysql_stmt_free_result(stmt); | 151 | mysql_stmt_free_result (stmt); |
152 | return GNUNET_NO; | 152 | return GNUNET_NO; |
153 | } | 153 | } |
154 | 154 | ||
155 | num_fields = 0; | 155 | num_fields = 0; |
156 | for (unsigned int i = 0; NULL != rs[i].pre_conv; i++) | 156 | for (unsigned int i = 0; NULL != rs[i].pre_conv; i++) |
157 | num_fields += rs[i].num_fields; | 157 | num_fields += rs[i].num_fields; |
158 | 158 | ||
159 | if (mysql_stmt_field_count(stmt) != num_fields) | 159 | if (mysql_stmt_field_count (stmt) != num_fields) |
160 | { | 160 | { |
161 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 161 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
162 | "Number of fields mismatch between SQL result and result specification\n"); | 162 | "Number of fields mismatch between SQL result and result specification\n"); |
163 | return GNUNET_SYSERR; | 163 | return GNUNET_SYSERR; |
164 | } | 164 | } |
165 | 165 | ||
166 | { | 166 | { |
167 | MYSQL_BIND result[num_fields]; | 167 | MYSQL_BIND result[num_fields]; |
168 | unsigned int field_off; | 168 | unsigned int field_off; |
169 | 169 | ||
170 | memset(result, 0, sizeof(MYSQL_BIND) * num_fields); | 170 | memset (result, 0, sizeof(MYSQL_BIND) * num_fields); |
171 | field_off = 0; | 171 | field_off = 0; |
172 | for (unsigned int i = 0; NULL != rs[i].pre_conv; i++) | 172 | for (unsigned int i = 0; NULL != rs[i].pre_conv; i++) |
173 | { | 173 | { |
174 | struct GNUNET_MY_ResultSpec *rp = &rs[i]; | 174 | struct GNUNET_MY_ResultSpec *rp = &rs[i]; |
175 | |||
176 | if (GNUNET_OK != | ||
177 | rp->pre_conv(rp->conv_cls, | ||
178 | rp, | ||
179 | stmt, | ||
180 | field_off, | ||
181 | &result[field_off])) | ||
182 | 175 | ||
183 | { | 176 | if (GNUNET_OK != |
184 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 177 | rp->pre_conv (rp->conv_cls, |
185 | "Pre-conversion for MySQL result failed at offset %u\n", | 178 | rp, |
186 | i); | 179 | stmt, |
187 | return GNUNET_SYSERR; | 180 | field_off, |
188 | } | 181 | &result[field_off])) |
189 | field_off += rp->num_fields; | ||
190 | } | ||
191 | 182 | ||
192 | if (mysql_stmt_bind_result(stmt, result)) | ||
193 | { | 183 | { |
194 | GNUNET_log_from(GNUNET_ERROR_TYPE_ERROR, | 184 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
195 | "my", | 185 | "Pre-conversion for MySQL result failed at offset %u\n", |
196 | _("%s failed at %s:%d with error: %s\n"), | 186 | i); |
197 | "mysql_stmt_bind_result", | ||
198 | __FILE__, __LINE__, | ||
199 | mysql_stmt_error(stmt)); | ||
200 | return GNUNET_SYSERR; | 187 | return GNUNET_SYSERR; |
201 | } | 188 | } |
189 | field_off += rp->num_fields; | ||
190 | } | ||
191 | |||
192 | if (mysql_stmt_bind_result (stmt, result)) | ||
193 | { | ||
194 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, | ||
195 | "my", | ||
196 | _ ("%s failed at %s:%d with error: %s\n"), | ||
197 | "mysql_stmt_bind_result", | ||
198 | __FILE__, __LINE__, | ||
199 | mysql_stmt_error (stmt)); | ||
200 | return GNUNET_SYSERR; | ||
201 | } | ||
202 | #if TEST_OPTIMIZATION | 202 | #if TEST_OPTIMIZATION |
203 | (void)mysql_stmt_store_result(stmt); | 203 | (void) mysql_stmt_store_result (stmt); |
204 | #endif | 204 | #endif |
205 | ret = mysql_stmt_fetch(stmt); | 205 | ret = mysql_stmt_fetch (stmt); |
206 | if (MYSQL_NO_DATA == ret) | 206 | if (MYSQL_NO_DATA == ret) |
207 | { | 207 | { |
208 | mysql_stmt_free_result(stmt); | 208 | mysql_stmt_free_result (stmt); |
209 | return GNUNET_NO; | 209 | return GNUNET_NO; |
210 | } | 210 | } |
211 | if (1 == ret) | 211 | if (1 == ret) |
212 | { | 212 | { |
213 | GNUNET_log_from(GNUNET_ERROR_TYPE_ERROR, | 213 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, |
214 | "my", | 214 | "my", |
215 | _("%s failed at %s:%d with error: %s\n"), | 215 | _ ("%s failed at %s:%d with error: %s\n"), |
216 | "mysql_stmt_fetch", | 216 | "mysql_stmt_fetch", |
217 | __FILE__, __LINE__, | 217 | __FILE__, __LINE__, |
218 | mysql_stmt_error(stmt)); | 218 | mysql_stmt_error (stmt)); |
219 | GNUNET_MY_cleanup_result(rs); | 219 | GNUNET_MY_cleanup_result (rs); |
220 | mysql_stmt_free_result(stmt); | 220 | mysql_stmt_free_result (stmt); |
221 | return GNUNET_SYSERR; | 221 | return GNUNET_SYSERR; |
222 | } | 222 | } |
223 | field_off = 0; | 223 | field_off = 0; |
224 | for (unsigned int i = 0; NULL != rs[i].post_conv; i++) | 224 | for (unsigned int i = 0; NULL != rs[i].post_conv; i++) |
225 | { | 225 | { |
226 | struct GNUNET_MY_ResultSpec *rp = &rs[i]; | 226 | struct GNUNET_MY_ResultSpec *rp = &rs[i]; |
227 | 227 | ||
228 | if (NULL != rp->post_conv) | 228 | if (NULL != rp->post_conv) |
229 | if (GNUNET_OK != | 229 | if (GNUNET_OK != |
230 | rp->post_conv(rp->conv_cls, | 230 | rp->post_conv (rp->conv_cls, |
231 | rp, | 231 | rp, |
232 | stmt, | 232 | stmt, |
233 | field_off, | 233 | field_off, |
234 | &result[field_off])) | 234 | &result[field_off])) |
235 | { | 235 | { |
236 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 236 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
237 | "Post-conversion for MySQL result failed at offset %u\n", | 237 | "Post-conversion for MySQL result failed at offset %u\n", |
238 | i); | 238 | i); |
239 | mysql_stmt_free_result(stmt); | 239 | mysql_stmt_free_result (stmt); |
240 | GNUNET_MY_cleanup_result(rs); | 240 | GNUNET_MY_cleanup_result (rs); |
241 | return GNUNET_SYSERR; | 241 | return GNUNET_SYSERR; |
242 | } | 242 | } |
243 | field_off += rp->num_fields; | 243 | field_off += rp->num_fields; |
244 | } | 244 | } |
245 | } | 245 | } |
246 | return GNUNET_OK; | 246 | return GNUNET_OK; |
247 | } | 247 | } |
@@ -254,12 +254,12 @@ GNUNET_MY_extract_result(struct GNUNET_MYSQL_StatementHandle *sh, | |||
254 | * @param rs result specification to clean up | 254 | * @param rs result specification to clean up |
255 | */ | 255 | */ |
256 | void | 256 | void |
257 | GNUNET_MY_cleanup_result(struct GNUNET_MY_ResultSpec *rs) | 257 | GNUNET_MY_cleanup_result (struct GNUNET_MY_ResultSpec *rs) |
258 | { | 258 | { |
259 | for (unsigned int i = 0; NULL != rs[i].post_conv; i++) | 259 | for (unsigned int i = 0; NULL != rs[i].post_conv; i++) |
260 | if (NULL != rs[i].cleaner) | 260 | if (NULL != rs[i].cleaner) |
261 | rs[i].cleaner(rs[i].conv_cls, | 261 | rs[i].cleaner (rs[i].conv_cls, |
262 | &rs[i]); | 262 | &rs[i]); |
263 | } | 263 | } |
264 | 264 | ||
265 | 265 | ||
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 | ||
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 | }; |
diff --git a/src/my/test_my.c b/src/my/test_my.c index d9dcc71f9..c639fcfdd 100644 --- a/src/my/test_my.c +++ b/src/my/test_my.c | |||
@@ -36,17 +36,18 @@ | |||
36 | * @return 0 on succes | 36 | * @return 0 on succes |
37 | */ | 37 | */ |
38 | static int | 38 | static int |
39 | run_queries(struct GNUNET_MYSQL_Context *context) | 39 | run_queries (struct GNUNET_MYSQL_Context *context) |
40 | { | 40 | { |
41 | struct GNUNET_CRYPTO_RsaPublicKey *pub = NULL; | 41 | struct GNUNET_CRYPTO_RsaPublicKey *pub = NULL; |
42 | struct GNUNET_CRYPTO_RsaPublicKey *pub2 = NULL; | 42 | struct GNUNET_CRYPTO_RsaPublicKey *pub2 = NULL; |
43 | struct GNUNET_CRYPTO_RsaSignature *sig = NULL;; | 43 | struct GNUNET_CRYPTO_RsaSignature *sig = NULL;; |
44 | struct GNUNET_CRYPTO_RsaSignature *sig2 = NULL; | 44 | struct GNUNET_CRYPTO_RsaSignature *sig2 = NULL; |
45 | struct GNUNET_TIME_Absolute abs_time = GNUNET_TIME_absolute_get(); | 45 | struct GNUNET_TIME_Absolute abs_time = GNUNET_TIME_absolute_get (); |
46 | struct GNUNET_TIME_Absolute abs_time2; | 46 | struct GNUNET_TIME_Absolute abs_time2; |
47 | struct GNUNET_TIME_Absolute forever = GNUNET_TIME_UNIT_FOREVER_ABS; | 47 | struct GNUNET_TIME_Absolute forever = GNUNET_TIME_UNIT_FOREVER_ABS; |
48 | struct GNUNET_TIME_Absolute forever2; | 48 | struct GNUNET_TIME_Absolute forever2; |
49 | const struct GNUNET_TIME_AbsoluteNBO abs_time_nbo = GNUNET_TIME_absolute_hton(abs_time); | 49 | const struct GNUNET_TIME_AbsoluteNBO abs_time_nbo = |
50 | GNUNET_TIME_absolute_hton (abs_time); | ||
50 | struct GNUNET_HashCode hc; | 51 | struct GNUNET_HashCode hc; |
51 | struct GNUNET_HashCode hc2; | 52 | struct GNUNET_HashCode hc2; |
52 | const char msg[] = "hello"; | 53 | const char msg[] = "hello"; |
@@ -71,163 +72,163 @@ run_queries(struct GNUNET_MYSQL_Context *context) | |||
71 | struct GNUNET_CRYPTO_RsaPrivateKey *priv = NULL; | 72 | struct GNUNET_CRYPTO_RsaPrivateKey *priv = NULL; |
72 | struct GNUNET_HashCode hmsg; | 73 | struct GNUNET_HashCode hmsg; |
73 | 74 | ||
74 | priv = GNUNET_CRYPTO_rsa_private_key_create(1024); | 75 | priv = GNUNET_CRYPTO_rsa_private_key_create (1024); |
75 | pub = GNUNET_CRYPTO_rsa_private_key_get_public(priv); | 76 | pub = GNUNET_CRYPTO_rsa_private_key_get_public (priv); |
76 | memset(&hmsg, 42, sizeof(hmsg)); | 77 | memset (&hmsg, 42, sizeof(hmsg)); |
77 | sig = GNUNET_CRYPTO_rsa_sign_fdh(priv, | 78 | sig = GNUNET_CRYPTO_rsa_sign_fdh (priv, |
78 | &hmsg); | 79 | &hmsg); |
79 | u16 = 16; | 80 | u16 = 16; |
80 | u32 = 32; | 81 | u32 = 32; |
81 | u64 = UINT64_MAX; | 82 | u64 = UINT64_MAX; |
82 | 83 | ||
83 | memset(&hc, 0, sizeof(hc)); | 84 | memset (&hc, 0, sizeof(hc)); |
84 | memset(&hc2, 0, sizeof(hc2)); | 85 | memset (&hc2, 0, sizeof(hc2)); |
85 | 86 | ||
86 | statements_handle_insert | 87 | statements_handle_insert |
87 | = GNUNET_MYSQL_statement_prepare(context, | 88 | = GNUNET_MYSQL_statement_prepare (context, |
88 | "INSERT INTO test_my2 (" | 89 | "INSERT INTO test_my2 (" |
89 | " pub" | 90 | " pub" |
90 | ",sig" | 91 | ",sig" |
91 | ",abs_time" | 92 | ",abs_time" |
92 | ",forever" | 93 | ",forever" |
93 | ",abs_time_nbo" | 94 | ",abs_time_nbo" |
94 | ",hash" | 95 | ",hash" |
95 | ",vsize" | 96 | ",vsize" |
96 | ",str" | 97 | ",str" |
97 | ",u16" | 98 | ",u16" |
98 | ",u32" | 99 | ",u32" |
99 | ",u64" | 100 | ",u64" |
100 | ") VALUES " | 101 | ") VALUES " |
101 | "( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); | 102 | "( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); |
102 | 103 | ||
103 | if (NULL == statements_handle_insert) | 104 | if (NULL == statements_handle_insert) |
104 | { | 105 | { |
105 | fprintf(stderr, "Failed to prepared statement INSERT\n"); | 106 | fprintf (stderr, "Failed to prepared statement INSERT\n"); |
106 | GNUNET_CRYPTO_rsa_signature_free(sig); | 107 | GNUNET_CRYPTO_rsa_signature_free (sig); |
107 | GNUNET_CRYPTO_rsa_private_key_free(priv); | 108 | GNUNET_CRYPTO_rsa_private_key_free (priv); |
108 | GNUNET_CRYPTO_rsa_public_key_free(pub); | 109 | GNUNET_CRYPTO_rsa_public_key_free (pub); |
109 | return 1; | 110 | return 1; |
110 | } | 111 | } |
111 | 112 | ||
112 | struct GNUNET_MY_QueryParam params_insert[] = { | 113 | struct GNUNET_MY_QueryParam params_insert[] = { |
113 | GNUNET_MY_query_param_rsa_public_key(pub), | 114 | GNUNET_MY_query_param_rsa_public_key (pub), |
114 | GNUNET_MY_query_param_rsa_signature(sig), | 115 | GNUNET_MY_query_param_rsa_signature (sig), |
115 | GNUNET_MY_query_param_absolute_time(&abs_time), | 116 | GNUNET_MY_query_param_absolute_time (&abs_time), |
116 | GNUNET_MY_query_param_absolute_time(&forever), | 117 | GNUNET_MY_query_param_absolute_time (&forever), |
117 | GNUNET_MY_query_param_absolute_time_nbo(&abs_time_nbo), | 118 | GNUNET_MY_query_param_absolute_time_nbo (&abs_time_nbo), |
118 | GNUNET_MY_query_param_auto_from_type(&hc), | 119 | GNUNET_MY_query_param_auto_from_type (&hc), |
119 | GNUNET_MY_query_param_fixed_size(msg, strlen(msg)), | 120 | GNUNET_MY_query_param_fixed_size (msg, strlen (msg)), |
120 | GNUNET_MY_query_param_string(msg3), | 121 | GNUNET_MY_query_param_string (msg3), |
121 | GNUNET_MY_query_param_uint16(&u16), | 122 | GNUNET_MY_query_param_uint16 (&u16), |
122 | GNUNET_MY_query_param_uint32(&u32), | 123 | GNUNET_MY_query_param_uint32 (&u32), |
123 | GNUNET_MY_query_param_uint64(&u64), | 124 | GNUNET_MY_query_param_uint64 (&u64), |
124 | GNUNET_MY_query_param_end | 125 | GNUNET_MY_query_param_end |
125 | }; | 126 | }; |
126 | 127 | ||
127 | if (GNUNET_OK != GNUNET_MY_exec_prepared(context, | 128 | if (GNUNET_OK != GNUNET_MY_exec_prepared (context, |
128 | statements_handle_insert, | 129 | statements_handle_insert, |
129 | params_insert)) | 130 | params_insert)) |
130 | { | 131 | { |
131 | fprintf(stderr, "Failed to execute prepared statement INSERT\n"); | 132 | fprintf (stderr, "Failed to execute prepared statement INSERT\n"); |
132 | GNUNET_CRYPTO_rsa_signature_free(sig); | 133 | GNUNET_CRYPTO_rsa_signature_free (sig); |
133 | GNUNET_CRYPTO_rsa_private_key_free(priv); | 134 | GNUNET_CRYPTO_rsa_private_key_free (priv); |
134 | GNUNET_CRYPTO_rsa_public_key_free(pub); | 135 | GNUNET_CRYPTO_rsa_public_key_free (pub); |
135 | return 1; | 136 | return 1; |
136 | } | 137 | } |
137 | 138 | ||
138 | statements_handle_select | 139 | statements_handle_select |
139 | = GNUNET_MYSQL_statement_prepare(context, | 140 | = GNUNET_MYSQL_statement_prepare (context, |
140 | "SELECT" | 141 | "SELECT" |
141 | " pub" | 142 | " pub" |
142 | ",sig" | 143 | ",sig" |
143 | ",abs_time" | 144 | ",abs_time" |
144 | ",forever" | 145 | ",forever" |
145 | ",hash" | 146 | ",hash" |
146 | ",vsize" | 147 | ",vsize" |
147 | ",str" | 148 | ",str" |
148 | ",u16" | 149 | ",u16" |
149 | ",u32" | 150 | ",u32" |
150 | ",u64" | 151 | ",u64" |
151 | " FROM test_my2"); | 152 | " FROM test_my2"); |
152 | 153 | ||
153 | if (NULL == statements_handle_select) | 154 | if (NULL == statements_handle_select) |
154 | { | 155 | { |
155 | fprintf(stderr, "Failed to prepared statement SELECT\n"); | 156 | fprintf (stderr, "Failed to prepared statement SELECT\n"); |
156 | GNUNET_CRYPTO_rsa_signature_free(sig); | 157 | GNUNET_CRYPTO_rsa_signature_free (sig); |
157 | GNUNET_CRYPTO_rsa_private_key_free(priv); | 158 | GNUNET_CRYPTO_rsa_private_key_free (priv); |
158 | GNUNET_CRYPTO_rsa_public_key_free(pub); | 159 | GNUNET_CRYPTO_rsa_public_key_free (pub); |
159 | return 1; | 160 | return 1; |
160 | } | 161 | } |
161 | 162 | ||
162 | struct GNUNET_MY_QueryParam params_select[] = { | 163 | struct GNUNET_MY_QueryParam params_select[] = { |
163 | GNUNET_MY_query_param_end | 164 | GNUNET_MY_query_param_end |
164 | }; | 165 | }; |
165 | 166 | ||
166 | if (GNUNET_OK != GNUNET_MY_exec_prepared(context, | 167 | if (GNUNET_OK != GNUNET_MY_exec_prepared (context, |
167 | statements_handle_select, | 168 | statements_handle_select, |
168 | params_select)) | 169 | params_select)) |
169 | { | 170 | { |
170 | fprintf(stderr, "Failed to execute prepared statement SELECT\n"); | 171 | fprintf (stderr, "Failed to execute prepared statement SELECT\n"); |
171 | GNUNET_CRYPTO_rsa_signature_free(sig); | 172 | GNUNET_CRYPTO_rsa_signature_free (sig); |
172 | GNUNET_CRYPTO_rsa_private_key_free(priv); | 173 | GNUNET_CRYPTO_rsa_private_key_free (priv); |
173 | GNUNET_CRYPTO_rsa_public_key_free(pub); | 174 | GNUNET_CRYPTO_rsa_public_key_free (pub); |
174 | return 1; | 175 | return 1; |
175 | } | 176 | } |
176 | 177 | ||
177 | struct GNUNET_MY_ResultSpec results_select[] = { | 178 | struct GNUNET_MY_ResultSpec results_select[] = { |
178 | GNUNET_MY_result_spec_rsa_public_key(&pub2), | 179 | GNUNET_MY_result_spec_rsa_public_key (&pub2), |
179 | GNUNET_MY_result_spec_rsa_signature(&sig2), | 180 | GNUNET_MY_result_spec_rsa_signature (&sig2), |
180 | GNUNET_MY_result_spec_absolute_time(&abs_time2), | 181 | GNUNET_MY_result_spec_absolute_time (&abs_time2), |
181 | GNUNET_MY_result_spec_absolute_time(&forever2), | 182 | GNUNET_MY_result_spec_absolute_time (&forever2), |
182 | GNUNET_MY_result_spec_auto_from_type(&hc2), | 183 | GNUNET_MY_result_spec_auto_from_type (&hc2), |
183 | GNUNET_MY_result_spec_variable_size(&msg2, &msg2_len), | 184 | GNUNET_MY_result_spec_variable_size (&msg2, &msg2_len), |
184 | GNUNET_MY_result_spec_string(&msg4), | 185 | GNUNET_MY_result_spec_string (&msg4), |
185 | GNUNET_MY_result_spec_uint16(&u162), | 186 | GNUNET_MY_result_spec_uint16 (&u162), |
186 | GNUNET_MY_result_spec_uint32(&u322), | 187 | GNUNET_MY_result_spec_uint32 (&u322), |
187 | GNUNET_MY_result_spec_uint64(&u642), | 188 | GNUNET_MY_result_spec_uint64 (&u642), |
188 | GNUNET_MY_result_spec_end | 189 | GNUNET_MY_result_spec_end |
189 | }; | 190 | }; |
190 | 191 | ||
191 | ret = GNUNET_MY_extract_result(statements_handle_select, | 192 | ret = GNUNET_MY_extract_result (statements_handle_select, |
192 | results_select); | 193 | results_select); |
193 | 194 | ||
194 | GNUNET_assert(GNUNET_YES == ret); | 195 | GNUNET_assert (GNUNET_YES == ret); |
195 | GNUNET_break(abs_time.abs_value_us == abs_time2.abs_value_us); | 196 | GNUNET_break (abs_time.abs_value_us == abs_time2.abs_value_us); |
196 | GNUNET_break(forever.abs_value_us == forever2.abs_value_us); | 197 | GNUNET_break (forever.abs_value_us == forever2.abs_value_us); |
197 | GNUNET_break(0 == | 198 | GNUNET_break (0 == |
198 | memcmp(&hc, | 199 | memcmp (&hc, |
199 | &hc2, | 200 | &hc2, |
200 | sizeof(struct GNUNET_HashCode))); | 201 | sizeof(struct GNUNET_HashCode))); |
201 | 202 | ||
202 | GNUNET_assert(NULL != sig2); | 203 | GNUNET_assert (NULL != sig2); |
203 | GNUNET_assert(NULL != pub2); | 204 | GNUNET_assert (NULL != pub2); |
204 | GNUNET_break(0 == | 205 | GNUNET_break (0 == |
205 | GNUNET_CRYPTO_rsa_signature_cmp(sig, | 206 | GNUNET_CRYPTO_rsa_signature_cmp (sig, |
206 | sig2)); | 207 | sig2)); |
207 | GNUNET_break(0 == | 208 | GNUNET_break (0 == |
208 | GNUNET_CRYPTO_rsa_public_key_cmp(pub, | 209 | GNUNET_CRYPTO_rsa_public_key_cmp (pub, |
209 | pub2)); | 210 | pub2)); |
210 | 211 | ||
211 | GNUNET_break(strlen(msg) == msg2_len); | 212 | GNUNET_break (strlen (msg) == msg2_len); |
212 | GNUNET_break(0 == | 213 | GNUNET_break (0 == |
213 | strncmp(msg, | 214 | strncmp (msg, |
214 | msg2, | 215 | msg2, |
215 | msg2_len)); | 216 | msg2_len)); |
216 | 217 | ||
217 | GNUNET_break(strlen(msg3) == strlen(msg4)); | 218 | GNUNET_break (strlen (msg3) == strlen (msg4)); |
218 | GNUNET_break(0 == | 219 | GNUNET_break (0 == |
219 | strcmp(msg3, | 220 | strcmp (msg3, |
220 | msg4)); | 221 | msg4)); |
221 | 222 | ||
222 | GNUNET_break(16 == u162); | 223 | GNUNET_break (16 == u162); |
223 | GNUNET_break(32 == u322); | 224 | GNUNET_break (32 == u322); |
224 | GNUNET_break(UINT64_MAX == u642); | 225 | GNUNET_break (UINT64_MAX == u642); |
225 | 226 | ||
226 | GNUNET_MY_cleanup_result(results_select); | 227 | GNUNET_MY_cleanup_result (results_select); |
227 | 228 | ||
228 | GNUNET_CRYPTO_rsa_signature_free(sig); | 229 | GNUNET_CRYPTO_rsa_signature_free (sig); |
229 | GNUNET_CRYPTO_rsa_private_key_free(priv); | 230 | GNUNET_CRYPTO_rsa_private_key_free (priv); |
230 | GNUNET_CRYPTO_rsa_public_key_free(pub); | 231 | GNUNET_CRYPTO_rsa_public_key_free (pub); |
231 | 232 | ||
232 | if (GNUNET_OK != ret) | 233 | if (GNUNET_OK != ret) |
233 | return 1; | 234 | return 1; |
@@ -237,63 +238,63 @@ run_queries(struct GNUNET_MYSQL_Context *context) | |||
237 | 238 | ||
238 | 239 | ||
239 | int | 240 | int |
240 | main(int argc, const char *const argv[]) | 241 | main (int argc, const char *const argv[]) |
241 | { | 242 | { |
242 | struct GNUNET_CONFIGURATION_Handle *config; | 243 | struct GNUNET_CONFIGURATION_Handle *config; |
243 | struct GNUNET_MYSQL_Context *context; | 244 | struct GNUNET_MYSQL_Context *context; |
244 | int ret; | 245 | int ret; |
245 | 246 | ||
246 | GNUNET_log_setup("test-my", | 247 | GNUNET_log_setup ("test-my", |
247 | "WARNING", | 248 | "WARNING", |
248 | NULL); | 249 | NULL); |
249 | 250 | ||
250 | config = GNUNET_CONFIGURATION_create(); | 251 | config = GNUNET_CONFIGURATION_create (); |
251 | if (GNUNET_OK != | 252 | if (GNUNET_OK != |
252 | GNUNET_CONFIGURATION_parse(config, "test_my.conf")) | 253 | GNUNET_CONFIGURATION_parse (config, "test_my.conf")) |
253 | { | 254 | { |
254 | fprintf(stderr, "Failed to parse configuaration\n"); | 255 | fprintf (stderr, "Failed to parse configuaration\n"); |
255 | return 1; | 256 | return 1; |
256 | } | 257 | } |
257 | 258 | ||
258 | context = GNUNET_MYSQL_context_create(config, | 259 | context = GNUNET_MYSQL_context_create (config, |
259 | "datastore-mysql"); | 260 | "datastore-mysql"); |
260 | if (NULL == context) | 261 | if (NULL == context) |
261 | { | 262 | { |
262 | fprintf(stderr, "Failed to connect to database\n"); | 263 | fprintf (stderr, "Failed to connect to database\n"); |
263 | return 77; | 264 | return 77; |
264 | } | 265 | } |
265 | 266 | ||
266 | (void)GNUNET_MYSQL_statement_run(context, | 267 | (void) GNUNET_MYSQL_statement_run (context, |
267 | "DROP TABLE test_my2;"); | 268 | "DROP TABLE test_my2;"); |
268 | 269 | ||
269 | if (GNUNET_OK != | 270 | if (GNUNET_OK != |
270 | GNUNET_MYSQL_statement_run(context, | 271 | GNUNET_MYSQL_statement_run (context, |
271 | "CREATE TABLE IF NOT EXISTS test_my2(" | 272 | "CREATE TABLE IF NOT EXISTS test_my2(" |
272 | " pub BLOB NOT NULL" | 273 | " pub BLOB NOT NULL" |
273 | ",sig BLOB NOT NULL" | 274 | ",sig BLOB NOT NULL" |
274 | ",abs_time BIGINT NOT NULL" | 275 | ",abs_time BIGINT NOT NULL" |
275 | ",forever BIGINT NOT NULL" | 276 | ",forever BIGINT NOT NULL" |
276 | ",abs_time_nbo BIGINT NOT NULL" | 277 | ",abs_time_nbo BIGINT NOT NULL" |
277 | ",hash BLOB NOT NULL CHECK(LENGTH(hash)=64)" | 278 | ",hash BLOB NOT NULL CHECK(LENGTH(hash)=64)" |
278 | ",vsize BLOB NOT NULL" | 279 | ",vsize BLOB NOT NULL" |
279 | ",str BLOB NOT NULL" | 280 | ",str BLOB NOT NULL" |
280 | ",u16 SMALLINT NOT NULL" | 281 | ",u16 SMALLINT NOT NULL" |
281 | ",u32 INT NOT NULL" | 282 | ",u32 INT NOT NULL" |
282 | ",u64 BIGINT NOT NULL" | 283 | ",u64 BIGINT NOT NULL" |
283 | ")")) | 284 | ")")) |
284 | { | 285 | { |
285 | fprintf(stderr, | 286 | fprintf (stderr, |
286 | "Failed to create table. Database likely not setup correctly.\n"); | 287 | "Failed to create table. Database likely not setup correctly.\n"); |
287 | GNUNET_MYSQL_statements_invalidate(context); | 288 | GNUNET_MYSQL_statements_invalidate (context); |
288 | GNUNET_MYSQL_context_destroy(context); | 289 | GNUNET_MYSQL_context_destroy (context); |
289 | 290 | ||
290 | return 77; | 291 | return 77; |
291 | } | 292 | } |
292 | 293 | ||
293 | ret = run_queries(context); | 294 | ret = run_queries (context); |
294 | 295 | ||
295 | GNUNET_MYSQL_context_destroy(context); | 296 | GNUNET_MYSQL_context_destroy (context); |
296 | GNUNET_free(config); | 297 | GNUNET_free (config); |
297 | 298 | ||
298 | return ret; | 299 | return ret; |
299 | } | 300 | } |