h2s_full, useful for testing
[oweals/gnunet.git] / src / include / gnunet_common.h
index df601ac1976ed7e7efb9e926d89f85616c82bca0..8703dc3b7870b4b690df43644d76ab07ccc99b0c 100644 (file)
 #ifndef GNUNET_COMMON_H
 #define GNUNET_COMMON_H
 
+#if HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+#if HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+#ifdef MINGW
+#include "winproc.h"
+#endif
+
 /**
  * Version of the API (for entire gnunetutil.so library).
  */
@@ -71,12 +81,13 @@ struct GNUNET_MessageHeader
 {
 
   /**
-   * The length of the struct (in bytes, including the length field itself)
+   * The length of the struct (in bytes, including the length field itself),
+   * in big-endian format.
    */
   uint16_t size GNUNET_PACKED;
 
   /**
-   * The type of the message (XX_CS_PROTO_XXXX)
+   * The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
    */
   uint16_t type GNUNET_PACKED;
 
@@ -106,8 +117,8 @@ struct GNUNET_PeerIdentity
 /**
  * Function called with a filename.
  *
- * @param filename complete filename (absolute path)
  * @param cls closure
+ * @param filename complete filename (absolute path)
  * @return GNUNET_OK to continue to iterate,
  *  GNUNET_SYSERR to abort iteration with error!
  */
@@ -217,6 +228,16 @@ void GNUNET_logger_remove (GNUNET_Logger logger, void *logger_cls);
  */
 const char *GNUNET_h2s (const GNUNET_HashCode *hc);
 
+/**
+ * Convert a hash value to a string (for printing debug messages).
+ * This prints all 104 characters of a hashcode!
+ * This is one of the very few calls in the entire API that is
+ * NOT reentrant!
+ *
+ * @param hc the hash code
+ * @return string
+ */
+const char *GNUNET_h2s_full (const GNUNET_HashCode *hc);
 
 /**
  * Convert a peer identity to a string (for printing debug messages).
@@ -321,7 +342,7 @@ unsigned long long GNUNET_htonll (unsigned long long n);
  *
  * @param size the number of bytes to allocate, must be
  *        smaller than 40 MB.
- * @return pointer to size bytes of memory
+ * @return pointer to size bytes of memory, never NULL (!)
  */
 #define GNUNET_malloc(size) GNUNET_xmalloc_(size, __FILE__, __LINE__)
 
@@ -330,7 +351,7 @@ unsigned long long GNUNET_htonll (unsigned long long n);
  * The memory will be zero'ed out.
  *
  * @param size the number of bytes to allocate
- * @return pointer to size bytes of memory
+ * @return pointer to size bytes of memory, NULL if we do not have enough memory
  */
 #define GNUNET_malloc_large(size) GNUNET_xmalloc_unchecked_(size, __FILE__, __LINE__)
 
@@ -451,16 +472,16 @@ void *GNUNET_xmalloc_ (size_t size, const char *filename, int linenumber);
 
 
 /**
- * Allocate memory.  This function does not check if the
- * allocation request is within reasonable bounds, allowing
- * allocations larger than 40 MB.  If you don't expect the
- * possibility of very large allocations, use GNUNET_malloc instead.
- * The memory will be zero'ed out.
+ * Allocate memory.  This function does not check if the allocation
+ * request is within reasonable bounds, allowing allocations larger
+ * than 40 MB.  If you don't expect the possibility of very large
+ * allocations, use GNUNET_malloc instead.  The memory will be zero'ed
+ * out.
  *
  * @param size number of bytes to allocate
  * @param filename where is this call being made (for debugging)
  * @param linenumber line where this call is being made (for debugging)
- * @return allocated memory, never NULL
+ * @return pointer to size bytes of memory, NULL if we do not have enough memory
  */
 void *GNUNET_xmalloc_unchecked_ (size_t size,
                                  const char *filename, int linenumber);