aboutsummaryrefslogtreecommitdiff
path: root/src/fs/gnunet-helper-fs-publish.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/fs/gnunet-helper-fs-publish.c')
-rw-r--r--src/fs/gnunet-helper-fs-publish.c35
1 files changed, 29 insertions, 6 deletions
diff --git a/src/fs/gnunet-helper-fs-publish.c b/src/fs/gnunet-helper-fs-publish.c
index 2e63b12a8..6c2c76fe9 100644
--- a/src/fs/gnunet-helper-fs-publish.c
+++ b/src/fs/gnunet-helper-fs-publish.c
@@ -82,10 +82,12 @@ struct ScanTreeNode
82}; 82};
83 83
84 84
85#if HAVE_LIBEXTRACTOR
85/** 86/**
86 * List of libextractor plugins to use for extracting. 87 * List of libextractor plugins to use for extracting.
87 */ 88 */
88static struct EXTRACTOR_PluginList *plugins; 89static struct EXTRACTOR_PluginList *plugins;
90#endif
89 91
90/** 92/**
91 * File descriptor we use for IPC with the parent. 93 * File descriptor we use for IPC with the parent.
@@ -93,6 +95,7 @@ static struct EXTRACTOR_PluginList *plugins;
93static int output_stream; 95static int output_stream;
94 96
95 97
98#if HAVE_LIBEXTRACTOR
96/** 99/**
97 * Add meta data that libextractor finds to our meta data 100 * Add meta data that libextractor finds to our meta data
98 * container. 101 * container.
@@ -111,9 +114,13 @@ static int output_stream;
111 * @return always 0 to continue extracting 114 * @return always 0 to continue extracting
112 */ 115 */
113static int 116static int
114add_to_md (void *cls, const char *plugin_name, enum EXTRACTOR_MetaType type, 117add_to_md (void *cls,
115 enum EXTRACTOR_MetaFormat format, const char *data_mime_type, 118 const char *plugin_name,
116 const char *data, size_t data_len) 119 enum EXTRACTOR_MetaType type,
120 enum EXTRACTOR_MetaFormat format,
121 const char *data_mime_type,
122 const char *data,
123 size_t data_len)
117{ 124{
118 struct GNUNET_CONTAINER_MetaData *md = cls; 125 struct GNUNET_CONTAINER_MetaData *md = cls;
119 126
@@ -134,6 +141,7 @@ add_to_md (void *cls, const char *plugin_name, enum EXTRACTOR_MetaType type,
134 } 141 }
135 return 0; 142 return 0;
136} 143}
144#endif
137 145
138 146
139/** 147/**
@@ -151,7 +159,7 @@ free_tree (struct ScanTreeNode *tree)
151 if (NULL != tree->parent) 159 if (NULL != tree->parent)
152 GNUNET_CONTAINER_DLL_remove (tree->parent->children_head, 160 GNUNET_CONTAINER_DLL_remove (tree->parent->children_head,
153 tree->parent->children_tail, 161 tree->parent->children_tail,
154 tree); 162 tree);
155 GNUNET_free (tree->filename); 163 GNUNET_free (tree->filename);
156 GNUNET_free (tree); 164 GNUNET_free (tree);
157} 165}
@@ -383,7 +391,13 @@ extract_files (struct ScanTreeNode *item)
383 391
384 /* this is the expensive operation, *afterwards* we'll check for aborts */ 392 /* this is the expensive operation, *afterwards* we'll check for aborts */
385 meta = GNUNET_CONTAINER_meta_data_create (); 393 meta = GNUNET_CONTAINER_meta_data_create ();
386 EXTRACTOR_extract (plugins, item->filename, NULL, 0, &add_to_md, meta); 394#if HAVE_LIBEXTRACTOR
395 EXTRACTOR_extract (plugins,
396 item->filename,
397 NULL, 0,
398 &add_to_md,
399 meta);
400#endif
387 slen = strlen (item->filename) + 1; 401 slen = strlen (item->filename) + 1;
388 size = GNUNET_CONTAINER_meta_data_get_serialized_size (meta); 402 size = GNUNET_CONTAINER_meta_data_get_serialized_size (meta);
389 if (-1 == size) 403 if (-1 == size)
@@ -525,10 +539,12 @@ main (int argc,
525 if ( (NULL == ex) || 539 if ( (NULL == ex) ||
526 (0 != strcmp (ex, "-")) ) 540 (0 != strcmp (ex, "-")) )
527 { 541 {
542#if HAVE_LIBEXTRACTOR
528 plugins = EXTRACTOR_plugin_add_defaults (EXTRACTOR_OPTION_DEFAULT_POLICY); 543 plugins = EXTRACTOR_plugin_add_defaults (EXTRACTOR_OPTION_DEFAULT_POLICY);
529 if (NULL != ex) 544 if (NULL != ex)
530 plugins = EXTRACTOR_plugin_add_config (plugins, ex, 545 plugins = EXTRACTOR_plugin_add_config (plugins, ex,
531 EXTRACTOR_OPTION_DEFAULT_POLICY); 546 EXTRACTOR_OPTION_DEFAULT_POLICY);
547#endif
532 } 548 }
533 549
534 /* scan tree to find out how much work there is to be done */ 550 /* scan tree to find out how much work there is to be done */
@@ -536,7 +552,9 @@ main (int argc,
536 &root)) 552 &root))
537 { 553 {
538 (void) write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_ERROR, NULL, 0); 554 (void) write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_ERROR, NULL, 0);
555#if HAVE_LIBEXTRACTOR
539 EXTRACTOR_plugin_remove_all (plugins); 556 EXTRACTOR_plugin_remove_all (plugins);
557#endif
540#if WINDOWS 558#if WINDOWS
541 GNUNET_free ((void*) argv); 559 GNUNET_free ((void*) argv);
542#endif 560#endif
@@ -547,7 +565,9 @@ main (int argc,
547 if (GNUNET_OK != 565 if (GNUNET_OK !=
548 write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_COUNTING_DONE, NULL, 0)) 566 write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_COUNTING_DONE, NULL, 0))
549 { 567 {
568#if HAVE_LIBEXTRACTOR
550 EXTRACTOR_plugin_remove_all (plugins); 569 EXTRACTOR_plugin_remove_all (plugins);
570#endif
551#if WINDOWS 571#if WINDOWS
552 GNUNET_free ((void*) argv); 572 GNUNET_free ((void*) argv);
553#endif 573#endif
@@ -560,7 +580,9 @@ main (int argc,
560 { 580 {
561 (void) write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_ERROR, NULL, 0); 581 (void) write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_ERROR, NULL, 0);
562 free_tree (root); 582 free_tree (root);
583#if HAVE_LIBEXTRACTOR
563 EXTRACTOR_plugin_remove_all (plugins); 584 EXTRACTOR_plugin_remove_all (plugins);
585#endif
564#if WINDOWS 586#if WINDOWS
565 GNUNET_free ((void*) argv); 587 GNUNET_free ((void*) argv);
566#endif 588#endif
@@ -570,7 +592,9 @@ main (int argc,
570 } 592 }
571 /* enable "clean" shutdown by telling parent that we are done */ 593 /* enable "clean" shutdown by telling parent that we are done */
572 (void) write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_FINISHED, NULL, 0); 594 (void) write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_FINISHED, NULL, 0);
595#if HAVE_LIBEXTRACTOR
573 EXTRACTOR_plugin_remove_all (plugins); 596 EXTRACTOR_plugin_remove_all (plugins);
597#endif
574#if WINDOWS 598#if WINDOWS
575 GNUNET_free ((void*) argv); 599 GNUNET_free ((void*) argv);
576#endif 600#endif
@@ -578,4 +602,3 @@ main (int argc,
578} 602}
579 603
580/* end of gnunet-helper-fs-publish.c */ 604/* end of gnunet-helper-fs-publish.c */
581