gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r11558 - in gnunet: . src/fs src/include src/util


From: gnunet
Subject: [GNUnet-SVN] r11558 - in gnunet: . src/fs src/include src/util
Date: Mon, 31 May 2010 10:24:42 +0200

Author: grothoff
Date: 2010-05-31 10:24:42 +0200 (Mon, 31 May 2010)
New Revision: 11558

Added:
   gnunet/src/fs/test_fs_file_information_meta_data_image.jpg
Removed:
   gnunet/src/util/test_container_meta_data_image.jpg
Modified:
   gnunet/TODO
   gnunet/src/fs/fs_file_information.c
   gnunet/src/fs/test_fs_file_information.c
   gnunet/src/include/gnunet_container_lib.h
   gnunet/src/include/gnunet_fs_service.h
   gnunet/src/util/Makefile.am
   gnunet/src/util/container_meta_data.c
   gnunet/src/util/test_container_meta_data.c
Log:
done

Modified: gnunet/TODO
===================================================================
--- gnunet/TODO 2010-05-31 08:09:28 UTC (rev 11557)
+++ gnunet/TODO 2010-05-31 08:24:42 UTC (rev 11558)
@@ -135,11 +135,6 @@
   - figure out where in the GUI we should show active uploads/unindex 
operations and allow aborts
 * SETUP:
   - design & implement new setup tool
-* UTIL:
-  - remove dependency on GNU LE from util (linker-wise) so that
-    not all binaries are linked against LE! (header is OK!)
-    (seems that only GNUNET_CONTAINER_meta_data_extract_from_file
-    needs to be moved to another location, i.e. FS/file-info for this!)
 
 0.9.0pre3:
 * TRACEKIT: [MW]

