summaryrefslogtreecommitdiff
path: root/src/fs/fs_dirmetascan.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/fs/fs_dirmetascan.c')
-rw-r--r--src/fs/fs_dirmetascan.c473
1 files changed, 239 insertions, 234 deletions
diff --git a/src/fs/fs_dirmetascan.c b/src/fs/fs_dirmetascan.c
index dd207e2c9..9202de5ab 100644
--- a/src/fs/fs_dirmetascan.c
+++ b/src/fs/fs_dirmetascan.c
@@ -16,7 +16,7 @@
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_dirmetascan.c 22 * @file fs/fs_dirmetascan.c
@@ -35,9 +35,7 @@
35 * An opaque structure a pointer to which is returned to the 35 * An opaque structure a pointer to which is returned to the
36 * caller to be used to control the scanner. 36 * caller to be used to control the scanner.
37 */ 37 */
38struct GNUNET_FS_DirScanner 38struct GNUNET_FS_DirScanner {
39{
40
41 /** 39 /**
42 * Helper process. 40 * Helper process.
43 */ 41 */
@@ -96,20 +94,20 @@ struct GNUNET_FS_DirScanner
96 * @param ds directory scanner structure 94 * @param ds directory scanner structure
97 */ 95 */
98void 96void
99GNUNET_FS_directory_scan_abort (struct GNUNET_FS_DirScanner *ds) 97GNUNET_FS_directory_scan_abort(struct GNUNET_FS_DirScanner *ds)
100{ 98{
101 /* terminate helper */ 99 /* terminate helper */
102 if (NULL != ds->helper) 100 if (NULL != ds->helper)
103 GNUNET_HELPER_stop (ds->helper, GNUNET_NO); 101 GNUNET_HELPER_stop(ds->helper, GNUNET_NO);
104 102
105 /* free resources */ 103 /* free resources */
106 if (NULL != ds->toplevel) 104 if (NULL != ds->toplevel)
107 GNUNET_FS_share_tree_free (ds->toplevel); 105 GNUNET_FS_share_tree_free(ds->toplevel);
108 if (NULL != ds->stop_task) 106 if (NULL != ds->stop_task)
109 GNUNET_SCHEDULER_cancel (ds->stop_task); 107 GNUNET_SCHEDULER_cancel(ds->stop_task);
110 GNUNET_free_non_null (ds->ex_arg); 108 GNUNET_free_non_null(ds->ex_arg);
111 GNUNET_free (ds->filename_expanded); 109 GNUNET_free(ds->filename_expanded);
112 GNUNET_free (ds); 110 GNUNET_free(ds);
113} 111}
114 112
115 113
@@ -122,16 +120,16 @@ GNUNET_FS_directory_scan_abort (struct GNUNET_FS_DirScanner *ds)
122 * @return the results of the scan (a directory tree) 120 * @return the results of the scan (a directory tree)
123 */ 121 */
124struct GNUNET_FS_ShareTreeItem * 122struct GNUNET_FS_ShareTreeItem *
125GNUNET_FS_directory_scan_get_result (struct GNUNET_FS_DirScanner *ds) 123GNUNET_FS_directory_scan_get_result(struct GNUNET_FS_DirScanner *ds)
126{ 124{
127 struct GNUNET_FS_ShareTreeItem *result; 125 struct GNUNET_FS_ShareTreeItem *result;
128 126
129 /* check that we're actually done */ 127 /* check that we're actually done */
130 GNUNET_assert (NULL == ds->helper); 128 GNUNET_assert(NULL == ds->helper);
131 /* preserve result */ 129 /* preserve result */
132 result = ds->toplevel; 130 result = ds->toplevel;
133 ds->toplevel = NULL; 131 ds->toplevel = NULL;
134 GNUNET_FS_directory_scan_abort (ds); 132 GNUNET_FS_directory_scan_abort(ds);
135 return result; 133 return result;
136} 134}
137 135
@@ -144,35 +142,35 @@ GNUNET_FS_directory_scan_get_result (struct GNUNET_FS_DirScanner *ds)
144 * @return next file, NULL for none 142 * @return next file, NULL for none
145 */ 143 */
146static struct GNUNET_FS_ShareTreeItem * 144static struct GNUNET_FS_ShareTreeItem *
147advance (struct GNUNET_FS_ShareTreeItem *pos) 145advance(struct GNUNET_FS_ShareTreeItem *pos)
148{ 146{
149 int moved; 147 int moved;
150 148
151 GNUNET_assert (NULL != pos); 149 GNUNET_assert(NULL != pos);
152 moved = 0; /* must not terminate, even on file, otherwise "normal" */ 150 moved = 0; /* must not terminate, even on file, otherwise "normal" */
153 while ((pos->is_directory == GNUNET_YES) || (0 == moved)) 151 while ((pos->is_directory == GNUNET_YES) || (0 == moved))
154 {
155 if ((moved != -1) && (NULL != pos->children_head))
156 {
157 pos = pos->children_head;
158 moved = 1; /* can terminate if file */
159 continue;
160 }
161 if (NULL != pos->next)
162 {
163 pos = pos->next;
164 moved = 1; /* can terminate if file */
165 continue;
166 }
167 if (NULL != pos->parent)
168 { 152 {
169 pos = pos->parent; 153 if ((moved != -1) && (NULL != pos->children_head))
170 moved = -1; /* force move to 'next' or 'parent' */ 154 {
171 continue; 155 pos = pos->children_head;
156 moved = 1; /* can terminate if file */
157 continue;
158 }
159 if (NULL != pos->next)
160 {
161 pos = pos->next;
162 moved = 1; /* can terminate if file */
163 continue;
164 }
165 if (NULL != pos->parent)
166 {
167 pos = pos->parent;
168 moved = -1; /* force move to 'next' or 'parent' */
169 continue;
170 }
171 /* no more options, end of traversal */
172 return NULL;
172 } 173 }
173 /* no more options, end of traversal */
174 return NULL;
175 }
176 return pos; 174 return pos;
177} 175}
178 176
@@ -186,30 +184,30 @@ advance (struct GNUNET_FS_ShareTreeItem *pos)
186 * @return new entry that was just created 184 * @return new entry that was just created
187 */ 185 */
188static struct GNUNET_FS_ShareTreeItem * 186static struct GNUNET_FS_ShareTreeItem *
189expand_tree (struct GNUNET_FS_ShareTreeItem *parent, 187expand_tree(struct GNUNET_FS_ShareTreeItem *parent,
190 const char *filename, 188 const char *filename,
191 int is_directory) 189 int is_directory)
192{ 190{
193 struct GNUNET_FS_ShareTreeItem *chld; 191 struct GNUNET_FS_ShareTreeItem *chld;
194 size_t slen; 192 size_t slen;
195 193
196 chld = GNUNET_new (struct GNUNET_FS_ShareTreeItem); 194 chld = GNUNET_new(struct GNUNET_FS_ShareTreeItem);
197 chld->parent = parent; 195 chld->parent = parent;
198 chld->filename = GNUNET_strdup (filename); 196 chld->filename = GNUNET_strdup(filename);
199 GNUNET_asprintf (&chld->short_filename, 197 GNUNET_asprintf(&chld->short_filename,
200 "%s%s", 198 "%s%s",
201 GNUNET_STRINGS_get_short_name (filename), 199 GNUNET_STRINGS_get_short_name(filename),
202 is_directory == GNUNET_YES ? "/" : ""); 200 is_directory == GNUNET_YES ? "/" : "");
203 /* make sure we do not end with '//' */ 201 /* make sure we do not end with '//' */
204 slen = strlen (chld->short_filename); 202 slen = strlen(chld->short_filename);
205 if ((slen >= 2) && (chld->short_filename[slen - 1] == '/') && 203 if ((slen >= 2) && (chld->short_filename[slen - 1] == '/') &&
206 (chld->short_filename[slen - 2] == '/')) 204 (chld->short_filename[slen - 2] == '/'))
207 chld->short_filename[slen - 1] = '\0'; 205 chld->short_filename[slen - 1] = '\0';
208 chld->is_directory = is_directory; 206 chld->is_directory = is_directory;
209 if (NULL != parent) 207 if (NULL != parent)
210 GNUNET_CONTAINER_DLL_insert (parent->children_head, 208 GNUNET_CONTAINER_DLL_insert(parent->children_head,
211 parent->children_tail, 209 parent->children_tail,
212 chld); 210 chld);
213 return chld; 211 return chld;
214} 212}
215 213
@@ -220,20 +218,20 @@ expand_tree (struct GNUNET_FS_ShareTreeItem *parent,
220 * @param cls the 'struct GNUNET_FS_DirScanner' 218 * @param cls the 'struct GNUNET_FS_DirScanner'
221 */ 219 */
222static void 220static void
223finish_scan (void *cls) 221finish_scan(void *cls)
224{ 222{
225 struct GNUNET_FS_DirScanner *ds = cls; 223 struct GNUNET_FS_DirScanner *ds = cls;
226 224
227 ds->stop_task = NULL; 225 ds->stop_task = NULL;
228 if (NULL != ds->helper) 226 if (NULL != ds->helper)
229 { 227 {
230 GNUNET_HELPER_stop (ds->helper, GNUNET_NO); 228 GNUNET_HELPER_stop(ds->helper, GNUNET_NO);
231 ds->helper = NULL; 229 ds->helper = NULL;
232 } 230 }
233 ds->progress_callback (ds->progress_callback_cls, 231 ds->progress_callback(ds->progress_callback_cls,
234 NULL, 232 NULL,
235 GNUNET_SYSERR, 233 GNUNET_SYSERR,
236 GNUNET_FS_DIRSCANNER_FINISHED); 234 GNUNET_FS_DIRSCANNER_FINISHED);
237} 235}
238 236
239 237
@@ -248,168 +246,175 @@ finish_scan (void *cls)
248 * #GNUNET_SYSERR to stop further processing with error 246 * #GNUNET_SYSERR to stop further processing with error
249 */ 247 */
250static int 248static int
251process_helper_msgs (void *cls, const struct GNUNET_MessageHeader *msg) 249process_helper_msgs(void *cls, const struct GNUNET_MessageHeader *msg)
252{ 250{
253 struct GNUNET_FS_DirScanner *ds = cls; 251 struct GNUNET_FS_DirScanner *ds = cls;
254 const char *filename; 252 const char *filename;
255 size_t left; 253 size_t left;
256 254
257#if 0 255#if 0
258 fprintf (stderr, 256 fprintf(stderr,
259 "DMS parses %u-byte message of type %u\n", 257 "DMS parses %u-byte message of type %u\n",
260 (unsigned int) ntohs (msg->size), 258 (unsigned int)ntohs(msg->size),
261 (unsigned int) ntohs (msg->type)); 259 (unsigned int)ntohs(msg->type));
262#endif 260#endif
263 left = ntohs (msg->size) - sizeof (struct GNUNET_MessageHeader); 261 left = ntohs(msg->size) - sizeof(struct GNUNET_MessageHeader);
264 filename = (const char *) &msg[1]; 262 filename = (const char *)&msg[1];
265 switch (ntohs (msg->type)) 263 switch (ntohs(msg->type))
266 {
267 case GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_PROGRESS_FILE:
268 if (filename[left - 1] != '\0')
269 {
270 GNUNET_break (0);
271 break;
272 }
273 ds->progress_callback (ds->progress_callback_cls,
274 filename,
275 GNUNET_NO,
276 GNUNET_FS_DIRSCANNER_FILE_START);
277 if (NULL == ds->toplevel)
278 {
279 ds->toplevel = expand_tree (ds->pos, filename, GNUNET_NO);
280 }
281 else
282 { 264 {
283 GNUNET_assert (NULL != ds->pos); 265 case GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_PROGRESS_FILE:
284 (void) expand_tree (ds->pos, filename, GNUNET_NO); 266 if (filename[left - 1] != '\0')
285 } 267 {
286 return GNUNET_OK; 268 GNUNET_break(0);
287 case GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_PROGRESS_DIRECTORY: 269 break;
288 if (filename[left - 1] != '\0') 270 }
289 { 271 ds->progress_callback(ds->progress_callback_cls,
290 GNUNET_break (0); 272 filename,
273 GNUNET_NO,
274 GNUNET_FS_DIRSCANNER_FILE_START);
275 if (NULL == ds->toplevel)
276 {
277 ds->toplevel = expand_tree(ds->pos, filename, GNUNET_NO);
278 }
279 else
280 {
281 GNUNET_assert(NULL != ds->pos);
282 (void)expand_tree(ds->pos, filename, GNUNET_NO);
283 }
284 return GNUNET_OK;
285
286 case GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_PROGRESS_DIRECTORY:
287 if (filename[left - 1] != '\0')
288 {
289 GNUNET_break(0);
290 break;
291 }
292 if (0 == strcmp("..", filename))
293 {
294 if (NULL == ds->pos)
295 {
296 GNUNET_break(0);
297 break;
298 }
299 ds->pos = ds->pos->parent;
300 return GNUNET_OK;
301 }
302 ds->progress_callback(ds->progress_callback_cls,
303 filename,
304 GNUNET_YES,
305 GNUNET_FS_DIRSCANNER_FILE_START);
306 ds->pos = expand_tree(ds->pos, filename, GNUNET_YES);
307 if (NULL == ds->toplevel)
308 ds->toplevel = ds->pos;
309 return GNUNET_OK;
310
311 case GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_ERROR:
291 break; 312 break;
292 } 313
293 if (0 == strcmp ("..", filename)) 314 case GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_SKIP_FILE:
294 { 315 if ('\0' != filename[left - 1])
295 if (NULL == ds->pos)
296 {
297 GNUNET_break (0);
298 break; 316 break;
299 } 317 ds->progress_callback(ds->progress_callback_cls,
300 ds->pos = ds->pos->parent; 318 filename,
319 GNUNET_SYSERR,
320 GNUNET_FS_DIRSCANNER_FILE_IGNORED);
301 return GNUNET_OK; 321 return GNUNET_OK;
302 } 322
303 ds->progress_callback (ds->progress_callback_cls, 323 case GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_COUNTING_DONE:
304 filename, 324 if (0 != left)
305 GNUNET_YES, 325 {
306 GNUNET_FS_DIRSCANNER_FILE_START); 326 GNUNET_break(0);
307 ds->pos = expand_tree (ds->pos, filename, GNUNET_YES); 327 break;
308 if (NULL == ds->toplevel) 328 }
309 ds->toplevel = ds->pos; 329 if (NULL == ds->toplevel)
310 return GNUNET_OK;
311 case GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_ERROR:
312 break;
313 case GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_SKIP_FILE:
314 if ('\0' != filename[left - 1])
315 break;
316 ds->progress_callback (ds->progress_callback_cls,
317 filename,
318 GNUNET_SYSERR,
319 GNUNET_FS_DIRSCANNER_FILE_IGNORED);
320 return GNUNET_OK;
321 case GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_COUNTING_DONE:
322 if (0 != left)
323 {
324 GNUNET_break (0);
325 break;
326 }
327 if (NULL == ds->toplevel)
328 break;
329 ds->progress_callback (ds->progress_callback_cls,
330 NULL,
331 GNUNET_SYSERR,
332 GNUNET_FS_DIRSCANNER_ALL_COUNTED);
333 ds->pos = ds->toplevel;
334 if (GNUNET_YES == ds->pos->is_directory)
335 ds->pos = advance (ds->pos);
336 return GNUNET_OK;
337 case GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_META_DATA: {
338 size_t nlen;
339 const char *end;
340
341 if (NULL == ds->pos)
342 {
343 GNUNET_break (0);
344 break;
345 }
346 end = memchr (filename, 0, left);
347 if (NULL == end)
348 {
349 GNUNET_break (0);
350 break;
351 }
352 end++;
353 nlen = end - filename;
354 left -= nlen;
355 if (0 != strcmp (filename, ds->pos->filename))
356 {
357 GNUNET_break (0);
358 break;
359 }
360 ds->progress_callback (ds->progress_callback_cls,
361 filename,
362 GNUNET_YES,
363 GNUNET_FS_DIRSCANNER_EXTRACT_FINISHED);
364 if (0 < left)
365 {
366 ds->pos->meta = GNUNET_CONTAINER_meta_data_deserialize (end, left);
367 if (NULL == ds->pos->meta)
368 {
369 GNUNET_break (0);
370 break; 330 break;
371 } 331 ds->progress_callback(ds->progress_callback_cls,
372 /* having full filenames is too dangerous; always make sure we clean them up */ 332 NULL,
373 GNUNET_CONTAINER_meta_data_delete (ds->pos->meta, 333 GNUNET_SYSERR,
374 EXTRACTOR_METATYPE_FILENAME, 334 GNUNET_FS_DIRSCANNER_ALL_COUNTED);
375 NULL, 335 ds->pos = ds->toplevel;
376 0); 336 if (GNUNET_YES == ds->pos->is_directory)
377 /* instead, put in our 'safer' original filename */ 337 ds->pos = advance(ds->pos);
378 GNUNET_CONTAINER_meta_data_insert (ds->pos->meta, 338 return GNUNET_OK;
379 "<libgnunetfs>", 339
380 EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME, 340 case GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_META_DATA: {
381 EXTRACTOR_METAFORMAT_UTF8, 341 size_t nlen;
382 "text/plain", 342 const char *end;
383 ds->pos->short_filename, 343
384 strlen (ds->pos->short_filename) + 1); 344 if (NULL == ds->pos)
385 } 345 {
386 ds->pos->ksk_uri = GNUNET_FS_uri_ksk_create_from_meta_data (ds->pos->meta); 346 GNUNET_break(0);
387 ds->pos = advance (ds->pos); 347 break;
388 return GNUNET_OK; 348 }
389 } 349 end = memchr(filename, 0, left);
390 case GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_FINISHED: 350 if (NULL == end)
391 if (NULL != ds->pos) 351 {
392 { 352 GNUNET_break(0);
393 GNUNET_break (0); 353 break;
394 break; 354 }
355 end++;
356 nlen = end - filename;
357 left -= nlen;
358 if (0 != strcmp(filename, ds->pos->filename))
359 {
360 GNUNET_break(0);
361 break;
362 }
363 ds->progress_callback(ds->progress_callback_cls,
364 filename,
365 GNUNET_YES,
366 GNUNET_FS_DIRSCANNER_EXTRACT_FINISHED);
367 if (0 < left)
368 {
369 ds->pos->meta = GNUNET_CONTAINER_meta_data_deserialize(end, left);
370 if (NULL == ds->pos->meta)
371 {
372 GNUNET_break(0);
373 break;
374 }
375 /* having full filenames is too dangerous; always make sure we clean them up */
376 GNUNET_CONTAINER_meta_data_delete(ds->pos->meta,
377 EXTRACTOR_METATYPE_FILENAME,
378 NULL,
379 0);
380 /* instead, put in our 'safer' original filename */
381 GNUNET_CONTAINER_meta_data_insert(ds->pos->meta,
382 "<libgnunetfs>",
383 EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME,
384 EXTRACTOR_METAFORMAT_UTF8,
385 "text/plain",
386 ds->pos->short_filename,
387 strlen(ds->pos->short_filename) + 1);
388 }
389 ds->pos->ksk_uri = GNUNET_FS_uri_ksk_create_from_meta_data(ds->pos->meta);
390 ds->pos = advance(ds->pos);
391 return GNUNET_OK;
395 } 392 }
396 if (0 != left) 393
397 { 394 case GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_FINISHED:
398 GNUNET_break (0); 395 if (NULL != ds->pos)
396 {
397 GNUNET_break(0);
398 break;
399 }
400 if (0 != left)
401 {
402 GNUNET_break(0);
403 break;
404 }
405 if (NULL == ds->toplevel)
406 break;
407 ds->stop_task = GNUNET_SCHEDULER_add_now(&finish_scan, ds);
408 return GNUNET_OK;
409
410 default:
411 GNUNET_break(0);
399 break; 412 break;
400 } 413 }
401 if (NULL == ds->toplevel) 414 ds->progress_callback(ds->progress_callback_cls,
402 break; 415 NULL,
403 ds->stop_task = GNUNET_SCHEDULER_add_now (&finish_scan, ds); 416 GNUNET_SYSERR,
404 return GNUNET_OK; 417 GNUNET_FS_DIRSCANNER_INTERNAL_ERROR);
405 default:
406 GNUNET_break (0);
407 break;
408 }
409 ds->progress_callback (ds->progress_callback_cls,
410 NULL,
411 GNUNET_SYSERR,
412 GNUNET_FS_DIRSCANNER_INTERNAL_ERROR);
413 return GNUNET_OK; 418 return GNUNET_OK;
414} 419}
415 420
@@ -420,17 +425,17 @@ process_helper_msgs (void *cls, const struct GNUNET_MessageHeader *msg)
420 * @param cls the 'struct GNUNET_FS_DirScanner' callback. 425 * @param cls the 'struct GNUNET_FS_DirScanner' callback.
421 */ 426 */
422static void 427static void
423helper_died_cb (void *cls) 428helper_died_cb(void *cls)
424{ 429{
425 struct GNUNET_FS_DirScanner *ds = cls; 430 struct GNUNET_FS_DirScanner *ds = cls;
426 431
427 ds->helper = NULL; 432 ds->helper = NULL;
428 if (NULL != ds->stop_task) 433 if (NULL != ds->stop_task)
429 return; /* normal death, was finished */ 434 return; /* normal death, was finished */
430 ds->progress_callback (ds->progress_callback_cls, 435 ds->progress_callback(ds->progress_callback_cls,
431 NULL, 436 NULL,
432 GNUNET_SYSERR, 437 GNUNET_SYSERR,
433 GNUNET_FS_DIRSCANNER_INTERNAL_ERROR); 438 GNUNET_FS_DIRSCANNER_INTERNAL_ERROR);
434} 439}
435 440
436 441
@@ -446,48 +451,48 @@ helper_died_cb (void *cls)
446 * @return directory scanner object to be used for controlling the scanner 451 * @return directory scanner object to be used for controlling the scanner
447 */ 452 */
448struct GNUNET_FS_DirScanner * 453struct GNUNET_FS_DirScanner *
449GNUNET_FS_directory_scan_start (const char *filename, 454GNUNET_FS_directory_scan_start(const char *filename,
450 int disable_extractor, 455 int disable_extractor,
451 const char *ex, 456 const char *ex,
452 GNUNET_FS_DirScannerProgressCallback cb, 457 GNUNET_FS_DirScannerProgressCallback cb,
453 void *cb_cls) 458 void *cb_cls)
454{ 459{
455 struct stat sbuf; 460 struct stat sbuf;
456 char *filename_expanded; 461 char *filename_expanded;
457 struct GNUNET_FS_DirScanner *ds; 462 struct GNUNET_FS_DirScanner *ds;
458 463
459 if (0 != stat (filename, &sbuf)) 464 if (0 != stat(filename, &sbuf))
460 return NULL; 465 return NULL;
461 filename_expanded = GNUNET_STRINGS_filename_expand (filename); 466 filename_expanded = GNUNET_STRINGS_filename_expand(filename);
462 if (NULL == filename_expanded) 467 if (NULL == filename_expanded)
463 return NULL; 468 return NULL;
464 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 469 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
465 "Starting to scan directory `%s'\n", 470 "Starting to scan directory `%s'\n",
466 filename_expanded); 471 filename_expanded);
467 ds = GNUNET_new (struct GNUNET_FS_DirScanner); 472 ds = GNUNET_new(struct GNUNET_FS_DirScanner);
468 ds->progress_callback = cb; 473 ds->progress_callback = cb;
469 ds->progress_callback_cls = cb_cls; 474 ds->progress_callback_cls = cb_cls;
470 ds->filename_expanded = filename_expanded; 475 ds->filename_expanded = filename_expanded;
471 if (disable_extractor) 476 if (disable_extractor)
472 ds->ex_arg = GNUNET_strdup ("-"); 477 ds->ex_arg = GNUNET_strdup("-");
473 else 478 else
474 ds->ex_arg = (NULL != ex) ? GNUNET_strdup (ex) : NULL; 479 ds->ex_arg = (NULL != ex) ? GNUNET_strdup(ex) : NULL;
475 ds->args[0] = "gnunet-helper-fs-publish"; 480 ds->args[0] = "gnunet-helper-fs-publish";
476 ds->args[1] = ds->filename_expanded; 481 ds->args[1] = ds->filename_expanded;
477 ds->args[2] = ds->ex_arg; 482 ds->args[2] = ds->ex_arg;
478 ds->args[3] = NULL; 483 ds->args[3] = NULL;
479 ds->helper = GNUNET_HELPER_start (GNUNET_NO, 484 ds->helper = GNUNET_HELPER_start(GNUNET_NO,
480 "gnunet-helper-fs-publish", 485 "gnunet-helper-fs-publish",
481 ds->args, 486 ds->args,
482 &process_helper_msgs, 487 &process_helper_msgs,
483 &helper_died_cb, 488 &helper_died_cb,
484 ds); 489 ds);
485 if (NULL == ds->helper) 490 if (NULL == ds->helper)
486 { 491 {
487 GNUNET_free (filename_expanded); 492 GNUNET_free(filename_expanded);
488 GNUNET_free (ds); 493 GNUNET_free(ds);
489 return NULL; 494 return NULL;
490 } 495 }
491 return ds; 496 return ds;
492} 497}
493 498