#ifdef MINGW
#include "winproc.h"
#endif
-
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#endif
+#ifdef HAVE_STDARG_H
+#include <stdarg.h>
+#endif
+
/**
* Version of the API (for entire gnunetutil.so library).
*/
*/
enum GNUNET_ErrorType
{
+ GNUNET_ERROR_TYPE_NONE = 0,
GNUNET_ERROR_TYPE_ERROR = 1,
GNUNET_ERROR_TYPE_WARNING = 2,
GNUNET_ERROR_TYPE_INFO = 4,
GNUNET_ERROR_TYPE_BULK = 32
};
+
/**
* User-defined handler for log messages.
*
GNUNET_log_setup (const char *comp,
const char *loglevel, const char *logfile);
+
/**
* Add a custom logger.
*
*/
void GNUNET_logger_add (GNUNET_Logger logger, void *logger_cls);
+
/**
* Remove a custom logger.
*
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).
* This is one of the very few calls in the entire API that is
*/
const char *GNUNET_error_type_to_string (enum GNUNET_ErrorType kind);
+
/**
* Use this for fatal errors that cannot be handled
*/
*/
#define GNUNET_malloc(size) GNUNET_xmalloc_(size, __FILE__, __LINE__)
+/**
+ * Allocate and initialize a block of memory.
+ *
+ * @param buf data to initalize the block with
+ * @param size the number of bytes in buf (and size of the allocation)
+ * @return pointer to size bytes of memory, never NULL (!)
+ */
+#define GNUNET_memdup(buf,size) GNUNET_xmemdup_(buf, size, __FILE__, __LINE__)
+
/**
* Wrapper around malloc. Allocates size bytes of memory.
* The memory will be zero'ed out.
void *GNUNET_xmalloc_ (size_t size, const char *filename, int linenumber);
+
+/**
+ * Allocate and initialize memory. Checks the return value, aborts if no more
+ * memory is available. Don't use GNUNET_xmemdup_ directly. Use the
+ * GNUNET_memdup macro.
+ *
+ * @param buf buffer to initialize from (must contain size bytes)
+ * @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
+ */
+void *GNUNET_xmemdup_ (const void *buf, 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
* memory is available.
*/
void *GNUNET_xrealloc_ (void *ptr,
- const size_t n, const char *filename, int linenumber);
+ size_t n, const char *filename, int linenumber);
/**
* Free memory. Merely a wrapper for the case that we