tolerate additional IPv4 address now available for gnunet.org
[oweals/gnunet.git] / src / fs / fs_tree.h
index 532c9e9aa2065568bcb7622c6935174521353538..13a8603c5b0a0106910cb7971ae88e298edd2292 100644 (file)
@@ -1,21 +1,21 @@
 /*
      This file is part of GNUnet.
-     (C) 2009 Christian Grothoff (and other contributing authors)
+     Copyright (C) 2009 GNUnet e.V.
 
-     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 3, or (at your
-     option) any later version.
+     GNUnet is free software: you can redistribute it and/or modify it
+     under the terms of the GNU Affero General Public License as published
+     by the Free Software Foundation, either version 3 of the License,
+     or (at your option) any later version.
 
      GNUnet is distributed in the hope that it will be useful, but
      WITHOUT ANY WARRANTY; without even the implied warranty of
      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-     General Public License for more details.
+     Affero General Public License for more details.
+    
+     You should have received a copy of the GNU Affero General Public License
+     along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-     You should have received a copy of the GNU General Public License
-     along with GNUnet; see the file COPYING.  If not, write to the
-     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-     Boston, MA 02111-1307, USA.
+     SPDX-License-Identifier: AGPL3.0-or-later
 */
 
 /**
 #ifndef GNUNET_FS_TREE_H
 #define GNUNET_FS_TREE_H
 
-#include "fs.h"
+#include "fs_api.h"
 
 /**
- * Compute the depth of the CHK tree.  
+ * Compute the depth of the CHK tree.
  *
  * @param flen file length for which to compute the depth
  * @return depth of the tree, always > 0.  A depth of 1 means only a DBLOCK.
  */
-unsigned int GNUNET_FS_compute_depth (uint64_t flen);
+unsigned int
+GNUNET_FS_compute_depth (uint64_t flen);
 
 
 /**
@@ -52,7 +53,8 @@ unsigned int GNUNET_FS_compute_depth (uint64_t flen);
  * @param depth depth of the block.  depth==0 is a DBLOCK.
  * @return number of bytes of payload a subtree of this depth may correspond to
  */
-uint64_t GNUNET_FS_tree_compute_tree_size (unsigned int depth);
+uint64_t
+GNUNET_FS_tree_compute_tree_size (unsigned int depth);
 
 
 /**
@@ -66,8 +68,9 @@ uint64_t GNUNET_FS_tree_compute_tree_size (unsigned int depth);
  * @param depth depth of the node in the tree, 0 for DBLOCK
  * @return number of bytes stored in this node
  */
-size_t GNUNET_FS_tree_calculate_block_size (uint64_t fsize, uint64_t offset,
-                                            unsigned int depth);
+size_t
+GNUNET_FS_tree_calculate_block_size (uint64_t fsize, uint64_t offset,
+                                     unsigned int depth);
 
 
 /**
@@ -130,48 +133,53 @@ typedef void (*GNUNET_FS_TreeProgressCallback) (void *cls, uint64_t offset,
  * @param cls closure for reader, proc, progress and cont
  * @param reader function to call to read plaintext data
  * @param proc function to call on each encrypted block
- * @param progress function to call with progress information 
+ * @param progress function to call with progress information
  * @param cont function to call when done
  * @return tree encoder context
  */
-struct GNUNET_FS_TreeEncoder *GNUNET_FS_tree_encoder_create (struct
-                                                             GNUNET_FS_Handle
-                                                             *h, uint64_t size,
-                                                             void *cls,
-                                                             GNUNET_FS_DataReader
-                                                             reader,
-                                                             GNUNET_FS_TreeBlockProcessor
-                                                             proc,
-                                                             GNUNET_FS_TreeProgressCallback
-                                                             progress,
-                                                             GNUNET_SCHEDULER_Task
-                                                             cont);
+struct GNUNET_FS_TreeEncoder *
+GNUNET_FS_tree_encoder_create (struct GNUNET_FS_Handle *h, uint64_t size,
+                               void *cls, GNUNET_FS_DataReader reader,
+                               GNUNET_FS_TreeBlockProcessor proc,
+                               GNUNET_FS_TreeProgressCallback progress,
+                               GNUNET_SCHEDULER_TaskCallback cont);
 
 
 /**
- * Encrypt the next block of the file (and 
- * call proc and progress accordingly; or 
+ * Encrypt the next block of the file (and
+ * call proc and progress accordingly; or
  * of course "cont" if we have already completed
  * encoding of the entire file).
  *
  * @param te tree encoder to use
  */
-void GNUNET_FS_tree_encoder_next (struct GNUNET_FS_TreeEncoder *te);
+void
+GNUNET_FS_tree_encoder_next (struct GNUNET_FS_TreeEncoder *te);
+
+
+/**
+ * Get the resulting URI from the encoding.
+ *
+ * @param te the tree encoder to clean up
+ * @return uri set to the resulting URI (if encoding finished), NULL otherwise
+ */
+struct GNUNET_FS_Uri *
+GNUNET_FS_tree_encoder_get_uri (struct GNUNET_FS_TreeEncoder *te);
 
 
 /**
  * Clean up a tree encoder and return information
- * about the resulting URI or an error message.
- * 
+ * about possible errors.
+ *
  * @param te the tree encoder to clean up
- * @param uri set to the resulting URI (if encoding finished)
  * @param emsg set to an error message (if an error occured
  *        within the tree encoder; if this function is called
  *        prior to completion and prior to an internal error,
- *        both "*uri" and "*emsg" will be set to NULL).
+ *        both "*emsg" will be set to NULL).
  */
-void GNUNET_FS_tree_encoder_finish (struct GNUNET_FS_TreeEncoder *te,
-                                    struct GNUNET_FS_Uri **uri, char **emsg);
+void
+GNUNET_FS_tree_encoder_finish (struct GNUNET_FS_TreeEncoder *te,
+                               char **emsg);
 
 
 #if 0
@@ -180,25 +188,28 @@ void GNUNET_FS_tree_encoder_finish (struct GNUNET_FS_TreeEncoder *te,
 /**
  * Get data that would be needed to resume
  * the encoding later.
- * 
+ *
  * @param te encoding to resume
  * @param data set to the resume data
  * @param size set to the size of the resume data
  */
-void GNUNET_FS_tree_encoder_resume_get_data (const struct GNUNET_FS_TreeEncoder
-                                             *te, void **data, size_t * size);
+void
+GNUNET_FS_tree_encoder_resume_get_data (const struct GNUNET_FS_TreeEncoder *te,
+                                        void **data, size_t * size);
 
 
 /**
  * Reset tree encoder to point previously
  * obtained for resuming.
- * 
+ *
  * @param te encoding to resume
  * @param data the resume data
  * @param size the size of the resume data
  */
-void GNUNET_FS_tree_encoder_resume (struct GNUNET_FS_TreeEncoder *te,
-                                    const void *data, size_t size);
+void
+GNUNET_FS_tree_encoder_resume (struct GNUNET_FS_TreeEncoder *te,
+                               const void *data, size_t size);
+
 #endif
 
 #endif