diff options
Diffstat (limited to 'src/fs/gnunet-helper-fs-publish.c')
-rw-r--r-- | src/fs/gnunet-helper-fs-publish.c | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/src/fs/gnunet-helper-fs-publish.c b/src/fs/gnunet-helper-fs-publish.c index cc58f62b5..214650b0f 100644 --- a/src/fs/gnunet-helper-fs-publish.c +++ b/src/fs/gnunet-helper-fs-publish.c | |||
@@ -125,8 +125,8 @@ add_to_md (void *cls, const char *plugin_name, enum EXTRACTOR_MetaType type, | |||
125 | memcpy (zdata, data, data_len); | 125 | memcpy (zdata, data, data_len); |
126 | zdata[data_len] = '\0'; | 126 | zdata[data_len] = '\0'; |
127 | (void) GNUNET_CONTAINER_meta_data_insert (md, plugin_name, type, format, | 127 | (void) GNUNET_CONTAINER_meta_data_insert (md, plugin_name, type, format, |
128 | data_mime_type, zdata, data_len + 1); | 128 | data_mime_type, zdata, data_len + 1); |
129 | } | 129 | } |
130 | else | 130 | else |
131 | { | 131 | { |
132 | (void) GNUNET_CONTAINER_meta_data_insert (md, plugin_name, type, format, | 132 | (void) GNUNET_CONTAINER_meta_data_insert (md, plugin_name, type, format, |
@@ -141,7 +141,7 @@ add_to_md (void *cls, const char *plugin_name, enum EXTRACTOR_MetaType type, | |||
141 | * | 141 | * |
142 | * @param tree tree to free | 142 | * @param tree tree to free |
143 | */ | 143 | */ |
144 | static void | 144 | static void |
145 | free_tree (struct ScanTreeNode *tree) | 145 | free_tree (struct ScanTreeNode *tree) |
146 | { | 146 | { |
147 | struct ScanTreeNode *pos; | 147 | struct ScanTreeNode *pos; |
@@ -151,7 +151,7 @@ free_tree (struct ScanTreeNode *tree) | |||
151 | if (NULL != tree->parent) | 151 | if (NULL != tree->parent) |
152 | GNUNET_CONTAINER_DLL_remove (tree->parent->children_head, | 152 | GNUNET_CONTAINER_DLL_remove (tree->parent->children_head, |
153 | tree->parent->children_tail, | 153 | tree->parent->children_tail, |
154 | tree); | 154 | tree); |
155 | GNUNET_free (tree->filename); | 155 | GNUNET_free (tree->filename); |
156 | GNUNET_free (tree); | 156 | GNUNET_free (tree); |
157 | } | 157 | } |
@@ -205,7 +205,7 @@ write_message (uint16_t message_type, | |||
205 | struct GNUNET_MessageHeader hdr; | 205 | struct GNUNET_MessageHeader hdr; |
206 | 206 | ||
207 | #if 0 | 207 | #if 0 |
208 | fprintf (stderr, | 208 | fprintf (stderr, |
209 | "Helper sends %u-byte message of type %u\n", | 209 | "Helper sends %u-byte message of type %u\n", |
210 | (unsigned int) (sizeof (struct GNUNET_MessageHeader) + data_length), | 210 | (unsigned int) (sizeof (struct GNUNET_MessageHeader) + data_length), |
211 | (unsigned int) message_type); | 211 | (unsigned int) message_type); |
@@ -295,7 +295,7 @@ scan_callback (void *cls, | |||
295 | * | 295 | * |
296 | * @param filename file or directory to scan | 296 | * @param filename file or directory to scan |
297 | * @param dst where to store the resulting share tree item; | 297 | * @param dst where to store the resulting share tree item; |
298 | * NULL is stored in @a dst upon recoverable errors (#GNUNET_OK is returned) | 298 | * NULL is stored in @a dst upon recoverable errors (#GNUNET_OK is returned) |
299 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 299 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
300 | */ | 300 | */ |
301 | static int | 301 | static int |
@@ -323,7 +323,7 @@ preprocess_file (const char *filename, | |||
323 | 323 | ||
324 | /* Report the progress */ | 324 | /* Report the progress */ |
325 | if (GNUNET_OK != | 325 | if (GNUNET_OK != |
326 | write_message (S_ISDIR (sbuf.st_mode) | 326 | write_message (S_ISDIR (sbuf.st_mode) |
327 | ? GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_PROGRESS_DIRECTORY | 327 | ? GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_PROGRESS_DIRECTORY |
328 | : GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_PROGRESS_FILE, | 328 | : GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_PROGRESS_FILE, |
329 | filename, strlen (filename) + 1)) | 329 | filename, strlen (filename) + 1)) |
@@ -338,9 +338,9 @@ preprocess_file (const char *filename, | |||
338 | 338 | ||
339 | rc.parent = item; | 339 | rc.parent = item; |
340 | rc.stop = GNUNET_NO; | 340 | rc.stop = GNUNET_NO; |
341 | GNUNET_DISK_directory_scan (filename, | 341 | GNUNET_DISK_directory_scan (filename, |
342 | &scan_callback, | 342 | &scan_callback, |
343 | &rc); | 343 | &rc); |
344 | if ( (GNUNET_YES == rc.stop) || | 344 | if ( (GNUNET_YES == rc.stop) || |
345 | (GNUNET_OK != | 345 | (GNUNET_OK != |
346 | write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_PROGRESS_DIRECTORY, | 346 | write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_PROGRESS_DIRECTORY, |
@@ -363,7 +363,7 @@ preprocess_file (const char *filename, | |||
363 | */ | 363 | */ |
364 | static int | 364 | static int |
365 | extract_files (struct ScanTreeNode *item) | 365 | extract_files (struct ScanTreeNode *item) |
366 | { | 366 | { |
367 | struct GNUNET_CONTAINER_MetaData *meta; | 367 | struct GNUNET_CONTAINER_MetaData *meta; |
368 | ssize_t size; | 368 | ssize_t size; |
369 | size_t slen; | 369 | size_t slen; |
@@ -380,7 +380,7 @@ extract_files (struct ScanTreeNode *item) | |||
380 | return GNUNET_SYSERR; | 380 | return GNUNET_SYSERR; |
381 | return GNUNET_OK; | 381 | return GNUNET_OK; |
382 | } | 382 | } |
383 | 383 | ||
384 | /* this is the expensive operation, *afterwards* we'll check for aborts */ | 384 | /* this is the expensive operation, *afterwards* we'll check for aborts */ |
385 | meta = GNUNET_CONTAINER_meta_data_create (); | 385 | meta = GNUNET_CONTAINER_meta_data_create (); |
386 | EXTRACTOR_extract (plugins, item->filename, NULL, 0, &add_to_md, meta); | 386 | EXTRACTOR_extract (plugins, item->filename, NULL, 0, &add_to_md, meta); |
@@ -393,7 +393,7 @@ extract_files (struct ScanTreeNode *item) | |||
393 | if (GNUNET_OK != | 393 | if (GNUNET_OK != |
394 | write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_META_DATA, | 394 | write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_META_DATA, |
395 | item->filename, slen)) | 395 | item->filename, slen)) |
396 | return GNUNET_SYSERR; | 396 | return GNUNET_SYSERR; |
397 | return GNUNET_OK; | 397 | return GNUNET_OK; |
398 | } | 398 | } |
399 | else if (size > (UINT16_MAX - sizeof (struct GNUNET_MessageHeader) - slen)) | 399 | else if (size > (UINT16_MAX - sizeof (struct GNUNET_MessageHeader) - slen)) |
@@ -404,7 +404,7 @@ extract_files (struct ScanTreeNode *item) | |||
404 | { | 404 | { |
405 | char buf[size + slen]; | 405 | char buf[size + slen]; |
406 | char *dst = &buf[slen]; | 406 | char *dst = &buf[slen]; |
407 | 407 | ||
408 | memcpy (buf, item->filename, slen); | 408 | memcpy (buf, item->filename, slen); |
409 | size = GNUNET_CONTAINER_meta_data_serialize (meta, | 409 | size = GNUNET_CONTAINER_meta_data_serialize (meta, |
410 | &dst, size, | 410 | &dst, size, |
@@ -417,7 +417,7 @@ extract_files (struct ScanTreeNode *item) | |||
417 | GNUNET_CONTAINER_meta_data_destroy (meta); | 417 | GNUNET_CONTAINER_meta_data_destroy (meta); |
418 | if (GNUNET_OK != | 418 | if (GNUNET_OK != |
419 | write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_META_DATA, | 419 | write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_META_DATA, |
420 | buf, | 420 | buf, |
421 | slen + size)) | 421 | slen + size)) |
422 | return GNUNET_SYSERR; | 422 | return GNUNET_SYSERR; |
423 | } | 423 | } |
@@ -456,7 +456,7 @@ ignore_sigpipe () | |||
456 | * @param flags flags to use (O_RDONLY or O_WRONLY) | 456 | * @param flags flags to use (O_RDONLY or O_WRONLY) |
457 | */ | 457 | */ |
458 | static void | 458 | static void |
459 | make_dev_zero (int fd, | 459 | make_dev_zero (int fd, |
460 | int flags) | 460 | int flags) |
461 | { | 461 | { |
462 | int z; | 462 | int z; |
@@ -483,7 +483,7 @@ make_dev_zero (int fd, | |||
483 | * otherwise custom plugins to load from LE | 483 | * otherwise custom plugins to load from LE |
484 | * @return 0 on success | 484 | * @return 0 on success |
485 | */ | 485 | */ |
486 | int | 486 | int |
487 | main (int argc, | 487 | main (int argc, |
488 | char *const *argv) | 488 | char *const *argv) |
489 | { | 489 | { |
@@ -502,7 +502,7 @@ main (int argc, | |||
502 | output_stream = 1; /* stdout */ | 502 | output_stream = 1; /* stdout */ |
503 | #else | 503 | #else |
504 | ignore_sigpipe (); | 504 | ignore_sigpipe (); |
505 | /* move stdout to some other FD for IPC, bind | 505 | /* move stdout to some other FD for IPC, bind |
506 | stdout/stderr to /dev/null */ | 506 | stdout/stderr to /dev/null */ |
507 | output_stream = dup (1); | 507 | output_stream = dup (1); |
508 | make_dev_zero (1, O_WRONLY); | 508 | make_dev_zero (1, O_WRONLY); |
@@ -512,7 +512,7 @@ main (int argc, | |||
512 | /* parse command line */ | 512 | /* parse command line */ |
513 | if ( (3 != argc) && (2 != argc) ) | 513 | if ( (3 != argc) && (2 != argc) ) |
514 | { | 514 | { |
515 | FPRINTF (stderr, | 515 | FPRINTF (stderr, |
516 | "%s", | 516 | "%s", |
517 | "gnunet-helper-fs-publish needs exactly one or two arguments\n"); | 517 | "gnunet-helper-fs-publish needs exactly one or two arguments\n"); |
518 | #if WINDOWS | 518 | #if WINDOWS |
@@ -532,7 +532,7 @@ main (int argc, | |||
532 | } | 532 | } |
533 | 533 | ||
534 | /* scan tree to find out how much work there is to be done */ | 534 | /* scan tree to find out how much work there is to be done */ |
535 | if (GNUNET_OK != preprocess_file (filename_expanded, | 535 | if (GNUNET_OK != preprocess_file (filename_expanded, |
536 | &root)) | 536 | &root)) |
537 | { | 537 | { |
538 | (void) write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_ERROR, NULL, 0); | 538 | (void) write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_ERROR, NULL, 0); |
@@ -542,7 +542,7 @@ main (int argc, | |||
542 | #endif | 542 | #endif |
543 | return 2; | 543 | return 2; |
544 | } | 544 | } |
545 | /* signal that we're done counting files, so that a percentage of | 545 | /* signal that we're done counting files, so that a percentage of |
546 | progress can now be calculated */ | 546 | progress can now be calculated */ |
547 | if (GNUNET_OK != | 547 | if (GNUNET_OK != |
548 | write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_COUNTING_DONE, NULL, 0)) | 548 | write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_COUNTING_DONE, NULL, 0)) |
@@ -551,7 +551,7 @@ main (int argc, | |||
551 | #if WINDOWS | 551 | #if WINDOWS |
552 | GNUNET_free ((void*) argv); | 552 | GNUNET_free ((void*) argv); |
553 | #endif | 553 | #endif |
554 | return 3; | 554 | return 3; |
555 | } | 555 | } |
556 | if (NULL != root) | 556 | if (NULL != root) |
557 | { | 557 | { |
@@ -572,7 +572,7 @@ main (int argc, | |||
572 | (void) write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_FINISHED, NULL, 0); | 572 | (void) write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_FINISHED, NULL, 0); |
573 | EXTRACTOR_plugin_remove_all (plugins); | 573 | EXTRACTOR_plugin_remove_all (plugins); |
574 | #if WINDOWS | 574 | #if WINDOWS |
575 | GNUNET_free ((void*) argv); | 575 | GNUNET_free ((void*) argv); |
576 | #endif | 576 | #endif |
577 | return 0; | 577 | return 0; |
578 | } | 578 | } |