fixing common off-by-one error with respect to maximum message size
[oweals/gnunet.git] / src / fs / fs_file_information.c
index c04c5a56ea263f20567e12b6bf5afa2198878368..2e9b7b6678426e86ff9df19dc12f6b433ee0bae2 100644 (file)
@@ -627,6 +627,19 @@ GNUNET_FS_file_information_create_from_directory (struct GNUNET_FS_Handle *h,
 }
 
 
+/**
+ * Test if a given entry represents a directory.
+ *
+ * @param ent check if this FI represents a directory
+ * @return GNUNET_YES if so, GNUNET_NO if not
+ */
+int
+GNUNET_FS_file_information_is_directory (struct GNUNET_FS_FileInformation *ent)
+{
+  return ent->is_directory;
+}
+
+
 /**
  * Create an entry for an empty directory in a publish-structure.
  * This function should be used by applications for which the
@@ -719,7 +732,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,
@@ -728,6 +743,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;
@@ -736,6 +752,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,
@@ -744,6 +761,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;
@@ -768,7 +786,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 */
@@ -786,6 +806,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);
@@ -805,6 +826,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);
     }