-remove trailing whitespace
[oweals/gnunet.git] / src / include / gnunet_bio_lib.h
index f0b486fd21c1e292036b1bc016d10ed3036d872c..2612883963a45dafd4b1406759b38435bbe91ff5 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
@@ -22,6 +22,8 @@
  * @file include/gnunet_bio_lib.h
  * @brief buffered IO API
  * @author Christian Grothoff
+ * @defgroup bio Buffered binary disk IO (with endianess conversion)
+ * @{
  */
 
 #ifndef GNUNET_BIO_LIB_H
@@ -38,6 +40,7 @@ extern "C"
 #endif
 
 /**
+ * @ingroup bio
  * Handle for buffered reading.
  */
 struct GNUNET_BIO_ReadHandle;
@@ -49,7 +52,8 @@ struct GNUNET_BIO_ReadHandle;
  * @param fn file name to be opened
  * @return IO handle on success, NULL on error
  */
-struct GNUNET_BIO_ReadHandle *GNUNET_BIO_read_open (const char *fn);
+struct GNUNET_BIO_ReadHandle *
+GNUNET_BIO_read_open (const char *fn);
 
 
 /**
@@ -58,9 +62,10 @@ struct GNUNET_BIO_ReadHandle *GNUNET_BIO_read_open (const char *fn);
  *
  * @param h file handle
  * @param emsg set to the error message
- * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
+ * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise
  */
-int GNUNET_BIO_read_close (struct GNUNET_BIO_ReadHandle *h, char **emsg);
+int
+GNUNET_BIO_read_close (struct GNUNET_BIO_ReadHandle *h, char **emsg);
 
 
 /**
@@ -70,10 +75,11 @@ int GNUNET_BIO_read_close (struct GNUNET_BIO_ReadHandle *h, char **emsg);
  * @param what describes what is being read (for error message creation)
  * @param result the buffer to write the result to
  * @param len the number of bytes to read
- * @return GNUNET_OK on success, GNUNET_SYSERR on failure
+ * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
  */
-int GNUNET_BIO_read (struct GNUNET_BIO_ReadHandle *h,
-                     const char *what, void *result, size_t len);
+int
+GNUNET_BIO_read (struct GNUNET_BIO_ReadHandle *h, const char *what,
+                 void *result, size_t len);
 
 
 /**
@@ -84,10 +90,12 @@ int GNUNET_BIO_read (struct GNUNET_BIO_ReadHandle *h,
  * @param line line number in the source file
  * @param result the buffer to write the result to
  * @param len the number of bytes to read
- * @return GNUNET_OK on success, GNUNET_SYSERR on failure
+ * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
  */
-int GNUNET_BIO_read_fn (struct GNUNET_BIO_ReadHandle *h,
-                        const char *file, int line, void *result, size_t len);
+int
+GNUNET_BIO_read_fn (struct GNUNET_BIO_ReadHandle *h,
+                    const char *file, int line,
+                    void *result, size_t len);
 
 /**
  * Read 0-terminated string from a file.
@@ -96,11 +104,12 @@ int GNUNET_BIO_read_fn (struct GNUNET_BIO_ReadHandle *h,
  * @param what describes what is being read (for error message creation)
  * @param result the buffer to store a pointer to the (allocated) string to
  *        (note that *result could be set to NULL as well)
- * @param maxLen maximum allowed length for the string
- * @return GNUNET_OK on success, GNUNET_SYSERR on failure
+ * @param max_length maximum allowed length for the string
+ * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
  */
-int GNUNET_BIO_read_string (struct GNUNET_BIO_ReadHandle *h,
-                            const char *what, char **result, size_t maxLen);
+int
+GNUNET_BIO_read_string (struct GNUNET_BIO_ReadHandle *h, const char *what,
+                        char **result, size_t max_length);
 
 
 /**
@@ -109,11 +118,11 @@ int GNUNET_BIO_read_string (struct GNUNET_BIO_ReadHandle *h,
  * @param h handle to an open file
  * @param what describes what is being read (for error message creation)
  * @param result the buffer to store a pointer to the (allocated) metadata
- * @return GNUNET_OK on success, GNUNET_SYSERR on failure
+ * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
  */
-int GNUNET_BIO_read_meta_data (struct GNUNET_BIO_ReadHandle *h,
-                               const char *what,
-                               struct GNUNET_CONTAINER_MetaData **result);
+int
+GNUNET_BIO_read_meta_data (struct GNUNET_BIO_ReadHandle *h, const char *what,
+                           struct GNUNET_CONTAINER_MetaData **result);
 
 
 /**
@@ -142,10 +151,11 @@ int GNUNET_BIO_read_meta_data (struct GNUNET_BIO_ReadHandle *h,
  * @param file name of the source file
  * @param line line number in the code
  * @param i address of 32-bit integer to read
- * @return GNUNET_OK on success, GNUNET_SYSERR on error
+ * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
  */
-int GNUNET_BIO_read_int32__ (struct GNUNET_BIO_ReadHandle *h,
-                             const char *file, int line, int32_t * i);
+int
+GNUNET_BIO_read_int32__ (struct GNUNET_BIO_ReadHandle *h, const char *file,
+                         int line, int32_t * i);
 
 
 /**
@@ -164,10 +174,11 @@ int GNUNET_BIO_read_int32__ (struct GNUNET_BIO_ReadHandle *h,
  * @param file name of the source file
  * @param line line number in the code
  * @param i address of 64-bit integer to read
- * @return GNUNET_OK on success, GNUNET_SYSERR on error
+ * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
  */
-int GNUNET_BIO_read_int64__ (struct GNUNET_BIO_ReadHandle *h,
-                             const char *file, int line, int64_t * i);
+int
+GNUNET_BIO_read_int64__ (struct GNUNET_BIO_ReadHandle *h, const char *file,
+                         int line, int64_t * i);
 
 
 /**
@@ -190,7 +201,8 @@ struct GNUNET_BIO_WriteHandle;
  * @param fn file name to be opened
  * @return IO handle on success, NULL on error
  */
-struct GNUNET_BIO_WriteHandle *GNUNET_BIO_write_open (const char *fn);
+struct GNUNET_BIO_WriteHandle *
+GNUNET_BIO_write_open (const char *fn);
 
 
 /**
@@ -199,7 +211,8 @@ struct GNUNET_BIO_WriteHandle *GNUNET_BIO_write_open (const char *fn);
  * @param h file handle
  * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
  */
-int GNUNET_BIO_write_close (struct GNUNET_BIO_WriteHandle *h);
+int
+GNUNET_BIO_write_close (struct GNUNET_BIO_WriteHandle *h);
 
 
 /**
@@ -208,10 +221,22 @@ int GNUNET_BIO_write_close (struct GNUNET_BIO_WriteHandle *h);
  * @param h handle to open file
  * @param buffer the data to write
  * @param n number of bytes to write
- * @return GNUNET_OK on success, GNUNET_SYSERR on error
+ * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
  */
-int GNUNET_BIO_write (struct GNUNET_BIO_WriteHandle *h,
-                      const void *buffer, size_t n);
+int
+GNUNET_BIO_write (struct GNUNET_BIO_WriteHandle *h, const void *buffer,
+                  size_t n);
+
+
+/**
+ * Force a buffered writer to flush its buffer
+ *
+ * @param h the writer handle
+ * @return #GNUNET_OK upon success.  Upon failure #GNUNET_SYSERR is returned and
+ *           the file is closed
+ */
+int
+GNUNET_BIO_flush (struct GNUNET_BIO_WriteHandle *h);
 
 
 /**
@@ -219,11 +244,10 @@ int GNUNET_BIO_write (struct GNUNET_BIO_WriteHandle *h,
  *
  * @param h handle to open file
  * @param s string to write (can be NULL)
- * @return GNUNET_OK on success, GNUNET_SYSERR on error
+ * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
  */
-int GNUNET_BIO_write_string (struct GNUNET_BIO_WriteHandle *h, const char *s);
-
-
+int
+GNUNET_BIO_write_string (struct GNUNET_BIO_WriteHandle *h, const char *s);
 
 
 /**
@@ -231,10 +255,11 @@ int GNUNET_BIO_write_string (struct GNUNET_BIO_WriteHandle *h, const char *s);
  *
  * @param h handle to open file
  * @param m metadata to write
- * @return GNUNET_OK on success, GNUNET_SYSERR on error
+ * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
  */
-int GNUNET_BIO_write_meta_data (struct GNUNET_BIO_WriteHandle *h,
-                                const struct GNUNET_CONTAINER_MetaData *m);
+int
+GNUNET_BIO_write_meta_data (struct GNUNET_BIO_WriteHandle *h,
+                            const struct GNUNET_CONTAINER_MetaData *m);
 
 
 
@@ -261,20 +286,22 @@ int GNUNET_BIO_write_meta_data (struct GNUNET_BIO_WriteHandle *h,
  * Write an (u)int32_t.
  *
  * @param h hande to open file
- * @param i address of 32-bit integer to write
- * @return GNUNET_OK on success, GNUNET_SYSERR on error
+ * @param i 32-bit integer to write
+ * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
  */
-int GNUNET_BIO_write_int32 (struct GNUNET_BIO_WriteHandle *h, int32_t i);
+int
+GNUNET_BIO_write_int32 (struct GNUNET_BIO_WriteHandle *h, int32_t i);
 
 
 /**
  * Write an (u)int64_t.
  *
  * @param h hande to open file
- * @param i address of 64-bit integer to write
- * @return GNUNET_OK on success, GNUNET_SYSERR on error
+ * @param i 64-bit integer to write
+ * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
  */
-int GNUNET_BIO_write_int64 (struct GNUNET_BIO_WriteHandle *h, int64_t i);
+int
+GNUNET_BIO_write_int64 (struct GNUNET_BIO_WriteHandle *h, int64_t i);
 
 
 #if 0                           /* keep Emacsens' auto-indent happy */
@@ -284,6 +311,8 @@ int GNUNET_BIO_write_int64 (struct GNUNET_BIO_WriteHandle *h, int64_t i);
 }
 #endif
 
+/** @} */ /* end of group bio */
+
 /* ifndef GNUNET_BIO_LIB_H */
 #endif
 /* end of gnunet_bio_lib.h */