diff options
-rw-r--r-- | ChangeLog | 16 | ||||
-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 | ||||
-rw-r--r-- | tst/va_test.c | 7 |
6 files changed, 46 insertions, 50 deletions
@@ -1,3 +1,19 @@ +beber from elaine.melee : 07/12/05 01:36:57 +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 + +File changes : +M src/espik_config.c +M src/espik.c +M src/espik_debug.c +M src/espik_debug.h +M tst/va_test.c + beber from rampa : 02/12/05 12:36:36 add handler for when we get connected and disconnect also see if connection is unavailable 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); diff --git a/tst/va_test.c b/tst/va_test.c index 9b527f2..96cd65d 100644 --- a/tst/va_test.c +++ b/tst/va_test.c @@ -7,8 +7,9 @@ #define espik_debug_print(fmt, ...) \ { \ - fprintf (stdout, "%s, %s, %i: \n", __func__, __FILE__, __LINE__); \ - vfprintf (stdout, fmt, __VA_ARGS__); \ + fprintf (stdout, "%s+%i @%s: '", __FILE__, __LINE__, __func__); \ + fprintf (stdout, fmt, __VA_ARGS__); \ + fprintf (stdout, "'\n"); \ } #endif /* __GNUC__ */ @@ -17,7 +18,7 @@ int main() { int a = 10; - espik_debug_print ("a : %d\n", a); + espik_debug_print ("a : %d", a); return (0); } |