summaryrefslogtreecommitdiff
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
parentdcc6013961e0fe94d19293ee6539ec69b0100051 (diff)
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
20 20
21dnl espik specific check (include in m4) 21dnl espik specific check (include in m4)
22AC_C___ATTRIBUTE__ 22AC_C___ATTRIBUTE__
23AC_ESPIK_DEBUG
24 23
25AC_ARG_WITH(evas-config, 24AC_ARG_WITH(evas-config,
26[ --with-evas-config=EVAS_CONFIG use evas-config specified ], 25[ --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 @@
1dnl Debug mode
2AC_DEFUN([AC_ESPIK_DEBUG],
3[
4 AC_MSG_CHECKING(for debug)
5 AC_ARG_ENABLE(
6 [debug],
7 AC_HELP_STRING([--enable-debug], [Enable debug mode (default=yes)]),
8 [if test "$enable_debug" = "no"; then
9 debug="no"
10 else
11 debug="yes"
12 fi
13 ],
14 [debug="yes"])
15
16 if test "$debug" != "no"; then
17 debug="yes"
18 DEBUG_CFLAGS="-g -D_ESPIK_DEBUG_"
19 else
20 DEBUG_LDFLAGS="-s"
21 fi
22
23 AC_MSG_RESULT($debug ($DEBUG_CFLAGS$DEBUG_LDFLAGS))
24
25 AC_SUBST(DEBUG_CFLAGS)
26 AC_SUBST(DEBUG_LDFLAGS)
27])
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 @@
1## Process this file with automake to produce Makefile.in 1## Process this file with automake to produce Makefile.in
2 2
3AM_CFLAGS = \ 3AM_CFLAGS = \
4 $(DEBUG_CFLAGS) \ 4 -g \
5 -W -Wall \ 5 -W -Wall \
6 -Wdeclaration-after-statement \ 6 -Wdeclaration-after-statement \
7 -Wundef -Wold-style-definition \ 7 -Wundef -Wold-style-definition \
@@ -9,22 +9,19 @@ AM_CFLAGS = \
9 9
10ESPIKHEADERS = \ 10ESPIKHEADERS = \
11 espik.h \ 11 espik.h \
12 espik_config.h \
13 espik_common_handler.h \ 12 espik_common_handler.h \
13 espik_config.h \
14 espik_error.h \ 14 espik_error.h \
15 espik_debug.h \
16 espik_global.h 15 espik_global.h
17 16
18espik_SOURCES = \ 17espik_SOURCES = \
19 espik.c \ 18 espik.c \
20 espik_config.c \
21 espik_common_handler.c \ 19 espik_common_handler.c \
20 espik_config.c \
22 espik_error.c \ 21 espik_error.c \
23 espik_debug.c \
24 $(ESPIKHEADERS) 22 $(ESPIKHEADERS)
25 23
26espik_LDADD = \ 24espik_LDADD = \
27 $(DEBUG_LDFLAGS) \
28 @ecore_libs@ 25 @ecore_libs@
29 26
30bin_PROGRAMS = espik 27bin_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 @@
11#include <Ecore_Data.h> /* List */ 11#include <Ecore_Data.h> /* List */
12 12
13/* Espik Stuff */ 13/* Espik Stuff */
14#include "espik.h"
15#include "espik_global.h" 14#include "espik_global.h"
16#include "espik_config.h" 15#include "espik_config.h"
17#include "espik_common_handler.h" 16#include "espik_common_handler.h"
18#include "espik_debug.h" 17#include "espik.h"
19 18
20typedef int (*Handler_Func) (void *data, int ev_type, void *ev); 19typedef int (*Handler_Func) (void *data, int ev_type, void *ev);
21 20
22/* 21/* typedef int (*Handler_Fd_Func) (void *data, Ecore_Fd_Handler * fd_handler); */
23typedef int (*Handler_Fd_Func) (void *data, Ecore_Fd_Handler * fd_handler);
24*/
25
26static void espik_init(void)
27{
28 ptr_list = ecore_list_new();
29}
30 22
31static void espik_destroy_ptr(void *ptr) 23static void espik_destroy_ptr(void *ptr)
32{ 24{
33 if (ptr) 25 if (ptr)
34 { 26 {
35 espik_debug_print("Freeing data..."); 27 printf ("Freeing data...");
36 free (ptr); 28 free (ptr);
37 ptr = NULL; 29 ptr = NULL;
38 } 30 }
39} 31}
40 32
33static void espik_init(void)
34{
35 printf ("Welcome to %s-%s\n", APPS_NAME, ESPIK_VERSION);
36 ptr_list = ecore_list_new();
37
38 if (!ecore_init ())
39 {
40 printf ("Cannot init ecore; %d\n", 1);
41 exit (-1);
42 }
43
44 ecore_list_set_free_cb (ptr_list, espik_destroy_ptr);
45}
46
41void espik_free (void *ptr) 47void espik_free (void *ptr)
42{ 48{
43 espik_enter();
44 ecore_list_append (ptr_list, ptr); 49 ecore_list_append (ptr_list, ptr);
45 espik_leave();
46} 50}
47 51
48void espik_shutdown(void) 52void espik_shutdown(void)
@@ -54,9 +58,8 @@ void espik_shutdown(void)
54int del_backslash (char *msg) 58int del_backslash (char *msg)
55{ 59{
56 int i, count; 60 int i, count;
57 espik_enter();
58 61
59 for (i = 0, count = 0; msg[i]; i++) 62 for (i = 0, count = 0 ; msg[i] ; i++)
60 { 63 {
61 if (msg[i] == '\n') 64 if (msg[i] == '\n')
62 { 65 {
@@ -65,26 +68,14 @@ int del_backslash (char *msg)
65 } 68 }
66 } 69 }
67 70
68 espik_leave();
69 return (count); 71 return (count);
70} 72}
71 73
72int main (int argc, char **argv) 74int main (int argc, char **argv)
73{ 75{
74 Ecore_Fd_Handler *fd_kb; 76 Ecore_Fd_Handler *fd_kb;
75 __indent_level = 0;
76 espik_enter();
77
78 printf ("Welcome to %s-%s\n", APPS_NAME, ESPIK_VERSION);
79 espik_init();
80 77
81 if (!ecore_init ()) 78 espik_init ();
82 {
83 printf ("Cannot init ecore; %d\n", 1);
84 exit (-1);
85 }
86
87 ecore_list_set_free_cb(ptr_list, espik_destroy_ptr);
88 espik_config_init (); 79 espik_config_init ();
89 80
90 if (argc < 3) 81 if (argc < 3)
@@ -118,12 +109,9 @@ int main (int argc, char **argv)
118 exit (-1); 109 exit (-1);
119 } 110 }
120 111
121 /* Init IRC connection */
122
123 ecore_main_loop_begin (); 112 ecore_main_loop_begin ();
124 113
125 espik_shutdown(); 114 espik_shutdown();
126 espik_debug_print ("end");
127 115
128 espik_config_shutdown (a_infos); 116 espik_config_shutdown (a_infos);
129 117
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 @@
6#include <Ecore.h> 6#include <Ecore.h>
7 7
8#include "espik_global.h" 8#include "espik_global.h"
9#include "espik_common_handler.h"
10#include "espik.h" 9#include "espik.h"
11#include "espik_error.h" 10#include "espik_error.h"
12#include "espik_debug.h" 11#include "espik_common_handler.h"
13 12
14#define INPUT_LENGHT 200 13#define INPUT_LENGHT 200
15 14
@@ -17,7 +16,6 @@ int kb_get (void* data __UNUSED__, Ecore_Fd_Handler* fd_handler)
17{ 16{
18 char kb[INPUT_LENGHT]; 17 char kb[INPUT_LENGHT];
19 int count; 18 int count;
20 espik_enter();
21 19
22 do 20 do
23 { 21 {
@@ -28,7 +26,7 @@ int kb_get (void* data __UNUSED__, Ecore_Fd_Handler* fd_handler)
28 if (count > 1) 26 if (count > 1)
29 { 27 {
30 del_backslash (kb); 28 del_backslash (kb);
31 espik_debug_print ("%s", kb); 29 printf ("%s", kb);
32 } 30 }
33 } 31 }
34 while (count >= INPUT_LENGHT - 2); 32 while (count >= INPUT_LENGHT - 2);
@@ -46,6 +44,5 @@ int kb_get (void* data __UNUSED__, Ecore_Fd_Handler* fd_handler)
46 return (0); 44 return (0);
47 } 45 }
48 46
49 espik_leave();
50 return (1); 47 return (1);
51} 48}
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 @@
8 8
9#include <Ecore_Config.h> 9#include <Ecore_Config.h>
10 10
11#include "espik_config.h"
12#include "espik_error.h" 11#include "espik_error.h"
13#include "espik_debug.h" 12#include "espik_config.h"
14 13
15static int ret; /* For debug */ 14static int ret; /* For debug */
16 15
17t_servinfo* espik_server_config_set (char* server, unsigned short port) 16t_servinfo* espik_server_config_set (char* server, unsigned short port)
18{ 17{
19 t_servinfo* s_info; 18 t_servinfo* s_info;
20 espik_enter();
21 19
22 s_info = malloc (sizeof (t_servinfo)); 20 s_info = malloc (sizeof (t_servinfo));
23 21
@@ -25,7 +23,6 @@ t_servinfo* espik_server_config_set (char* server, unsigned short port)
25 s_info->port = port; 23 s_info->port = port;
26 24
27 espik_free (server); 25 espik_free (server);
28 espik_leave();
29 return (s_info); 26 return (s_info);
30} 27}
31 28
@@ -33,7 +30,6 @@ t_userinfo* espik_user_sysinfo_get (void)
33{ 30{
34 struct passwd* pw; 31 struct passwd* pw;
35 t_userinfo* u_info; 32 t_userinfo* u_info;
36 espik_enter();
37 33
38 pw = getpwuid (getuid ()); 34 pw = getpwuid (getuid ());
39 35
@@ -51,14 +47,12 @@ t_userinfo* espik_user_sysinfo_get (void)
51 espik_free (u_info); 47 espik_free (u_info);
52 espik_free (pw); 48 espik_free (pw);
53 49
54 espik_leave();
55 return (u_info); 50 return (u_info);
56} 51}
57 52
58void espik_config_default_set (void) 53void espik_config_default_set (void)
59{ 54{
60 t_userinfo* user_sysinfo; 55 t_userinfo* user_sysinfo;
61 espik_enter();
62 56
63 ecore_config_string_default ("/config/server/0/host", "beber.melee"); 57 ecore_config_string_default ("/config/server/0/host", "beber.melee");
64 ecore_config_int_default ("/config/server/0/port", 6667); 58 ecore_config_int_default ("/config/server/0/port", 6667);
@@ -78,16 +72,13 @@ void espik_config_default_set (void)
78 espik_free (user_sysinfo->username); 72 espik_free (user_sysinfo->username);
79 espik_free (user_sysinfo->realname); 73 espik_free (user_sysinfo->realname);
80 espik_free (user_sysinfo); 74 espik_free (user_sysinfo);
81 espik_leave();
82} 75}
83 76
84void espik_config_init (void) 77void espik_config_init (void)
85{ 78{
86 espik_enter();
87
88 if ((ret = ecore_config_init (APPS_NAME)) != ECORE_CONFIG_ERR_SUCC) 79 if ((ret = ecore_config_init (APPS_NAME)) != ECORE_CONFIG_ERR_SUCC)
89 { 80 {
90 espik_debug_print ("Init ecore_config failed (%d)", ret); 81 printf ("Init ecore_config failed (%d)", ret);
91 //kill_me (2); 82 //kill_me (2);
92 //exit (ret); 83 //exit (ret);
93 } 84 }
@@ -96,14 +87,13 @@ void espik_config_init (void)
96 { 87 {
97 /* If an config option is not present, 88 /* If an config option is not present,
98 * this will force it to a value */ 89 * this will force it to a value */
99 espik_debug_print ("Load ecore_config failed (%d)", ret); 90 printf ("Load ecore_config failed (%d)", ret);
100 espik_config_default_set (); 91 espik_config_default_set ();
101 /* 92 /*
102 kill_me (2); 93 kill_me (2);
103 exit (ret); 94 exit (ret);
104 */ 95 */
105 } 96 }
106 espik_leave();
107} 97}
108 98
109void espik_config_shutdown (t_info s_info) 99void espik_config_shutdown (t_info s_info)
@@ -118,8 +108,6 @@ void espik_config_shutdown (t_info s_info)
118 108
119void espik_config_get (t_info *s_info) 109void espik_config_get (t_info *s_info)
120{ 110{
121 espik_enter();
122
123 s_info->server = malloc (sizeof (t_servinfo)); 111 s_info->server = malloc (sizeof (t_servinfo));
124 s_info->client = malloc (sizeof (t_userinfo)); 112 s_info->client = malloc (sizeof (t_userinfo));
125 113
@@ -137,16 +125,13 @@ void espik_config_get (t_info *s_info)
137 125
138 if (ecore_config_save () != ECORE_CONFIG_ERR_SUCC) 126 if (ecore_config_save () != ECORE_CONFIG_ERR_SUCC)
139 { 127 {
140 espik_debug_print ("Save ecore_config failed"); 128 printf ("Save ecore_config failed");
141 exit (-1); 129 exit (-1);
142 } 130 }
143 espik_leave();
144} 131}
145 132
146void espik_config_set (t_info config) 133void espik_config_set (t_info config)
147{ 134{
148 espik_enter();
149
150 ecore_config_int_set ("/config/server/len", 1); 135 ecore_config_int_set ("/config/server/len", 1);
151 ecore_config_string_set ("/config/server/0/host", config.server->host); 136 ecore_config_string_set ("/config/server/0/host", config.server->host);
152 ecore_config_int_set ("/config/server/0/port", 137 ecore_config_int_set ("/config/server/0/port",
@@ -162,8 +147,7 @@ void espik_config_set (t_info config)
162 147
163 if (ecore_config_save () != ECORE_CONFIG_ERR_SUCC) 148 if (ecore_config_save () != ECORE_CONFIG_ERR_SUCC)
164 { 149 {
165 espik_debug_print ("Save ecore_config failed"); 150 printf ("Save ecore_config failed");
166 exit (-1); 151 exit (-1);
167 } 152 }
168 espik_leave();
169} 153}
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 @@
1#include <unistd.h>
2#include <stdio.h>
3#include <stdlib.h>
4
5#include "espik_debug.h"
6
7#ifdef __GLIBC__
8#include <execinfo.h>
9#endif /* __GLIBC__ */
10
11#ifdef _ESPIK_DEBUG_
12#include <signal.h>
13#endif /* _ESPIK_DEBUG_ */
14
15#if 0
16inline void espik_debug_bt (int num)
17{
18#if 0
19#ifdef __GLIBC__
20#ifdef _ESPIK_DEBUG_
21
22 void* array[128];
23 size_t size;
24 char** strings;
25 size_t i;
26
27 /*
28 if (!debug_bt)
29 return;
30 */
31
32 fprintf(stderr, "\n***** Backtrace (Signal %d) *****\n", num);
33 size = backtrace(array, 128);
34 strings = backtrace_symbols(array, size);
35 for (i = 0 ; i < size ; i++)
36 fprintf(stderr, "%s\n", strings[i]);
37
38 if (strings)
39 free(strings);
40
41#endif /* _ESPIK_DEBUG_ */
42#endif /* __GLIBC__ */
43
44#ifndef __GLIBC__
45 fprintf(stderr, "Your system doesn't have glibc. Backtraces disabled."
46 "But program receive signal %d.\n", num);
47#endif /* __GLIBC__ */
48#endif
49 num ++; /* Just for avoid warning */
50}
51
52void espik_debug_init()
53{
54#ifdef _ESPIK_DEBUG_
55 struct sigaction sa;
56
57 sa.sa_handler = espik_debug_bt;
58 memset (&sa, 0, sizeof (struct sigaction));
59 sigaction(SIGSEGV, &sa, (struct sigaction *)0);
60 sigaction(SIGINT, &sa, (struct sigaction *)0);
61 sigaction(SIGKILL, &sa, (struct sigaction *)0);
62#endif /* _ESPIK_DEBUG_ */
63}
64
65void kill_me (short num)
66{
67 espik_debug_bt(num);
68 exit (num);
69}
70
71#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 @@
1#ifndef ESPIK_DEBUG_H
2#define ESPIK_DEBUG_H
3
4#include "espik_global.h"
5
6#define DEBUG_PRINT_FILENO stdout
7#define DEBUG_ENTLEV_FILENO stderr
8
9
10#if defined (_ESPIK_DEBUG_) && defined (__GNUC__)
11#define espik_debug_print(fmt, ...) \
12{ \
13 fprintf (DEBUG_PRINT_FILENO, "%s +%i @%s: '", __FILE__, __LINE__, \
14 __func__); \
15 fprintf (DEBUG_PRINT_FILENO, fmt, ##__VA_ARGS__); \
16 fprintf (DEBUG_PRINT_FILENO, "'\n"); \
17}
18#else
19#define espik_debug_print(fmt, ...) \
20{ \
21}
22#endif /* _ESPIK_DEBUG_ && __GNUC__ */
23
24#ifdef _ESPIK_DEBUG_
25int __indent_level;
26
27#define espik_enter() \
28{ \
29 __indent_level++; \
30 fprintf (DEBUG_ENTLEV_FILENO, ">%*c%s +%i @%s\n", __indent_level, ' ', \
31 __FILE__, __LINE__, __func__); \
32}
33//#define espik_enter() {}
34
35#define espik_leave() \
36{ \
37 fprintf (DEBUG_ENTLEV_FILENO, "<%*c%s +%i @%s\n", __indent_level, ' ', \
38 __FILE__, __LINE__, __func__); \
39 __indent_level--; \
40}
41//#define espik_leave() {}
42
43#else
44
45#define espik_enter() \
46{ \
47}
48
49#define espik_leave() \
50{ \
51}
52
53#endif /* _ESPIK_DEBUG_ */
54
55#if 0
56inline void espik_bt (void);
57void espik_debug_init();
58void kill_me (short num);
59#endif
60
61#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 @@
10#include "espik_error.h" 10#include "espik_error.h"
11/*#include "espik_common_handler.h"*/ 11/*#include "espik_common_handler.h"*/
12#include "espik_net.h" 12#include "espik_net.h"
13#include "espik_debug.h"
14#include "espik.h" 13#include "espik.h"
15 14
16char* current_chan; 15char* current_chan;
@@ -22,12 +21,12 @@ typedef struct
22} cmd_t; 21} cmd_t;
23 22
24cmd_t cmd_tab[] = { 23cmd_t cmd_tab[] = {
25 { "JOIN", irc_join }, 24 { "JOIN", irc_join },
26 { "PART", irc_part }, 25 { "PART", irc_part },
27 { "PRIVMSG", irc_privmsg }, 26 { "PRIVMSG", irc_privmsg },
28 { "QUIT", irc_quit }, 27 { "QUIT", irc_quit },
29 { "RAW", irc_raw }, 28 { "RAW", irc_raw },
30 { "NICK", irc_nick }, 29 { "NICK", irc_nick },
31/* { "ACTION", irc_action }, */ 30/* { "ACTION", irc_action }, */
32 { 0, 0 } 31 { 0, 0 }
33}; 32};
@@ -40,7 +39,6 @@ char** separate_commandline (char *msg)
40{ 39{
41 unsigned int len; 40 unsigned int len;
42 char** two_words; 41 char** two_words;
43 espik_enter();
44 42
45 /* Yes, do nothing, just get len ! */ 43 /* Yes, do nothing, just get len ! */
46 for (len = 0 ; msg[len] != ' ' && msg[len] != '\t' ; len++); 44 for (len = 0 ; msg[len] != ' ' && msg[len] != '\t' ; len++);
@@ -56,7 +54,6 @@ char** separate_commandline (char *msg)
56 } 54 }
57 while (*two_words[1] == ' ' || *two_words[1] == '\t'); 55 while (*two_words[1] == ' ' || *two_words[1] == '\t');
58 56
59 espik_leave();
60 return (two_words); 57 return (two_words);
61} 58}
62 59
@@ -80,27 +77,22 @@ void string_upper (char *str)
80 77
81unsigned short sendmsg_len (char* msg) 78unsigned short sendmsg_len (char* msg)
82{ 79{
83 espik_enter();
84 espik_leave();
85 return (strlen (msg) + 2); 80 return (strlen (msg) + 2);
86} 81}
87 82
88buf_t make_buffer(int len) 83buf_t make_buffer(int len)
89{ 84{
90 buf_t buf; 85 buf_t buf;
91 espik_enter();
92 86
93 buf.buf = malloc (len); 87 buf.buf = malloc (len);
94 buf.len = len + 1; /* Alloc trailing \0 */ 88 buf.len = len + 1; /* Alloc trailing \0 */
95 89
96 espik_leave();
97 return (buf); 90 return (buf);
98} 91}
99 92
100char* irc_privmsg (char* chan, char* msg) 93char* irc_privmsg (char* chan, char* msg)
101{ 94{
102 buf_t out; 95 buf_t out;
103 espik_enter();
104 96
105 out = make_buffer (strlen ("PRIVMSG") + 1 /* "PRIVMSG " */ 97 out = make_buffer (strlen ("PRIVMSG") + 1 /* "PRIVMSG " */
106 + strlen (chan) + 2 /* ":<channel> "*/ 98 + strlen (chan) + 2 /* ":<channel> "*/
@@ -109,14 +101,12 @@ char* irc_privmsg (char* chan, char* msg)
109 snprintf (out.buf, out.len, "PRIVMSG %s :%s", chan, msg); 101 snprintf (out.buf, out.len, "PRIVMSG %s :%s", chan, msg);
110 102
111 free (msg); 103 free (msg);
112 espik_leave();
113 return (out.buf); 104 return (out.buf);
114} 105}
115 106
116char* irc_join (char* chan __UNUSED__, char* msg) 107char* irc_join (char* chan __UNUSED__, char* msg)
117{ 108{
118 buf_t out; 109 buf_t out;
119 espik_enter();
120 110
121 /* Could also by '&' and so one ... 111 /* Could also by '&' and so one ...
122 * have to look on RFC, dev will be done with # only */ 112 * have to look on RFC, dev will be done with # only */
@@ -124,7 +114,6 @@ char* irc_join (char* chan __UNUSED__, char* msg)
124 { 114 {
125 espik_debug_print ("%s is not a channel", msg); 115 espik_debug_print ("%s is not a channel", msg);
126 espik_debug_print ("Usage: /JOIN #channel"); 116 espik_debug_print ("Usage: /JOIN #channel");
127 espik_leave();
128 return (0); 117 return (0);
129 } 118 }
130 119
@@ -134,14 +123,12 @@ char* irc_join (char* chan __UNUSED__, char* msg)
134 snprintf (out.buf, out.len, "JOIN %s", msg); 123 snprintf (out.buf, out.len, "JOIN %s", msg);
135 124
136 free (msg); 125 free (msg);
137 espik_leave();
138 return (out.buf); 126 return (out.buf);
139} 127}
140 128
141char* irc_part (char* chan, char* msg) 129char* irc_part (char* chan, char* msg)
142{ 130{
143 buf_t out; 131 buf_t out;
144 espik_enter();
145 132
146 if (msg[0] != '#') 133 if (msg[0] != '#')
147 { 134 {
@@ -165,14 +152,12 @@ char* irc_part (char* chan, char* msg)
165 } 152 }
166 153
167 free (msg); 154 free (msg);
168 espik_leave();
169 return (out.buf); 155 return (out.buf);
170} 156}
171 157
172char* irc_quit (char* chan __UNUSED__, char* msg) 158char* irc_quit (char* chan __UNUSED__, char* msg)
173{ 159{
174 buf_t out; 160 buf_t out;
175 espik_enter();
176 161
177 out = make_buffer (strlen ("QUIT") + 2 /* "QUIT :" */ 162 out = make_buffer (strlen ("QUIT") + 2 /* "QUIT :" */
178 + strlen (msg)); /* "<msg>EOF" */ 163 + strlen (msg)); /* "<msg>EOF" */
@@ -189,20 +174,16 @@ char* irc_quit (char* chan __UNUSED__, char* msg)
189 */ 174 */
190 free (msg); 175 free (msg);
191 176
192 espik_leave();
193 return (out.buf); 177 return (out.buf);
194} 178}
195 179
196char* irc_raw (char* chan __UNUSED__, char* msg) 180char* irc_raw (char* chan __UNUSED__, char* msg)
197{ 181{
198 espik_enter();
199 espik_leave();
200 return (msg); 182 return (msg);
201} 183}
202 184
203char* irc_nick (char* chan __UNUSED__, char* nick) 185char* irc_nick (char* chan __UNUSED__, char* nick)
204{ 186{
205 espik_enter();
206 buf_t out; 187 buf_t out;
207 188
208 out = make_buffer (strlen ("NICK") + 1 /* "NICK " */ 189 out = make_buffer (strlen ("NICK") + 1 /* "NICK " */
@@ -212,7 +193,6 @@ char* irc_nick (char* chan __UNUSED__, char* nick)
212 193
213 espik_debug_print ("NICK CHANGED REQUEST: %s", nick); 194 espik_debug_print ("NICK CHANGED REQUEST: %s", nick);
214 195
215 espik_leave();
216 return (out.buf); 196 return (out.buf);
217} 197}
218 198
@@ -237,7 +217,6 @@ void irc_disconnect (Ecore_Con_Server *sock)
237char* irc_send (char* msg) 217char* irc_send (char* msg)
238{ 218{
239 char* out; 219 char* out;
240 espik_enter();
241 220
242 out = NULL; 221 out = NULL;
243 222
@@ -273,24 +252,19 @@ char* irc_send (char* msg)
273 { 252 {
274 espik_debug_print ("%s is not a know command", 253 espik_debug_print ("%s is not a know command",
275 cmd_and_message[0]); 254 cmd_and_message[0]);
276 espik_leave();
277 return (0); 255 return (0);
278 } 256 }
279 } 257 }
280 else 258 else
281 {
282 out = irc_privmsg (current_chan, msg); 259 out = irc_privmsg (current_chan, msg);
283 }
284 260
285 if (!out) 261 if (!out)
286 { 262 {
287 free (msg); 263 free (msg);
288 espik_leave();
289 return (0); 264 return (0);
290 } 265 }
291 266
292 espik_debug_print ("%s", out); 267 espik_debug_print ("%s", out);
293 268
294 espik_leave();
295 return (out); 269 return (out);
296} 270}
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 @@
4#include <stdlib.h> 4#include <stdlib.h>
5 5
6#include "espik_global.h" 6#include "espik_global.h"
7#include "espik_net.h"
8#include "espik_common_handler.h" 7#include "espik_common_handler.h"
9#include "espik_error.h" 8#include "espik_error.h"
10#include "espik_debug.h"
11#include "espik_irc.h" 9#include "espik_irc.h"
12#include "espik.h" 10#include "espik.h"
11#include "espik_net.h"
13 12
14#include <Ecore.h> 13#include <Ecore.h>
15#include <Ecore_Con.h> 14#include <Ecore_Con.h>
@@ -26,15 +25,11 @@ Ecore_Event_Handler* ret;
26void espik_con_init (t_info serv_info) 25void espik_con_init (t_info serv_info)
27{ 26{
28 int nb_launch; 27 int nb_launch;
29 espik_enter();
30 28
31 nb_launch = ecore_con_init (); 29 nb_launch = ecore_con_init ();
32
33 com_active = 0; 30 com_active = 0;
34 31
35 /* 32 /* espik_debug_printf ("nb_launch = %d", nb_launch); */
36 espik_debug_printf ("nb_launch = %d", nb_launch);
37 */
38 33
39 con_sock = ecore_con_server_connect (ECORE_CON_REMOTE_SYSTEM, 34 con_sock = ecore_con_server_connect (ECORE_CON_REMOTE_SYSTEM,
40 serv_info.server->host, 35 serv_info.server->host,
@@ -73,14 +68,11 @@ void espik_con_init (t_info serv_info)
73 exit (-1); 68 exit (-1);
74 } 69 }
75 espik_free (ret); 70 espik_free (ret);
76
77 espik_leave();
78} 71}
79 72
80void send_login() 73void send_login()
81{ 74{
82 espik_enter(); 75/* espik_debug_print ("<<<<<<<< DUMMMMY CODE >>>>>>>"); */
83// espik_debug_print ("<<<<<<<< DUMMMMY CODE >>>>>>>");
84 76
85 char *tmp, *tmp2; 77 char *tmp, *tmp2;
86 78
@@ -104,26 +96,21 @@ void send_login()
104 96
105 com_active = 1; 97 com_active = 1;
106 98
107// espik_debug_print ("<<<<<<<< DUMMMMY CODE >>>>>>>"); 99/* espik_debug_print ("<<<<<<<< DUMMMMY CODE >>>>>>>"); */
108 100
109 free (tmp); 101 free (tmp);
110 free (tmp2); 102 free (tmp2);
111 103
112 connected++; 104 connected++;
113 espik_leave();
114} 105}
115 106
116void espik_con_up() 107void espik_con_up()
117{ 108{
118 espik_enter();
119 printf ("Connected\n"); 109 printf ("Connected\n");
120 espik_leave();
121} 110}
122 111
123void espik_con_shutdown () 112void espik_con_shutdown ()
124{ 113{
125 espik_enter();
126
127 if (!connected) 114 if (!connected)
128 espik_debug_print ("Unable to connect to server"); 115 espik_debug_print ("Unable to connect to server");
129 116
@@ -140,14 +127,12 @@ void espik_con_shutdown ()
140 127
141 ecore_main_loop_quit (); 128 ecore_main_loop_quit ();
142 espik_free (server_dns); 129 espik_free (server_dns);
143
144 espik_leave();
145} 130}
146 131
147void espik_raw_send (const char *msg) 132void espik_raw_send (const char *msg)
148{ 133{
149 buf_t buf; 134 buf_t buf;
150 espik_enter(); 135 int i;
151 136
152 buf = make_buffer (strlen(msg) + 1); /* <MESSAGE>\r\n\0" */ 137 buf = make_buffer (strlen(msg) + 1); /* <MESSAGE>\r\n\0" */
153 138
@@ -156,7 +141,7 @@ void espik_raw_send (const char *msg)
156 espik_debug_print("strlen(msg): %d", strlen(msg)); 141 espik_debug_print("strlen(msg): %d", strlen(msg));
157 espik_debug_print("buf.len: %d", buf.len); 142 espik_debug_print("buf.len: %d", buf.len);
158 buf.buf[buf.len-1] = '\n'; 143 buf.buf[buf.len-1] = '\n';
159// buf.buf[buf.len] = '\0'; 144/* buf.buf[buf.len] = '\0'; */
160 145
161 espik_debug_print ("\n\nmsg(%d): %s\n\nout(%d-%d): %s\n", strlen(msg), msg, strlen(buf.buf), buf.len, buf.buf); 146 espik_debug_print ("\n\nmsg(%d): %s\n\nout(%d-%d): %s\n", strlen(msg), msg, strlen(buf.buf), buf.len, buf.buf);
162 /* 147 /*
@@ -165,17 +150,13 @@ void espik_raw_send (const char *msg)
165 printf ("out[len-1]: 0x%X\n", out[len - 1]); 150 printf ("out[len-1]: 0x%X\n", out[len - 1]);
166 */ 151 */
167 152
168 int i;
169 for (i = 0 ; buf.buf[i] != 0 ; i++) 153 for (i = 0 ; buf.buf[i] != 0 ; i++)
170 {
171 espik_debug_print ("buf.buf[%d]: '%d'", i, buf.buf[i]); 154 espik_debug_print ("buf.buf[%d]: '%d'", i, buf.buf[i]);
172 }
173 155
174 156
175 ret_int = ecore_con_server_send (con_sock, buf.buf, buf.len); 157 ret_int = ecore_con_server_send (con_sock, buf.buf, buf.len);
176 158
177 espik_debug_print ("ret_int: %d", ret_int); 159 espik_debug_print ("ret_int: %d", ret_int);
178 free (buf.buf); 160 free (buf.buf);
179// free (msg); 161/* free (msg); */
180 espik_leave();
181} 162}