+/***/
+
+#include "silclog_i.h"
+
+/****f* silcutil/SilcLogAPI/SilcLogCb
+ *
+ * SYNOPSIS
+ *
+ * typedef SilcBool (*SilcLogCb)(SilcLogType type, char *message,
+ * void *context);
+ *
+ * DESCRIPTION
+ *
+ * The logging custom callback function. The `type' is the channel ID
+ * that triggered the event, which allows you to use the same callback
+ * function for multiple logging channels.
+ *
+ * The `message' parameter points to a null-terminated buffer containing
+ * the received message, while `context' is the caller-specified context.
+ * The message must not be modified or freed by the callback function.
+ * If the function returns TRUE, SilcLog will assume the message was
+ * handled and won't run its default handler.
+ *
+ * SEE ALSO
+ * silc_log_set_callback
+ *
+ ***/
+typedef SilcBool (*SilcLogCb)(SilcLogType type, char *message, void *context);
+
+/****f* silcutil/SilcLogAPI/SilcLogDebugCb
+ *
+ * SYNOPSIS
+ *
+ * typedef SilcBool (*SilcLogDebugCb)(char *file, char *function, int line,
+ * char *message, void *context);
+ *
+ * DESCRIPTION
+ *
+ * The debug logging callback function. The default behaviour is to
+ * output messages to stderr. `file', `function', and `line' are the
+ * corresponding offsets in the source files. `message' points to a
+ * null-terminated buffer containing the debugging message, and `context'
+ * is the caller-specified context.
+ *
+ * The message must not be modified or freed by the callback function.
+ * If the function returns TRUE, SilcLog will assume the message as handled
+ * and won't run its default handler.
+ *
+ * SEE ALSO
+ * silc_debug, silc_log_set_debug_callbacks
+ *
+ ***/
+typedef SilcBool (*SilcLogDebugCb)(char *file, char *function, int line,
+ char *message, void *context);
+
+/****f* silcutil/SilcLogAPI/SilcLogHexdumpCb
+ *
+ * SYNOPSIS
+ *
+ * typedef SilcBool
+ * (*SilcDebugHexdumpCb)(char *file, char *function, int line,
+ * unsigned char *data,
+ * SilcUInt32 data_len,
+ * char *message, void *context;
+ *
+ * DESCRIPTION
+ *
+ * The hexdump logging callback function. The default behaviour is to
+ * print a formatted hexdump to stderr, and is commonly what you would
+ * like it to be. `file', `function', and `line' are the corresponding
+ * offsets in the source files. `data' is the begin of the buffer that
+ * should be hexdumped, which is `data_len' bytes long.
+ *
+ * The `message' parameter points to a null-terminated buffer containing
+ * the received message, while `context' is the caller-specified context.
+ * The message must not be modified or freed by the callback function.
+ * If the function returns TRUE, SilcLog will assume the message as handled
+ * and won't run its default handler.
+ *
+ * SEE ALSO
+ * silc_debug_hexdump, silc_log_set_debug_callbacks
+ *
+ ***/
+typedef SilcBool (*SilcLogHexdumpCb)(char *file, char *function, int line,
+ unsigned char *data, SilcUInt32 data_len,
+ char *message, void *context);
+
+/* Macros */
+
+/****d* silcutil/SilcLogAPI/SILC_LOG_INFO
+ *
+ * NAME
+ *
+ * #define SILC_LOG_INFO(...)
+ *
+ * DESCRIPTION
+ *
+ * This macro is a wrapper to the main logging function.
+ * It supports variable argument list formatting, and *automatically*
+ * appends newline at the end of the string.
+ *
+ * NOTES
+ *
+ * This macro requires double parenthesis to ensure that the VA list
+ * formatting would work correctly.
+ *
+ * EXAMPLE
+ *
+ * SILC_LOG_INFO(("Today i feel %s", core->mood));
+ *
+ * SOURCE
+ */
+#define SILC_LOG_INFO(fmt) silc_log_output(SILC_LOG_INFO, silc_format fmt)
+/***/
+
+/****d* silcutil/SilcLogAPI/SILC_LOG_WARNING
+ *
+ * NAME
+ *
+ * #define SILC_LOG_WARNING(...)
+ *
+ * DESCRIPTION
+ *
+ * Wrapper to the WARNING logging channel.
+ * Please see the SILC_LOG_INFO macro.
+ *
+ * SEE ALSO
+ * SILC_LOG_INFO
+ *
+ * SOURCE
+ */
+#define SILC_LOG_WARNING(fmt) silc_log_output(SILC_LOG_WARNING, silc_format fmt)
+/***/
+
+/****d* silcutil/SilcLogAPI/SILC_LOG_ERROR
+ *
+ * NAME
+ *
+ * #define SILC_LOG_ERROR(...)
+ *
+ * DESCRIPTION
+ *
+ * Wrapper to the ERROR logging channel.
+ * Please see the SILC_LOG_INFO macro.
+ *
+ * SEE ALSO
+ * SILC_LOG_INFO
+ *
+ * SOURCE
+ */
+#define SILC_LOG_ERROR(fmt) silc_log_output(SILC_LOG_ERROR, silc_format fmt)
+/***/
+
+/****d* silcutil/SilcLogAPI/SILC_LOG_FATAL
+ *
+ * NAME
+ *
+ * #define SILC_LOG_FATAL(...)
+ *
+ * DESCRIPTION
+ *
+ * Wrapper to the FATAL logging channel.
+ * Please see the SILC_LOG_INFO macro.
+ *
+ * SEE ALSO
+ * SILC_LOG_INFO
+ *
+ * SOURCE
+ */
+#define SILC_LOG_FATAL(fmt) silc_log_output(SILC_LOG_FATAL, silc_format fmt)
+/***/
+
+/****d* silcutil/SilcLogAPI/SILC_LOG_DEBUG
+ *
+ * NAME
+ *
+ * #define SILC_LOG_DEBUG(...)
+ *
+ * DESCRIPTION
+ *
+ * This is a special wrapper to the debugging output (usually stderr).
+ * The standard behaviour is the same as SILC_LOG_INFO, with the difference
+ * that this macro also depends on the global define SILC_DEBUG.
+ *
+ * Undefining SILC_DEBUG causes these functions to be defined to an empty
+ * value, thus removing all debug logging calls from the compiled
+ * application.
+ *
+ * SOURCE
+ */
+#if defined(SILC_DEBUG)
+#define SILC_LOG_DEBUG(fmt) silc_log_output_debug(__FILE__, \
+ __FUNCTION__, \
+ __LINE__, \
+ silc_format fmt)
+#define SILC_NOT_IMPLEMENTED(string) \
+ SILC_LOG_INFO(("*********** %s: NOT IMPLEMENTED YET", string));
+#else
+#define SILC_LOG_DEBUG(fmt) do { } while(0)
+#define SILC_NOT_IMPLEMENTED(string) do { } while(0)
+#endif /* SILC_DEBUG */
+/***/
+
+/****d* silcutil/SilcLogAPI/SILC_LOG_HEXDUMP
+ *
+ * NAME
+ *
+ * #define SILC_LOG_HEXDUMP(...)
+ *
+ * DESCRIPTION
+ *
+ * This is a special wrapper to the hexdump output function. This macro
+ * behaves slightly differently from other logging wrappers.
+ * The first parameter, is composed by a group of parameters delimited by
+ * parenthesis.
+ * The second parameter is a `char *' pointer pointing to the beginning
+ * of the memory section that should be hexdumped, and the third parameter
+ * is the length of this memory section.
+ * Undefining the global SILC_DEBUG define causes these functions to be
+ * defined to an empty value, thus removing all debug logging calls from
+ * the compiled application.
+ * This macro is also affected by the global variable silc_debug_hexdump.
+ *
+ * EXAMPLE
+ *
+ * SILC_LOG_HEXDUMP(("Outgoing packet [%d], len %d", pckt->seq, pckt->len),
+ * pckt->data, pckt->datalen);
+ *
+ * SOURCE
+ */
+#if defined(SILC_DEBUG)
+#define SILC_LOG_HEXDUMP(fmt, data, len) silc_log_output_hexdump(__FILE__, \
+ __FUNCTION__, \
+ __LINE__, \
+ (void *)(data), (len), \
+ silc_format fmt)
+#else
+#define SILC_LOG_HEXDUMP(fmt, data, len) do { } while(0)
+#endif /* SILC_DEBUG */
+/***/