Modified: gnunet/src/fs/fs_file_information.c
===================================================================
--- gnunet/src/fs/fs_file_information.c 2010-05-31 08:09:28 UTC (rev 11557)
+++ gnunet/src/fs/fs_file_information.c 2010-05-31 08:24:42 UTC (rev 11558)
@@ -36,6 +36,74 @@
 
 
 /**
+ * Add meta data that libextractor finds to our meta data
+ * container.
+ *
+ * @param cls closure, our meta data container
+ * @param plugin_name name of the plugin that produced this value;
+ *        special values can be used (i.e. '<zlib>' for zlib being
+ *        used in the main libextractor library and yielding
+ *        meta data).
+ * @param type libextractor-type describing the meta data
+ * @param format basic format information about data
+ * @param data_mime_type mime-type of data (not of the original file);
+ *        can be NULL (if mime-type is not known)
+ * @param data actual meta-data found
+ * @param data_len number of bytes in data
+ * @return always 0 to continue extracting
+ */
+static int
+add_to_md(void *cls,
+         const char *plugin_name,
+         enum EXTRACTOR_MetaType type,
+         enum EXTRACTOR_MetaFormat format,
+         const char *data_mime_type,
+         const char *data,
+         size_t data_len)
+{
+  struct GNUNET_CONTAINER_MetaData *md = cls;
+  (void) GNUNET_CONTAINER_meta_data_insert (md,
+                                           plugin_name,
+                                           type,
+                                           format,
+                                           data_mime_type,
+                                           data,
+                                           data_len);
+  return 0;
+}
+
+
+/**
+ * Extract meta-data from a file.
+ *
+ * @return GNUNET_SYSERR on error, otherwise the number
+ *   of meta-data items obtained
+ */
+int
+GNUNET_FS_meta_data_extract_from_file (struct GNUNET_CONTAINER_MetaData
+                                      *md, const char *filename,
+                                      struct EXTRACTOR_PluginList *
+                                      extractors)
+{
+  int old;
+
+  if (filename == NULL)
+    return GNUNET_SYSERR;
+  if (extractors == NULL)
+    return 0;
+  old = GNUNET_CONTAINER_meta_data_iterate (md, NULL, NULL);
+  GNUNET_assert (old >= 0);
+  EXTRACTOR_extract (extractors, 
+                    filename,
+                    NULL, 0,
+                    &add_to_md,
+                    md);
+  return (GNUNET_CONTAINER_meta_data_iterate (md, NULL, NULL) - old);
+}
+
+
+
+/**
  * Obtain the name under which this file information
  * structure is stored on disk.  Only works for top-level
  * file information structures.
@@ -350,9 +418,9 @@
   else
     {
       meta = GNUNET_CONTAINER_meta_data_create ();
-      GNUNET_CONTAINER_meta_data_extract_from_file (meta,
-                                                   filename,
-                                                   dsc->extractors);
+      GNUNET_FS_meta_data_extract_from_file (meta,
+                                            filename,
+                                            dsc->extractors);
       // FIXME: remove path from filename in metadata!
       keywords = GNUNET_FS_uri_ksk_create_from_meta_data (meta);
       ksk_uri = GNUNET_FS_uri_ksk_canonicalize (keywords);

Modified: gnunet/src/fs/test_fs_file_information.c
===================================================================
--- gnunet/src/fs/test_fs_file_information.c    2010-05-31 08:09:28 UTC (rev 
11557)
+++ gnunet/src/fs/test_fs_file_information.c    2010-05-31 08:24:42 UTC (rev 
11558)
@@ -155,6 +155,62 @@
 }
 
 
+static int
+testThumbnail ()
+{
+  struct GNUNET_CONTAINER_MetaData *m;
+  struct GNUNET_CONTAINER_MetaData *d;
+  struct EXTRACTOR_PluginList *ex;
+  unsigned char *thumb;
+  size_t size;
+  char *date;
+
+  ex = EXTRACTOR_plugin_add_config (NULL, "thumbnailgtk", 
EXTRACTOR_OPTION_DEFAULT_POLICY);
+  if (ex == NULL)
+    {
+      fprintf (stderr,
+               "Test incomplete, have no GTK thumbnail extractor 
available.\n");
+      return 0;                 /* can not test, no thumbnailer */
+    }
+  ex = EXTRACTOR_plugin_add_config (ex, "mime", 
EXTRACTOR_OPTION_DEFAULT_POLICY);
+  m = GNUNET_CONTAINER_meta_data_create ();
+  if (3 != GNUNET_FS_meta_data_extract_from_file (m,
+                                                 
"test_fs_file_information_meta_data_image.jpg",
+                                                 ex))
+    {
+      GNUNET_break (0);
+      EXTRACTOR_plugin_remove_all (ex);
+      GNUNET_CONTAINER_meta_data_destroy (m);
+      return 1;
+    }
+  EXTRACTOR_plugin_remove_all (ex);
+  d = GNUNET_CONTAINER_meta_data_duplicate (m);
+  GNUNET_CONTAINER_meta_data_destroy (m);
+  thumb = NULL;
+  size = GNUNET_CONTAINER_meta_data_get_thumbnail (d, &thumb);
+  if (size == 0)
+    {
+      GNUNET_break (0);
+      GNUNET_CONTAINER_meta_data_destroy (d);
+      return 1;
+    }
+  GNUNET_free (thumb);
+  GNUNET_CONTAINER_meta_data_add_publication_date (d);
+  date = GNUNET_CONTAINER_meta_data_get_by_type (d,
+                                                 
EXTRACTOR_METATYPE_PUBLICATION_DATE);
+  if (date == NULL)
+    {
+      GNUNET_break (0);
+      GNUNET_CONTAINER_meta_data_destroy (d);
+      return 1;
+    }
+  GNUNET_free (date);
+  GNUNET_CONTAINER_meta_data_destroy (d);
+  return 0;
+}
+
+
+
 int
 main (int argc, char *argv[])
 {
@@ -178,6 +234,8 @@
                    "WARNING",
 #endif
                    NULL);
+  if (0 != testThumbnail ())
+    return 1;
   GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1,
                       argvx, "test-fs-file_information",
                      "nohelp", options, &run, NULL);

Copied: gnunet/src/fs/test_fs_file_information_meta_data_image.jpg (from rev 
11556, gnunet/src/util/test_container_meta_data_image.jpg)
===================================================================
(Binary files differ)

