diff options
author | Christian Grothoff <christian@grothoff.org> | 2017-03-14 00:31:02 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2017-03-14 00:31:02 +0100 |
commit | 8d71f909cb22fbf6774e4042309a8eb133af3bfc (patch) | |
tree | 0efc19ac24a6521f927772364f1379154d2d0cad /src/peerstore/test_peerstore_api_iterate.c | |
parent | 6e01dc4d91d072e8e58ba0140fb7f4ddd5109358 (diff) | |
download | gnunet-8d71f909cb22fbf6774e4042309a8eb133af3bfc.tar.gz gnunet-8d71f909cb22fbf6774e4042309a8eb133af3bfc.zip |
convert sqlite peerstore to using libgnunetsq
Diffstat (limited to 'src/peerstore/test_peerstore_api_iterate.c')
-rw-r--r-- | src/peerstore/test_peerstore_api_iterate.c | 73 |
1 files changed, 56 insertions, 17 deletions
diff --git a/src/peerstore/test_peerstore_api_iterate.c b/src/peerstore/test_peerstore_api_iterate.c index 83a6bf7b7..c607d9fb3 100644 --- a/src/peerstore/test_peerstore_api_iterate.c +++ b/src/peerstore/test_peerstore_api_iterate.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) | 3 | Copyright (C) 2013-2017 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 |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -42,7 +42,8 @@ static int count = 0; | |||
42 | 42 | ||
43 | 43 | ||
44 | static void | 44 | static void |
45 | iter3_cb (void *cls, const struct GNUNET_PEERSTORE_Record *record, | 45 | iter3_cb (void *cls, |
46 | const struct GNUNET_PEERSTORE_Record *record, | ||
46 | const char *emsg) | 47 | const char *emsg) |
47 | { | 48 | { |
48 | if (NULL != emsg) | 49 | if (NULL != emsg) |
@@ -63,7 +64,8 @@ iter3_cb (void *cls, const struct GNUNET_PEERSTORE_Record *record, | |||
63 | 64 | ||
64 | 65 | ||
65 | static void | 66 | static void |
66 | iter2_cb (void *cls, const struct GNUNET_PEERSTORE_Record *record, | 67 | iter2_cb (void *cls, |
68 | const struct GNUNET_PEERSTORE_Record *record, | ||
67 | const char *emsg) | 69 | const char *emsg) |
68 | { | 70 | { |
69 | if (NULL != emsg) | 71 | if (NULL != emsg) |
@@ -78,13 +80,19 @@ iter2_cb (void *cls, const struct GNUNET_PEERSTORE_Record *record, | |||
78 | } | 80 | } |
79 | GNUNET_assert (count == 2); | 81 | GNUNET_assert (count == 2); |
80 | count = 0; | 82 | count = 0; |
81 | ic = GNUNET_PEERSTORE_iterate (h, ss, NULL, NULL, GNUNET_TIME_UNIT_FOREVER_REL, | 83 | ic = GNUNET_PEERSTORE_iterate (h, |
82 | iter3_cb, NULL); | 84 | ss, |
85 | NULL, | ||
86 | NULL, | ||
87 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
88 | &iter3_cb, | ||
89 | NULL); | ||
83 | } | 90 | } |
84 | 91 | ||
85 | 92 | ||
86 | static void | 93 | static void |
87 | iter1_cb (void *cls, const struct GNUNET_PEERSTORE_Record *record, | 94 | iter1_cb (void *cls, |
95 | const struct GNUNET_PEERSTORE_Record *record, | ||
88 | const char *emsg) | 96 | const char *emsg) |
89 | { | 97 | { |
90 | if (NULL != emsg) | 98 | if (NULL != emsg) |
@@ -99,30 +107,61 @@ iter1_cb (void *cls, const struct GNUNET_PEERSTORE_Record *record, | |||
99 | } | 107 | } |
100 | GNUNET_assert (count == 1); | 108 | GNUNET_assert (count == 1); |
101 | count = 0; | 109 | count = 0; |
102 | ic = GNUNET_PEERSTORE_iterate (h, ss, &p1, NULL, GNUNET_TIME_UNIT_FOREVER_REL, | 110 | ic = GNUNET_PEERSTORE_iterate (h, |
103 | iter2_cb, NULL); | 111 | ss, |
112 | &p1, | ||
113 | NULL, | ||
114 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
115 | iter2_cb, | ||
116 | NULL); | ||
104 | } | 117 | } |
105 | 118 | ||
106 | 119 | ||
107 | static void | 120 | static void |
108 | run (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, | 121 | run (void *cls, |
122 | const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
109 | struct GNUNET_TESTING_Peer *peer) | 123 | struct GNUNET_TESTING_Peer *peer) |
110 | { | 124 | { |
111 | h = GNUNET_PEERSTORE_connect (cfg); | 125 | h = GNUNET_PEERSTORE_connect (cfg); |
112 | GNUNET_assert (NULL != h); | 126 | GNUNET_assert (NULL != h); |
113 | memset (&p1, 1, sizeof (p1)); | 127 | memset (&p1, 1, sizeof (p1)); |
114 | memset (&p2, 2, sizeof (p2)); | 128 | memset (&p2, 2, sizeof (p2)); |
115 | GNUNET_PEERSTORE_store (h, ss, &p1, k1, val, strlen (val) + 1, | 129 | GNUNET_PEERSTORE_store (h, |
130 | ss, | ||
131 | &p1, | ||
132 | k1, | ||
133 | val, | ||
134 | strlen (val) + 1, | ||
116 | GNUNET_TIME_UNIT_FOREVER_ABS, | 135 | GNUNET_TIME_UNIT_FOREVER_ABS, |
117 | GNUNET_PEERSTORE_STOREOPTION_REPLACE, NULL, NULL); | 136 | GNUNET_PEERSTORE_STOREOPTION_REPLACE, |
118 | GNUNET_PEERSTORE_store (h, ss, &p1, k2, val, strlen (val) + 1, | 137 | NULL, |
138 | NULL); | ||
139 | GNUNET_PEERSTORE_store (h, | ||
140 | ss, | ||
141 | &p1, | ||
142 | k2, | ||
143 | val, | ||
144 | strlen (val) + 1, | ||
119 | GNUNET_TIME_UNIT_FOREVER_ABS, | 145 | GNUNET_TIME_UNIT_FOREVER_ABS, |
120 | GNUNET_PEERSTORE_STOREOPTION_REPLACE, NULL, NULL); | 146 | GNUNET_PEERSTORE_STOREOPTION_REPLACE, |
121 | GNUNET_PEERSTORE_store (h, ss, &p2, k3, val, strlen (val) + 1, | 147 | NULL, |
148 | NULL); | ||
149 | GNUNET_PEERSTORE_store (h, | ||
150 | ss, | ||
151 | &p2, | ||
152 | k3, | ||
153 | val, | ||
154 | strlen (val) + 1, | ||
122 | GNUNET_TIME_UNIT_FOREVER_ABS, | 155 | GNUNET_TIME_UNIT_FOREVER_ABS, |
123 | GNUNET_PEERSTORE_STOREOPTION_REPLACE, NULL, NULL); | 156 | GNUNET_PEERSTORE_STOREOPTION_REPLACE, |
124 | ic = GNUNET_PEERSTORE_iterate (h, ss, &p1, k1, GNUNET_TIME_UNIT_FOREVER_REL, | 157 | NULL, |
125 | iter1_cb, NULL); | 158 | NULL); |
159 | ic = GNUNET_PEERSTORE_iterate (h, | ||
160 | ss, | ||
161 | &p1, | ||
162 | k1, | ||
163 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
164 | &iter1_cb, NULL); | ||
126 | } | 165 | } |
127 | 166 | ||
128 | 167 | ||