diff options
author | beber <beber> | 2005-12-07 00:36:35 +0000 |
---|---|---|
committer | beber <beber> | 2005-12-07 00:36:35 +0000 |
commit | cfa7d8ca36d9dfa5608f04999f9bbdd778102d2a (patch) | |
tree | 85b49afaa2d476f32e2650c4b44ccb05c3fa7838 /src | |
parent | make it compile (diff) | |
download | espik-cfa7d8ca36d9dfa5608f04999f9bbdd778102d2a.tar.xz |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/espik.c | 12 | ||||
-rw-r--r-- | src/espik_config.c | 5 | ||||
-rw-r--r-- | src/espik_debug.c | 42 | ||||
-rw-r--r-- | src/espik_debug.h | 14 |
4 files changed, 26 insertions, 47 deletions
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 <sys/types.h> #include <unistd.h> #include <pwd.h> +#include <string.h> #include <Ecore_Config.h> @@ -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 <unistd.h> #include <stdio.h> #include <stdlib.h> -#include <sys/varargs.h> #include "espik_debug.h" @@ -9,47 +8,16 @@ # include <execinfo.h> #endif /* __GLIBC__ */ -#if _ESPIK_DEBUG_ +#ifdef _ESPIK_DEBUG_ # 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 -} +//static int indent_level = 0; inline void espik_debug_bt (int num) { #ifdef __GLIBC__ -# if _ESPIK_DEBUG_ +# ifdef _ESPIK_DEBUG_ void* array[128]; size_t size; @@ -77,14 +45,14 @@ inline void espik_debug_bt (int num) void espik_debug_init() { -#if _ESPIK_DEBUG_ +#ifdef _ESPIK_DEBUG_ struct sigaction sa; sa.sa_handler = espik_debug_bt; sigaction(SIGSEGV, &sa, (struct sigaction *)0); sigaction(SIGINT, &sa, (struct sigaction *)0); sigaction(SIGKILL, &sa, (struct sigaction *)0); -#endif +#endif /* _ESPIK_DEBUG_ */ } void kill_me (short num) diff --git a/src/espik_debug.h b/src/espik_debug.h index c1f35f3..3bf52ab 100644 --- a/src/espik_debug.h +++ b/src/espik_debug.h @@ -3,7 +3,19 @@ #include "espik_global.h" -void espik_debug_print (char *fct, ...); +#ifdef __GNUC__ +#define espik_debug_print(fmt, ...) \ +{ \ + fprintf (stdout, "%s+%i @%s: '", __FILE__, __LINE__, __func__); \ + fprintf (stdout, fmt, __VA_ARGS__); \ + fprintf (stdout, "'\n"); \ +} +#else +#define espik_debug_print(fmt, ...) \ +{ \ +} +#endif /* __GNUC__ */ + inline void espik_bt (void); void espik_debug_init(); void kill_me (short num); |