diff options
author | Nils Gillmann <ng0@n0.is> | 2018-06-13 08:05:15 +0000 |
---|---|---|
committer | Nils Gillmann <ng0@n0.is> | 2018-06-13 08:05:15 +0000 |
commit | 5c7f4f919d2569f49e4223d77000452dd2ec4e97 (patch) | |
tree | 8cec76a5dda6b034d1e5b85eee76a43fafd8a4a5 /src/my | |
parent | 1f7a2dd68d1e6260fad4af042878c0a07d39bc12 (diff) | |
parent | 8503c6fa26449228fa691c1dedfe3ca1a8d0b9ba (diff) | |
download | gnunet-5c7f4f919d2569f49e4223d77000452dd2ec4e97.tar.gz gnunet-5c7f4f919d2569f49e4223d77000452dd2ec4e97.zip |
Merge branch 'master' of gnunet.org:gnunet
Signed-off-by: Nils Gillmann <ng0@n0.is>
Diffstat (limited to 'src/my')
-rw-r--r-- | src/my/Makefile.am | 3 | ||||
-rw-r--r-- | src/my/my.c | 44 | ||||
-rw-r--r-- | src/my/my_query_helper.c | 40 | ||||
-rw-r--r-- | src/my/my_result_helper.c | 22 | ||||
-rw-r--r-- | src/my/test_my.c | 18 |
5 files changed, 63 insertions, 64 deletions
diff --git a/src/my/Makefile.am b/src/my/Makefile.am index 959085c5f..cead9a8b4 100644 --- a/src/my/Makefile.am +++ b/src/my/Makefile.am | |||
@@ -30,6 +30,9 @@ TESTS = \ | |||
30 | test_my | 30 | test_my |
31 | endif | 31 | endif |
32 | 32 | ||
33 | EXTRA_DIST = \ | ||
34 | test_my.conf | ||
35 | |||
33 | check_PROGRAMS= \ | 36 | check_PROGRAMS= \ |
34 | test_my | 37 | test_my |
35 | 38 | ||
diff --git a/src/my/my.c b/src/my/my.c index 459f09b6a..2f4cd3ba3 100644 --- a/src/my/my.c +++ b/src/my/my.c | |||
@@ -1,21 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet | 2 | This file is part of GNUnet |
3 | Copyright (C) 2016 Inria & GNUnet e.V. | 3 | Copyright (C) 2016, 2018 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | it under the terms of the GNU General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
7 | by the Free Software Foundation; either version 3, or (at your | 7 | by the Free Software Foundation, either version 3 of the License, |
8 | option) any later version. | 8 | or (at your option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with GNUnet; see the file COPYING. If not, write to the | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301, USA. | ||
19 | */ | 17 | */ |
20 | /** | 18 | /** |
21 | * @file my/my.c | 19 | * @file my/my.c |
@@ -45,19 +43,20 @@ GNUNET_MY_exec_prepared (struct GNUNET_MYSQL_Context *mc, | |||
45 | { | 43 | { |
46 | const struct GNUNET_MY_QueryParam *p; | 44 | const struct GNUNET_MY_QueryParam *p; |
47 | unsigned int num; | 45 | unsigned int num; |
48 | unsigned int i; | ||
49 | MYSQL_STMT *stmt; | 46 | MYSQL_STMT *stmt; |
50 | 47 | ||
51 | num = 0; | 48 | num = 0; |
52 | for (i=0;NULL != params[i].conv;i++) | 49 | for (unsigned int i=0;NULL != params[i].conv;i++) |
53 | num += params[i].num_params; | 50 | num += params[i].num_params; |
54 | { | 51 | { |
55 | MYSQL_BIND qbind[num]; | 52 | MYSQL_BIND qbind[num]; |
56 | unsigned int off; | 53 | unsigned int off; |
57 | 54 | ||
58 | memset (qbind, 0, sizeof(qbind)); | 55 | memset (qbind, |
56 | 0, | ||
57 | sizeof(qbind)); | ||
59 | off = 0; | 58 | off = 0; |
60 | for (i=0;NULL != (p = ¶ms[i])->conv;i++) | 59 | for (unsigned int i=0;NULL != (p = ¶ms[i])->conv;i++) |
61 | { | 60 | { |
62 | if (GNUNET_OK != | 61 | if (GNUNET_OK != |
63 | p->conv (p->conv_cls, | 62 | p->conv (p->conv_cls, |
@@ -113,9 +112,7 @@ void | |||
113 | GNUNET_MY_cleanup_query (struct GNUNET_MY_QueryParam *qp, | 112 | GNUNET_MY_cleanup_query (struct GNUNET_MY_QueryParam *qp, |
114 | MYSQL_BIND *qbind) | 113 | MYSQL_BIND *qbind) |
115 | { | 114 | { |
116 | unsigned int i; | 115 | for (unsigned int i=0; NULL != qp[i].conv ;i++) |
117 | |||
118 | for (i=0; NULL != qp[i].conv ;i++) | ||
119 | if (NULL != qp[i].cleaner) | 116 | if (NULL != qp[i].cleaner) |
120 | qp[i].cleaner (qp[i].conv_cls, | 117 | qp[i].cleaner (qp[i].conv_cls, |
121 | &qbind[i]); | 118 | &qbind[i]); |
@@ -138,7 +135,6 @@ GNUNET_MY_extract_result (struct GNUNET_MYSQL_StatementHandle *sh, | |||
138 | struct GNUNET_MY_ResultSpec *rs) | 135 | struct GNUNET_MY_ResultSpec *rs) |
139 | { | 136 | { |
140 | unsigned int num_fields; | 137 | unsigned int num_fields; |
141 | unsigned int i; | ||
142 | int ret; | 138 | int ret; |
143 | MYSQL_STMT *stmt; | 139 | MYSQL_STMT *stmt; |
144 | 140 | ||
@@ -155,7 +151,7 @@ GNUNET_MY_extract_result (struct GNUNET_MYSQL_StatementHandle *sh, | |||
155 | } | 151 | } |
156 | 152 | ||
157 | num_fields = 0; | 153 | num_fields = 0; |
158 | for (i=0;NULL != rs[i].pre_conv;i++) | 154 | for (unsigned int i=0;NULL != rs[i].pre_conv;i++) |
159 | num_fields += rs[i].num_fields; | 155 | num_fields += rs[i].num_fields; |
160 | 156 | ||
161 | if (mysql_stmt_field_count (stmt) != num_fields) | 157 | if (mysql_stmt_field_count (stmt) != num_fields) |
@@ -171,7 +167,7 @@ GNUNET_MY_extract_result (struct GNUNET_MYSQL_StatementHandle *sh, | |||
171 | 167 | ||
172 | memset (result, 0, sizeof (MYSQL_BIND) * num_fields); | 168 | memset (result, 0, sizeof (MYSQL_BIND) * num_fields); |
173 | field_off = 0; | 169 | field_off = 0; |
174 | for (i=0;NULL != rs[i].pre_conv;i++) | 170 | for (unsigned int i=0;NULL != rs[i].pre_conv;i++) |
175 | { | 171 | { |
176 | struct GNUNET_MY_ResultSpec *rp = &rs[i]; | 172 | struct GNUNET_MY_ResultSpec *rp = &rs[i]; |
177 | 173 | ||
@@ -223,7 +219,7 @@ GNUNET_MY_extract_result (struct GNUNET_MYSQL_StatementHandle *sh, | |||
223 | return GNUNET_SYSERR; | 219 | return GNUNET_SYSERR; |
224 | } | 220 | } |
225 | field_off = 0; | 221 | field_off = 0; |
226 | for (i=0;NULL != rs[i].post_conv;i++) | 222 | for (unsigned int i=0;NULL != rs[i].post_conv;i++) |
227 | { | 223 | { |
228 | struct GNUNET_MY_ResultSpec *rp = &rs[i]; | 224 | struct GNUNET_MY_ResultSpec *rp = &rs[i]; |
229 | 225 | ||
@@ -258,9 +254,7 @@ GNUNET_MY_extract_result (struct GNUNET_MYSQL_StatementHandle *sh, | |||
258 | void | 254 | void |
259 | GNUNET_MY_cleanup_result (struct GNUNET_MY_ResultSpec *rs) | 255 | GNUNET_MY_cleanup_result (struct GNUNET_MY_ResultSpec *rs) |
260 | { | 256 | { |
261 | unsigned int i; | 257 | for (unsigned int i=0;NULL != rs[i].post_conv;i++) |
262 | |||
263 | for (i=0;NULL != rs[i].post_conv;i++) | ||
264 | if (NULL != rs[i].cleaner) | 258 | if (NULL != rs[i].cleaner) |
265 | rs[i].cleaner (rs[i].conv_cls, | 259 | rs[i].cleaner (rs[i].conv_cls, |
266 | &rs[i]); | 260 | &rs[i]); |
diff --git a/src/my/my_query_helper.c b/src/my/my_query_helper.c index 17ade5a92..b2a893a44 100644 --- a/src/my/my_query_helper.c +++ b/src/my/my_query_helper.c | |||
@@ -2,20 +2,18 @@ | |||
2 | This file is part of GNUnet | 2 | This file is part of GNUnet |
3 | Copyright (C) 2016 GNUnet e.V. | 3 | Copyright (C) 2016 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | it under the terms of the GNU General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
7 | by the Free Software Foundation; either version 3, or (at your | 7 | by the Free Software Foundation, either version 3 of the License, |
8 | option) any later version. | 8 | or (at your option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with GNUnet; see the file COPYING. If not, write to the | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301, USA. | ||
19 | */ | 17 | */ |
20 | /** | 18 | /** |
21 | * @file my/my_query_helper.c | 19 | * @file my/my_query_helper.c |
@@ -39,6 +37,7 @@ static void | |||
39 | my_clean_query (void *cls, | 37 | my_clean_query (void *cls, |
40 | MYSQL_BIND *qbind) | 38 | MYSQL_BIND *qbind) |
41 | { | 39 | { |
40 | (void) cls; | ||
42 | GNUNET_free (qbind[0].buffer); | 41 | GNUNET_free (qbind[0].buffer); |
43 | } | 42 | } |
44 | 43 | ||
@@ -56,6 +55,7 @@ my_conv_fixed_size (void *cls, | |||
56 | const struct GNUNET_MY_QueryParam *qp, | 55 | const struct GNUNET_MY_QueryParam *qp, |
57 | MYSQL_BIND *qbind) | 56 | MYSQL_BIND *qbind) |
58 | { | 57 | { |
58 | (void) cls; | ||
59 | GNUNET_assert (1 == qp->num_params); | 59 | GNUNET_assert (1 == qp->num_params); |
60 | qbind->buffer = (void *) qp->data; | 60 | qbind->buffer = (void *) qp->data; |
61 | qbind->buffer_length = qp->data_len; | 61 | qbind->buffer_length = qp->data_len; |
@@ -101,12 +101,11 @@ my_conv_string (void *cls, | |||
101 | const struct GNUNET_MY_QueryParam *qp, | 101 | const struct GNUNET_MY_QueryParam *qp, |
102 | MYSQL_BIND *qbind) | 102 | MYSQL_BIND *qbind) |
103 | { | 103 | { |
104 | (void) cls; | ||
104 | GNUNET_assert (1 == qp->num_params); | 105 | GNUNET_assert (1 == qp->num_params); |
105 | |||
106 | qbind->buffer = (void *) qp->data; | 106 | qbind->buffer = (void *) qp->data; |
107 | qbind->buffer_length = qp->data_len; | 107 | qbind->buffer_length = qp->data_len; |
108 | qbind->buffer_type = MYSQL_TYPE_STRING; | 108 | qbind->buffer_type = MYSQL_TYPE_STRING; |
109 | |||
110 | return 1; | 109 | return 1; |
111 | } | 110 | } |
112 | 111 | ||
@@ -144,10 +143,12 @@ my_conv_uint16 (void *cls, | |||
144 | const struct GNUNET_MY_QueryParam *qp, | 143 | const struct GNUNET_MY_QueryParam *qp, |
145 | MYSQL_BIND *qbind) | 144 | MYSQL_BIND *qbind) |
146 | { | 145 | { |
146 | (void) cls; | ||
147 | GNUNET_assert (1 == qp->num_params); | 147 | GNUNET_assert (1 == qp->num_params); |
148 | qbind->buffer = (void *) qp->data; | 148 | qbind->buffer = (void *) qp->data; |
149 | qbind->buffer_length = sizeof (uint16_t); | 149 | qbind->buffer_length = sizeof (uint16_t); |
150 | qbind->buffer_type = MYSQL_TYPE_SHORT; | 150 | qbind->buffer_type = MYSQL_TYPE_SHORT; |
151 | qbind->is_unsigned = 1; | ||
151 | return 1; | 152 | return 1; |
152 | } | 153 | } |
153 | 154 | ||
@@ -186,11 +187,12 @@ my_conv_uint32 (void *cls, | |||
186 | const struct GNUNET_MY_QueryParam *qp, | 187 | const struct GNUNET_MY_QueryParam *qp, |
187 | MYSQL_BIND *qbind) | 188 | MYSQL_BIND *qbind) |
188 | { | 189 | { |
190 | (void) cls; | ||
189 | GNUNET_assert (1 == qp->num_params); | 191 | GNUNET_assert (1 == qp->num_params); |
190 | qbind->buffer = (void *) qp->data; | 192 | qbind->buffer = (void *) qp->data; |
191 | qbind->buffer_length = sizeof(uint32_t); | 193 | qbind->buffer_length = sizeof(uint32_t); |
192 | qbind->buffer_type = MYSQL_TYPE_LONG; | 194 | qbind->buffer_type = MYSQL_TYPE_LONG; |
193 | 195 | qbind->is_unsigned = 1; | |
194 | return 1; | 196 | return 1; |
195 | } | 197 | } |
196 | 198 | ||
@@ -229,10 +231,12 @@ my_conv_uint64 (void *cls, | |||
229 | const struct GNUNET_MY_QueryParam *qp, | 231 | const struct GNUNET_MY_QueryParam *qp, |
230 | MYSQL_BIND * qbind) | 232 | MYSQL_BIND * qbind) |
231 | { | 233 | { |
234 | (void) cls; | ||
232 | GNUNET_assert (1 == qp->num_params); | 235 | GNUNET_assert (1 == qp->num_params); |
233 | qbind->buffer = (void *) qp->data; | 236 | qbind->buffer = (void *) qp->data; |
234 | qbind->buffer_length = sizeof (uint64_t); | 237 | qbind->buffer_length = sizeof (uint64_t); |
235 | qbind->buffer_type = MYSQL_TYPE_LONGLONG; | 238 | qbind->buffer_type = MYSQL_TYPE_LONGLONG; |
239 | qbind->is_unsigned = 1; | ||
236 | return 1; | 240 | return 1; |
237 | } | 241 | } |
238 | 242 | ||
@@ -275,14 +279,13 @@ my_conv_rsa_public_key (void *cls, | |||
275 | char *buf; | 279 | char *buf; |
276 | size_t buf_size; | 280 | size_t buf_size; |
277 | 281 | ||
282 | (void) cls; | ||
278 | GNUNET_assert(1 == qp->num_params); | 283 | GNUNET_assert(1 == qp->num_params); |
279 | 284 | buf_size = GNUNET_CRYPTO_rsa_public_key_encode (rsa, | |
280 | buf_size = GNUNET_CRYPTO_rsa_public_key_encode (rsa, &buf); | 285 | &buf); |
281 | |||
282 | qbind->buffer = (void *) buf; | 286 | qbind->buffer = (void *) buf; |
283 | qbind->buffer_length = buf_size; | 287 | qbind->buffer_length = buf_size; |
284 | qbind->buffer_type = MYSQL_TYPE_BLOB; | 288 | qbind->buffer_type = MYSQL_TYPE_BLOB; |
285 | |||
286 | return 1; | 289 | return 1; |
287 | } | 290 | } |
288 | 291 | ||
@@ -327,14 +330,13 @@ my_conv_rsa_signature (void *cls, | |||
327 | char *buf; | 330 | char *buf; |
328 | size_t buf_size; | 331 | size_t buf_size; |
329 | 332 | ||
333 | (void) cls; | ||
330 | GNUNET_assert(1 == qp->num_params); | 334 | GNUNET_assert(1 == qp->num_params); |
331 | |||
332 | buf_size = GNUNET_CRYPTO_rsa_signature_encode (sig, | 335 | buf_size = GNUNET_CRYPTO_rsa_signature_encode (sig, |
333 | &buf); | 336 | &buf); |
334 | qbind->buffer = (void *) buf; | 337 | qbind->buffer = (void *) buf; |
335 | qbind->buffer_length = buf_size; | 338 | qbind->buffer_length = buf_size; |
336 | qbind->buffer_type = MYSQL_TYPE_BLOB; | 339 | qbind->buffer_type = MYSQL_TYPE_BLOB; |
337 | |||
338 | return 1; | 340 | return 1; |
339 | } | 341 | } |
340 | 342 | ||
diff --git a/src/my/my_result_helper.c b/src/my/my_result_helper.c index f84550ced..df4b15e61 100644 --- a/src/my/my_result_helper.c +++ b/src/my/my_result_helper.c | |||
@@ -2,16 +2,18 @@ | |||
2 | This file is part of GNUnet | 2 | This file is part of GNUnet |
3 | Copyright (C) 2014, 2015, 2016 GNUnet e.V. | 3 | Copyright (C) 2014, 2015, 2016 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify it under the | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | terms of the GNU General Public License as published by the Free Software | 6 | under the terms of the GNU Affero General Public License as published |
7 | Foundation; either version 3, or (at your option) any later version. | 7 | by the Free Software Foundation, either version 3 of the License, |
8 | 8 | or (at your option) any later version. | |
9 | GNUnet is distributed in the hope that it will be useful, but WITHOUT ANY | 9 | |
10 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR | 10 | GNUnet is distributed in the hope that it will be useful, but |
11 | A PARTICULAR PURPOSE. See the GNU General Public License for more details. | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | You should have received a copy of the GNU General Public License along with | 13 | Affero General Public License for more details. |
14 | GNUnet; see the file COPYING. If not, If not, see <http://www.gnu.org/licenses/> | 14 | |
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
15 | */ | 17 | */ |
16 | /** | 18 | /** |
17 | * @file my/my_result_helper.c | 19 | * @file my/my_result_helper.c |
diff --git a/src/my/test_my.c b/src/my/test_my.c index aa02ad515..22a61dcb6 100644 --- a/src/my/test_my.c +++ b/src/my/test_my.c | |||
@@ -2,20 +2,18 @@ | |||
2 | This file is part of GNUnet | 2 | This file is part of GNUnet |
3 | Copyright (C) 2016 GNUnet e.V. | 3 | Copyright (C) 2016 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | it under the terms of the GNU General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
7 | by the Free Software Foundation; either version 3, or (at your | 7 | by the Free Software Foundation, either version 3 of the License, |
8 | option) any later version. | 8 | or (at your option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with GNUnet; see the file COPYING. If not, write to the | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301, USA. | ||
19 | */ | 17 | */ |
20 | /** | 18 | /** |
21 | * @file my/test_my.c | 19 | * @file my/test_my.c |