plane hacking
[oweals/gnunet.git] / src / fs / fs_file_information.c
index 367061cae578fa3bb3398ca759024a57793fc2bf..b9b5928dbce737cee3aabc5c4fb0a4d417660571 100644 (file)
@@ -4,7 +4,7 @@
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
-     by the Free Software Foundation; either version 2, or (at your
+     by the Free Software Foundation; either version 3, or (at your
      option) any later version.
 
      GNUnet is distributed in the hope that it will be useful, but
@@ -181,6 +181,8 @@ GNUNET_FS_file_information_create_from_file (struct GNUNET_FS_Handle *h,
                                                       anonymity,
                                                       priority,
                                                       expirationTime);
+  if (ret == NULL)
+    return NULL;
   ret->h = h;
   ret->filename = GNUNET_strdup (filename);
   fn = filename;
@@ -612,8 +614,9 @@ GNUNET_FS_file_information_create_from_directory (struct GNUNET_FS_Handle *h,
       dc.entries = dc.entries->next;
     }
   fn = filename;
-  while (NULL != (ss = strstr (fn,
-                              DIR_SEPARATOR_STR)))
+  while ( (NULL != (ss = strstr (fn,
+                                DIR_SEPARATOR_STR))) &&
+         (strlen (ss) > 1) )
     fn = ss + 1;
   GNUNET_CONTAINER_meta_data_insert (ret->meta,
                                     "<gnunet>",
@@ -732,7 +735,9 @@ GNUNET_FS_file_information_inspect (struct GNUNET_FS_FileInformation *dir,
                                    void *proc_cls)
 {
   struct GNUNET_FS_FileInformation *pos;
+  int no;
 
+  no = GNUNET_NO;
   if (GNUNET_OK !=
       proc (proc_cls, 
            dir,
@@ -741,6 +746,7 @@ GNUNET_FS_file_information_inspect (struct GNUNET_FS_FileInformation *dir,
            &dir->keywords,
            &dir->anonymity,
            &dir->priority,
+           (dir->is_directory) ? &no : &dir->data.file.do_index,
            &dir->expirationTime,
            &dir->client_info))
     return;
@@ -749,6 +755,7 @@ GNUNET_FS_file_information_inspect (struct GNUNET_FS_FileInformation *dir,
   pos = dir->data.dir.entries;
   while (pos != NULL)
     {
+      no = GNUNET_NO;
       if (GNUNET_OK != 
          proc (proc_cls, 
                pos,
@@ -757,6 +764,7 @@ GNUNET_FS_file_information_inspect (struct GNUNET_FS_FileInformation *dir,
                &pos->keywords,
                &pos->anonymity,
                &pos->priority,
+               (dir->is_directory) ? &no : &dir->data.file.do_index,
                &pos->expirationTime,
                &pos->client_info))
        break;
@@ -781,7 +789,9 @@ GNUNET_FS_file_information_destroy (struct GNUNET_FS_FileInformation *fi,
                                    void *cleaner_cls)
 {
   struct GNUNET_FS_FileInformation *pos;
+  int no;
 
+  no = GNUNET_NO;
   if (fi->is_directory)
     {
       /* clean up directory */
@@ -799,6 +809,7 @@ GNUNET_FS_file_information_destroy (struct GNUNET_FS_FileInformation *fi,
                 &fi->keywords,
                 &fi->anonymity,
                 &fi->priority,
+                &no,
                 &fi->expirationTime,
                 &fi->client_info);
       GNUNET_free_non_null (fi->data.dir.dir_data);
@@ -818,6 +829,7 @@ GNUNET_FS_file_information_destroy (struct GNUNET_FS_FileInformation *fi,
                 &fi->keywords,
                 &fi->anonymity,
                 &fi->priority,
+                &fi->data.file.do_index,
                 &fi->expirationTime,
                 &fi->client_info);
     }