From cfa7d8ca36d9dfa5608f04999f9bbdd778102d2a Mon Sep 17 00:00:00 2001 From: beber Date: Wed, 7 Dec 2005 00:36:35 +0000 Subject: Avoid warning Make macro debug work (after compile :p) Format macro debug outpout (file.c+ligne @file.c: 'message') Start to use this macro #if -> #ifdeF del old macro code move macro to .h instead of .c while it's not an inline and use everywhere --- src/espik.c | 12 +++++------- src/espik_config.c | 5 +++-- src/espik_debug.c | 42 +++++------------------------------------- src/espik_debug.h | 14 +++++++++++++- 4 files changed, 26 insertions(+), 47 deletions(-) (limited to 'src') diff --git a/src/espik.c b/src/espik.c index f18cfdf..d092a71 100644 --- a/src/espik.c +++ b/src/espik.c @@ -69,13 +69,11 @@ int main (int argc, char **argv) espik_config_set (a_infos); -#if _ESPIK_DEBUG_ - printf ("host: %s\n", a_infos.server->host); - printf ("port: %hd\n", a_infos.server->port); - printf ("nick: %s\n", a_infos.client->nickname); - printf ("user: %s\n", a_infos.client->username); - printf ("real: %s\n", a_infos.client->realname); -#endif + espik_debug_print ("host: %s", a_infos.server->host); + espik_debug_print ("port: %hd", a_infos.server->port); + espik_debug_print ("nick: %s", a_infos.client->nickname); + espik_debug_print ("user: %s", a_infos.client->username); + espik_debug_print ("real: %s", a_infos.client->realname); if (!ecore_init ()) { diff --git a/src/espik_config.c b/src/espik_config.c index 9c22564..2df8d65 100644 --- a/src/espik_config.c +++ b/src/espik_config.c @@ -4,6 +4,7 @@ #include #include #include +#include #include @@ -67,14 +68,14 @@ void espik_config_init () { if ((ret = ecore_config_init (APPS_NAME)) != ECORE_CONFIG_ERR_SUCC) { - fprintf (stderr, "espik_config_init: Init ecore_config failed (%d)\n", ret); + espik_debug_print ("Init ecore_config failed (%d)", ret); kill_me (2); /* exit (ret); */ } if ((ret = ecore_config_load ()) != ECORE_CONFIG_ERR_SUCC) { - fprintf (stderr, "espik_config_init: Load ecore_config failed (%d)\n", ret); + espik_debug_print ("Load ecore_config failed (%d)", ret); kill_me (2); // exit (ret); } diff --git a/src/espik_debug.c b/src/espik_debug.c index d072890..11b3188 100644 --- a/src/espik_debug.c +++ b/src/espik_debug.c @@ -1,7 +1,6 @@ #include #include #include -#include #include "espik_debug.h" @@ -9,47 +8,16 @@ # include #endif /* __GLIBC__ */ -#if _ESPIK_DEBUG_ +#ifdef _ESPIK_DEBUG_ # include #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, "