+#ifndef SILC_SYMBIAN
+ silclog.debug_cb = NULL;
+ silclog.debug_context = NULL;
+ silclog.hexdump_cb = NULL;
+ silclog.hexdump_context = NULL;
+#endif /* !SILC_SYMBIAN */
+}
+
+/* Set current debug string */
+
+void silc_log_set_debug_string(const char *debug_string)
+{
+#ifndef SILC_SYMBIAN
+ char *string;
+ int len;
+ if ((strchr(debug_string, '(') && strchr(debug_string, ')')) ||
+ strchr(debug_string, '$'))
+ string = silc_strdup(debug_string);
+ else
+ string = silc_string_regexify(debug_string);
+ len = strlen(string);
+ if (len >= sizeof(silclog.debug_string))
+ len = sizeof(silclog.debug_string) - 1;
+ memset(silclog.debug_string, 0, sizeof(silclog.debug_string));
+ strncpy(silclog.debug_string, string, len);
+ silc_free(string);
+#endif /* !SILC_SYMBIAN */
+}
+
+/* Set timestamp */
+
+void silc_log_timestamp(SilcBool enable)
+{
+#ifndef SILC_SYMBIAN
+ silclog.timestamp = enable;
+#endif /* !SILC_SYMBIAN */
+}
+
+/* Set flushdelay */
+
+void silc_log_flushdelay(SilcUInt32 flushdelay)
+{
+#ifndef SILC_SYMBIAN
+ silclog.flushdelay = flushdelay;
+#endif /* !SILC_SYMBIAN */
+}
+
+/* Set quick logging */
+
+void silc_log_quick(SilcBool enable)
+{
+#ifndef SILC_SYMBIAN
+ silclog.quick = enable;
+#endif /* !SILC_SYMBIAN */
+}
+
+/* Set debugging */
+
+void silc_log_debug(SilcBool enable)
+{
+#ifndef SILC_SYMBIAN
+ silclog.debug = enable;
+#endif /* !SILC_SYMBIAN */
+}
+
+/* Set debug hexdump */
+
+void silc_log_debug_hexdump(SilcBool enable)
+{
+#ifndef SILC_SYMBIAN
+ silclog.debug_hexdump = enable;
+#endif /* !SILC_SYMBIAN */
+}
+
+/* Outputs the debug message to stderr. */
+
+void silc_log_output_debug(char *file, const char *function,
+ int line, char *string)
+{
+ SilcTimeStruct curtime;
+
+#ifndef SILC_SYMBIAN
+ if (!silclog.debug)
+ goto end;
+
+ if (!silc_string_regex_match(silclog.debug_string, file) &&
+ !silc_string_regex_match(silclog.debug_string, function))
+ goto end;
+
+ if (silclog.debug_cb) {
+ if ((*silclog.debug_cb)(file, (char *)function, line, string,
+ silclog.debug_context))
+ goto end;
+ }
+#endif /* !SILC_SYMBIAN */
+
+ silc_time_value(0, &curtime);
+
+#ifdef SILC_WIN32
+ if (strrchr(function, '\\'))
+ fprintf(stderr, "%s:%d: %s\n", strrchr(function, '\\') + 1, line, string);
+ else
+#endif /* SILC_WIN32 */
+#ifdef SILC_SYMBIAN
+ silc_symbian_debug(function, line, string);
+#else
+ fprintf(stderr, "%02d:%02d:%02d %s:%d: %s\n", curtime.hour,
+ curtime.minute, curtime.second, function, line,
+ string);
+ fflush(stderr);
+#endif /* SILC_SYMBIAN */
+
+ end:
+ silc_free(string);
+}
+
+/* Hexdumps a message */
+
+void silc_log_output_hexdump(char *file, const char *function,
+ int line, void *data_in,
+ SilcUInt32 len, char *string)
+{
+#ifndef SILC_SYMBIAN
+ if (!silclog.debug_hexdump)
+ goto end;
+
+ if (!silc_string_regex_match(silclog.debug_string, file) &&
+ !silc_string_regex_match(silclog.debug_string, function))
+ goto end;
+
+ if (silclog.hexdump_cb) {
+ if ((*silclog.hexdump_cb)(file, (char *)function, line,
+ data_in, len, string, silclog.hexdump_context))
+ goto end;
+ }
+#endif /* !SILC_SYMBIAN */
+
+ fprintf(stderr, "%s:%d: %s\n", function, line, string);
+
+ silc_hexdump(data_in, len, stderr);
+
+ end:
+ silc_free(string);