diff options
-rw-r--r-- | src/fs/Makefile.am | 4 | ||||
-rw-r--r-- | src/fs/fs_file_information.c | 59 | ||||
-rw-r--r-- | src/fs/gnunet-helper-fs-publish.c | 35 | ||||
-rw-r--r-- | src/include/gnunet_fs_service.h | 15 |
4 files changed, 33 insertions, 80 deletions
diff --git a/src/fs/Makefile.am b/src/fs/Makefile.am index ccbffc355..99b8f2def 100644 --- a/src/fs/Makefile.am +++ b/src/fs/Makefile.am | |||
@@ -44,8 +44,7 @@ libgnunetfs_la_SOURCES = \ | |||
44 | libgnunetfs_la_LIBADD = \ | 44 | libgnunetfs_la_LIBADD = \ |
45 | $(top_builddir)/src/datastore/libgnunetdatastore.la \ | 45 | $(top_builddir)/src/datastore/libgnunetdatastore.la \ |
46 | $(top_builddir)/src/util/libgnunetutil.la \ | 46 | $(top_builddir)/src/util/libgnunetutil.la \ |
47 | -lextractor \ | 47 | $(GN_LIBINTL) $(XLIB) -lunistring -lextractor |
48 | $(GN_LIBINTL) $(XLIB) -lunistring | ||
49 | 48 | ||
50 | libgnunetfs_la_LDFLAGS = \ | 49 | libgnunetfs_la_LDFLAGS = \ |
51 | $(GN_LIB_LDFLAGS) $(WINFLAGS) \ | 50 | $(GN_LIB_LDFLAGS) $(WINFLAGS) \ |
@@ -114,7 +113,6 @@ gnunet_publish_DEPENDENCIES = \ | |||
114 | gnunet_helper_fs_publish_SOURCES = \ | 113 | gnunet_helper_fs_publish_SOURCES = \ |
115 | gnunet-helper-fs-publish.c | 114 | gnunet-helper-fs-publish.c |
116 | gnunet_helper_fs_publish_LDADD = \ | 115 | gnunet_helper_fs_publish_LDADD = \ |
117 | $(top_builddir)/src/fs/libgnunetfs.la \ | ||
118 | $(top_builddir)/src/util/libgnunetutil.la \ | 116 | $(top_builddir)/src/util/libgnunetutil.la \ |
119 | -lextractor \ | 117 | -lextractor \ |
120 | $(GN_LIBINTL) | 118 | $(GN_LIBINTL) |
diff --git a/src/fs/fs_file_information.c b/src/fs/fs_file_information.c index 01ce6f54b..a633dcb7b 100644 --- a/src/fs/fs_file_information.c +++ b/src/fs/fs_file_information.c | |||
@@ -22,10 +22,6 @@ | |||
22 | * @file fs/fs_file_information.c | 22 | * @file fs/fs_file_information.c |
23 | * @brief Manage information for publishing directory hierarchies | 23 | * @brief Manage information for publishing directory hierarchies |
24 | * @author Christian Grothoff | 24 | * @author Christian Grothoff |
25 | * | ||
26 | * TODO: | ||
27 | * - metadata filename clean up code | ||
28 | * - metadata/ksk generation for directories from contained files | ||
29 | */ | 25 | */ |
30 | #include "platform.h" | 26 | #include "platform.h" |
31 | #include <extractor.h> | 27 | #include <extractor.h> |
@@ -35,61 +31,6 @@ | |||
35 | 31 | ||
36 | 32 | ||
37 | /** | 33 | /** |
38 | * Add meta data that libextractor finds to our meta data | ||
39 | * container. | ||
40 | * | ||
41 | * @param cls closure, our meta data container | ||
42 | * @param plugin_name name of the plugin that produced this value; | ||
43 | * special values can be used (i.e. '<zlib>' for zlib being | ||
44 | * used in the main libextractor library and yielding | ||
45 | * meta data). | ||
46 | * @param type libextractor-type describing the meta data | ||
47 | * @param format basic format information about data | ||
48 | * @param data_mime_type mime-type of data (not of the original file); | ||
49 | * can be NULL (if mime-type is not known) | ||
50 | * @param data actual meta-data found | ||
51 | * @param data_len number of bytes in data | ||
52 | * @return always 0 to continue extracting | ||
53 | */ | ||
54 | static int | ||
55 | add_to_md (void *cls, const char *plugin_name, enum EXTRACTOR_MetaType type, | ||
56 | enum EXTRACTOR_MetaFormat format, const char *data_mime_type, | ||
57 | const char *data, size_t data_len) | ||
58 | { | ||
59 | struct GNUNET_CONTAINER_MetaData *md = cls; | ||
60 | |||
61 | (void) GNUNET_CONTAINER_meta_data_insert (md, plugin_name, type, format, | ||
62 | data_mime_type, data, data_len); | ||
63 | return 0; | ||
64 | } | ||
65 | |||
66 | |||
67 | /** | ||
68 | * Extract meta-data from a file. | ||
69 | * | ||
70 | * @return GNUNET_SYSERR on error, otherwise the number | ||
71 | * of meta-data items obtained | ||
72 | */ | ||
73 | int | ||
74 | GNUNET_FS_meta_data_extract_from_file (struct GNUNET_CONTAINER_MetaData *md, | ||
75 | const char *filename, | ||
76 | struct EXTRACTOR_PluginList *extractors) | ||
77 | { | ||
78 | int old; | ||
79 | |||
80 | if (filename == NULL) | ||
81 | return GNUNET_SYSERR; | ||
82 | if (extractors == NULL) | ||
83 | return 0; | ||
84 | old = GNUNET_CONTAINER_meta_data_iterate (md, NULL, NULL); | ||
85 | GNUNET_assert (old >= 0); | ||
86 | EXTRACTOR_extract (extractors, filename, NULL, 0, &add_to_md, md); | ||
87 | return (GNUNET_CONTAINER_meta_data_iterate (md, NULL, NULL) - old); | ||
88 | } | ||
89 | |||
90 | |||
91 | |||
92 | /** | ||
93 | * Obtain the name under which this file information | 34 | * Obtain the name under which this file information |
94 | * structure is stored on disk. Only works for top-level | 35 | * structure is stored on disk. Only works for top-level |
95 | * file information structures. | 36 | * file information structures. |
diff --git a/src/fs/gnunet-helper-fs-publish.c b/src/fs/gnunet-helper-fs-publish.c index a1a2c1a80..546c2ba88 100644 --- a/src/fs/gnunet-helper-fs-publish.c +++ b/src/fs/gnunet-helper-fs-publish.c | |||
@@ -88,6 +88,36 @@ static struct EXTRACTOR_PluginList *plugins; | |||
88 | 88 | ||
89 | 89 | ||
90 | /** | 90 | /** |
91 | * Add meta data that libextractor finds to our meta data | ||
92 | * container. | ||
93 | * | ||
94 | * @param cls closure, our meta data container | ||
95 | * @param plugin_name name of the plugin that produced this value; | ||
96 | * special values can be used (i.e. '<zlib>' for zlib being | ||
97 | * used in the main libextractor library and yielding | ||
98 | * meta data). | ||
99 | * @param type libextractor-type describing the meta data | ||
100 | * @param format basic format information about data | ||
101 | * @param data_mime_type mime-type of data (not of the original file); | ||
102 | * can be NULL (if mime-type is not known) | ||
103 | * @param data actual meta-data found | ||
104 | * @param data_len number of bytes in data | ||
105 | * @return always 0 to continue extracting | ||
106 | */ | ||
107 | static int | ||
108 | add_to_md (void *cls, const char *plugin_name, enum EXTRACTOR_MetaType type, | ||
109 | enum EXTRACTOR_MetaFormat format, const char *data_mime_type, | ||
110 | const char *data, size_t data_len) | ||
111 | { | ||
112 | struct GNUNET_CONTAINER_MetaData *md = cls; | ||
113 | |||
114 | (void) GNUNET_CONTAINER_meta_data_insert (md, plugin_name, type, format, | ||
115 | data_mime_type, data, data_len); | ||
116 | return 0; | ||
117 | } | ||
118 | |||
119 | |||
120 | /** | ||
91 | * Free memory of the 'tree' structure | 121 | * Free memory of the 'tree' structure |
92 | * | 122 | * |
93 | * @param tree tree to free | 123 | * @param tree tree to free |
@@ -322,9 +352,8 @@ extract_files (struct ScanTreeNode *item) | |||
322 | 352 | ||
323 | /* this is the expensive operation, *afterwards* we'll check for aborts */ | 353 | /* this is the expensive operation, *afterwards* we'll check for aborts */ |
324 | meta = GNUNET_CONTAINER_meta_data_create (); | 354 | meta = GNUNET_CONTAINER_meta_data_create (); |
325 | GNUNET_FS_meta_data_extract_from_file (meta, | 355 | if (NULL != plugins) |
326 | item->filename, | 356 | EXTRACTOR_extract (plugins, item->filename, NULL, 0, &add_to_md, meta); |
327 | plugins); | ||
328 | slen = strlen (item->filename) + 1; | 357 | slen = strlen (item->filename) + 1; |
329 | size = GNUNET_CONTAINER_meta_data_get_serialized_size (meta); | 358 | size = GNUNET_CONTAINER_meta_data_get_serialized_size (meta); |
330 | if ( (-1 == size) || | 359 | if ( (-1 == size) || |
diff --git a/src/include/gnunet_fs_service.h b/src/include/gnunet_fs_service.h index a984d8a2d..454a5c953 100644 --- a/src/include/gnunet_fs_service.h +++ b/src/include/gnunet_fs_service.h | |||
@@ -1696,21 +1696,6 @@ GNUNET_FS_stop (struct GNUNET_FS_Handle *h); | |||
1696 | 1696 | ||
1697 | 1697 | ||
1698 | /** | 1698 | /** |
1699 | * Extract meta-data from a file. | ||
1700 | * | ||
1701 | * @param md metadata to set | ||
1702 | * @param filename name of file to inspect | ||
1703 | * @param extractors plugins to use | ||
1704 | * @return GNUNET_SYSERR on error, otherwise the number | ||
1705 | * of meta-data items obtained | ||
1706 | */ | ||
1707 | int | ||
1708 | GNUNET_FS_meta_data_extract_from_file (struct GNUNET_CONTAINER_MetaData *md, | ||
1709 | const char *filename, | ||
1710 | struct EXTRACTOR_PluginList *extractors); | ||
1711 | |||
1712 | |||
1713 | /** | ||
1714 | * Function called on entries in a GNUNET_FS_FileInformation publish-structure. | 1699 | * Function called on entries in a GNUNET_FS_FileInformation publish-structure. |
1715 | * | 1700 | * |
1716 | * @param cls closure | 1701 | * @param cls closure |