/**
* Version of the API (for entire gnunetutil.so library).
*/
-#define GNUNET_UTIL_VERSION 0x00090501
+#define GNUNET_UTIL_VERSION 0x000A0100
/**
- * Named constants for return values. The following
- * invariants hold: "GNUNET_NO == 0" (to allow "if (GNUNET_NO)")
- * "GNUNET_OK != GNUNET_SYSERR", "GNUNET_OK != GNUNET_NO", "GNUNET_NO != GNUNET_SYSERR"
- * and finally "GNUNET_YES != GNUNET_NO".
+ * Named constants for return values. The following invariants hold:
+ * `GNUNET_NO == 0` (to allow `if (GNUNET_NO)`) `GNUNET_OK !=
+ * GNUNET_SYSERR`, `GNUNET_OK != GNUNET_NO`, `GNUNET_NO !=
+ * GNUNET_SYSERR` and finally `GNUNET_YES != GNUNET_NO`.
*/
#define GNUNET_OK 1
#define GNUNET_SYSERR -1
/**
* @ingroup logging
- * define GNUNET_EXTRA_LOGGING if using this header outside the GNUnet source
+ * define #GNUNET_EXTRA_LOGGING if using this header outside the GNUnet source
* tree where gnunet_config.h is unavailable
*/
#ifndef GNUNET_EXTRA_LOGGING
/**
* Define as empty, GNUNET_PACKED should suffice, but this won't work on W32
*/
-#define GNUNET_NETWORK_STRUCT_BEGIN
+#define GNUNET_NETWORK_STRUCT_BEGIN
/**
* Define as empty, GNUNET_PACKED should suffice, but this won't work on W32;
* #GNUNET_NO to stop iteration with no error,
* #GNUNET_SYSERR to abort iteration with error!
*/
-typedef int (*GNUNET_FileNameCallback) (void *cls, const char *filename);
+typedef int
+(*GNUNET_FileNameCallback) (void *cls,
+ const char *filename);
/* ****************************** logging ***************************** */
* @param date when was the message logged?
* @param message what is the message
*/
-typedef void (*GNUNET_Logger) (void *cls, enum GNUNET_ErrorType kind,
- const char *component, const char *date,
+typedef void (*GNUNET_Logger) (void *cls,
+ enum GNUNET_ErrorType kind,
+ const char *component,
+ const char *date,
const char *message);
#if !defined(GNUNET_CULL_LOGGING)
int
-GNUNET_get_log_call_status (int caller_level,
+GNUNET_get_log_call_status (int caller_level,
const char *comp,
- const char *file,
- const char *function, int line);
+ const char *file,
+ const char *function,
+ int line);
#endif
}\
} while (0)
-#define GNUNET_log(kind,...) do { int log_line = __LINE__;\
+ #define GNUNET_log(kind,...) do { int log_line = __LINE__;\
static int log_call_enabled = GNUNET_LOG_CALL_STATUS;\
if ((GNUNET_EXTRA_LOGGING > 0) || ((GNUNET_ERROR_TYPE_DEBUG & (kind)) == 0)) { \
if (GN_UNLIKELY(log_call_enabled == -1))\
* @param option name of missing option
*/
void
-GNUNET_log_config_missing (enum GNUNET_ErrorType kind,
+GNUNET_log_config_missing (enum GNUNET_ErrorType kind,
const char *section,
const char *option);
* @param required what is required that is invalid about the option
*/
void
-GNUNET_log_config_invalid (enum GNUNET_ErrorType kind,
+GNUNET_log_config_invalid (enum GNUNET_ErrorType kind,
const char *section,
const char *option,
const char *required);
* Ignore the next @a n calls to the log function.
*
* @param n number of log calls to ignore (could be negative)
- * @param check_reset GNUNET_YES to assert that the log skip counter is currently zero
+ * @param check_reset #GNUNET_YES to assert that the log skip counter is currently zero
*/
void
-GNUNET_log_skip (int n, int check_reset);
+GNUNET_log_skip (int n,
+ int check_reset);
/**
* @param comp default component to use
* @param loglevel what types of messages should be logged
* @param logfile change logging to logfile (use NULL to keep stderr)
- * @return GNUNET_OK on success, GNUNET_SYSERR if logfile could not be opened
+ * @return #GNUNET_OK on success, #GNUNET_SYSERR if logfile could not be opened
*/
int
-GNUNET_log_setup (const char *comp, const char *loglevel, const char *logfile);
+GNUNET_log_setup (const char *comp,
+ const char *loglevel,
+ const char *logfile);
/**
* Add a custom logger.
*
* @param logger log function
- * @param logger_cls closure for logger
+ * @param logger_cls closure for @a logger
*/
void
-GNUNET_logger_add (GNUNET_Logger logger, void *logger_cls);
+GNUNET_logger_add (GNUNET_Logger logger,
+ void *logger_cls);
/**
* Remove a custom logger.
*
* @param logger log function
- * @param logger_cls closure for logger
+ * @param logger_cls closure for @a logger
*/
void
-GNUNET_logger_remove (GNUNET_Logger logger, void *logger_cls);
+GNUNET_logger_remove (GNUNET_Logger logger,
+ void *logger_cls);
/**
*
* @param pid the peer identity
* @return string form of the pid; will be overwritten by next
- * call to #GNUNET_i2s.
+ * call to #GNUNET_i2s().
*/
const char *
GNUNET_i2s (const struct GNUNET_PeerIdentity *pid);
*
* @param pid the peer identity
* @return string form of the pid; will be overwritten by next
- * call to #GNUNET_i2s.
+ * call to #GNUNET_i2s_full().
*/
const char *
GNUNET_i2s_full (const struct GNUNET_PeerIdentity *pid);
* in the entire API that is NOT reentrant!
*
* @param addr the address
- * @param addrlen the length of the address
+ * @param addrlen the length of the @a addr
* @return nicely formatted string for the address
- * will be overwritten by next call to GNUNET_a2s.
+ * will be overwritten by next call to #GNUNET_a2s().
*/
const char *
-GNUNET_a2s (const struct sockaddr *addr, socklen_t addrlen);
+GNUNET_a2s (const struct sockaddr *addr,
+ socklen_t addrlen);
/**
* @param d the value in network byte order
* @return the same value in host byte order
*/
-double
+double
GNUNET_hton_double (double d);
/**
* @param d the value in network byte order
* @return the same value in host byte order
*/
-double
+double
GNUNET_ntoh_double (double d);
/* ************************* allocation functions ****************** */
*/
#define GNUNET_new(type) (type *) GNUNET_malloc (sizeof (type))
+/**
+ * @ingroup memory
+ * Allocate a size @a n array with structs or unions of the given @a type.
+ * Wrapper around #GNUNET_malloc that returns a pointer
+ * to the newly created objects of the correct type.
+ *
+ * @param n number of elements in the array
+ * @param type name of the struct or union, i.e. pass 'struct Foo'.
+ */
+#define GNUNET_new_array(n, type) (type *) GNUNET_malloc ((n) * sizeof (type))
+
/**
* @ingroup memory
* Wrapper around malloc. Allocates size bytes of memory.
#endif
-
-
#if 0 /* keep Emacsens' auto-indent happy */
{
#endif