aboutsummaryrefslogtreecommitdiff
path: root/src/fs/fs_unindex.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/fs/fs_unindex.c')
-rw-r--r--src/fs/fs_unindex.c856
1 files changed, 429 insertions, 427 deletions
diff --git a/src/fs/fs_unindex.c b/src/fs/fs_unindex.c
index be2dbbddd..c35d49312 100644
--- a/src/fs/fs_unindex.c
+++ b/src/fs/fs_unindex.c
@@ -48,26 +48,26 @@
48 * @return number of bytes copied to buf, 0 on error 48 * @return number of bytes copied to buf, 0 on error
49 */ 49 */
50static size_t 50static size_t
51unindex_reader(void *cls, 51unindex_reader (void *cls,
52 uint64_t offset, 52 uint64_t offset,
53 size_t max, 53 size_t max,
54 void *buf, 54 void *buf,
55 char **emsg) 55 char **emsg)
56{ 56{
57 struct GNUNET_FS_UnindexContext *uc = cls; 57 struct GNUNET_FS_UnindexContext *uc = cls;
58 size_t pt_size; 58 size_t pt_size;
59 59
60 pt_size = GNUNET_MIN(max, uc->file_size - offset); 60 pt_size = GNUNET_MIN (max, uc->file_size - offset);
61 if (offset != GNUNET_DISK_file_seek(uc->fh, offset, GNUNET_DISK_SEEK_SET)) 61 if (offset != GNUNET_DISK_file_seek (uc->fh, offset, GNUNET_DISK_SEEK_SET))
62 { 62 {
63 *emsg = GNUNET_strdup(_("Failed to find given position in file")); 63 *emsg = GNUNET_strdup (_ ("Failed to find given position in file"));
64 return 0; 64 return 0;
65 } 65 }
66 if (pt_size != GNUNET_DISK_file_read(uc->fh, buf, pt_size)) 66 if (pt_size != GNUNET_DISK_file_read (uc->fh, buf, pt_size))
67 { 67 {
68 *emsg = GNUNET_strdup(_("Failed to read file")); 68 *emsg = GNUNET_strdup (_ ("Failed to read file"));
69 return 0; 69 return 0;
70 } 70 }
71 return pt_size; 71 return pt_size;
72} 72}
73 73
@@ -81,21 +81,21 @@ unindex_reader(void *cls,
81 * @param offset where we are in the file (for progress) 81 * @param offset where we are in the file (for progress)
82 */ 82 */
83void 83void
84GNUNET_FS_unindex_make_status_(struct GNUNET_FS_ProgressInfo *pi, 84GNUNET_FS_unindex_make_status_ (struct GNUNET_FS_ProgressInfo *pi,
85 struct GNUNET_FS_UnindexContext *uc, 85 struct GNUNET_FS_UnindexContext *uc,
86 uint64_t offset) 86 uint64_t offset)
87{ 87{
88 pi->value.unindex.uc = uc; 88 pi->value.unindex.uc = uc;
89 pi->value.unindex.cctx = uc->client_info; 89 pi->value.unindex.cctx = uc->client_info;
90 pi->value.unindex.filename = uc->filename; 90 pi->value.unindex.filename = uc->filename;
91 pi->value.unindex.size = uc->file_size; 91 pi->value.unindex.size = uc->file_size;
92 pi->value.unindex.eta = 92 pi->value.unindex.eta =
93 GNUNET_TIME_calculate_eta(uc->start_time, offset, uc->file_size); 93 GNUNET_TIME_calculate_eta (uc->start_time, offset, uc->file_size);
94 pi->value.unindex.duration = 94 pi->value.unindex.duration =
95 GNUNET_TIME_absolute_get_duration(uc->start_time); 95 GNUNET_TIME_absolute_get_duration (uc->start_time);
96 pi->value.unindex.completed = offset; 96 pi->value.unindex.completed = offset;
97 pi->fsh = uc->h; 97 pi->fsh = uc->h;
98 uc->client_info = uc->h->upcb(uc->h->upcb_cls, pi); 98 uc->client_info = uc->h->upcb (uc->h->upcb_cls, pi);
99} 99}
100 100
101 101
@@ -110,11 +110,11 @@ GNUNET_FS_unindex_make_status_(struct GNUNET_FS_ProgressInfo *pi,
110 * @param depth depth of the block in the tree, 0 for DBLOCK 110 * @param depth depth of the block in the tree, 0 for DBLOCK
111 */ 111 */
112static void 112static void
113unindex_progress(void *cls, 113unindex_progress (void *cls,
114 uint64_t offset, 114 uint64_t offset,
115 const void *pt_block, 115 const void *pt_block,
116 size_t pt_size, 116 size_t pt_size,
117 unsigned int depth) 117 unsigned int depth)
118{ 118{
119 struct GNUNET_FS_UnindexContext *uc = cls; 119 struct GNUNET_FS_UnindexContext *uc = cls;
120 struct GNUNET_FS_ProgressInfo pi; 120 struct GNUNET_FS_ProgressInfo pi;
@@ -124,7 +124,7 @@ unindex_progress(void *cls,
124 pi.value.unindex.specifics.progress.offset = offset; 124 pi.value.unindex.specifics.progress.offset = offset;
125 pi.value.unindex.specifics.progress.data_len = pt_size; 125 pi.value.unindex.specifics.progress.data_len = pt_size;
126 pi.value.unindex.specifics.progress.depth = depth; 126 pi.value.unindex.specifics.progress.depth = depth;
127 GNUNET_FS_unindex_make_status_(&pi, uc, offset); 127 GNUNET_FS_unindex_make_status_ (&pi, uc, offset);
128} 128}
129 129
130 130
@@ -135,14 +135,14 @@ unindex_progress(void *cls,
135 * @param uc context for the failed unindexing operation 135 * @param uc context for the failed unindexing operation
136 */ 136 */
137static void 137static void
138signal_unindex_error(struct GNUNET_FS_UnindexContext *uc) 138signal_unindex_error (struct GNUNET_FS_UnindexContext *uc)
139{ 139{
140 struct GNUNET_FS_ProgressInfo pi; 140 struct GNUNET_FS_ProgressInfo pi;
141 141
142 pi.status = GNUNET_FS_STATUS_UNINDEX_ERROR; 142 pi.status = GNUNET_FS_STATUS_UNINDEX_ERROR;
143 pi.value.unindex.eta = GNUNET_TIME_UNIT_FOREVER_REL; 143 pi.value.unindex.eta = GNUNET_TIME_UNIT_FOREVER_REL;
144 pi.value.unindex.specifics.error.message = uc->emsg; 144 pi.value.unindex.specifics.error.message = uc->emsg;
145 GNUNET_FS_unindex_make_status_(&pi, uc, 0); 145 GNUNET_FS_unindex_make_status_ (&pi, uc, 0);
146} 146}
147 147
148 148
@@ -156,22 +156,22 @@ signal_unindex_error(struct GNUNET_FS_UnindexContext *uc)
156 * @param msg NULL on success, otherwise an error message 156 * @param msg NULL on success, otherwise an error message
157 */ 157 */
158static void 158static void
159process_cont(void *cls, 159process_cont (void *cls,
160 int success, 160 int success,
161 struct GNUNET_TIME_Absolute min_expiration, 161 struct GNUNET_TIME_Absolute min_expiration,
162 const char *msg) 162 const char *msg)
163{ 163{
164 struct GNUNET_FS_UnindexContext *uc = cls; 164 struct GNUNET_FS_UnindexContext *uc = cls;
165 165
166 if (success == GNUNET_SYSERR) 166 if (success == GNUNET_SYSERR)
167 { 167 {
168 uc->emsg = GNUNET_strdup(msg); 168 uc->emsg = GNUNET_strdup (msg);
169 signal_unindex_error(uc); 169 signal_unindex_error (uc);
170 return; 170 return;
171 } 171 }
172 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 172 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
173 "Datastore REMOVE operation succeeded\n"); 173 "Datastore REMOVE operation succeeded\n");
174 GNUNET_FS_tree_encoder_next(uc->tc); 174 GNUNET_FS_tree_encoder_next (uc->tc);
175} 175}
176 176
177 177
@@ -190,13 +190,13 @@ process_cont(void *cls,
190 * @param block_size size of block (in bytes) 190 * @param block_size size of block (in bytes)
191 */ 191 */
192static void 192static void
193unindex_process(void *cls, 193unindex_process (void *cls,
194 const struct ContentHashKey *chk, 194 const struct ContentHashKey *chk,
195 uint64_t offset, 195 uint64_t offset,
196 unsigned int depth, 196 unsigned int depth,
197 enum GNUNET_BLOCK_Type type, 197 enum GNUNET_BLOCK_Type type,
198 const void *block, 198 const void *block,
199 uint16_t block_size) 199 uint16_t block_size)
200{ 200{
201 struct GNUNET_FS_UnindexContext *uc = cls; 201 struct GNUNET_FS_UnindexContext *uc = cls;
202 uint32_t size; 202 uint32_t size;
@@ -204,21 +204,21 @@ unindex_process(void *cls,
204 struct OnDemandBlock odb; 204 struct OnDemandBlock odb;
205 205
206 if (type != GNUNET_BLOCK_TYPE_FS_DBLOCK) 206 if (type != GNUNET_BLOCK_TYPE_FS_DBLOCK)
207 { 207 {
208 size = block_size; 208 size = block_size;
209 data = block; 209 data = block;
210 } 210 }
211 else /* on-demand encoded DBLOCK */ 211 else /* on-demand encoded DBLOCK */
212 { 212 {
213 size = sizeof(struct OnDemandBlock); 213 size = sizeof(struct OnDemandBlock);
214 odb.offset = GNUNET_htonll(offset); 214 odb.offset = GNUNET_htonll (offset);
215 odb.file_id = uc->file_id; 215 odb.file_id = uc->file_id;
216 data = &odb; 216 data = &odb;
217 } 217 }
218 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 218 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
219 "Sending REMOVE request to DATASTORE service\n"); 219 "Sending REMOVE request to DATASTORE service\n");
220 GNUNET_DATASTORE_remove(uc->dsh, &chk->query, size, data, -2, 1, 220 GNUNET_DATASTORE_remove (uc->dsh, &chk->query, size, data, -2, 1,
221 &process_cont, uc); 221 &process_cont, uc);
222 uc->chk = *chk; 222 uc->chk = *chk;
223} 223}
224 224
@@ -231,24 +231,24 @@ unindex_process(void *cls,
231 * @param msg the response 231 * @param msg the response
232 */ 232 */
233static void 233static void
234handle_unindex_response(void *cls, 234handle_unindex_response (void *cls,
235 const struct GNUNET_MessageHeader *msg) 235 const struct GNUNET_MessageHeader *msg)
236{ 236{
237 struct GNUNET_FS_UnindexContext *uc = cls; 237 struct GNUNET_FS_UnindexContext *uc = cls;
238 struct GNUNET_FS_ProgressInfo pi; 238 struct GNUNET_FS_ProgressInfo pi;
239 239
240 if (NULL != uc->mq) 240 if (NULL != uc->mq)
241 { 241 {
242 GNUNET_MQ_destroy(uc->mq); 242 GNUNET_MQ_destroy (uc->mq);
243 uc->mq = NULL; 243 uc->mq = NULL;
244 } 244 }
245 uc->state = UNINDEX_STATE_COMPLETE; 245 uc->state = UNINDEX_STATE_COMPLETE;
246 pi.status = GNUNET_FS_STATUS_UNINDEX_COMPLETED; 246 pi.status = GNUNET_FS_STATUS_UNINDEX_COMPLETED;
247 pi.value.unindex.eta = GNUNET_TIME_UNIT_ZERO; 247 pi.value.unindex.eta = GNUNET_TIME_UNIT_ZERO;
248 GNUNET_FS_unindex_sync_(uc); 248 GNUNET_FS_unindex_sync_ (uc);
249 GNUNET_FS_unindex_make_status_(&pi, 249 GNUNET_FS_unindex_make_status_ (&pi,
250 uc, 250 uc,
251 uc->file_size); 251 uc->file_size);
252} 252}
253 253
254 254
@@ -261,20 +261,20 @@ handle_unindex_response(void *cls,
261 * @param error error code 261 * @param error error code
262 */ 262 */
263static void 263static void
264unindex_mq_error_handler(void *cls, 264unindex_mq_error_handler (void *cls,
265 enum GNUNET_MQ_Error error) 265 enum GNUNET_MQ_Error error)
266{ 266{
267 struct GNUNET_FS_UnindexContext *uc = cls; 267 struct GNUNET_FS_UnindexContext *uc = cls;
268 268
269 if (NULL != uc->mq) 269 if (NULL != uc->mq)
270 { 270 {
271 GNUNET_MQ_destroy(uc->mq); 271 GNUNET_MQ_destroy (uc->mq);
272 uc->mq = NULL; 272 uc->mq = NULL;
273 } 273 }
274 uc->state = UNINDEX_STATE_ERROR; 274 uc->state = UNINDEX_STATE_ERROR;
275 uc->emsg = GNUNET_strdup(_("Error communicating with `fs' service.")); 275 uc->emsg = GNUNET_strdup (_ ("Error communicating with `fs' service."));
276 GNUNET_FS_unindex_sync_(uc); 276 GNUNET_FS_unindex_sync_ (uc);
277 signal_unindex_error(uc); 277 signal_unindex_error (uc);
278} 278}
279 279
280 280
@@ -286,56 +286,56 @@ unindex_mq_error_handler(void *cls,
286 * @param uc our unindexing context 286 * @param uc our unindexing context
287 */ 287 */
288static void 288static void
289unindex_finish(struct GNUNET_FS_UnindexContext *uc) 289unindex_finish (struct GNUNET_FS_UnindexContext *uc)
290{ 290{
291 struct GNUNET_MQ_MessageHandler handlers[] = { 291 struct GNUNET_MQ_MessageHandler handlers[] = {
292 GNUNET_MQ_hd_fixed_size(unindex_response, 292 GNUNET_MQ_hd_fixed_size (unindex_response,
293 GNUNET_MESSAGE_TYPE_FS_UNINDEX_OK, 293 GNUNET_MESSAGE_TYPE_FS_UNINDEX_OK,
294 struct GNUNET_MessageHeader, 294 struct GNUNET_MessageHeader,
295 uc), 295 uc),
296 GNUNET_MQ_handler_end() 296 GNUNET_MQ_handler_end ()
297 }; 297 };
298 char *emsg; 298 char *emsg;
299 struct GNUNET_MQ_Envelope *env; 299 struct GNUNET_MQ_Envelope *env;
300 struct UnindexMessage *req; 300 struct UnindexMessage *req;
301 301
302 /* generate final progress message */ 302 /* generate final progress message */
303 unindex_progress(uc, 303 unindex_progress (uc,
304 uc->file_size, 304 uc->file_size,
305 NULL, 305 NULL,
306 0, 306 0,
307 0); 307 0);
308 GNUNET_FS_tree_encoder_finish(uc->tc, 308 GNUNET_FS_tree_encoder_finish (uc->tc,
309 &emsg); 309 &emsg);
310 uc->tc = NULL; 310 uc->tc = NULL;
311 GNUNET_DISK_file_close(uc->fh); 311 GNUNET_DISK_file_close (uc->fh);
312 uc->fh = NULL; 312 uc->fh = NULL;
313 GNUNET_DATASTORE_disconnect(uc->dsh, GNUNET_NO); 313 GNUNET_DATASTORE_disconnect (uc->dsh, GNUNET_NO);
314 uc->dsh = NULL; 314 uc->dsh = NULL;
315 uc->state = UNINDEX_STATE_FS_NOTIFY; 315 uc->state = UNINDEX_STATE_FS_NOTIFY;
316 GNUNET_FS_unindex_sync_(uc); 316 GNUNET_FS_unindex_sync_ (uc);
317 uc->mq = GNUNET_CLIENT_connect(uc->h->cfg, 317 uc->mq = GNUNET_CLIENT_connect (uc->h->cfg,
318 "fs", 318 "fs",
319 handlers, 319 handlers,
320 &unindex_mq_error_handler, 320 &unindex_mq_error_handler,
321 uc); 321 uc);
322 if (NULL == uc->mq) 322 if (NULL == uc->mq)
323 { 323 {
324 uc->state = UNINDEX_STATE_ERROR; 324 uc->state = UNINDEX_STATE_ERROR;
325 uc->emsg = 325 uc->emsg =
326 GNUNET_strdup(_("Failed to connect to FS service for unindexing.")); 326 GNUNET_strdup (_ ("Failed to connect to FS service for unindexing."));
327 GNUNET_FS_unindex_sync_(uc); 327 GNUNET_FS_unindex_sync_ (uc);
328 signal_unindex_error(uc); 328 signal_unindex_error (uc);
329 return; 329 return;
330 } 330 }
331 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 331 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
332 "Sending UNINDEX message to FS service\n"); 332 "Sending UNINDEX message to FS service\n");
333 env = GNUNET_MQ_msg(req, 333 env = GNUNET_MQ_msg (req,
334 GNUNET_MESSAGE_TYPE_FS_UNINDEX); 334 GNUNET_MESSAGE_TYPE_FS_UNINDEX);
335 req->reserved = 0; 335 req->reserved = 0;
336 req->file_id = uc->file_id; 336 req->file_id = uc->file_id;
337 GNUNET_MQ_send(uc->mq, 337 GNUNET_MQ_send (uc->mq,
338 env); 338 env);
339} 339}
340 340
341 341
@@ -351,49 +351,49 @@ unindex_finish(struct GNUNET_FS_UnindexContext *uc)
351 * @param reason kind of progress we are making 351 * @param reason kind of progress we are making
352 */ 352 */
353static void 353static void
354unindex_directory_scan_cb(void *cls, 354unindex_directory_scan_cb (void *cls,
355 const char *filename, 355 const char *filename,
356 int is_directory, 356 int is_directory,
357 enum GNUNET_FS_DirScannerProgressUpdateReason reason) 357 enum GNUNET_FS_DirScannerProgressUpdateReason reason)
358{ 358{
359 struct GNUNET_FS_UnindexContext *uc = cls; 359 struct GNUNET_FS_UnindexContext *uc = cls;
360 static struct GNUNET_FS_ShareTreeItem * directory_scan_result; 360 static struct GNUNET_FS_ShareTreeItem *directory_scan_result;
361 361
362 switch (reason) 362 switch (reason)
363 { 363 {
364 case GNUNET_FS_DIRSCANNER_FINISHED: 364 case GNUNET_FS_DIRSCANNER_FINISHED:
365 directory_scan_result = GNUNET_FS_directory_scan_get_result(uc->dscan); 365 directory_scan_result = GNUNET_FS_directory_scan_get_result (uc->dscan);
366 uc->dscan = NULL; 366 uc->dscan = NULL;
367 if (NULL != directory_scan_result->ksk_uri) 367 if (NULL != directory_scan_result->ksk_uri)
368 { 368 {
369 uc->ksk_uri = GNUNET_FS_uri_dup(directory_scan_result->ksk_uri); 369 uc->ksk_uri = GNUNET_FS_uri_dup (directory_scan_result->ksk_uri);
370 uc->state = UNINDEX_STATE_DS_REMOVE_KBLOCKS; 370 uc->state = UNINDEX_STATE_DS_REMOVE_KBLOCKS;
371 GNUNET_FS_unindex_sync_(uc); 371 GNUNET_FS_unindex_sync_ (uc);
372 GNUNET_FS_unindex_do_remove_kblocks_(uc); 372 GNUNET_FS_unindex_do_remove_kblocks_ (uc);
373 } 373 }
374 else 374 else
375 { 375 {
376 uc->emsg = GNUNET_strdup(_("Failed to get KSKs from directory scan.")); 376 uc->emsg = GNUNET_strdup (_ ("Failed to get KSKs from directory scan."));
377 GNUNET_FS_unindex_sync_(uc); 377 GNUNET_FS_unindex_sync_ (uc);
378 unindex_finish(uc); 378 unindex_finish (uc);
379 } 379 }
380 GNUNET_FS_share_tree_free(directory_scan_result); 380 GNUNET_FS_share_tree_free (directory_scan_result);
381 break; 381 break;
382 382
383 case GNUNET_FS_DIRSCANNER_INTERNAL_ERROR: 383 case GNUNET_FS_DIRSCANNER_INTERNAL_ERROR:
384 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, 384 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
385 _("Internal error scanning `%s'.\n"), 385 _ ("Internal error scanning `%s'.\n"),
386 uc->filename); 386 uc->filename);
387 GNUNET_FS_directory_scan_abort(uc->dscan); 387 GNUNET_FS_directory_scan_abort (uc->dscan);
388 uc->dscan = NULL; 388 uc->dscan = NULL;
389 uc->emsg = GNUNET_strdup(_("Failed to get KSKs from directory scan.")); 389 uc->emsg = GNUNET_strdup (_ ("Failed to get KSKs from directory scan."));
390 GNUNET_FS_unindex_sync_(uc); 390 GNUNET_FS_unindex_sync_ (uc);
391 unindex_finish(uc); 391 unindex_finish (uc);
392 break; 392 break;
393 393
394 default: 394 default:
395 break; 395 break;
396 } 396 }
397} 397}
398 398
399 399
@@ -403,18 +403,19 @@ unindex_directory_scan_cb(void *cls,
403 * @param uc context for the unindex operation. 403 * @param uc context for the unindex operation.
404 */ 404 */
405void 405void
406GNUNET_FS_unindex_do_extract_keywords_(struct GNUNET_FS_UnindexContext *uc) 406GNUNET_FS_unindex_do_extract_keywords_ (struct GNUNET_FS_UnindexContext *uc)
407{ 407{
408 char *ex; 408 char *ex;
409 409
410 if (GNUNET_OK != 410 if (GNUNET_OK !=
411 GNUNET_CONFIGURATION_get_value_string(uc->h->cfg, "FS", "EXTRACTORS", &ex)) 411 GNUNET_CONFIGURATION_get_value_string (uc->h->cfg, "FS", "EXTRACTORS",
412 &ex))
412 ex = NULL; 413 ex = NULL;
413 uc->dscan = GNUNET_FS_directory_scan_start(uc->filename, 414 uc->dscan = GNUNET_FS_directory_scan_start (uc->filename,
414 GNUNET_NO, ex, 415 GNUNET_NO, ex,
415 &unindex_directory_scan_cb, 416 &unindex_directory_scan_cb,
416 uc); 417 uc);
417 GNUNET_free_non_null(ex); 418 GNUNET_free_non_null (ex);
418} 419}
419 420
420 421
@@ -432,20 +433,20 @@ GNUNET_FS_unindex_do_extract_keywords_(struct GNUNET_FS_UnindexContext *uc)
432 * @param msg NULL on success, otherwise an error message 433 * @param msg NULL on success, otherwise an error message
433 */ 434 */
434static void 435static void
435continue_after_remove(void *cls, 436continue_after_remove (void *cls,
436 int32_t success, 437 int32_t success,
437 struct GNUNET_TIME_Absolute min_expiration, 438 struct GNUNET_TIME_Absolute min_expiration,
438 const char *msg) 439 const char *msg)
439{ 440{
440 struct GNUNET_FS_UnindexContext *uc = cls; 441 struct GNUNET_FS_UnindexContext *uc = cls;
441 442
442 uc->dqe = NULL; 443 uc->dqe = NULL;
443 if (success != GNUNET_YES) 444 if (success != GNUNET_YES)
444 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, 445 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
445 _("Failed to remove UBlock: %s\n"), 446 _ ("Failed to remove UBlock: %s\n"),
446 msg); 447 msg);
447 uc->ksk_offset++; 448 uc->ksk_offset++;
448 GNUNET_FS_unindex_do_remove_kblocks_(uc); 449 GNUNET_FS_unindex_do_remove_kblocks_ (uc);
449} 450}
450 451
451 452
@@ -472,16 +473,16 @@ continue_after_remove(void *cls,
472 * maybe 0 if no unique identifier is available 473 * maybe 0 if no unique identifier is available
473 */ 474 */
474static void 475static void
475process_kblock_for_unindex(void *cls, 476process_kblock_for_unindex (void *cls,
476 const struct GNUNET_HashCode *key, 477 const struct GNUNET_HashCode *key,
477 size_t size, 478 size_t size,
478 const void *data, 479 const void *data,
479 enum GNUNET_BLOCK_Type type, 480 enum GNUNET_BLOCK_Type type,
480 uint32_t priority, 481 uint32_t priority,
481 uint32_t anonymity, 482 uint32_t anonymity,
482 uint32_t replication, 483 uint32_t replication,
483 struct GNUNET_TIME_Absolute expiration, 484 struct GNUNET_TIME_Absolute expiration,
484 uint64_t uid) 485 uint64_t uid)
485{ 486{
486 struct GNUNET_FS_UnindexContext *uc = cls; 487 struct GNUNET_FS_UnindexContext *uc = cls;
487 const struct UBlock *ub; 488 const struct UBlock *ub;
@@ -490,82 +491,83 @@ process_kblock_for_unindex(void *cls,
490 491
491 uc->dqe = NULL; 492 uc->dqe = NULL;
492 if (NULL == data) 493 if (NULL == data)
493 { 494 {
494 /* no result */ 495 /* no result */
495 uc->ksk_offset++; 496 uc->ksk_offset++;
496 GNUNET_FS_unindex_do_remove_kblocks_(uc); 497 GNUNET_FS_unindex_do_remove_kblocks_ (uc);
497 return; 498 return;
498 } 499 }
499 GNUNET_assert(GNUNET_BLOCK_TYPE_FS_UBLOCK == type); 500 GNUNET_assert (GNUNET_BLOCK_TYPE_FS_UBLOCK == type);
500 if (size < sizeof(struct UBlock)) 501 if (size < sizeof(struct UBlock))
501 { 502 {
502 GNUNET_break(0); 503 GNUNET_break (0);
503 goto get_next; 504 goto get_next;
504 } 505 }
505 ub = data; 506 ub = data;
506 GNUNET_CRYPTO_hash(&ub->verification_key, 507 GNUNET_CRYPTO_hash (&ub->verification_key,
507 sizeof(ub->verification_key), 508 sizeof(ub->verification_key),
508 &query); 509 &query);
509 if (0 != memcmp(&query, 510 if (0 != memcmp (&query,
510 key, 511 key,
511 sizeof(struct GNUNET_HashCode))) 512 sizeof(struct GNUNET_HashCode)))
512 { 513 {
513 /* result does not match our keyword, skip */ 514 /* result does not match our keyword, skip */
514 goto get_next; 515 goto get_next;
515 } 516 }
516 { 517 {
517 char pt[size - sizeof(struct UBlock)]; 518 char pt[size - sizeof(struct UBlock)];
518 struct GNUNET_CRYPTO_EcdsaPublicKey anon_pub; 519 struct GNUNET_CRYPTO_EcdsaPublicKey anon_pub;
519 const char *keyword; 520 const char *keyword;
520 521
521 GNUNET_CRYPTO_ecdsa_key_get_public(GNUNET_CRYPTO_ecdsa_key_get_anonymous(), 522 GNUNET_CRYPTO_ecdsa_key_get_public (
522 &anon_pub); 523 GNUNET_CRYPTO_ecdsa_key_get_anonymous (),
524 &anon_pub);
523 keyword = &uc->ksk_uri->data.ksk.keywords[uc->ksk_offset][1]; 525 keyword = &uc->ksk_uri->data.ksk.keywords[uc->ksk_offset][1];
524 GNUNET_FS_ublock_decrypt_(&ub[1], size - sizeof(struct UBlock), 526 GNUNET_FS_ublock_decrypt_ (&ub[1], size - sizeof(struct UBlock),
525 &anon_pub, 527 &anon_pub,
526 keyword, 528 keyword,
527 pt); 529 pt);
528 if (NULL == memchr(&pt[1], 0, sizeof(pt) - 1)) 530 if (NULL == memchr (&pt[1], 0, sizeof(pt) - 1))
529 { 531 {
530 GNUNET_break_op(0); /* malformed UBlock */ 532 GNUNET_break_op (0); /* malformed UBlock */
531 goto get_next; 533 goto get_next;
532 } 534 }
533 chk_uri = GNUNET_FS_uri_parse(&pt[1], NULL); 535 chk_uri = GNUNET_FS_uri_parse (&pt[1], NULL);
534 if (NULL == chk_uri) 536 if (NULL == chk_uri)
535 {
536 GNUNET_break_op(0); /* malformed UBlock */
537 goto get_next;
538 }
539 }
540 if (0 != memcmp(&uc->chk,
541 &chk_uri->data.chk.chk,
542 sizeof(struct ContentHashKey)))
543 { 537 {
544 /* different CHK, ignore */ 538 GNUNET_break_op (0); /* malformed UBlock */
545 GNUNET_FS_uri_destroy(chk_uri);
546 goto get_next; 539 goto get_next;
547 } 540 }
548 GNUNET_FS_uri_destroy(chk_uri); 541 }
542 if (0 != memcmp (&uc->chk,
543 &chk_uri->data.chk.chk,
544 sizeof(struct ContentHashKey)))
545 {
546 /* different CHK, ignore */
547 GNUNET_FS_uri_destroy (chk_uri);
548 goto get_next;
549 }
550 GNUNET_FS_uri_destroy (chk_uri);
549 /* matches! */ 551 /* matches! */
550 uc->dqe = GNUNET_DATASTORE_remove(uc->dsh, 552 uc->dqe = GNUNET_DATASTORE_remove (uc->dsh,
551 key, 553 key,
552 size, 554 size,
553 data, 555 data,
554 0 /* priority */,
555 1 /* queue size */,
556 &continue_after_remove,
557 uc);
558 return;
559get_next:
560 uc->dqe = GNUNET_DATASTORE_get_key(uc->dsh,
561 uid + 1 /* next_uid */,
562 false /* random */,
563 &uc->uquery,
564 GNUNET_BLOCK_TYPE_FS_UBLOCK,
565 0 /* priority */, 556 0 /* priority */,
566 1 /* queue size */, 557 1 /* queue size */,
567 &process_kblock_for_unindex, 558 &continue_after_remove,
568 uc); 559 uc);
560 return;
561get_next:
562 uc->dqe = GNUNET_DATASTORE_get_key (uc->dsh,
563 uid + 1 /* next_uid */,
564 false /* random */,
565 &uc->uquery,
566 GNUNET_BLOCK_TYPE_FS_UBLOCK,
567 0 /* priority */,
568 1 /* queue size */,
569 &process_kblock_for_unindex,
570 uc);
569} 571}
570 572
571 573
@@ -575,7 +577,7 @@ get_next:
575 * @param uc context for the unindex operation. 577 * @param uc context for the unindex operation.
576 */ 578 */
577void 579void
578GNUNET_FS_unindex_do_remove_kblocks_(struct GNUNET_FS_UnindexContext *uc) 580GNUNET_FS_unindex_do_remove_kblocks_ (struct GNUNET_FS_UnindexContext *uc)
579{ 581{
580 const char *keyword; 582 const char *keyword;
581 const struct GNUNET_CRYPTO_EcdsaPrivateKey *anon; 583 const struct GNUNET_CRYPTO_EcdsaPrivateKey *anon;
@@ -583,41 +585,41 @@ GNUNET_FS_unindex_do_remove_kblocks_(struct GNUNET_FS_UnindexContext *uc)
583 struct GNUNET_CRYPTO_EcdsaPublicKey dpub; 585 struct GNUNET_CRYPTO_EcdsaPublicKey dpub;
584 586
585 if (NULL == uc->dsh) 587 if (NULL == uc->dsh)
586 uc->dsh = GNUNET_DATASTORE_connect(uc->h->cfg); 588 uc->dsh = GNUNET_DATASTORE_connect (uc->h->cfg);
587 if (NULL == uc->dsh) 589 if (NULL == uc->dsh)
588 { 590 {
589 uc->state = UNINDEX_STATE_ERROR; 591 uc->state = UNINDEX_STATE_ERROR;
590 uc->emsg = GNUNET_strdup(_("Failed to connect to `datastore' service.")); 592 uc->emsg = GNUNET_strdup (_ ("Failed to connect to `datastore' service."));
591 GNUNET_FS_unindex_sync_(uc); 593 GNUNET_FS_unindex_sync_ (uc);
592 signal_unindex_error(uc); 594 signal_unindex_error (uc);
593 return; 595 return;
594 } 596 }
595 if ((NULL == uc->ksk_uri) || 597 if ((NULL == uc->ksk_uri) ||
596 (uc->ksk_offset >= uc->ksk_uri->data.ksk.keywordCount)) 598 (uc->ksk_offset >= uc->ksk_uri->data.ksk.keywordCount))
597 { 599 {
598 unindex_finish(uc); 600 unindex_finish (uc);
599 return; 601 return;
600 } 602 }
601 anon = GNUNET_CRYPTO_ecdsa_key_get_anonymous(); 603 anon = GNUNET_CRYPTO_ecdsa_key_get_anonymous ();
602 GNUNET_CRYPTO_ecdsa_key_get_public(anon, 604 GNUNET_CRYPTO_ecdsa_key_get_public (anon,
603 &anon_pub); 605 &anon_pub);
604 keyword = &uc->ksk_uri->data.ksk.keywords[uc->ksk_offset][1]; 606 keyword = &uc->ksk_uri->data.ksk.keywords[uc->ksk_offset][1];
605 GNUNET_CRYPTO_ecdsa_public_key_derive(&anon_pub, 607 GNUNET_CRYPTO_ecdsa_public_key_derive (&anon_pub,
606 keyword, 608 keyword,
607 "fs-ublock", 609 "fs-ublock",
608 &dpub); 610 &dpub);
609 GNUNET_CRYPTO_hash(&dpub, 611 GNUNET_CRYPTO_hash (&dpub,
610 sizeof(dpub), 612 sizeof(dpub),
611 &uc->uquery); 613 &uc->uquery);
612 uc->dqe = GNUNET_DATASTORE_get_key(uc->dsh, 614 uc->dqe = GNUNET_DATASTORE_get_key (uc->dsh,
613 0 /* next_uid */, 615 0 /* next_uid */,
614 false /* random */, 616 false /* random */,
615 &uc->uquery, 617 &uc->uquery,
616 GNUNET_BLOCK_TYPE_FS_UBLOCK, 618 GNUNET_BLOCK_TYPE_FS_UBLOCK,
617 0 /* priority */, 619 0 /* priority */,
618 1 /* queue size */, 620 1 /* queue size */,
619 &process_kblock_for_unindex, 621 &process_kblock_for_unindex,
620 uc); 622 uc);
621} 623}
622 624
623 625
@@ -628,13 +630,13 @@ GNUNET_FS_unindex_do_remove_kblocks_(struct GNUNET_FS_UnindexContext *uc)
628 * @param cls our unindexing context 630 * @param cls our unindexing context
629 */ 631 */
630static void 632static void
631unindex_extract_keywords(void *cls) 633unindex_extract_keywords (void *cls)
632{ 634{
633 struct GNUNET_FS_UnindexContext *uc = cls; 635 struct GNUNET_FS_UnindexContext *uc = cls;
634 636
635 uc->state = UNINDEX_STATE_EXTRACT_KEYWORDS; 637 uc->state = UNINDEX_STATE_EXTRACT_KEYWORDS;
636 GNUNET_FS_unindex_sync_(uc); 638 GNUNET_FS_unindex_sync_ (uc);
637 GNUNET_FS_unindex_do_extract_keywords_(uc); 639 GNUNET_FS_unindex_do_extract_keywords_ (uc);
638} 640}
639 641
640 642
@@ -644,40 +646,40 @@ unindex_extract_keywords(void *cls)
644 * @param uc context for the unindex operation. 646 * @param uc context for the unindex operation.
645 */ 647 */
646void 648void
647GNUNET_FS_unindex_do_remove_(struct GNUNET_FS_UnindexContext *uc) 649GNUNET_FS_unindex_do_remove_ (struct GNUNET_FS_UnindexContext *uc)
648{ 650{
649 if (NULL == uc->dsh) 651 if (NULL == uc->dsh)
650 uc->dsh = GNUNET_DATASTORE_connect(uc->h->cfg); 652 uc->dsh = GNUNET_DATASTORE_connect (uc->h->cfg);
651 if (NULL == uc->dsh) 653 if (NULL == uc->dsh)
652 { 654 {
653 uc->state = UNINDEX_STATE_ERROR; 655 uc->state = UNINDEX_STATE_ERROR;
654 uc->emsg = GNUNET_strdup(_("Failed to connect to `datastore' service.")); 656 uc->emsg = GNUNET_strdup (_ ("Failed to connect to `datastore' service."));
655 GNUNET_FS_unindex_sync_(uc); 657 GNUNET_FS_unindex_sync_ (uc);
656 signal_unindex_error(uc); 658 signal_unindex_error (uc);
657 return; 659 return;
658 } 660 }
659 uc->fh = 661 uc->fh =
660 GNUNET_DISK_file_open(uc->filename, GNUNET_DISK_OPEN_READ, 662 GNUNET_DISK_file_open (uc->filename, GNUNET_DISK_OPEN_READ,
661 GNUNET_DISK_PERM_NONE); 663 GNUNET_DISK_PERM_NONE);
662 if (NULL == uc->fh) 664 if (NULL == uc->fh)
663 { 665 {
664 GNUNET_DATASTORE_disconnect(uc->dsh, GNUNET_NO); 666 GNUNET_DATASTORE_disconnect (uc->dsh, GNUNET_NO);
665 uc->dsh = NULL; 667 uc->dsh = NULL;
666 uc->state = UNINDEX_STATE_ERROR; 668 uc->state = UNINDEX_STATE_ERROR;
667 uc->emsg = GNUNET_strdup(_("Failed to open file for unindexing.")); 669 uc->emsg = GNUNET_strdup (_ ("Failed to open file for unindexing."));
668 GNUNET_FS_unindex_sync_(uc); 670 GNUNET_FS_unindex_sync_ (uc);
669 signal_unindex_error(uc); 671 signal_unindex_error (uc);
670 return; 672 return;
671 } 673 }
672 uc->tc = 674 uc->tc =
673 GNUNET_FS_tree_encoder_create(uc->h, 675 GNUNET_FS_tree_encoder_create (uc->h,
674 uc->file_size, 676 uc->file_size,
675 uc, 677 uc,
676 &unindex_reader, 678 &unindex_reader,
677 &unindex_process, 679 &unindex_process,
678 &unindex_progress, 680 &unindex_progress,
679 &unindex_extract_keywords); 681 &unindex_extract_keywords);
680 GNUNET_FS_tree_encoder_next(uc->tc); 682 GNUNET_FS_tree_encoder_next (uc->tc);
681} 683}
682 684
683 685
@@ -689,29 +691,29 @@ GNUNET_FS_unindex_do_remove_(struct GNUNET_FS_UnindexContext *uc)
689 * @param file_id computed hash, NULL on error 691 * @param file_id computed hash, NULL on error
690 */ 692 */
691void 693void
692GNUNET_FS_unindex_process_hash_(void *cls, 694GNUNET_FS_unindex_process_hash_ (void *cls,
693 const struct GNUNET_HashCode *file_id) 695 const struct GNUNET_HashCode *file_id)
694{ 696{
695 struct GNUNET_FS_UnindexContext *uc = cls; 697 struct GNUNET_FS_UnindexContext *uc = cls;
696 698
697 uc->fhc = NULL; 699 uc->fhc = NULL;
698 if (uc->state != UNINDEX_STATE_HASHING) 700 if (uc->state != UNINDEX_STATE_HASHING)
699 { 701 {
700 GNUNET_FS_unindex_stop(uc); 702 GNUNET_FS_unindex_stop (uc);
701 return; 703 return;
702 } 704 }
703 if (file_id == NULL) 705 if (file_id == NULL)
704 { 706 {
705 uc->state = UNINDEX_STATE_ERROR; 707 uc->state = UNINDEX_STATE_ERROR;
706 uc->emsg = GNUNET_strdup(_("Failed to compute hash of file.")); 708 uc->emsg = GNUNET_strdup (_ ("Failed to compute hash of file."));
707 GNUNET_FS_unindex_sync_(uc); 709 GNUNET_FS_unindex_sync_ (uc);
708 signal_unindex_error(uc); 710 signal_unindex_error (uc);
709 return; 711 return;
710 } 712 }
711 uc->file_id = *file_id; 713 uc->file_id = *file_id;
712 uc->state = UNINDEX_STATE_DS_REMOVE; 714 uc->state = UNINDEX_STATE_DS_REMOVE;
713 GNUNET_FS_unindex_sync_(uc); 715 GNUNET_FS_unindex_sync_ (uc);
714 GNUNET_FS_unindex_do_remove_(uc); 716 GNUNET_FS_unindex_do_remove_ (uc);
715} 717}
716 718
717 719
@@ -722,62 +724,62 @@ GNUNET_FS_unindex_process_hash_(void *cls,
722 * @param cls the `struct GNUNET_FS_UnindexContext` to signal for 724 * @param cls the `struct GNUNET_FS_UnindexContext` to signal for
723 */ 725 */
724void 726void
725GNUNET_FS_unindex_signal_suspend_(void *cls) 727GNUNET_FS_unindex_signal_suspend_ (void *cls)
726{ 728{
727 struct GNUNET_FS_UnindexContext *uc = cls; 729 struct GNUNET_FS_UnindexContext *uc = cls;
728 struct GNUNET_FS_ProgressInfo pi; 730 struct GNUNET_FS_ProgressInfo pi;
729 731
730 /* FIXME: lots of duplication with unindex_stop here! */ 732 /* FIXME: lots of duplication with unindex_stop here! */
731 if (uc->dscan != NULL) 733 if (uc->dscan != NULL)
732 { 734 {
733 GNUNET_FS_directory_scan_abort(uc->dscan); 735 GNUNET_FS_directory_scan_abort (uc->dscan);
734 uc->dscan = NULL; 736 uc->dscan = NULL;
735 } 737 }
736 if (NULL != uc->dqe) 738 if (NULL != uc->dqe)
737 { 739 {
738 GNUNET_DATASTORE_cancel(uc->dqe); 740 GNUNET_DATASTORE_cancel (uc->dqe);
739 uc->dqe = NULL; 741 uc->dqe = NULL;
740 } 742 }
741 if (uc->fhc != NULL) 743 if (uc->fhc != NULL)
742 { 744 {
743 GNUNET_CRYPTO_hash_file_cancel(uc->fhc); 745 GNUNET_CRYPTO_hash_file_cancel (uc->fhc);
744 uc->fhc = NULL; 746 uc->fhc = NULL;
745 } 747 }
746 if (NULL != uc->ksk_uri) 748 if (NULL != uc->ksk_uri)
747 { 749 {
748 GNUNET_FS_uri_destroy(uc->ksk_uri); 750 GNUNET_FS_uri_destroy (uc->ksk_uri);
749 uc->ksk_uri = NULL; 751 uc->ksk_uri = NULL;
750 } 752 }
751 if (NULL != uc->mq) 753 if (NULL != uc->mq)
752 { 754 {
753 GNUNET_MQ_destroy(uc->mq); 755 GNUNET_MQ_destroy (uc->mq);
754 uc->mq = NULL; 756 uc->mq = NULL;
755 } 757 }
756 if (NULL != uc->dsh) 758 if (NULL != uc->dsh)
757 { 759 {
758 GNUNET_DATASTORE_disconnect(uc->dsh, GNUNET_NO); 760 GNUNET_DATASTORE_disconnect (uc->dsh, GNUNET_NO);
759 uc->dsh = NULL; 761 uc->dsh = NULL;
760 } 762 }
761 if (NULL != uc->tc) 763 if (NULL != uc->tc)
762 { 764 {
763 GNUNET_FS_tree_encoder_finish(uc->tc, NULL); 765 GNUNET_FS_tree_encoder_finish (uc->tc, NULL);
764 uc->tc = NULL; 766 uc->tc = NULL;
765 } 767 }
766 if (uc->fh != NULL) 768 if (uc->fh != NULL)
767 { 769 {
768 GNUNET_DISK_file_close(uc->fh); 770 GNUNET_DISK_file_close (uc->fh);
769 uc->fh = NULL; 771 uc->fh = NULL;
770 } 772 }
771 GNUNET_FS_end_top(uc->h, uc->top); 773 GNUNET_FS_end_top (uc->h, uc->top);
772 pi.status = GNUNET_FS_STATUS_UNINDEX_SUSPEND; 774 pi.status = GNUNET_FS_STATUS_UNINDEX_SUSPEND;
773 GNUNET_FS_unindex_make_status_(&pi, uc, 775 GNUNET_FS_unindex_make_status_ (&pi, uc,
774 (uc->state == 776 (uc->state ==
775 UNINDEX_STATE_COMPLETE) ? uc->file_size : 0); 777 UNINDEX_STATE_COMPLETE) ? uc->file_size : 0);
776 GNUNET_break(NULL == uc->client_info); 778 GNUNET_break (NULL == uc->client_info);
777 GNUNET_free(uc->filename); 779 GNUNET_free (uc->filename);
778 GNUNET_free_non_null(uc->serialization); 780 GNUNET_free_non_null (uc->serialization);
779 GNUNET_free_non_null(uc->emsg); 781 GNUNET_free_non_null (uc->emsg);
780 GNUNET_free(uc); 782 GNUNET_free (uc);
781} 783}
782 784
783 785
@@ -790,38 +792,38 @@ GNUNET_FS_unindex_signal_suspend_(void *cls)
790 * @return NULL on error, otherwise handle 792 * @return NULL on error, otherwise handle
791 */ 793 */
792struct GNUNET_FS_UnindexContext * 794struct GNUNET_FS_UnindexContext *
793GNUNET_FS_unindex_start(struct GNUNET_FS_Handle *h, 795GNUNET_FS_unindex_start (struct GNUNET_FS_Handle *h,
794 const char *filename, 796 const char *filename,
795 void *cctx) 797 void *cctx)
796{ 798{
797 struct GNUNET_FS_UnindexContext *uc; 799 struct GNUNET_FS_UnindexContext *uc;
798 struct GNUNET_FS_ProgressInfo pi; 800 struct GNUNET_FS_ProgressInfo pi;
799 uint64_t size; 801 uint64_t size;
800 802
801 if (GNUNET_OK != 803 if (GNUNET_OK !=
802 GNUNET_DISK_file_size(filename, 804 GNUNET_DISK_file_size (filename,
803 &size, 805 &size,
804 GNUNET_YES, 806 GNUNET_YES,
805 GNUNET_YES)) 807 GNUNET_YES))
806 return NULL; 808 return NULL;
807 uc = GNUNET_new(struct GNUNET_FS_UnindexContext); 809 uc = GNUNET_new (struct GNUNET_FS_UnindexContext);
808 uc->h = h; 810 uc->h = h;
809 uc->filename = GNUNET_strdup(filename); 811 uc->filename = GNUNET_strdup (filename);
810 uc->start_time = GNUNET_TIME_absolute_get(); 812 uc->start_time = GNUNET_TIME_absolute_get ();
811 uc->file_size = size; 813 uc->file_size = size;
812 uc->client_info = cctx; 814 uc->client_info = cctx;
813 GNUNET_FS_unindex_sync_(uc); 815 GNUNET_FS_unindex_sync_ (uc);
814 pi.status = GNUNET_FS_STATUS_UNINDEX_START; 816 pi.status = GNUNET_FS_STATUS_UNINDEX_START;
815 pi.value.unindex.eta = GNUNET_TIME_UNIT_FOREVER_REL; 817 pi.value.unindex.eta = GNUNET_TIME_UNIT_FOREVER_REL;
816 GNUNET_FS_unindex_make_status_(&pi, uc, 0); 818 GNUNET_FS_unindex_make_status_ (&pi, uc, 0);
817 uc->fhc = 819 uc->fhc =
818 GNUNET_CRYPTO_hash_file(GNUNET_SCHEDULER_PRIORITY_IDLE, 820 GNUNET_CRYPTO_hash_file (GNUNET_SCHEDULER_PRIORITY_IDLE,
819 filename, 821 filename,
820 HASHING_BLOCKSIZE, 822 HASHING_BLOCKSIZE,
821 &GNUNET_FS_unindex_process_hash_, uc); 823 &GNUNET_FS_unindex_process_hash_, uc);
822 uc->top = GNUNET_FS_make_top(h, 824 uc->top = GNUNET_FS_make_top (h,
823 &GNUNET_FS_unindex_signal_suspend_, 825 &GNUNET_FS_unindex_signal_suspend_,
824 uc); 826 uc);
825 return uc; 827 return uc;
826} 828}
827 829
@@ -832,67 +834,67 @@ GNUNET_FS_unindex_start(struct GNUNET_FS_Handle *h,
832 * @param uc handle 834 * @param uc handle
833 */ 835 */
834void 836void
835GNUNET_FS_unindex_stop(struct GNUNET_FS_UnindexContext *uc) 837GNUNET_FS_unindex_stop (struct GNUNET_FS_UnindexContext *uc)
836{ 838{
837 struct GNUNET_FS_ProgressInfo pi; 839 struct GNUNET_FS_ProgressInfo pi;
838 840
839 if (NULL != uc->dscan) 841 if (NULL != uc->dscan)
840 { 842 {
841 GNUNET_FS_directory_scan_abort(uc->dscan); 843 GNUNET_FS_directory_scan_abort (uc->dscan);
842 uc->dscan = NULL; 844 uc->dscan = NULL;
843 } 845 }
844 if (NULL != uc->dqe) 846 if (NULL != uc->dqe)
845 { 847 {
846 GNUNET_DATASTORE_cancel(uc->dqe); 848 GNUNET_DATASTORE_cancel (uc->dqe);
847 uc->dqe = NULL; 849 uc->dqe = NULL;
848 } 850 }
849 if (NULL != uc->fhc) 851 if (NULL != uc->fhc)
850 { 852 {
851 GNUNET_CRYPTO_hash_file_cancel(uc->fhc); 853 GNUNET_CRYPTO_hash_file_cancel (uc->fhc);
852 uc->fhc = NULL; 854 uc->fhc = NULL;
853 } 855 }
854 if (NULL != uc->mq) 856 if (NULL != uc->mq)
855 { 857 {
856 GNUNET_MQ_destroy(uc->mq); 858 GNUNET_MQ_destroy (uc->mq);
857 uc->mq = NULL; 859 uc->mq = NULL;
858 } 860 }
859 if (NULL != uc->dsh) 861 if (NULL != uc->dsh)
860 { 862 {
861 GNUNET_DATASTORE_disconnect(uc->dsh, GNUNET_NO); 863 GNUNET_DATASTORE_disconnect (uc->dsh, GNUNET_NO);
862 uc->dsh = NULL; 864 uc->dsh = NULL;
863 } 865 }
864 if (NULL != uc->ksk_uri) 866 if (NULL != uc->ksk_uri)
865 { 867 {
866 GNUNET_FS_uri_destroy(uc->ksk_uri); 868 GNUNET_FS_uri_destroy (uc->ksk_uri);
867 uc->ksk_uri = NULL; 869 uc->ksk_uri = NULL;
868 } 870 }
869 if (NULL != uc->tc) 871 if (NULL != uc->tc)
870 { 872 {
871 GNUNET_FS_tree_encoder_finish(uc->tc, NULL); 873 GNUNET_FS_tree_encoder_finish (uc->tc, NULL);
872 uc->tc = NULL; 874 uc->tc = NULL;
873 } 875 }
874 if (uc->fh != NULL) 876 if (uc->fh != NULL)
875 { 877 {
876 GNUNET_DISK_file_close(uc->fh); 878 GNUNET_DISK_file_close (uc->fh);
877 uc->fh = NULL; 879 uc->fh = NULL;
878 } 880 }
879 GNUNET_FS_end_top(uc->h, uc->top); 881 GNUNET_FS_end_top (uc->h, uc->top);
880 if (uc->serialization != NULL) 882 if (uc->serialization != NULL)
881 { 883 {
882 GNUNET_FS_remove_sync_file_(uc->h, GNUNET_FS_SYNC_PATH_MASTER_UNINDEX, 884 GNUNET_FS_remove_sync_file_ (uc->h, GNUNET_FS_SYNC_PATH_MASTER_UNINDEX,
883 uc->serialization); 885 uc->serialization);
884 GNUNET_free(uc->serialization); 886 GNUNET_free (uc->serialization);
885 uc->serialization = NULL; 887 uc->serialization = NULL;
886 } 888 }
887 pi.status = GNUNET_FS_STATUS_UNINDEX_STOPPED; 889 pi.status = GNUNET_FS_STATUS_UNINDEX_STOPPED;
888 pi.value.unindex.eta = GNUNET_TIME_UNIT_ZERO; 890 pi.value.unindex.eta = GNUNET_TIME_UNIT_ZERO;
889 GNUNET_FS_unindex_make_status_(&pi, uc, 891 GNUNET_FS_unindex_make_status_ (&pi, uc,
890 (uc->state == 892 (uc->state ==
891 UNINDEX_STATE_COMPLETE) ? uc->file_size : 0); 893 UNINDEX_STATE_COMPLETE) ? uc->file_size : 0);
892 GNUNET_break(NULL == uc->client_info); 894 GNUNET_break (NULL == uc->client_info);
893 GNUNET_free_non_null(uc->emsg); 895 GNUNET_free_non_null (uc->emsg);
894 GNUNET_free(uc->filename); 896 GNUNET_free (uc->filename);
895 GNUNET_free(uc); 897 GNUNET_free (uc);
896} 898}
897 899
898/* end of fs_unindex.c */ 900/* end of fs_unindex.c */