aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBertrand Jacquin (Beber) <beber.mailing@gmail.com>2006-04-10 20:20:28 +0200
committerbeber <beber@meathook.melee>2006-04-10 20:20:28 +0200
commit8154279a91453985b4c67cd082249a0f7148f1e9 (patch)
tree6a9d617de70abd69502fa2bffe61c6ea5efc4ae3
parentimprove configure.in and delete m4 macros (diff)
downloadespik-8154279a91453985b4c67cd082249a0f7148f1e9.tar.xz
remove all old debugging code
-rw-r--r--configure.in1
-rw-r--r--m4/ac_espik_debug.m427
-rw-r--r--src/Makefile.am9
-rw-r--r--src/espik.c50
-rw-r--r--src/espik_common_handler.c7
-rw-r--r--src/espik_config.c26
-rw-r--r--src/espik_debug.c71
-rw-r--r--src/espik_debug.h61
-rw-r--r--src/espik_irc.c38
-rw-r--r--src/espik_net.c33
10 files changed, 42 insertions, 281 deletions
diff --git a/configure.in b/configure.in
index c031510..a1e64b6 100644
--- a/configure.in
+++ b/configure.in
@@ -20,7 +20,6 @@ AC_C_INLINE
dnl espik specific check (include in m4)
AC_C___ATTRIBUTE__
-AC_ESPIK_DEBUG
AC_ARG_WITH(evas-config,
[ --with-evas-config=EVAS_CONFIG use evas-config specified ],
diff --git a/m4/ac_espik_debug.m4 b/m4/ac_espik_debug.m4
deleted file mode 100644
index dcef075..0000000
--- a/m4/ac_espik_debug.m4
+++ /dev/null
@@ -1,27 +0,0 @@
-dnl Debug mode
-AC_DEFUN([AC_ESPIK_DEBUG],
-[
- AC_MSG_CHECKING(for debug)
- AC_ARG_ENABLE(
- [debug],
- AC_HELP_STRING([--enable-debug], [Enable debug mode (default=yes)]),
- [if test "$enable_debug" = "no"; then
- debug="no"
- else
- debug="yes"
- fi
- ],
- [debug="yes"])
-
- if test "$debug" != "no"; then
- debug="yes"
- DEBUG_CFLAGS="-g -D_ESPIK_DEBUG_"
- else
- DEBUG_LDFLAGS="-s"
- fi
-
- AC_MSG_RESULT($debug ($DEBUG_CFLAGS$DEBUG_LDFLAGS))
-
- AC_SUBST(DEBUG_CFLAGS)
- AC_SUBST(DEBUG_LDFLAGS)
-])
diff --git a/src/Makefile.am b/src/Makefile.am
index 0327757..30fcb53 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,7 +1,7 @@
## Process this file with automake to produce Makefile.in
AM_CFLAGS = \
- $(DEBUG_CFLAGS) \
+ -g \
-W -Wall \
-Wdeclaration-after-statement \
-Wundef -Wold-style-definition \
@@ -9,22 +9,19 @@ AM_CFLAGS = \
ESPIKHEADERS = \
espik.h \
- espik_config.h \
espik_common_handler.h \
+ espik_config.h \
espik_error.h \
- espik_debug.h \
espik_global.h
espik_SOURCES = \
espik.c \
- espik_config.c \
espik_common_handler.c \
+ espik_config.c \
espik_error.c \
- espik_debug.c \
$(ESPIKHEADERS)
espik_LDADD = \
- $(DEBUG_LDFLAGS) \
@ecore_libs@
bin_PROGRAMS = espik
diff --git a/src/espik.c b/src/espik.c
index 8763f21..026fc64 100644
--- a/src/espik.c
+++ b/src/espik.c
@@ -11,38 +11,42 @@
#include <Ecore_Data.h> /* List */
/* Espik Stuff */
-#include "espik.h"
#include "espik_global.h"
#include "espik_config.h"
#include "espik_common_handler.h"
-#include "espik_debug.h"
+#include "espik.h"
typedef int (*Handler_Func) (void *data, int ev_type, void *ev);
-/*
-typedef int (*Handler_Fd_Func) (void *data, Ecore_Fd_Handler * fd_handler);
-*/
-
-static void espik_init(void)
-{
- ptr_list = ecore_list_new();
-}
+/* typedef int (*Handler_Fd_Func) (void *data, Ecore_Fd_Handler * fd_handler); */
static void espik_destroy_ptr(void *ptr)
{
if (ptr)
{
- espik_debug_print("Freeing data...");
+ printf ("Freeing data...");
free (ptr);
ptr = NULL;
}
}
+static void espik_init(void)
+{
+ printf ("Welcome to %s-%s\n", APPS_NAME, ESPIK_VERSION);
+ ptr_list = ecore_list_new();
+
+ if (!ecore_init ())
+ {
+ printf ("Cannot init ecore; %d\n", 1);
+ exit (-1);
+ }
+
+ ecore_list_set_free_cb (ptr_list, espik_destroy_ptr);
+}
+
void espik_free (void *ptr)
{
- espik_enter();
ecore_list_append (ptr_list, ptr);
- espik_leave();
}
void espik_shutdown(void)
@@ -54,9 +58,8 @@ void espik_shutdown(void)
int del_backslash (char *msg)
{
int i, count;
- espik_enter();
- for (i = 0, count = 0; msg[i]; i++)
+ for (i = 0, count = 0 ; msg[i] ; i++)
{
if (msg[i] == '\n')
{
@@ -65,26 +68,14 @@ int del_backslash (char *msg)
}
}
- espik_leave();
return (count);
}
int main (int argc, char **argv)
{
Ecore_Fd_Handler *fd_kb;
- __indent_level = 0;
- espik_enter();
-
- printf ("Welcome to %s-%s\n", APPS_NAME, ESPIK_VERSION);
- espik_init();
- if (!ecore_init ())
- {
- printf ("Cannot init ecore; %d\n", 1);
- exit (-1);
- }
-
- ecore_list_set_free_cb(ptr_list, espik_destroy_ptr);
+ espik_init ();
espik_config_init ();
if (argc < 3)
@@ -118,12 +109,9 @@ int main (int argc, char **argv)
exit (-1);
}
- /* Init IRC connection */
-
ecore_main_loop_begin ();
espik_shutdown();
- espik_debug_print ("end");
espik_config_shutdown (a_infos);
diff --git a/src/espik_common_handler.c b/src/espik_common_handler.c
index 2dcb47f..6022344 100644
--- a/src/espik_common_handler.c
+++ b/src/espik_common_handler.c
@@ -6,10 +6,9 @@
#include <Ecore.h>
#include "espik_global.h"
-#include "espik_common_handler.h"
#include "espik.h"
#include "espik_error.h"
-#include "espik_debug.h"
+#include "espik_common_handler.h"
#define INPUT_LENGHT 200
@@ -17,7 +16,6 @@ int kb_get (void* data __UNUSED__, Ecore_Fd_Handler* fd_handler)
{
char kb[INPUT_LENGHT];
int count;
- espik_enter();
do
{
@@ -28,7 +26,7 @@ int kb_get (void* data __UNUSED__, Ecore_Fd_Handler* fd_handler)
if (count > 1)
{
del_backslash (kb);
- espik_debug_print ("%s", kb);
+ printf ("%s", kb);
}
}
while (count >= INPUT_LENGHT - 2);
@@ -46,6 +44,5 @@ int kb_get (void* data __UNUSED__, Ecore_Fd_Handler* fd_handler)
return (0);
}
- espik_leave();
return (1);
}
diff --git a/src/espik_config.c b/src/espik_config.c
index 410fcf0..bbae1b8 100644
--- a/src/espik_config.c
+++ b/src/espik_config.c
@@ -8,16 +8,14 @@
#include <Ecore_Config.h>
-#include "espik_config.h"
#include "espik_error.h"
-#include "espik_debug.h"
+#include "espik_config.h"
static int ret; /* For debug */
t_servinfo* espik_server_config_set (char* server, unsigned short port)
{
t_servinfo* s_info;
- espik_enter();
s_info = malloc (sizeof (t_servinfo));
@@ -25,7 +23,6 @@ t_servinfo* espik_server_config_set (char* server, unsigned short port)
s_info->port = port;
espik_free (server);
- espik_leave();
return (s_info);
}
@@ -33,7 +30,6 @@ t_userinfo* espik_user_sysinfo_get (void)
{
struct passwd* pw;
t_userinfo* u_info;
- espik_enter();
pw = getpwuid (getuid ());
@@ -51,14 +47,12 @@ t_userinfo* espik_user_sysinfo_get (void)
espik_free (u_info);
espik_free (pw);
- espik_leave();
return (u_info);
}
void espik_config_default_set (void)
{
t_userinfo* user_sysinfo;
- espik_enter();
ecore_config_string_default ("/config/server/0/host", "beber.melee");
ecore_config_int_default ("/config/server/0/port", 6667);
@@ -78,16 +72,13 @@ void espik_config_default_set (void)
espik_free (user_sysinfo->username);
espik_free (user_sysinfo->realname);
espik_free (user_sysinfo);
- espik_leave();
}
void espik_config_init (void)
{
- espik_enter();
-
if ((ret = ecore_config_init (APPS_NAME)) != ECORE_CONFIG_ERR_SUCC)
{
- espik_debug_print ("Init ecore_config failed (%d)", ret);
+ printf ("Init ecore_config failed (%d)", ret);
//kill_me (2);
//exit (ret);
}
@@ -96,14 +87,13 @@ void espik_config_init (void)
{
/* If an config option is not present,
* this will force it to a value */
- espik_debug_print ("Load ecore_config failed (%d)", ret);
+ printf ("Load ecore_config failed (%d)", ret);
espik_config_default_set ();
/*
kill_me (2);
exit (ret);
*/
}
- espik_leave();
}
void espik_config_shutdown (t_info s_info)
@@ -118,8 +108,6 @@ void espik_config_shutdown (t_info s_info)
void espik_config_get (t_info *s_info)
{
- espik_enter();
-
s_info->server = malloc (sizeof (t_servinfo));
s_info->client = malloc (sizeof (t_userinfo));
@@ -137,16 +125,13 @@ void espik_config_get (t_info *s_info)
if (ecore_config_save () != ECORE_CONFIG_ERR_SUCC)
{
- espik_debug_print ("Save ecore_config failed");
+ printf ("Save ecore_config failed");
exit (-1);
}
- espik_leave();
}
void espik_config_set (t_info config)
{
- espik_enter();
-
ecore_config_int_set ("/config/server/len", 1);
ecore_config_string_set ("/config/server/0/host", config.server->host);
ecore_config_int_set ("/config/server/0/port",
@@ -162,8 +147,7 @@ void espik_config_set (t_info config)
if (ecore_config_save () != ECORE_CONFIG_ERR_SUCC)
{
- espik_debug_print ("Save ecore_config failed");
+ printf ("Save ecore_config failed");
exit (-1);
}
- espik_leave();
}
diff --git a/src/espik_debug.c b/src/espik_debug.c
deleted file mode 100644
index 04b32a1..0000000
--- a/src/espik_debug.c
+++ /dev/null
@@ -1,71 +0,0 @@
-#include <unistd.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "espik_debug.h"
-
-#ifdef __GLIBC__
-#include <execinfo.h>
-#endif /* __GLIBC__ */
-
-#ifdef _ESPIK_DEBUG_
-#include <signal.h>
-#endif /* _ESPIK_DEBUG_ */
-
-#if 0
-inline void espik_debug_bt (int num)
-{
-#if 0
-#ifdef __GLIBC__
-#ifdef _ESPIK_DEBUG_
-
- void* array[128];
- size_t size;
- char** strings;
- size_t i;
-
- /*
- if (!debug_bt)
- return;
- */
-
- fprintf(stderr, "\n***** Backtrace (Signal %d) *****\n", num);
- size = backtrace(array, 128);
- strings = backtrace_symbols(array, size);
- for (i = 0 ; i < size ; i++)
- fprintf(stderr, "%s\n", strings[i]);
-
- if (strings)
- free(strings);
-
-#endif /* _ESPIK_DEBUG_ */
-#endif /* __GLIBC__ */
-
-#ifndef __GLIBC__
- fprintf(stderr, "Your system doesn't have glibc. Backtraces disabled."
- "But program receive signal %d.\n", num);
-#endif /* __GLIBC__ */
-#endif
- num ++; /* Just for avoid warning */
-}
-
-void espik_debug_init()
-{
-#ifdef _ESPIK_DEBUG_
- struct sigaction sa;
-
- sa.sa_handler = espik_debug_bt;
- memset (&sa, 0, sizeof (struct sigaction));
- sigaction(SIGSEGV, &sa, (struct sigaction *)0);
- sigaction(SIGINT, &sa, (struct sigaction *)0);
- sigaction(SIGKILL, &sa, (struct sigaction *)0);
-#endif /* _ESPIK_DEBUG_ */
-}
-
-void kill_me (short num)
-{
- espik_debug_bt(num);
- exit (num);
-}
-
-#endif
diff --git a/src/espik_debug.h b/src/espik_debug.h
deleted file mode 100644
index e1c058b..0000000
--- a/src/espik_debug.h
+++ /dev/null
@@ -1,61 +0,0 @@
-#ifndef ESPIK_DEBUG_H
-#define ESPIK_DEBUG_H
-
-#include "espik_global.h"
-
-#define DEBUG_PRINT_FILENO stdout
-#define DEBUG_ENTLEV_FILENO stderr
-
-
-#if defined (_ESPIK_DEBUG_) && defined (__GNUC__)
-#define espik_debug_print(fmt, ...) \
-{ \
- fprintf (DEBUG_PRINT_FILENO, "%s +%i @%s: '", __FILE__, __LINE__, \
- __func__); \
- fprintf (DEBUG_PRINT_FILENO, fmt, ##__VA_ARGS__); \
- fprintf (DEBUG_PRINT_FILENO, "'\n"); \
-}
-#else
-#define espik_debug_print(fmt, ...) \
-{ \
-}
-#endif /* _ESPIK_DEBUG_ && __GNUC__ */
-
-#ifdef _ESPIK_DEBUG_
-int __indent_level;
-
-#define espik_enter() \
-{ \
- __indent_level++; \
- fprintf (DEBUG_ENTLEV_FILENO, ">%*c%s +%i @%s\n", __indent_level, ' ', \
- __FILE__, __LINE__, __func__); \
-}
-//#define espik_enter() {}
-
-#define espik_leave() \
-{ \
- fprintf (DEBUG_ENTLEV_FILENO, "<%*c%s +%i @%s\n", __indent_level, ' ', \
- __FILE__, __LINE__, __func__); \
- __indent_level--; \
-}
-//#define espik_leave() {}
-
-#else
-
-#define espik_enter() \
-{ \
-}
-
-#define espik_leave() \
-{ \
-}
-
-#endif /* _ESPIK_DEBUG_ */
-
-#if 0
-inline void espik_bt (void);
-void espik_debug_init();
-void kill_me (short num);
-#endif
-
-#endif /* ESPIK_DEBUG_H */
diff --git a/src/espik_irc.c b/src/espik_irc.c
index dbe962d..21c418f 100644
--- a/src/espik_irc.c
+++ b/src/espik_irc.c
@@ -10,7 +10,6 @@
#include "espik_error.h"
/*#include "espik_common_handler.h"*/
#include "espik_net.h"
-#include "espik_debug.h"
#include "espik.h"
char* current_chan;
@@ -22,12 +21,12 @@ typedef struct
} cmd_t;
cmd_t cmd_tab[] = {
- { "JOIN", irc_join },
- { "PART", irc_part },
- { "PRIVMSG", irc_privmsg },
- { "QUIT", irc_quit },
- { "RAW", irc_raw },
- { "NICK", irc_nick },
+ { "JOIN", irc_join },
+ { "PART", irc_part },
+ { "PRIVMSG", irc_privmsg },
+ { "QUIT", irc_quit },
+ { "RAW", irc_raw },
+ { "NICK", irc_nick },
/* { "ACTION", irc_action }, */
{ 0, 0 }
};
@@ -40,7 +39,6 @@ char** separate_commandline (char *msg)
{
unsigned int len;
char** two_words;
- espik_enter();
/* Yes, do nothing, just get len ! */
for (len = 0 ; msg[len] != ' ' && msg[len] != '\t' ; len++);
@@ -56,7 +54,6 @@ char** separate_commandline (char *msg)
}
while (*two_words[1] == ' ' || *two_words[1] == '\t');
- espik_leave();
return (two_words);
}
@@ -80,27 +77,22 @@ void string_upper (char *str)
unsigned short sendmsg_len (char* msg)
{
- espik_enter();
- espik_leave();
return (strlen (msg) + 2);
}
buf_t make_buffer(int len)
{
buf_t buf;
- espik_enter();
buf.buf = malloc (len);
buf.len = len + 1; /* Alloc trailing \0 */
- espik_leave();
return (buf);
}
char* irc_privmsg (char* chan, char* msg)
{
buf_t out;
- espik_enter();
out = make_buffer (strlen ("PRIVMSG") + 1 /* "PRIVMSG " */
+ strlen (chan) + 2 /* ":<channel> "*/
@@ -109,14 +101,12 @@ char* irc_privmsg (char* chan, char* msg)
snprintf (out.buf, out.len, "PRIVMSG %s :%s", chan, msg);
free (msg);
- espik_leave();
return (out.buf);
}
char* irc_join (char* chan __UNUSED__, char* msg)
{
buf_t out;
- espik_enter();
/* Could also by '&' and so one ...
* have to look on RFC, dev will be done with # only */
@@ -124,7 +114,6 @@ char* irc_join (char* chan __UNUSED__, char* msg)
{
espik_debug_print ("%s is not a channel", msg);
espik_debug_print ("Usage: /JOIN #channel");
- espik_leave();
return (0);
}
@@ -134,14 +123,12 @@ char* irc_join (char* chan __UNUSED__, char* msg)
snprintf (out.buf, out.len, "JOIN %s", msg);
free (msg);
- espik_leave();
return (out.buf);
}
char* irc_part (char* chan, char* msg)
{
buf_t out;
- espik_enter();
if (msg[0] != '#')
{
@@ -165,14 +152,12 @@ char* irc_part (char* chan, char* msg)
}
free (msg);
- espik_leave();
return (out.buf);
}
char* irc_quit (char* chan __UNUSED__, char* msg)
{
buf_t out;
- espik_enter();
out = make_buffer (strlen ("QUIT") + 2 /* "QUIT :" */
+ strlen (msg)); /* "<msg>EOF" */
@@ -189,20 +174,16 @@ char* irc_quit (char* chan __UNUSED__, char* msg)
*/
free (msg);
- espik_leave();
return (out.buf);
}
char* irc_raw (char* chan __UNUSED__, char* msg)
{
- espik_enter();
- espik_leave();
return (msg);
}
char* irc_nick (char* chan __UNUSED__, char* nick)
{
- espik_enter();
buf_t out;
out = make_buffer (strlen ("NICK") + 1 /* "NICK " */
@@ -212,7 +193,6 @@ char* irc_nick (char* chan __UNUSED__, char* nick)
espik_debug_print ("NICK CHANGED REQUEST: %s", nick);
- espik_leave();
return (out.buf);
}
@@ -237,7 +217,6 @@ void irc_disconnect (Ecore_Con_Server *sock)
char* irc_send (char* msg)
{
char* out;
- espik_enter();
out = NULL;
@@ -273,24 +252,19 @@ char* irc_send (char* msg)
{
espik_debug_print ("%s is not a know command",
cmd_and_message[0]);
- espik_leave();
return (0);
}
}
else
- {
out = irc_privmsg (current_chan, msg);
- }
if (!out)
{
free (msg);
- espik_leave();
return (0);
}
espik_debug_print ("%s", out);
- espik_leave();
return (out);
}
diff --git a/src/espik_net.c b/src/espik_net.c
index d56f070..4c0ce1f 100644
--- a/src/espik_net.c
+++ b/src/espik_net.c
@@ -4,12 +4,11 @@
#include <stdlib.h>
#include "espik_global.h"
-#include "espik_net.h"
#include "espik_common_handler.h"
#include "espik_error.h"
-#include "espik_debug.h"
#include "espik_irc.h"
#include "espik.h"
+#include "espik_net.h"
#include <Ecore.h>
#include <Ecore_Con.h>
@@ -26,15 +25,11 @@ Ecore_Event_Handler* ret;
void espik_con_init (t_info serv_info)
{
int nb_launch;
- espik_enter();
nb_launch = ecore_con_init ();
-
com_active = 0;
- /*
- espik_debug_printf ("nb_launch = %d", nb_launch);
- */
+ /* espik_debug_printf ("nb_launch = %d", nb_launch); */
con_sock = ecore_con_server_connect (ECORE_CON_REMOTE_SYSTEM,
serv_info.server->host,
@@ -73,14 +68,11 @@ void espik_con_init (t_info serv_info)
exit (-1);
}
espik_free (ret);
-
- espik_leave();
}
void send_login()
{
- espik_enter();
-// espik_debug_print ("<<<<<<<< DUMMMMY CODE >>>>>>>");
+/* espik_debug_print ("<<<<<<<< DUMMMMY CODE >>>>>>>"); */
char *tmp, *tmp2;
@@ -104,26 +96,21 @@ void send_login()
com_active = 1;
-// espik_debug_print ("<<<<<<<< DUMMMMY CODE >>>>>>>");
+/* espik_debug_print ("<<<<<<<< DUMMMMY CODE >>>>>>>"); */
free (tmp);
free (tmp2);
connected++;
- espik_leave();
}
void espik_con_up()
{
- espik_enter();
printf ("Connected\n");
- espik_leave();
}
void espik_con_shutdown ()
{
- espik_enter();
-
if (!connected)
espik_debug_print ("Unable to connect to server");
@@ -140,14 +127,12 @@ void espik_con_shutdown ()
ecore_main_loop_quit ();
espik_free (server_dns);
-
- espik_leave();
}
void espik_raw_send (const char *msg)
{
buf_t buf;
- espik_enter();
+ int i;
buf = make_buffer (strlen(msg) + 1); /* <MESSAGE>\r\n\0" */
@@ -156,7 +141,7 @@ void espik_raw_send (const char *msg)
espik_debug_print("strlen(msg): %d", strlen(msg));
espik_debug_print("buf.len: %d", buf.len);
buf.buf[buf.len-1] = '\n';
-// buf.buf[buf.len] = '\0';
+/* buf.buf[buf.len] = '\0'; */
espik_debug_print ("\n\nmsg(%d): %s\n\nout(%d-%d): %s\n", strlen(msg), msg, strlen(buf.buf), buf.len, buf.buf);
/*
@@ -165,17 +150,13 @@ void espik_raw_send (const char *msg)
printf ("out[len-1]: 0x%X\n", out[len - 1]);
*/
- int i;
for (i = 0 ; buf.buf[i] != 0 ; i++)
- {
espik_debug_print ("buf.buf[%d]: '%d'", i, buf.buf[i]);
- }
ret_int = ecore_con_server_send (con_sock, buf.buf, buf.len);
espik_debug_print ("ret_int: %d", ret_int);
free (buf.buf);
-// free (msg);
- espik_leave();
+/* free (msg); */
}