-fixes
[oweals/gnunet.git] / src / fs / gnunet-helper-fs-publish.c
index 9594c19c2b2588f05dabe65ed2f37b0da7a6280a..4f704640818e46a31fc741770a6dee576fd14267 100644 (file)
@@ -253,10 +253,9 @@ scan_callback (void *cls,
     return GNUNET_SYSERR;
   }
   chld->parent = rc->parent;
-  if (NULL != rc->parent)
-    GNUNET_CONTAINER_DLL_insert (rc->parent->children_head,
-                                rc->parent->children_tail,
-                                chld);
+  GNUNET_CONTAINER_DLL_insert (rc->parent->children_head,
+                              rc->parent->children_tail,
+                              chld);
   return GNUNET_OK;
 }
 
@@ -299,7 +298,7 @@ preprocess_file (const char *filename,
   item->filename = GNUNET_strdup (filename);
   item->is_directory = (S_ISDIR (sbuf.st_mode)) ? GNUNET_YES : GNUNET_NO;
   item->file_size = (uint64_t) sbuf.st_size;
-  if (item->is_directory)
+  if (item->is_directory == GNUNET_YES)
   {
     struct RecursionContext rc;
 
@@ -335,7 +334,7 @@ extract_files (struct ScanTreeNode *item)
   ssize_t size;
   size_t slen;
 
-  if (item->is_directory)
+  if (item->is_directory == GNUNET_YES)
   {
     /* for directories, we simply only descent, no extraction, no
        progress reporting */
@@ -354,8 +353,7 @@ extract_files (struct ScanTreeNode *item)
     EXTRACTOR_extract (plugins, item->filename, NULL, 0, &add_to_md, meta);
   slen = strlen (item->filename) + 1;
   size = GNUNET_CONTAINER_meta_data_get_serialized_size (meta);
-  if ( (-1 == size) ||
-       (size >= GNUNET_SERVER_MAX_MESSAGE_SIZE - slen) )
+  if (-1 == size)
   {
     /* no meta data */
     GNUNET_CONTAINER_meta_data_destroy (meta);
@@ -371,8 +369,8 @@ extract_files (struct ScanTreeNode *item)
     
     memcpy (buf, item->filename, slen);
     size = GNUNET_CONTAINER_meta_data_serialize (meta,
-                                                &dst, size,
-                                                GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL);
+                                                &dst, size - slen,
+                                                GNUNET_CONTAINER_META_DATA_SERIALIZE_PART);
     GNUNET_CONTAINER_meta_data_destroy (meta);
     if (GNUNET_OK !=
        write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_META_DATA,
@@ -401,6 +399,13 @@ int main(int argc,
   const char *ex;
   struct ScanTreeNode *root;
 
+#if WINDOWS
+  /* We're using stdout to communicate binary data back to the parent; use
+   * binary mode.
+   */
+  _setmode (1, _O_BINARY);
+#endif
+
   /* parse command line */
   if ( (argc != 3) && (argc != 2) )
   {