diff options
Diffstat (limited to 'src/fs/fs_list_indexed.c')
-rw-r--r-- | src/fs/fs_list_indexed.c | 134 |
1 files changed, 66 insertions, 68 deletions
diff --git a/src/fs/fs_list_indexed.c b/src/fs/fs_list_indexed.c index 08a7be48e..c023d0ac6 100644 --- a/src/fs/fs_list_indexed.c +++ b/src/fs/fs_list_indexed.c | |||
@@ -11,12 +11,12 @@ | |||
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 | Affero 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 Affero General Public License | 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/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @file fs/fs_list_indexed.c | 22 | * @file fs/fs_list_indexed.c |
@@ -34,9 +34,7 @@ | |||
34 | /** | 34 | /** |
35 | * Context for #GNUNET_FS_get_indexed_files(). | 35 | * Context for #GNUNET_FS_get_indexed_files(). |
36 | */ | 36 | */ |
37 | struct GNUNET_FS_GetIndexedContext | 37 | struct GNUNET_FS_GetIndexedContext { |
38 | { | ||
39 | |||
40 | /** | 38 | /** |
41 | * Connection to the FS service. | 39 | * Connection to the FS service. |
42 | */ | 40 | */ |
@@ -72,15 +70,15 @@ struct GNUNET_FS_GetIndexedContext | |||
72 | * @param msg message with indexing information | 70 | * @param msg message with indexing information |
73 | */ | 71 | */ |
74 | static void | 72 | static void |
75 | handle_index_info_end (void *cls, | 73 | handle_index_info_end(void *cls, |
76 | const struct GNUNET_MessageHeader *msg) | 74 | const struct GNUNET_MessageHeader *msg) |
77 | { | 75 | { |
78 | struct GNUNET_FS_GetIndexedContext *gic = cls; | 76 | struct GNUNET_FS_GetIndexedContext *gic = cls; |
79 | 77 | ||
80 | (void) gic->iterator (gic->iterator_cls, | 78 | (void)gic->iterator(gic->iterator_cls, |
81 | NULL, | 79 | NULL, |
82 | NULL); | 80 | NULL); |
83 | GNUNET_FS_get_indexed_files_cancel (gic); | 81 | GNUNET_FS_get_indexed_files_cancel(gic); |
84 | } | 82 | } |
85 | 83 | ||
86 | 84 | ||
@@ -92,18 +90,18 @@ handle_index_info_end (void *cls, | |||
92 | * @param iim message with indexing information | 90 | * @param iim message with indexing information |
93 | */ | 91 | */ |
94 | static int | 92 | static int |
95 | check_index_info (void *cls, | 93 | check_index_info(void *cls, |
96 | const struct IndexInfoMessage *iim) | 94 | const struct IndexInfoMessage *iim) |
97 | { | 95 | { |
98 | uint16_t msize = ntohs (iim->header.size) - sizeof (*iim); | 96 | uint16_t msize = ntohs(iim->header.size) - sizeof(*iim); |
99 | const char *filename; | 97 | const char *filename; |
100 | 98 | ||
101 | filename = (const char *) &iim[1]; | 99 | filename = (const char *)&iim[1]; |
102 | if (filename[msize - 1] != '\0') | 100 | if (filename[msize - 1] != '\0') |
103 | { | 101 | { |
104 | GNUNET_break (0); | 102 | GNUNET_break(0); |
105 | return GNUNET_SYSERR; | 103 | return GNUNET_SYSERR; |
106 | } | 104 | } |
107 | return GNUNET_OK; | 105 | return GNUNET_OK; |
108 | } | 106 | } |
109 | 107 | ||
@@ -116,21 +114,21 @@ check_index_info (void *cls, | |||
116 | * @param iim message with indexing information | 114 | * @param iim message with indexing information |
117 | */ | 115 | */ |
118 | static void | 116 | static void |
119 | handle_index_info (void *cls, | 117 | handle_index_info(void *cls, |
120 | const struct IndexInfoMessage *iim) | 118 | const struct IndexInfoMessage *iim) |
121 | { | 119 | { |
122 | struct GNUNET_FS_GetIndexedContext *gic = cls; | 120 | struct GNUNET_FS_GetIndexedContext *gic = cls; |
123 | const char *filename; | 121 | const char *filename; |
124 | 122 | ||
125 | filename = (const char *) &iim[1]; | 123 | filename = (const char *)&iim[1]; |
126 | if (GNUNET_OK != | 124 | if (GNUNET_OK != |
127 | gic->iterator (gic->iterator_cls, | 125 | gic->iterator(gic->iterator_cls, |
128 | filename, | 126 | filename, |
129 | &iim->file_id)) | 127 | &iim->file_id)) |
130 | { | 128 | { |
131 | GNUNET_FS_get_indexed_files_cancel (gic); | 129 | GNUNET_FS_get_indexed_files_cancel(gic); |
132 | return; | 130 | return; |
133 | } | 131 | } |
134 | } | 132 | } |
135 | 133 | ||
136 | 134 | ||
@@ -143,16 +141,16 @@ handle_index_info (void *cls, | |||
143 | * @param error error code | 141 | * @param error error code |
144 | */ | 142 | */ |
145 | static void | 143 | static void |
146 | mq_error_handler (void *cls, | 144 | mq_error_handler(void *cls, |
147 | enum GNUNET_MQ_Error error) | 145 | enum GNUNET_MQ_Error error) |
148 | { | 146 | { |
149 | struct GNUNET_FS_GetIndexedContext *gic = cls; | 147 | struct GNUNET_FS_GetIndexedContext *gic = cls; |
150 | 148 | ||
151 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 149 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, |
152 | _("Failed to receive response from `%s' service.\n"), | 150 | _("Failed to receive response from `%s' service.\n"), |
153 | "fs"); | 151 | "fs"); |
154 | (void) gic->iterator (gic->iterator_cls, NULL, NULL); | 152 | (void)gic->iterator(gic->iterator_cls, NULL, NULL); |
155 | GNUNET_FS_get_indexed_files_cancel (gic); | 153 | GNUNET_FS_get_indexed_files_cancel(gic); |
156 | } | 154 | } |
157 | 155 | ||
158 | 156 | ||
@@ -165,45 +163,45 @@ mq_error_handler (void *cls, | |||
165 | * @return NULL on error ('iter' is not called) | 163 | * @return NULL on error ('iter' is not called) |
166 | */ | 164 | */ |
167 | struct GNUNET_FS_GetIndexedContext * | 165 | struct GNUNET_FS_GetIndexedContext * |
168 | GNUNET_FS_get_indexed_files (struct GNUNET_FS_Handle *h, | 166 | GNUNET_FS_get_indexed_files(struct GNUNET_FS_Handle *h, |
169 | GNUNET_FS_IndexedFileProcessor iterator, | 167 | GNUNET_FS_IndexedFileProcessor iterator, |
170 | void *iterator_cls) | 168 | void *iterator_cls) |
171 | { | 169 | { |
172 | struct GNUNET_FS_GetIndexedContext *gic | 170 | struct GNUNET_FS_GetIndexedContext *gic |
173 | = GNUNET_new (struct GNUNET_FS_GetIndexedContext); | 171 | = GNUNET_new(struct GNUNET_FS_GetIndexedContext); |
174 | struct GNUNET_MQ_MessageHandler handlers[] = { | 172 | struct GNUNET_MQ_MessageHandler handlers[] = { |
175 | GNUNET_MQ_hd_fixed_size (index_info_end, | 173 | GNUNET_MQ_hd_fixed_size(index_info_end, |
176 | GNUNET_MESSAGE_TYPE_FS_INDEX_LIST_END, | 174 | GNUNET_MESSAGE_TYPE_FS_INDEX_LIST_END, |
177 | struct GNUNET_MessageHeader, | 175 | struct GNUNET_MessageHeader, |
178 | gic), | 176 | gic), |
179 | GNUNET_MQ_hd_var_size (index_info, | 177 | GNUNET_MQ_hd_var_size(index_info, |
180 | GNUNET_MESSAGE_TYPE_FS_INDEX_LIST_ENTRY, | 178 | GNUNET_MESSAGE_TYPE_FS_INDEX_LIST_ENTRY, |
181 | struct IndexInfoMessage, | 179 | struct IndexInfoMessage, |
182 | gic), | 180 | gic), |
183 | GNUNET_MQ_handler_end () | 181 | GNUNET_MQ_handler_end() |
184 | }; | 182 | }; |
185 | struct GNUNET_MQ_Envelope *env; | 183 | struct GNUNET_MQ_Envelope *env; |
186 | struct GNUNET_MessageHeader *msg; | 184 | struct GNUNET_MessageHeader *msg; |
187 | 185 | ||
188 | gic->mq = GNUNET_CLIENT_connect (h->cfg, | 186 | gic->mq = GNUNET_CLIENT_connect(h->cfg, |
189 | "fs", | 187 | "fs", |
190 | handlers, | 188 | handlers, |
191 | &mq_error_handler, | 189 | &mq_error_handler, |
192 | h); | 190 | h); |
193 | if (NULL == gic->mq) | 191 | if (NULL == gic->mq) |
194 | { | 192 | { |
195 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 193 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, |
196 | _("Failed to not connect to `%s' service.\n"), | 194 | _("Failed to not connect to `%s' service.\n"), |
197 | "fs"); | 195 | "fs"); |
198 | GNUNET_free (gic); | 196 | GNUNET_free(gic); |
199 | return NULL; | 197 | return NULL; |
200 | } | 198 | } |
201 | gic->iterator = iterator; | 199 | gic->iterator = iterator; |
202 | gic->iterator_cls = iterator_cls; | 200 | gic->iterator_cls = iterator_cls; |
203 | env = GNUNET_MQ_msg (msg, | 201 | env = GNUNET_MQ_msg(msg, |
204 | GNUNET_MESSAGE_TYPE_FS_INDEX_LIST_GET); | 202 | GNUNET_MESSAGE_TYPE_FS_INDEX_LIST_GET); |
205 | GNUNET_MQ_send (gic->mq, | 203 | GNUNET_MQ_send(gic->mq, |
206 | env); | 204 | env); |
207 | return gic; | 205 | return gic; |
208 | } | 206 | } |
209 | 207 | ||
@@ -214,10 +212,10 @@ GNUNET_FS_get_indexed_files (struct GNUNET_FS_Handle *h, | |||
214 | * @param gic operation to cancel | 212 | * @param gic operation to cancel |
215 | */ | 213 | */ |
216 | void | 214 | void |
217 | GNUNET_FS_get_indexed_files_cancel (struct GNUNET_FS_GetIndexedContext *gic) | 215 | GNUNET_FS_get_indexed_files_cancel(struct GNUNET_FS_GetIndexedContext *gic) |
218 | { | 216 | { |
219 | GNUNET_MQ_destroy (gic->mq); | 217 | GNUNET_MQ_destroy(gic->mq); |
220 | GNUNET_free (gic); | 218 | GNUNET_free(gic); |
221 | } | 219 | } |
222 | 220 | ||
223 | 221 | ||