Modified: gnunet/src/include/gnunet_container_lib.h
===================================================================
--- gnunet/src/include/gnunet_container_lib.h   2010-05-31 08:09:28 UTC (rev 
11557)
+++ gnunet/src/include/gnunet_container_lib.h   2010-05-31 08:24:42 UTC (rev 
11558)
@@ -365,21 +365,6 @@
                                          GNUNET_CONTAINER_MetaData
                                          *md, unsigned char **thumb);
 
-/**
- * Extract meta-data from a file.
- *
- * @param md metadata to set
- * @param filename name of file to inspect
- * @param extractors plugins to use
- * @return GNUNET_SYSERR on error, otherwise the number
- *   of meta-data items obtained
- */
-int 
-GNUNET_CONTAINER_meta_data_extract_from_file (struct
-                                             GNUNET_CONTAINER_MetaData
-                                             *md, const char *filename,
-                                             struct EXTRACTOR_PluginList *
-                                             extractors);
 
 
 /**

Modified: gnunet/src/include/gnunet_fs_service.h
===================================================================
--- gnunet/src/include/gnunet_fs_service.h      2010-05-31 08:09:28 UTC (rev 
11557)
+++ gnunet/src/include/gnunet_fs_service.h      2010-05-31 08:24:42 UTC (rev 
11558)
@@ -1574,6 +1574,23 @@
 
 
 /**
+ * Extract meta-data from a file.
+ *
+ * @param md metadata to set
+ * @param filename name of file to inspect
+ * @param extractors plugins to use
+ * @return GNUNET_SYSERR on error, otherwise the number
+ *   of meta-data items obtained
+ */
+int 
+GNUNET_FS_meta_data_extract_from_file (struct
+                                      GNUNET_CONTAINER_MetaData
+                                      *md, const char *filename,
+                                      struct EXTRACTOR_PluginList *
+                                      extractors);
+
+
+/**
  * Function called on entries in a GNUNET_FS_FileInformation publish-structure.
  *
  * @param cls closure

Modified: gnunet/src/util/Makefile.am
===================================================================
--- gnunet/src/util/Makefile.am 2010-05-31 08:09:28 UTC (rev 11557)
+++ gnunet/src/util/Makefile.am 2010-05-31 08:24:42 UTC (rev 11558)
@@ -71,7 +71,7 @@
 libgnunetutil_la_LIBADD = \
   $(GCLIBADD) $(WINLIB) \
   $(LIBGCRYPT_LIBS) \
-  -lgmp -lltdl -lz -lextractor $(XLIB)
+  -lgmp -lltdl -lz $(XLIB)
 
 libgnunetutil_la_LDFLAGS = \
   $(GN_LIB_LDFLAGS) \
@@ -373,7 +373,6 @@
   program_lib_strnlen.c \
   program_lib_mempcpy.c \
   test_configuration_data.conf \
-  test_container_meta_data_image.jpg \
   test_program_data.conf \
   test_pseudonym_data.conf \
   test_resolver_api_data.conf \

Modified: gnunet/src/util/container_meta_data.c
===================================================================
--- gnunet/src/util/container_meta_data.c       2010-05-31 08:09:28 UTC (rev 
11557)
+++ gnunet/src/util/container_meta_data.c       2010-05-31 08:24:42 UTC (rev 
11558)
@@ -608,73 +608,8 @@
 }
 
 
-/**
- * Add meta data that libextractor finds to our meta data
- * container.
- *
- * @param cls closure, our meta data container
- * @param plugin_name name of the plugin that produced this value;
- *        special values can be used (i.e. '<zlib>' for zlib being
- *        used in the main libextractor library and yielding
- *        meta data).
- * @param type libextractor-type describing the meta data
- * @param format basic format information about data
- * @param data_mime_type mime-type of data (not of the original file);
- *        can be NULL (if mime-type is not known)
- * @param data actual meta-data found
- * @param data_len number of bytes in data
- * @return always 0 to continue extracting
- */
-static int
-add_to_md(void *cls,
-         const char *plugin_name,
-         enum EXTRACTOR_MetaType type,
-         enum EXTRACTOR_MetaFormat format,
-         const char *data_mime_type,
-         const char *data,
-         size_t data_len)
-{
-  struct GNUNET_CONTAINER_MetaData *md = cls;
-  (void) GNUNET_CONTAINER_meta_data_insert (md,
-                                           plugin_name,
-                                           type,
-                                           format,
-                                           data_mime_type,
-                                           data,
-                                           data_len);
-  return 0;
-}
 
