diff options
Diffstat (limited to 'src/fs/gnunet-publish.c')
-rw-r--r-- | src/fs/gnunet-publish.c | 530 |
1 files changed, 257 insertions, 273 deletions
diff --git a/src/fs/gnunet-publish.c b/src/fs/gnunet-publish.c index fbf32c2a7..84cbf0aac 100644 --- a/src/fs/gnunet-publish.c +++ b/src/fs/gnunet-publish.c | |||
@@ -67,7 +67,7 @@ static struct GNUNET_FS_Uri *topKeywords; | |||
67 | /** | 67 | /** |
68 | * Options we set for published blocks. | 68 | * Options we set for published blocks. |
69 | */ | 69 | */ |
70 | static struct GNUNET_FS_BlockOptions bo = { {0LL}, 1, 365, 1 }; | 70 | static struct GNUNET_FS_BlockOptions bo = {{0LL}, 1, 365, 1}; |
71 | 71 | ||
72 | /** | 72 | /** |
73 | * Value of URI provided on command-line (when not publishing | 73 | * Value of URI provided on command-line (when not publishing |
@@ -200,8 +200,7 @@ do_stop_task (void *cls) | |||
200 | * field in the GNUNET_FS_ProgressInfo struct. | 200 | * field in the GNUNET_FS_ProgressInfo struct. |
201 | */ | 201 | */ |
202 | static void * | 202 | static void * |
203 | progress_cb (void *cls, | 203 | progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info) |
204 | const struct GNUNET_FS_ProgressInfo *info) | ||
205 | { | 204 | { |
206 | const char *s; | 205 | const char *s; |
207 | char *suri; | 206 | char *suri; |
@@ -214,50 +213,51 @@ progress_cb (void *cls, | |||
214 | if (verbose) | 213 | if (verbose) |
215 | { | 214 | { |
216 | s = GNUNET_STRINGS_relative_time_to_string (info->value.publish.eta, | 215 | s = GNUNET_STRINGS_relative_time_to_string (info->value.publish.eta, |
217 | GNUNET_YES); | 216 | GNUNET_YES); |
218 | FPRINTF (stdout, | 217 | fprintf (stdout, |
219 | _("Publishing `%s' at %llu/%llu (%s remaining)\n"), | 218 | _ ("Publishing `%s' at %llu/%llu (%s remaining)\n"), |
220 | info->value.publish.filename, | 219 | info->value.publish.filename, |
221 | (unsigned long long) info->value.publish.completed, | 220 | (unsigned long long) info->value.publish.completed, |
222 | (unsigned long long) info->value.publish.size, s); | 221 | (unsigned long long) info->value.publish.size, |
222 | s); | ||
223 | } | 223 | } |
224 | break; | 224 | break; |
225 | case GNUNET_FS_STATUS_PUBLISH_PROGRESS_DIRECTORY: | 225 | case GNUNET_FS_STATUS_PUBLISH_PROGRESS_DIRECTORY: |
226 | if (verbose) | 226 | if (verbose) |
227 | { | 227 | { |
228 | s = GNUNET_STRINGS_relative_time_to_string (info->value.publish.specifics.progress_directory.eta, | 228 | s = GNUNET_STRINGS_relative_time_to_string (info->value.publish.specifics |
229 | GNUNET_YES); | 229 | .progress_directory.eta, |
230 | FPRINTF (stdout, | 230 | GNUNET_YES); |
231 | _("Publishing `%s' at %llu/%llu (%s remaining)\n"), | 231 | fprintf (stdout, |
232 | _ ("Publishing `%s' at %llu/%llu (%s remaining)\n"), | ||
232 | info->value.publish.filename, | 233 | info->value.publish.filename, |
233 | (unsigned long long) info->value.publish.specifics.progress_directory.completed, | 234 | (unsigned long long) |
234 | (unsigned long long) info->value.publish.specifics.progress_directory.total, s); | 235 | info->value.publish.specifics.progress_directory.completed, |
236 | (unsigned long long) | ||
237 | info->value.publish.specifics.progress_directory.total, | ||
238 | s); | ||
235 | } | 239 | } |
236 | break; | 240 | break; |
237 | case GNUNET_FS_STATUS_PUBLISH_ERROR: | 241 | case GNUNET_FS_STATUS_PUBLISH_ERROR: |
238 | FPRINTF (stderr, | 242 | fprintf (stderr, |
239 | _("Error publishing: %s.\n"), | 243 | _ ("Error publishing: %s.\n"), |
240 | info->value.publish.specifics.error.message); | 244 | info->value.publish.specifics.error.message); |
241 | ret = 1; | 245 | ret = 1; |
242 | GNUNET_SCHEDULER_shutdown (); | 246 | GNUNET_SCHEDULER_shutdown (); |
243 | break; | 247 | break; |
244 | case GNUNET_FS_STATUS_PUBLISH_COMPLETED: | 248 | case GNUNET_FS_STATUS_PUBLISH_COMPLETED: |
245 | FPRINTF (stdout, | 249 | fprintf (stdout, |
246 | _("Publishing `%s' done.\n"), | 250 | _ ("Publishing `%s' done.\n"), |
247 | info->value.publish.filename); | 251 | info->value.publish.filename); |
248 | suri = GNUNET_FS_uri_to_string (info->value.publish.specifics. | 252 | suri = |
249 | completed.chk_uri); | 253 | GNUNET_FS_uri_to_string (info->value.publish.specifics.completed.chk_uri); |
250 | FPRINTF (stdout, | 254 | fprintf (stdout, _ ("URI is `%s'.\n"), suri); |
251 | _("URI is `%s'.\n"), | ||
252 | suri); | ||
253 | GNUNET_free (suri); | 255 | GNUNET_free (suri); |
254 | if (NULL != info->value.publish.specifics.completed.sks_uri) | 256 | if (NULL != info->value.publish.specifics.completed.sks_uri) |
255 | { | 257 | { |
256 | suri = GNUNET_FS_uri_to_string (info->value.publish.specifics. | 258 | suri = GNUNET_FS_uri_to_string ( |
257 | completed.sks_uri); | 259 | info->value.publish.specifics.completed.sks_uri); |
258 | FPRINTF (stdout, | 260 | fprintf (stdout, _ ("Namespace URI is `%s'.\n"), suri); |
259 | _("Namespace URI is `%s'.\n"), | ||
260 | suri); | ||
261 | GNUNET_free (suri); | 261 | GNUNET_free (suri); |
262 | } | 262 | } |
263 | if (NULL == info->value.publish.pctx) | 263 | if (NULL == info->value.publish.pctx) |
@@ -270,33 +270,25 @@ progress_cb (void *cls, | |||
270 | GNUNET_break (NULL == pc); | 270 | GNUNET_break (NULL == pc); |
271 | return NULL; | 271 | return NULL; |
272 | case GNUNET_FS_STATUS_UNINDEX_START: | 272 | case GNUNET_FS_STATUS_UNINDEX_START: |
273 | FPRINTF (stderr, | 273 | fprintf (stderr, "%s", _ ("Starting cleanup after abort\n")); |
274 | "%s", | ||
275 | _("Starting cleanup after abort\n")); | ||
276 | return NULL; | 274 | return NULL; |
277 | case GNUNET_FS_STATUS_UNINDEX_PROGRESS: | 275 | case GNUNET_FS_STATUS_UNINDEX_PROGRESS: |
278 | return NULL; | 276 | return NULL; |
279 | case GNUNET_FS_STATUS_UNINDEX_COMPLETED: | 277 | case GNUNET_FS_STATUS_UNINDEX_COMPLETED: |
280 | FPRINTF (stderr, | 278 | fprintf (stderr, "%s", _ ("Cleanup after abort completed.\n")); |
281 | "%s", | ||
282 | _("Cleanup after abort completed.\n")); | ||
283 | GNUNET_FS_unindex_stop (info->value.unindex.uc); | 279 | GNUNET_FS_unindex_stop (info->value.unindex.uc); |
284 | return NULL; | 280 | return NULL; |
285 | case GNUNET_FS_STATUS_UNINDEX_ERROR: | 281 | case GNUNET_FS_STATUS_UNINDEX_ERROR: |
286 | FPRINTF (stderr, | 282 | fprintf (stderr, "%s", _ ("Cleanup after abort failed.\n")); |
287 | "%s", | ||
288 | _("Cleanup after abort failed.\n")); | ||
289 | GNUNET_FS_unindex_stop (info->value.unindex.uc); | 283 | GNUNET_FS_unindex_stop (info->value.unindex.uc); |
290 | return NULL; | 284 | return NULL; |
291 | case GNUNET_FS_STATUS_UNINDEX_STOPPED: | 285 | case GNUNET_FS_STATUS_UNINDEX_STOPPED: |
292 | return NULL; | 286 | return NULL; |
293 | default: | 287 | default: |
294 | FPRINTF (stderr, | 288 | fprintf (stderr, _ ("Unexpected status: %d\n"), info->status); |
295 | _("Unexpected status: %d\n"), | ||
296 | info->status); | ||
297 | return NULL; | 289 | return NULL; |
298 | } | 290 | } |
299 | return ""; /* non-null */ | 291 | return ""; /* non-null */ |
300 | } | 292 | } |
301 | 293 | ||
302 | 294 | ||
@@ -319,7 +311,8 @@ meta_printer (void *cls, | |||
319 | enum EXTRACTOR_MetaType type, | 311 | enum EXTRACTOR_MetaType type, |
320 | enum EXTRACTOR_MetaFormat format, | 312 | enum EXTRACTOR_MetaFormat format, |
321 | const char *data_mime_type, | 313 | const char *data_mime_type, |
322 | const char *data, size_t data_size) | 314 | const char *data, |
315 | size_t data_size) | ||
323 | { | 316 | { |
324 | if ((EXTRACTOR_METAFORMAT_UTF8 != format) && | 317 | if ((EXTRACTOR_METAFORMAT_UTF8 != format) && |
325 | (EXTRACTOR_METAFORMAT_C_STRING != format)) | 318 | (EXTRACTOR_METAFORMAT_C_STRING != format)) |
@@ -327,15 +320,9 @@ meta_printer (void *cls, | |||
327 | if (EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME == type) | 320 | if (EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME == type) |
328 | return 0; | 321 | return 0; |
329 | #if HAVE_LIBEXTRACTOR | 322 | #if HAVE_LIBEXTRACTOR |
330 | FPRINTF (stdout, | 323 | fprintf (stdout, "\t%s - %s\n", EXTRACTOR_metatype_to_string (type), data); |
331 | "\t%s - %s\n", | ||
332 | EXTRACTOR_metatype_to_string (type), | ||
333 | data); | ||
334 | #else | 324 | #else |
335 | FPRINTF (stdout, | 325 | fprintf (stdout, "\t%d - %s\n", type, data); |
336 | "\t%d - %s\n", | ||
337 | type, | ||
338 | data); | ||
339 | #endif | 326 | #endif |
340 | return 0; | 327 | return 0; |
341 | } | 328 | } |
@@ -350,11 +337,9 @@ meta_printer (void *cls, | |||
350 | * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to abort | 337 | * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to abort |
351 | */ | 338 | */ |
352 | static int | 339 | static int |
353 | keyword_printer (void *cls, | 340 | keyword_printer (void *cls, const char *keyword, int is_mandatory) |
354 | const char *keyword, | ||
355 | int is_mandatory) | ||
356 | { | 341 | { |
357 | FPRINTF (stdout, "\t%s\n", keyword); | 342 | fprintf (stdout, "\t%s\n", keyword); |
358 | return GNUNET_OK; | 343 | return GNUNET_OK; |
359 | } | 344 | } |
360 | 345 | ||
@@ -392,8 +377,7 @@ publish_inspector (void *cls, | |||
392 | 377 | ||
393 | if (cls == fi) | 378 | if (cls == fi) |
394 | return GNUNET_OK; | 379 | return GNUNET_OK; |
395 | if ( (disable_extractor) && | 380 | if ((disable_extractor) && (NULL != *uri)) |
396 | (NULL != *uri) ) | ||
397 | { | 381 | { |
398 | GNUNET_FS_uri_destroy (*uri); | 382 | GNUNET_FS_uri_destroy (*uri); |
399 | *uri = NULL; | 383 | *uri = NULL; |
@@ -423,29 +407,21 @@ publish_inspector (void *cls, | |||
423 | GNUNET_CONTAINER_meta_data_add_publication_date (m); | 407 | GNUNET_CONTAINER_meta_data_add_publication_date (m); |
424 | if (extract_only) | 408 | if (extract_only) |
425 | { | 409 | { |
426 | fn = GNUNET_CONTAINER_meta_data_get_by_type (m, | 410 | fn = GNUNET_CONTAINER_meta_data_get_by_type ( |
427 | EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME); | 411 | m, |
412 | EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME); | ||
428 | fs = GNUNET_STRINGS_byte_size_fancy (length); | 413 | fs = GNUNET_STRINGS_byte_size_fancy (length); |
429 | FPRINTF (stdout, | 414 | fprintf (stdout, _ ("Meta data for file `%s' (%s)\n"), fn, fs); |
430 | _("Meta data for file `%s' (%s)\n"), | ||
431 | fn, | ||
432 | fs); | ||
433 | GNUNET_CONTAINER_meta_data_iterate (m, &meta_printer, NULL); | 415 | GNUNET_CONTAINER_meta_data_iterate (m, &meta_printer, NULL); |
434 | FPRINTF (stdout, | 416 | fprintf (stdout, _ ("Keywords for file `%s' (%s)\n"), fn, fs); |
435 | _("Keywords for file `%s' (%s)\n"), | ||
436 | fn, | ||
437 | fs); | ||
438 | GNUNET_free (fn); | 417 | GNUNET_free (fn); |
439 | GNUNET_free (fs); | 418 | GNUNET_free (fs); |
440 | if (NULL != *uri) | 419 | if (NULL != *uri) |
441 | GNUNET_FS_uri_ksk_get_keywords (*uri, &keyword_printer, NULL); | 420 | GNUNET_FS_uri_ksk_get_keywords (*uri, &keyword_printer, NULL); |
442 | FPRINTF (stdout, | 421 | fprintf (stdout, "%s", "\n"); |
443 | "%s", | ||
444 | "\n"); | ||
445 | } | 422 | } |
446 | if (GNUNET_YES == GNUNET_FS_meta_data_test_for_directory (m)) | 423 | if (GNUNET_YES == GNUNET_FS_meta_data_test_for_directory (m)) |
447 | GNUNET_FS_file_information_inspect (fi, | 424 | GNUNET_FS_file_information_inspect (fi, &publish_inspector, fi); |
448 | &publish_inspector, fi); | ||
449 | return GNUNET_OK; | 425 | return GNUNET_OK; |
450 | } | 426 | } |
451 | 427 | ||
@@ -466,9 +442,7 @@ uri_sks_continuation (void *cls, | |||
466 | { | 442 | { |
467 | if (NULL != emsg) | 443 | if (NULL != emsg) |
468 | { | 444 | { |
469 | FPRINTF (stderr, | 445 | fprintf (stderr, "%s\n", emsg); |
470 | "%s\n", | ||
471 | emsg); | ||
472 | ret = 1; | 446 | ret = 1; |
473 | } | 447 | } |
474 | GNUNET_SCHEDULER_shutdown (); | 448 | GNUNET_SCHEDULER_shutdown (); |
@@ -493,9 +467,7 @@ uri_ksk_continuation (void *cls, | |||
493 | 467 | ||
494 | if (NULL != emsg) | 468 | if (NULL != emsg) |
495 | { | 469 | { |
496 | FPRINTF (stderr, | 470 | fprintf (stderr, "%s\n", emsg); |
497 | "%s\n", | ||
498 | emsg); | ||
499 | ret = 1; | 471 | ret = 1; |
500 | } | 472 | } |
501 | if (NULL == namespace) | 473 | if (NULL == namespace) |
@@ -505,15 +477,15 @@ uri_ksk_continuation (void *cls, | |||
505 | } | 477 | } |
506 | priv = GNUNET_IDENTITY_ego_get_private_key (namespace); | 478 | priv = GNUNET_IDENTITY_ego_get_private_key (namespace); |
507 | GNUNET_FS_publish_sks (ctx, | 479 | GNUNET_FS_publish_sks (ctx, |
508 | priv, | 480 | priv, |
509 | this_id, | 481 | this_id, |
510 | next_id, | 482 | next_id, |
511 | meta, | 483 | meta, |
512 | uri, | 484 | uri, |
513 | &bo, | 485 | &bo, |
514 | GNUNET_FS_PUBLISH_OPTION_NONE, | 486 | GNUNET_FS_PUBLISH_OPTION_NONE, |
515 | &uri_sks_continuation, | 487 | &uri_sks_continuation, |
516 | NULL); | 488 | NULL); |
517 | } | 489 | } |
518 | 490 | ||
519 | 491 | ||
@@ -536,8 +508,9 @@ get_file_information (struct GNUNET_FS_ShareTreeItem *item) | |||
536 | if (NULL == item->meta) | 508 | if (NULL == item->meta) |
537 | item->meta = GNUNET_CONTAINER_meta_data_create (); | 509 | item->meta = GNUNET_CONTAINER_meta_data_create (); |
538 | GNUNET_CONTAINER_meta_data_delete (item->meta, | 510 | GNUNET_CONTAINER_meta_data_delete (item->meta, |
539 | EXTRACTOR_METATYPE_MIMETYPE, | 511 | EXTRACTOR_METATYPE_MIMETYPE, |
540 | NULL, 0); | 512 | NULL, |
513 | 0); | ||
541 | GNUNET_FS_meta_data_make_directory (item->meta); | 514 | GNUNET_FS_meta_data_make_directory (item->meta); |
542 | if (NULL == item->ksk_uri) | 515 | if (NULL == item->ksk_uri) |
543 | { | 516 | { |
@@ -545,12 +518,15 @@ get_file_information (struct GNUNET_FS_ShareTreeItem *item) | |||
545 | item->ksk_uri = GNUNET_FS_uri_ksk_create_from_args (1, &mime); | 518 | item->ksk_uri = GNUNET_FS_uri_ksk_create_from_args (1, &mime); |
546 | } | 519 | } |
547 | else | 520 | else |
548 | GNUNET_FS_uri_ksk_add_keyword (item->ksk_uri, GNUNET_FS_DIRECTORY_MIME, | 521 | GNUNET_FS_uri_ksk_add_keyword (item->ksk_uri, |
549 | GNUNET_NO); | 522 | GNUNET_FS_DIRECTORY_MIME, |
550 | fi = GNUNET_FS_file_information_create_empty_directory (ctx, NULL, | 523 | GNUNET_NO); |
551 | item->ksk_uri, | 524 | fi = GNUNET_FS_file_information_create_empty_directory (ctx, |
552 | item->meta, | 525 | NULL, |
553 | &bo, item->filename); | 526 | item->ksk_uri, |
527 | item->meta, | ||
528 | &bo, | ||
529 | item->filename); | ||
554 | for (child = item->children_head; child; child = child->next) | 530 | for (child = item->children_head; child; child = child->next) |
555 | { | 531 | { |
556 | fic = get_file_information (child); | 532 | fic = get_file_information (child); |
@@ -559,11 +535,13 @@ get_file_information (struct GNUNET_FS_ShareTreeItem *item) | |||
559 | } | 535 | } |
560 | else | 536 | else |
561 | { | 537 | { |
562 | fi = GNUNET_FS_file_information_create_from_file (ctx, NULL, | 538 | fi = GNUNET_FS_file_information_create_from_file (ctx, |
563 | item->filename, | 539 | NULL, |
564 | item->ksk_uri, item->meta, | 540 | item->filename, |
565 | !do_insert, | 541 | item->ksk_uri, |
566 | &bo); | 542 | item->meta, |
543 | ! do_insert, | ||
544 | &bo); | ||
567 | } | 545 | } |
568 | return fi; | 546 | return fi; |
569 | } | 547 | } |
@@ -585,9 +563,7 @@ directory_trim_complete (struct GNUNET_FS_ShareTreeItem *directory_scan_result) | |||
585 | GNUNET_FS_share_tree_free (directory_scan_result); | 563 | GNUNET_FS_share_tree_free (directory_scan_result); |
586 | if (NULL == fi) | 564 | if (NULL == fi) |
587 | { | 565 | { |
588 | FPRINTF (stderr, | 566 | fprintf (stderr, "%s", _ ("Could not publish\n")); |
589 | "%s", | ||
590 | _("Could not publish\n")); | ||
591 | ret = 1; | 567 | ret = 1; |
592 | GNUNET_SCHEDULER_shutdown (); | 568 | GNUNET_SCHEDULER_shutdown (); |
593 | return; | 569 | return; |
@@ -603,16 +579,17 @@ directory_trim_complete (struct GNUNET_FS_ShareTreeItem *directory_scan_result) | |||
603 | priv = NULL; | 579 | priv = NULL; |
604 | else | 580 | else |
605 | priv = GNUNET_IDENTITY_ego_get_private_key (namespace); | 581 | priv = GNUNET_IDENTITY_ego_get_private_key (namespace); |
606 | pc = GNUNET_FS_publish_start (ctx, fi, | 582 | pc = GNUNET_FS_publish_start (ctx, |
607 | priv, this_id, next_id, | 583 | fi, |
608 | (do_simulate) ? | 584 | priv, |
609 | GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY : | 585 | this_id, |
610 | GNUNET_FS_PUBLISH_OPTION_NONE); | 586 | next_id, |
587 | (do_simulate) | ||
588 | ? GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY | ||
589 | : GNUNET_FS_PUBLISH_OPTION_NONE); | ||
611 | if (NULL == pc) | 590 | if (NULL == pc) |
612 | { | 591 | { |
613 | FPRINTF (stderr, | 592 | fprintf (stderr, "%s", _ ("Could not start publishing.\n")); |
614 | "%s", | ||
615 | _("Could not start publishing.\n")); | ||
616 | ret = 1; | 593 | ret = 1; |
617 | GNUNET_SCHEDULER_shutdown (); | 594 | GNUNET_SCHEDULER_shutdown (); |
618 | return; | 595 | return; |
@@ -633,9 +610,9 @@ directory_trim_complete (struct GNUNET_FS_ShareTreeItem *directory_scan_result) | |||
633 | */ | 610 | */ |
634 | static void | 611 | static void |
635 | directory_scan_cb (void *cls, | 612 | directory_scan_cb (void *cls, |
636 | const char *filename, | 613 | const char *filename, |
637 | int is_directory, | 614 | int is_directory, |
638 | enum GNUNET_FS_DirScannerProgressUpdateReason reason) | 615 | enum GNUNET_FS_DirScannerProgressUpdateReason reason) |
639 | { | 616 | { |
640 | struct GNUNET_FS_ShareTreeItem *directory_scan_result; | 617 | struct GNUNET_FS_ShareTreeItem *directory_scan_result; |
641 | 618 | ||
@@ -645,46 +622,36 @@ directory_scan_cb (void *cls, | |||
645 | if (verbose > 1) | 622 | if (verbose > 1) |
646 | { | 623 | { |
647 | if (is_directory == GNUNET_YES) | 624 | if (is_directory == GNUNET_YES) |
648 | FPRINTF (stdout, | 625 | fprintf (stdout, _ ("Scanning directory `%s'.\n"), filename); |
649 | _("Scanning directory `%s'.\n"), | ||
650 | filename); | ||
651 | else | 626 | else |
652 | FPRINTF (stdout, | 627 | fprintf (stdout, _ ("Scanning file `%s'.\n"), filename); |
653 | _("Scanning file `%s'.\n"), | ||
654 | filename); | ||
655 | } | 628 | } |
656 | break; | 629 | break; |
657 | case GNUNET_FS_DIRSCANNER_FILE_IGNORED: | 630 | case GNUNET_FS_DIRSCANNER_FILE_IGNORED: |
658 | FPRINTF (stderr, | 631 | fprintf (stderr, |
659 | _("There was trouble processing file `%s', skipping it.\n"), | 632 | _ ("There was trouble processing file `%s', skipping it.\n"), |
660 | filename); | 633 | filename); |
661 | break; | 634 | break; |
662 | case GNUNET_FS_DIRSCANNER_ALL_COUNTED: | 635 | case GNUNET_FS_DIRSCANNER_ALL_COUNTED: |
663 | if (verbose) | 636 | if (verbose) |
664 | FPRINTF (stdout, | 637 | fprintf (stdout, "%s", _ ("Preprocessing complete.\n")); |
665 | "%s", | ||
666 | _("Preprocessing complete.\n")); | ||
667 | break; | 638 | break; |
668 | case GNUNET_FS_DIRSCANNER_EXTRACT_FINISHED: | 639 | case GNUNET_FS_DIRSCANNER_EXTRACT_FINISHED: |
669 | if (verbose > 2) | 640 | if (verbose > 2) |
670 | FPRINTF (stdout, | 641 | fprintf (stdout, |
671 | _("Extracting meta data from file `%s' complete.\n"), | 642 | _ ("Extracting meta data from file `%s' complete.\n"), |
672 | filename); | 643 | filename); |
673 | break; | 644 | break; |
674 | case GNUNET_FS_DIRSCANNER_FINISHED: | 645 | case GNUNET_FS_DIRSCANNER_FINISHED: |
675 | if (verbose > 1) | 646 | if (verbose > 1) |
676 | FPRINTF (stdout, | 647 | fprintf (stdout, "%s", _ ("Meta data extraction has finished.\n")); |
677 | "%s", | ||
678 | _("Meta data extraction has finished.\n")); | ||
679 | directory_scan_result = GNUNET_FS_directory_scan_get_result (ds); | 648 | directory_scan_result = GNUNET_FS_directory_scan_get_result (ds); |
680 | ds = NULL; | 649 | ds = NULL; |
681 | GNUNET_FS_share_tree_trim (directory_scan_result); | 650 | GNUNET_FS_share_tree_trim (directory_scan_result); |
682 | directory_trim_complete (directory_scan_result); | 651 | directory_trim_complete (directory_scan_result); |
683 | break; | 652 | break; |
684 | case GNUNET_FS_DIRSCANNER_INTERNAL_ERROR: | 653 | case GNUNET_FS_DIRSCANNER_INTERNAL_ERROR: |
685 | FPRINTF (stdout, | 654 | fprintf (stdout, "%s", _ ("Error scanning directory.\n")); |
686 | "%s", | ||
687 | _("Error scanning directory.\n")); | ||
688 | ret = 1; | 655 | ret = 1; |
689 | GNUNET_SCHEDULER_shutdown (); | 656 | GNUNET_SCHEDULER_shutdown (); |
690 | break; | 657 | break; |
@@ -708,12 +675,9 @@ identity_continuation (const char *args0) | |||
708 | char *ex; | 675 | char *ex; |
709 | char *emsg; | 676 | char *emsg; |
710 | 677 | ||
711 | if ( (NULL != pseudonym) && | 678 | if ((NULL != pseudonym) && (NULL == namespace)) |
712 | (NULL == namespace) ) | ||
713 | { | 679 | { |
714 | FPRINTF (stderr, | 680 | fprintf (stderr, _ ("Selected pseudonym `%s' unknown\n"), pseudonym); |
715 | _("Selected pseudonym `%s' unknown\n"), | ||
716 | pseudonym); | ||
717 | ret = 1; | 681 | ret = 1; |
718 | GNUNET_SCHEDULER_shutdown (); | 682 | GNUNET_SCHEDULER_shutdown (); |
719 | return; | 683 | return; |
@@ -723,17 +687,16 @@ identity_continuation (const char *args0) | |||
723 | emsg = NULL; | 687 | emsg = NULL; |
724 | if (NULL == (uri = GNUNET_FS_uri_parse (uri_string, &emsg))) | 688 | if (NULL == (uri = GNUNET_FS_uri_parse (uri_string, &emsg))) |
725 | { | 689 | { |
726 | FPRINTF (stderr, | 690 | fprintf (stderr, _ ("Failed to parse URI: %s\n"), emsg); |
727 | _("Failed to parse URI: %s\n"), | ||
728 | emsg); | ||
729 | GNUNET_free (emsg); | 691 | GNUNET_free (emsg); |
730 | ret = 1; | 692 | ret = 1; |
731 | GNUNET_SCHEDULER_shutdown (); | 693 | GNUNET_SCHEDULER_shutdown (); |
732 | return; | 694 | return; |
733 | } | 695 | } |
734 | GNUNET_FS_publish_ksk (ctx, | 696 | GNUNET_FS_publish_ksk (ctx, |
735 | topKeywords, | 697 | topKeywords, |
736 | meta, uri, | 698 | meta, |
699 | uri, | ||
737 | &bo, | 700 | &bo, |
738 | GNUNET_FS_PUBLISH_OPTION_NONE, | 701 | GNUNET_FS_PUBLISH_OPTION_NONE, |
739 | &uri_ksk_continuation, | 702 | &uri_ksk_continuation, |
@@ -743,24 +706,27 @@ identity_continuation (const char *args0) | |||
743 | if (GNUNET_OK != | 706 | if (GNUNET_OK != |
744 | GNUNET_CONFIGURATION_get_value_string (cfg, "FS", "EXTRACTORS", &ex)) | 707 | GNUNET_CONFIGURATION_get_value_string (cfg, "FS", "EXTRACTORS", &ex)) |
745 | ex = NULL; | 708 | ex = NULL; |
746 | if (0 != ACCESS (args0, R_OK)) | 709 | if (0 != access (args0, R_OK)) |
747 | { | 710 | { |
748 | FPRINTF (stderr, | 711 | fprintf (stderr, |
749 | _("Failed to access `%s': %s\n"), | 712 | _ ("Failed to access `%s': %s\n"), |
750 | args0, | 713 | args0, |
751 | STRERROR (errno)); | 714 | strerror (errno)); |
752 | GNUNET_free_non_null (ex); | 715 | GNUNET_free_non_null (ex); |
753 | return; | 716 | return; |
754 | } | 717 | } |
755 | ds = GNUNET_FS_directory_scan_start (args0, | 718 | ds = GNUNET_FS_directory_scan_start (args0, |
756 | disable_extractor, | 719 | disable_extractor, |
757 | ex, | 720 | ex, |
758 | &directory_scan_cb, NULL); | 721 | &directory_scan_cb, |
722 | NULL); | ||
759 | if (NULL == ds) | 723 | if (NULL == ds) |
760 | { | 724 | { |
761 | FPRINTF (stderr, | 725 | fprintf ( |
762 | "%s", | 726 | stderr, |
763 | _("Failed to start meta directory scanner. Is gnunet-helper-publish-fs installed?\n")); | 727 | "%s", |
728 | _ ( | ||
729 | "Failed to start meta directory scanner. Is gnunet-helper-publish-fs installed?\n")); | ||
764 | GNUNET_free_non_null (ex); | 730 | GNUNET_free_non_null (ex); |
765 | return; | 731 | return; |
766 | } | 732 | } |
@@ -781,9 +747,9 @@ identity_continuation (const char *args0) | |||
781 | */ | 747 | */ |
782 | static void | 748 | static void |
783 | identity_cb (void *cls, | 749 | identity_cb (void *cls, |
784 | struct GNUNET_IDENTITY_Ego *ego, | 750 | struct GNUNET_IDENTITY_Ego *ego, |
785 | void **ctx, | 751 | void **ctx, |
786 | const char *name) | 752 | const char *name) |
787 | { | 753 | { |
788 | const char *args0 = cls; | 754 | const char *args0 = cls; |
789 | 755 | ||
@@ -795,7 +761,7 @@ identity_cb (void *cls, | |||
795 | if (NULL == name) | 761 | if (NULL == name) |
796 | return; | 762 | return; |
797 | if (0 == strcmp (name, pseudonym)) | 763 | if (0 == strcmp (name, pseudonym)) |
798 | namespace = ego; | 764 | namespace = ego; |
799 | } | 765 | } |
800 | 766 | ||
801 | 767 | ||
@@ -816,20 +782,20 @@ run (void *cls, | |||
816 | /* check arguments */ | 782 | /* check arguments */ |
817 | if ((NULL != uri_string) && (extract_only)) | 783 | if ((NULL != uri_string) && (extract_only)) |
818 | { | 784 | { |
819 | printf (_("Cannot extract metadata from a URI!\n")); | 785 | printf (_ ("Cannot extract metadata from a URI!\n")); |
820 | ret = -1; | 786 | ret = -1; |
821 | return; | 787 | return; |
822 | } | 788 | } |
823 | if (((NULL == uri_string) || (extract_only)) && | 789 | if (((NULL == uri_string) || (extract_only)) && |
824 | ((NULL == args[0]) || (NULL != args[1]))) | 790 | ((NULL == args[0]) || (NULL != args[1]))) |
825 | { | 791 | { |
826 | printf (_("You must specify one and only one filename for insertion.\n")); | 792 | printf (_ ("You must specify one and only one filename for insertion.\n")); |
827 | ret = -1; | 793 | ret = -1; |
828 | return; | 794 | return; |
829 | } | 795 | } |
830 | if ((NULL != uri_string) && (NULL != args[0])) | 796 | if ((NULL != uri_string) && (NULL != args[0])) |
831 | { | 797 | { |
832 | printf (_("You must NOT specify an URI and a filename.\n")); | 798 | printf (_ ("You must NOT specify an URI and a filename.\n")); |
833 | ret = -1; | 799 | ret = -1; |
834 | return; | 800 | return; |
835 | } | 801 | } |
@@ -837,49 +803,51 @@ run (void *cls, | |||
837 | { | 803 | { |
838 | if (NULL == this_id) | 804 | if (NULL == this_id) |
839 | { | 805 | { |
840 | FPRINTF (stderr, _("Option `%s' is required when using option `%s'.\n"), | 806 | fprintf (stderr, |
841 | "-t", "-P"); | 807 | _ ("Option `%s' is required when using option `%s'.\n"), |
808 | "-t", | ||
809 | "-P"); | ||
842 | ret = -1; | 810 | ret = -1; |
843 | return; | 811 | return; |
844 | } | 812 | } |
845 | } | 813 | } |
846 | else | 814 | else |
847 | { /* ordinary insertion checks */ | 815 | { /* ordinary insertion checks */ |
848 | if (NULL != next_id) | 816 | if (NULL != next_id) |
849 | { | 817 | { |
850 | FPRINTF (stderr, | 818 | fprintf (stderr, |
851 | _("Option `%s' makes no sense without option `%s'.\n"), | 819 | _ ("Option `%s' makes no sense without option `%s'.\n"), |
852 | "-N", "-P"); | 820 | "-N", |
821 | "-P"); | ||
853 | ret = -1; | 822 | ret = -1; |
854 | return; | 823 | return; |
855 | } | 824 | } |
856 | if (NULL != this_id) | 825 | if (NULL != this_id) |
857 | { | 826 | { |
858 | FPRINTF (stderr, | 827 | fprintf (stderr, |
859 | _("Option `%s' makes no sense without option `%s'.\n"), | 828 | _ ("Option `%s' makes no sense without option `%s'.\n"), |
860 | "-t", "-P"); | 829 | "-t", |
830 | "-P"); | ||
861 | ret = -1; | 831 | ret = -1; |
862 | return; | 832 | return; |
863 | } | 833 | } |
864 | } | 834 | } |
865 | cfg = c; | 835 | cfg = c; |
866 | ctx = | 836 | ctx = GNUNET_FS_start (cfg, |
867 | GNUNET_FS_start (cfg, "gnunet-publish", &progress_cb, NULL, | 837 | "gnunet-publish", |
868 | GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END); | 838 | &progress_cb, |
839 | NULL, | ||
840 | GNUNET_FS_FLAGS_NONE, | ||
841 | GNUNET_FS_OPTIONS_END); | ||
869 | if (NULL == ctx) | 842 | if (NULL == ctx) |
870 | { | 843 | { |
871 | FPRINTF (stderr, | 844 | fprintf (stderr, _ ("Could not initialize `%s' subsystem.\n"), "FS"); |
872 | _("Could not initialize `%s' subsystem.\n"), | ||
873 | "FS"); | ||
874 | ret = 1; | 845 | ret = 1; |
875 | return; | 846 | return; |
876 | } | 847 | } |
877 | GNUNET_SCHEDULER_add_shutdown (&do_stop_task, | 848 | GNUNET_SCHEDULER_add_shutdown (&do_stop_task, NULL); |
878 | NULL); | ||
879 | if (NULL != pseudonym) | 849 | if (NULL != pseudonym) |
880 | identity = GNUNET_IDENTITY_connect (cfg, | 850 | identity = GNUNET_IDENTITY_connect (cfg, &identity_cb, args[0]); |
881 | &identity_cb, | ||
882 | args[0]); | ||
883 | else | 851 | else |
884 | identity_continuation (args[0]); | 852 | identity_continuation (args[0]); |
885 | } | 853 | } |
@@ -893,104 +861,120 @@ run (void *cls, | |||
893 | * @return 0 ok, 1 on error | 861 | * @return 0 ok, 1 on error |
894 | */ | 862 | */ |
895 | int | 863 | int |
896 | main (int argc, | 864 | main (int argc, char *const *argv) |
897 | char *const *argv) | ||
898 | { | 865 | { |
899 | struct GNUNET_GETOPT_CommandLineOption options[] = { | 866 | struct GNUNET_GETOPT_CommandLineOption options[] = |
900 | GNUNET_GETOPT_option_uint ('a', | 867 | {GNUNET_GETOPT_option_uint ('a', |
901 | "anonymity", | 868 | "anonymity", |
902 | "LEVEL", | 869 | "LEVEL", |
903 | gettext_noop ("set the desired LEVEL of sender-anonymity"), | 870 | gettext_noop ( |
904 | &bo.anonymity_level), | 871 | "set the desired LEVEL of sender-anonymity"), |
905 | GNUNET_GETOPT_option_flag ('D', | 872 | &bo.anonymity_level), |
906 | "disable-extractor", | 873 | GNUNET_GETOPT_option_flag ( |
907 | gettext_noop ("do not use libextractor to add keywords or metadata"), | 874 | 'D', |
908 | &disable_extractor), | 875 | "disable-extractor", |
909 | GNUNET_GETOPT_option_flag ('E', | 876 | gettext_noop ("do not use libextractor to add keywords or metadata"), |
910 | "enable-creation-time", | 877 | &disable_extractor), |
911 | gettext_noop ("enable adding the creation time to the " | 878 | GNUNET_GETOPT_option_flag ('E', |
912 | "metadata of the uploaded file"), | 879 | "enable-creation-time", |
913 | &enable_creation_time), | 880 | gettext_noop ( |
914 | GNUNET_GETOPT_option_flag ('e', | 881 | "enable adding the creation time to the " |
915 | "extract", | 882 | "metadata of the uploaded file"), |
916 | gettext_noop ("print list of extracted keywords that would " | 883 | &enable_creation_time), |
917 | "be used, but do not perform upload"), | 884 | GNUNET_GETOPT_option_flag ('e', |
918 | &extract_only), | 885 | "extract", |
919 | GNUNET_FS_GETOPT_KEYWORDS ('k', | 886 | gettext_noop ( |
920 | "key", | 887 | "print list of extracted keywords that would " |
921 | "KEYWORD", | 888 | "be used, but do not perform upload"), |
922 | gettext_noop ("add an additional keyword for the top-level " | 889 | &extract_only), |
923 | "file or directory (this option can be specified multiple times)"), | 890 | GNUNET_FS_GETOPT_KEYWORDS ( |
924 | &topKeywords), | 891 | 'k', |
925 | GNUNET_FS_GETOPT_METADATA ('m', | 892 | "key", |
926 | "meta", | 893 | "KEYWORD", |
927 | "TYPE:VALUE", | 894 | gettext_noop ( |
928 | gettext_noop ("set the meta-data for the given TYPE to the given VALUE"), | 895 | "add an additional keyword for the top-level " |
929 | &meta), | 896 | "file or directory (this option can be specified multiple times)"), |
930 | GNUNET_GETOPT_option_flag ('n', | 897 | &topKeywords), |
931 | "noindex", | 898 | GNUNET_FS_GETOPT_METADATA ( |
932 | gettext_noop ("do not index, perform full insertion (stores " | 899 | 'm', |
933 | "entire file in encrypted form in GNUnet database)"), | 900 | "meta", |
934 | &do_insert), | 901 | "TYPE:VALUE", |
935 | GNUNET_GETOPT_option_string ('N', | 902 | gettext_noop ("set the meta-data for the given TYPE to the given VALUE"), |
936 | "next", | 903 | &meta), |
937 | "ID", | 904 | GNUNET_GETOPT_option_flag ( |
938 | gettext_noop ("specify ID of an updated version to be " | 905 | 'n', |
939 | "published in the future (for namespace insertions only)"), | 906 | "noindex", |
940 | &next_id), | 907 | gettext_noop ("do not index, perform full insertion (stores " |
941 | GNUNET_GETOPT_option_uint ('p', | 908 | "entire file in encrypted form in GNUnet database)"), |
942 | "priority", | 909 | &do_insert), |
943 | "PRIORITY", | 910 | GNUNET_GETOPT_option_string ( |
944 | gettext_noop ("specify the priority of the content"), | 911 | 'N', |
945 | &bo.content_priority), | 912 | "next", |
946 | GNUNET_GETOPT_option_string ('P', | 913 | "ID", |
947 | "pseudonym", | 914 | gettext_noop ("specify ID of an updated version to be " |
948 | "NAME", | 915 | "published in the future (for namespace insertions only)"), |
949 | gettext_noop ("publish the files under the pseudonym " | 916 | &next_id), |
950 | "NAME (place file into namespace)"), | 917 | GNUNET_GETOPT_option_uint ('p', |
951 | &pseudonym), | 918 | "priority", |
952 | GNUNET_GETOPT_option_uint ('r', | 919 | "PRIORITY", |
953 | "replication", | 920 | gettext_noop ( |
954 | "LEVEL", | 921 | "specify the priority of the content"), |
955 | gettext_noop ("set the desired replication LEVEL"), | 922 | &bo.content_priority), |
956 | &bo.replication_level), | 923 | GNUNET_GETOPT_option_string ('P', |
957 | GNUNET_GETOPT_option_flag ('s', | 924 | "pseudonym", |
958 | "simulate-only", | 925 | "NAME", |
959 | gettext_noop ("only simulate the process but do not do " | 926 | gettext_noop ( |
960 | "any actual publishing (useful to compute URIs)"), | 927 | "publish the files under the pseudonym " |
961 | &do_simulate), | 928 | "NAME (place file into namespace)"), |
962 | GNUNET_GETOPT_option_string ('t', | 929 | &pseudonym), |
963 | "this", | 930 | GNUNET_GETOPT_option_uint ('r', |
964 | "ID", | 931 | "replication", |
965 | gettext_noop ("set the ID of this version of the publication " | 932 | "LEVEL", |
966 | "(for namespace insertions only)"), | 933 | gettext_noop ( |
967 | &this_id), | 934 | "set the desired replication LEVEL"), |
968 | GNUNET_GETOPT_option_string ('u', | 935 | &bo.replication_level), |
969 | "uri", | 936 | GNUNET_GETOPT_option_flag ('s', |
970 | "URI", | 937 | "simulate-only", |
971 | gettext_noop ("URI to be published (can be used instead of passing a " | 938 | gettext_noop ( |
972 | "file to add keywords to the file with the respective URI)"), | 939 | "only simulate the process but do not do " |
973 | &uri_string), | 940 | "any actual publishing (useful to compute URIs)"), |
974 | 941 | &do_simulate), | |
975 | GNUNET_GETOPT_option_verbose (&verbose), | 942 | GNUNET_GETOPT_option_string ('t', |
976 | 943 | "this", | |
977 | GNUNET_GETOPT_OPTION_END | 944 | "ID", |
978 | }; | 945 | gettext_noop ( |
946 | "set the ID of this version of the publication " | ||
947 | "(for namespace insertions only)"), | ||
948 | &this_id), | ||
949 | GNUNET_GETOPT_option_string ( | ||
950 | 'u', | ||
951 | "uri", | ||
952 | "URI", | ||
953 | gettext_noop ( | ||
954 | "URI to be published (can be used instead of passing a " | ||
955 | "file to add keywords to the file with the respective URI)"), | ||
956 | &uri_string), | ||
957 | |||
958 | GNUNET_GETOPT_option_verbose (&verbose), | ||
959 | |||
960 | GNUNET_GETOPT_OPTION_END}; | ||
979 | bo.expiration_time = | 961 | bo.expiration_time = |
980 | GNUNET_TIME_year_to_time (GNUNET_TIME_get_current_year () + 2); | 962 | GNUNET_TIME_year_to_time (GNUNET_TIME_get_current_year () + 2); |
981 | 963 | ||
982 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) | 964 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) |
983 | return 2; | 965 | return 2; |
984 | ret = (GNUNET_OK == | 966 | ret = |
985 | GNUNET_PROGRAM_run (argc, | 967 | (GNUNET_OK == |
986 | argv, | 968 | GNUNET_PROGRAM_run (argc, |
987 | "gnunet-publish [OPTIONS] FILENAME", | 969 | argv, |
988 | gettext_noop | 970 | "gnunet-publish [OPTIONS] FILENAME", |
989 | ("Publish a file or directory on GNUnet"), | 971 | gettext_noop ("Publish a file or directory on GNUnet"), |
990 | options, | 972 | options, |
991 | &run, | 973 | &run, |
992 | NULL)) ? ret : 1; | 974 | NULL)) |
993 | GNUNET_free ((void*) argv); | 975 | ? ret |
976 | : 1; | ||
977 | GNUNET_free ((void *) argv); | ||
994 | return ret; | 978 | return ret; |
995 | } | 979 | } |
996 | 980 | ||