start fewer FS probes concurrently, run them all in the same task to avoid undue...
[oweals/gnunet.git] / src / fs / fs_directory.c
index 61ed1586f5806ea792eb36219388636a2c096d69..3c5e5a4106dfe13b6fb255d276f155bc78d290f0 100644 (file)
@@ -34,7 +34,7 @@
  */
 #include "platform.h"
 #include "gnunet_fs_service.h"
-#include "fs.h"
+#include "fs_api.h"
 
 /**
  * String that is used to indicate that a file
  * Does the meta-data claim that this is a directory?
  * Checks if the mime-type is that of a GNUnet directory.
  *
- * @return GNUNET_YES if it is, GNUNET_NO if it is not, GNUNET_SYSERR if
- *  we have no mime-type information (treat as 'GNUNET_NO')
+ * @return #GNUNET_YES if it is, #GNUNET_NO if it is not, #GNUNET_SYSERR if
+ *  we have no mime-type information (treat as #GNUNET_NO)
  */
 int
-GNUNET_FS_meta_data_test_for_directory (const struct GNUNET_CONTAINER_MetaData
-                                        *md)
+GNUNET_FS_meta_data_test_for_directory (const struct GNUNET_CONTAINER_MetaData *md)
 {
   char *mime;
   int ret;
 
   if (NULL == md)
     return GNUNET_SYSERR;
-  mime =
-      GNUNET_CONTAINER_meta_data_get_by_type (md, EXTRACTOR_METATYPE_MIMETYPE);
-  if (mime == NULL)
+  mime = GNUNET_CONTAINER_meta_data_get_by_type (md, EXTRACTOR_METATYPE_MIMETYPE);
+  if (NULL == mime)
     return GNUNET_SYSERR;
-  ret = (0 == strcmp (mime, GNUNET_FS_DIRECTORY_MIME)) ? GNUNET_YES : GNUNET_NO;
+  ret = (0 == strcasecmp (mime, GNUNET_FS_DIRECTORY_MIME)) ? GNUNET_YES : GNUNET_NO;
   GNUNET_free (mime);
   return ret;
 }
@@ -72,7 +70,7 @@ GNUNET_FS_meta_data_test_for_directory (const struct GNUNET_CONTAINER_MetaData
 /**
  * Set the MIMETYPE information for the given
  * metadata to "application/gnunet-directory".
- * 
+ *
  * @param md metadata to add mimetype to
  */
 void
@@ -124,7 +122,7 @@ struct GetFullDataClosure
  *        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 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
@@ -197,11 +195,7 @@ GNUNET_FS_directory_list_contents (size_t size, const void *data,
   if ((offset == 0) &&
       ((size < 8 + sizeof (uint32_t)) ||
        (0 != memcmp (cdata, GNUNET_FS_DIRECTORY_MAGIC, 8))))
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                _("MAGIC mismatch.  This is not a GNUnet directory.\n"));
     return GNUNET_SYSERR;
-  }
   pos = offset;
   if (offset == 0)
   {
@@ -341,7 +335,7 @@ struct GNUNET_FS_DirectoryBuilder
 
 /**
  * Create a directory builder.
- * 
+ *
  * @param mdir metadata for the directory
  */
 struct GNUNET_FS_DirectoryBuilder *
@@ -350,7 +344,7 @@ GNUNET_FS_directory_builder_create (const struct GNUNET_CONTAINER_MetaData
 {
   struct GNUNET_FS_DirectoryBuilder *ret;
 
-  ret = GNUNET_malloc (sizeof (struct GNUNET_FS_DirectoryBuilder));
+  ret = GNUNET_new (struct GNUNET_FS_DirectoryBuilder);
   if (mdir != NULL)
     ret->meta = GNUNET_CONTAINER_meta_data_duplicate (mdir);
   else
@@ -362,7 +356,7 @@ GNUNET_FS_directory_builder_create (const struct GNUNET_CONTAINER_MetaData
 
 /**
  * Add an entry to a directory.
- * 
+ *
  * @param bld directory to extend
  * @param uri uri of the entry (must not be a KSK)
  * @param md metadata of the entry