aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/espik_debug.c38
-rw-r--r--src/espik_debug.h1
2 files changed, 37 insertions, 2 deletions
diff --git a/src/espik_debug.c b/src/espik_debug.c
index 0ea9c24..d072890 100644
--- a/src/espik_debug.c
+++ b/src/espik_debug.c
@@ -1,8 +1,9 @@
-#include "espik_debug.h"
-
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
+#include <sys/varargs.h>
+
+#include "espik_debug.h"
#ifdef __GLIBC__
# include <execinfo.h>
@@ -12,6 +13,39 @@
# include <signal.h>
#endif /* _ESPIK_DEBUG_ */
+static int indent_level = 0;
+
+void espik_debug_print (char *fct, ...)
+{
+#if _ESPIK_DEBUG_
+ va_list ap;
+ char c, *s;
+ int d;
+
+ va_start (ap, fct);
+ while (*fct)
+ {
+ fprintf (stderr, ">fct : %c\n", *(fct+1));
+ switch (*fct++)
+ {
+ case 's': s = va_arg (ap, char*);
+ fprintf (stderr, "%s", s);
+ break;
+ case 'd': d = va_arg (ap, int);
+ fprintf (stderr, "%d", d);
+ break;
+ case 'c': c = va_arg (ap, char);
+ fprintf (stderr, "%c", c);
+ break;
+ default : fprintf (stderr, "Unknown type : %c\n", *fct);
+ }
+ fprintf (stderr, "<fct : %c\n", *fct);
+ }
+
+ va_end (ap);
+#endif
+}
+
inline void espik_debug_bt (int num)
{
#ifdef __GLIBC__
diff --git a/src/espik_debug.h b/src/espik_debug.h
index 5baacf8..c1f35f3 100644
--- a/src/espik_debug.h
+++ b/src/espik_debug.h
@@ -3,6 +3,7 @@
#include "espik_global.h"
+void espik_debug_print (char *fct, ...);
inline void espik_bt (void);
void espik_debug_init();
void kill_me (short num);