summaryrefslogtreecommitdiffstats
path: root/lasso
diff options
context:
space:
mode:
authorValery Febvre <vfebvre at easter-eggs.com>2004-07-07 15:20:57 +0000
committerValery Febvre <vfebvre at easter-eggs.com>2004-07-07 15:20:57 +0000
commitdb0dede4778b240cdabdf941059d81b2c3d3b65b (patch)
tree9a621189f243120640b9af9d73d6e2ba3d17746f /lasso
parent5d8479a6f6873cecda61e164389abdb35977421f (diff)
downloadlasso-db0dede4778b240cdabdf941059d81b2c3d3b65b.tar.gz
lasso-db0dede4778b240cdabdf941059d81b2c3d3b65b.tar.xz
lasso-db0dede4778b240cdabdf941059d81b2c3d3b65b.zip
Added initial debug message system
Diffstat (limited to 'lasso')
-rw-r--r--lasso/xml/Makefile.am8
-rw-r--r--lasso/xml/debug.c89
-rw-r--r--lasso/xml/debug.h58
-rw-r--r--lasso/xml/tools.h1
-rw-r--r--lasso/xml/xml.c6
5 files changed, 157 insertions, 5 deletions
diff --git a/lasso/xml/Makefile.am b/lasso/xml/Makefile.am
index c341d148..da23ff9c 100644
--- a/lasso/xml/Makefile.am
+++ b/lasso/xml/Makefile.am
@@ -13,9 +13,10 @@ INCLUDES = \
noinst_LTLIBRARIES = liblasso-xml.la
liblasso_xml_la_SOURCES = \
- xml.c \
strings.c \
tools.c \
+ debug.c \
+ xml.c \
ds_signature.c \
lib_assertion.c \
lib_authentication_statement.c \
@@ -62,10 +63,11 @@ liblasso_xml_la_SOURCES = \
soap-env_body.c
liblassoinclude_HEADERS = \
- lib.h \
- saml.h \
strings.h \
tools.h \
+ debug.h \
+ lib.h \
+ saml.h \
xml.h \
ds_signature.h \
lib_assertion.h \
diff --git a/lasso/xml/debug.c b/lasso/xml/debug.c
new file mode 100644
index 00000000..ab6e5b84
--- /dev/null
+++ b/lasso/xml/debug.c
@@ -0,0 +1,89 @@
+/* $Id$
+ *
+ * Lasso - A free implementation of the Liberty Alliance specifications.
+ *
+ * Copyright (C) 2004 Entr'ouvert
+ * http://lasso.entrouvert.org
+ *
+ * Author: Valery Febvre <vfebvre@easter-eggs.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <lasso/xml/debug.h>
+
+int debug_line;
+char debug_filename[512];
+char debug_function[512];
+static const char *errorcode[4] = {
+ "DEBUG:",
+ "INFO:",
+ "WARNING:",
+ "ERROR:"
+};
+
+void
+set_debug_info(int line,
+ char *filename,
+ char *function)
+{
+ debug_line = line;
+ strncpy(debug_filename, filename, 512);
+ strncpy(debug_function, function, 512);
+}
+
+void
+_debug(unsigned int level,
+ const char *format, ...)
+{
+ char debug_string[1024];
+ char new_debug_string[2048];
+ char *color;
+
+ va_list args;
+
+ if ((level < 0) || (level > 2)) {
+ printf("DEBUG LEVEL level=%d, must be 0<=x<=2 !!!\n");
+ return;
+ }
+
+ va_start(args, format);
+ vsprintf(debug_string, format, args);
+ va_end(args);
+
+ switch (level) {
+ case ERROR:
+ color = red;
+ break;
+ case WARNING:
+ color = blue;
+ break;
+ case DEBUG:
+ case INFO:
+ color = green;
+ break;
+ }
+
+ sprintf(new_debug_string,
+ "%s%s%s (%s/%s:%d)\t%s",
+ color,
+ errorcode[level],
+ black,
+ debug_filename, debug_function,
+ debug_line, debug_string);
+
+ printf("%s", new_debug_string);
+ fflush(stdout);
+}
diff --git a/lasso/xml/debug.h b/lasso/xml/debug.h
new file mode 100644
index 00000000..162c7749
--- /dev/null
+++ b/lasso/xml/debug.h
@@ -0,0 +1,58 @@
+/* $Id$
+ *
+ * Lasso - A free implementation of the Liberty Alliance specifications.
+ *
+ * Copyright (C) 2004 Entr'ouvert
+ * http://lasso.entrouvert.org
+ *
+ * Author: Valery Febvre <vfebvre@easter-eggs.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef __LASSO_DEBUG_H__
+#define __LASSO_DEBUG_H__
+
+#include <stdio.h>
+#include <stdarg.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#define black "\033[m"
+#define red "\033[31m"
+#define green "\033[32m"
+#define blue "\033[34m"
+
+#define DEBUG 0
+#define INFO 1
+#define WARNING 2
+#define ERROR 3
+
+void set_debug_info(int line, char *filename, char *function);
+void _debug(unsigned int level, const char *format, ...);
+
+#if defined LASSO_DEBUG
+#define debug set_debug_info(__LINE__, __FILE__, __FUNCTION__); _debug
+#else
+#define debug(level, format, ...);
+#endif
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __LASSO_DEBUG_H__ */
diff --git a/lasso/xml/tools.h b/lasso/xml/tools.h
index 61f7e387..1222169a 100644
--- a/lasso/xml/tools.h
+++ b/lasso/xml/tools.h
@@ -38,6 +38,7 @@ extern "C" {
#include <xmlsec/crypto.h>
#include <lasso/export.h>
+#include <lasso/xml/debug.h>
typedef enum {
lassoSignatureMethodRsaSha1 = 1,
diff --git a/lasso/xml/xml.c b/lasso/xml/xml.c
index 8958db2e..547df3e3 100644
--- a/lasso/xml/xml.c
+++ b/lasso/xml/xml.c
@@ -1254,7 +1254,8 @@ lasso_node_dispose(LassoNode *node)
/* unref reference counted objects */
/* we don't have any here */
- g_print("%s 0x%x disposed ...\n", lasso_node_get_name(node), node);
+ //g_print("%s 0x%x disposed ...\n", lasso_node_get_name(node), node);
+ debug(INFO, "%s 0x%x disposed ...\n", lasso_node_get_name(node), node);
}
static void
@@ -1263,7 +1264,8 @@ lasso_node_finalize(LassoNode *node)
gint i;
LassoNode *child;
- g_print("%s 0x%x finalized ...\n", lasso_node_get_name(node), node);
+ //g_print("%s 0x%x finalized ...\n", lasso_node_get_name(node), node);
+ debug(INFO, "%s 0x%x finalized ...\n", lasso_node_get_name(node), node);
if (node->private->node_is_weak_ref == FALSE) {
xmlUnlinkNode(node->private->node);