-
 /**
- * Extract meta-data from a file.
- *
- * @return GNUNET_SYSERR on error, otherwise the number
- *   of meta-data items obtained
- */
-int
-GNUNET_CONTAINER_meta_data_extract_from_file (struct GNUNET_CONTAINER_MetaData
-                                              *md, const char *filename,
-                                              struct EXTRACTOR_PluginList *
-                                              extractors)
-{
-  unsigned int old;
-
-  if (filename == NULL)
-    return GNUNET_SYSERR;
-  if (extractors == NULL)
-    return 0;
-  old = md->item_count;
-  EXTRACTOR_extract (extractors, 
-                    filename,
-                    NULL, 0,
-                    &add_to_md,
-                    md);
-  return (int) (md->item_count - old);
-}
-
-
-/**
  * Try to compress the given block of data.
  *
  * @param data block to compress; if compression

Modified: gnunet/src/util/test_container_meta_data.c
===================================================================
--- gnunet/src/util/test_container_meta_data.c  2010-05-31 08:09:28 UTC (rev 
11557)
+++ gnunet/src/util/test_container_meta_data.c  2010-05-31 08:24:42 UTC (rev 
11558)
@@ -231,61 +231,6 @@
 }
 
 
-static int
-testThumbnail ()
-{
-  struct GNUNET_CONTAINER_MetaData *m;
-  struct GNUNET_CONTAINER_MetaData *d;
-  struct EXTRACTOR_PluginList *ex;
-  unsigned char *thumb;
-  size_t size;
-  char *date;
-
-  ex = EXTRACTOR_plugin_add_config (NULL, "thumbnailgtk", 
EXTRACTOR_OPTION_DEFAULT_POLICY);
-  if (ex == NULL)
-    {
-      fprintf (stderr,
-               "Test incomplete, have no GTK thumbnail extractor 
available.\n");
-      return 0;                 /* can not test, no thumbnailer */
-    }
-  ex = EXTRACTOR_plugin_add_config (ex, "mime", 
EXTRACTOR_OPTION_DEFAULT_POLICY);
-  m = GNUNET_CONTAINER_meta_data_create ();
-  if (3 != GNUNET_CONTAINER_meta_data_extract_from_file (m,
-                                                         
"test_container_meta_data_image.jpg",
-                                                         ex))
-    {
-      GNUNET_break (0);
-      EXTRACTOR_plugin_remove_all (ex);
-      GNUNET_CONTAINER_meta_data_destroy (m);
-      return 1;
-    }
-  EXTRACTOR_plugin_remove_all (ex);
-  d = GNUNET_CONTAINER_meta_data_duplicate (m);
-  GNUNET_CONTAINER_meta_data_destroy (m);
-  thumb = NULL;
-  size = GNUNET_CONTAINER_meta_data_get_thumbnail (d, &thumb);
-  if (size == 0)
-    {
-      GNUNET_break (0);
-      GNUNET_CONTAINER_meta_data_destroy (d);
-      return 1;
-    }
-  GNUNET_free (thumb);
-  GNUNET_CONTAINER_meta_data_add_publication_date (d);
-  date = GNUNET_CONTAINER_meta_data_get_by_type (d,
-                                                 
EXTRACTOR_METATYPE_PUBLICATION_DATE);
-  if (date == NULL)
-    {
-      GNUNET_break (0);
-      GNUNET_CONTAINER_meta_data_destroy (d);
-      return 1;
-    }
-  GNUNET_free (date);
-  GNUNET_CONTAINER_meta_data_destroy (d);
-  return 0;
-}
-
-
 int
 main (int argc, char *argv[])
 {
@@ -298,7 +243,6 @@
   for (i = 1; i < 255; i++)
     failureCount += testMetaMore (i);
   failureCount += testMetaLink ();
-  failureCount += testThumbnail ();
 
   if (failureCount != 0)
     return 1;

Deleted: gnunet/src/util/test_container_meta_data_image.jpg
===================================================================
(Binary files differ)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]