aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.in1
-rw-r--r--src/espik.c12
-rw-r--r--src/espik_common_handler.c5
-rw-r--r--src/espik_config.c15
-rw-r--r--src/espik_config.h1
-rw-r--r--src/espik_debug.h12
-rw-r--r--src/espik_irc.c19
-rw-r--r--src/espik_net.c24
8 files changed, 57 insertions, 32 deletions
diff --git a/configure.in b/configure.in
index c47245e..e9753a2 100644
--- a/configure.in
+++ b/configure.in
@@ -20,6 +20,7 @@ dnl espik specific check (include in m4)
AC_C___ATTRIBUTE__
AC_ESPIK_DEBUG
AC_CHK_ECORE
+AC_CHK_EVAS
AC_OUTPUT([
Makefile
diff --git a/src/espik.c b/src/espik.c
index f1d55dd..45b4dd7 100644
--- a/src/espik.c
+++ b/src/espik.c
@@ -122,28 +122,26 @@ int main (int argc, char **argv)
ecore_con_server_del (con_sock);
*/
- free (a_infos.server->host);
- free (a_infos.server);
+// free (a_infos.server->host);
+// free (a_infos.server);
/*
free (a_infos.client->nickname);
free (a_infos.client->username);
free (a_infos.client->realname);
*/
- free (a_infos.client);
+// free (a_infos.client);
- /*
- ecore_main_loop_quit ();
- */
espik_debug_print ("end");
- ecore_config_shutdown ();
+ espik_config_shutdown (&a_infos);
/*
espik_con_shutdown ();
*/
+ ecore_main_loop_quit ();
ecore_shutdown ();
//espik_leave();
diff --git a/src/espik_common_handler.c b/src/espik_common_handler.c
index d581dc4..3177cd9 100644
--- a/src/espik_common_handler.c
+++ b/src/espik_common_handler.c
@@ -108,6 +108,7 @@ int server_data (void* data __UNUSED__, int ev_type __UNUSED__,
espik_raw_send ("PONG guybrush.melee");
}
+ memset (msg, 0, strlen(msg));
free (msg);
espik_leave();
@@ -148,7 +149,7 @@ int kb_get (void* data __UNUSED__, Ecore_Fd_Handler* fd_handler)
if (count == 0)
{
- tmp = irc_quit ("", "^D pressed");
+ tmp = irc_quit (NULL, strdup("^D pressed"));
espik_debug_print ("tmp: %s", tmp);
espik_raw_send (tmp);
espik_debug_print ("AFTER espik_raw_send");
@@ -159,8 +160,6 @@ int kb_get (void* data __UNUSED__, Ecore_Fd_Handler* fd_handler)
*/
espik_con_shutdown ();
- ecore_main_loop_quit ();
-
free (tmp);
espik_leave();
return (0);
diff --git a/src/espik_config.c b/src/espik_config.c
index 168dfbf..6d6fc67 100644
--- a/src/espik_config.c
+++ b/src/espik_config.c
@@ -106,6 +106,21 @@ void espik_config_init ()
espik_leave();
}
+void espik_config_shutdown (t_info *s_info)
+{
+ free (s_info->server->host);
+// free (s_info->server->port);
+ free (s_info->server);
+ free (s_info->client->nickname);
+ free (s_info->client->username);
+ free (s_info->client->realname);
+ free (s_info->client);
+// free (s_info);
+
+ ecore_config_save();
+ ecore_config_shutdown();
+}
+
void espik_config_get (t_info *s_info)
{
espik_enter();
diff --git a/src/espik_config.h b/src/espik_config.h
index ea21ee9..e454cfd 100644
--- a/src/espik_config.h
+++ b/src/espik_config.h
@@ -10,6 +10,7 @@ void espik_config_default_set ();
void espik_config_init ();
void espik_config_get (t_info*);
void espik_config_set (t_info);
+void espik_config_shutdown (t_info *s_info);
#define ESPIK_CONFIG_VERSION 1
diff --git a/src/espik_debug.h b/src/espik_debug.h
index b17a9fd..fa28452 100644
--- a/src/espik_debug.h
+++ b/src/espik_debug.h
@@ -23,25 +23,25 @@
#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_enter() {}
-
-
+/*
#define espik_leave() \
{ \
fprintf (DEBUG_ENTLEV_FILENO, "<%*c%s +%i @%s\n", __indent_level, ' ', \
__FILE__, __LINE__, __func__); \
__indent_level--; \
}
-
-//#define espik_leave() {}
+*/
+#define espik_leave() {}
#else
diff --git a/src/espik_irc.c b/src/espik_irc.c
index 827a3e4..36408c8 100644
--- a/src/espik_irc.c
+++ b/src/espik_irc.c
@@ -91,7 +91,7 @@ buf_t make_buffer(int len)
espik_enter();
buf.buf = malloc (len);
- buf.len = len;
+ buf.len = len + 1;
espik_leave();
return (buf);
@@ -104,10 +104,11 @@ char* irc_privmsg (char* chan, char* msg)
out = make_buffer (strlen ("PRIVMSG") + 1 /* "PRIVMSG " */
+ strlen (chan) + 2 /* ":<channel> "*/
- + strlen (msg) + 1); /* "<msg>EOF" */
+ + strlen (msg)); /* "<msg>EOF" */
snprintf (out.buf, out.len, "PRIVMSG %s :%s", chan, msg);
+ free (msg);
espik_leave();
return (out.buf);
}
@@ -128,10 +129,11 @@ char* irc_join (char* chan __UNUSED__, char* msg)
}
out = make_buffer (strlen ("JOIN") + 1 /* "JOIN " */
- + strlen (msg) + 1); /* "<msg>EOF" */
+ + strlen (msg)); /* "<msg>EOF" */
snprintf (out.buf, out.len, "JOIN %s", msg);
+ free (msg);
espik_leave();
return (out.buf);
}
@@ -145,7 +147,7 @@ char* irc_part (char* chan, char* msg)
{
out = make_buffer (strlen ("PART") + 1 /* "PART " */
+ strlen (chan) + 2 /* ":<chan> " */
- + strlen (msg) + 1); /* "<msg>EOF" */
+ + strlen (msg)); /* "<msg>EOF" */
snprintf (out.buf, out.len, "PART %s :%s", chan, msg);
}
@@ -157,11 +159,12 @@ char* irc_part (char* chan, char* msg)
out = make_buffer (strlen ("PART") + 1 /* "PART " */
+ strlen (sep[0]) + 2 /* ":<chan> "*/
- + strlen (sep[1]) + 1); /* "<msg>EOF"*/
+ + strlen (sep[1])); /* "<msg>EOF"*/
snprintf (out.buf, out.len, "PART %s :%s", sep[0], sep[1]);
}
+ free (msg);
espik_leave();
return (out.buf);
}
@@ -172,7 +175,7 @@ char* irc_quit (char* chan __UNUSED__, char* msg)
espik_enter();
out = make_buffer (strlen ("QUIT") + 2 /* "QUIT :" */
- + strlen (msg) + 1); /* "<msg>EOF" */
+ + strlen (msg)); /* "<msg>EOF" */
snprintf (out.buf, out.len, "QUIT :%s", msg);
@@ -203,7 +206,7 @@ char* irc_nick (char* chan __UNUSED__, char* nick)
buf_t out;
out = make_buffer (strlen ("NICK") + 1 /* "NICK " */
- + strlen (nick) + 1); /* "<nick>EOF" */
+ + strlen (nick)); /* "<nick>EOF" */
snprintf (out.buf, out.len, "NICK %s", nick);
@@ -277,11 +280,11 @@ char* irc_send (char* msg)
else
{
out = irc_privmsg (current_chan, msg);
- free (msg);
}
if (!out)
{
+ free (msg);
espik_leave();
return (0);
}
diff --git a/src/espik_net.c b/src/espik_net.c
index e638682..c8b7652 100644
--- a/src/espik_net.c
+++ b/src/espik_net.c
@@ -93,12 +93,16 @@ void send_login()
espik_raw_send (tmp);
espik_debug_print("tmp2: %s", tmp2);
espik_raw_send (tmp2);
- espik_raw_send ("JOIN #e.fr");
+ espik_raw_send (strdup ("JOIN #e.fr"));
com_active = 1;
// espik_debug_print ("<<<<<<<< DUMMMMY CODE >>>>>>>");
+/* free (tmp);
+ free (tmp2);
+ */
+
connected++;
espik_leave();
}
@@ -122,6 +126,7 @@ void espik_con_shutdown ()
ecore_con_shutdown ();
ecore_main_loop_quit ();
+ free (server_dns);
espik_leave();
}
@@ -130,11 +135,13 @@ void espik_raw_send (char *msg)
buf_t buf;
espik_enter();
- buf = make_buffer (strlen(msg) + 2);
+ buf = make_buffer (strlen(msg) + 2); /* <MESSAGE>\r\n\0" */
- snprintf (buf.buf, buf.len, "%s\r", msg);
- /* Overid trailing \0 */
- buf.buf[strlen(buf.buf)] = '\n';
+ snprintf (buf.buf, buf.len, "%s\r\n", msg);
+ /* Override trailing \0 */
+ espik_debug_print("strlen(msg): %d", strlen(msg));
+ espik_debug_print("buf.len: %d", buf.len);
+ buf.buf[buf.len] = '\n';
espik_debug_print ("\n\nmsg(%d): %s\n\nout(%d-%d): %s\n", strlen(msg), msg, strlen(buf.buf), buf.len, buf.buf);
/*
@@ -145,15 +152,16 @@ void espik_raw_send (char *msg)
/*
int i;
- for (i = 0 ; i < buf.len ; i++)
+ for (i = 0 ; i < buf.len; i++)
{
- espik_debug_print ("buf.buf[%d]: '%c' '%d'", i, buf.buf[i], buf.buf[i]);
+ espik_debug_print ("buf.buf[%d]: '%d'", i, buf.buf[i]);
}
*/
- ret = ecore_con_server_send (con_sock, buf.buf, buf.len);
+ ret = ecore_con_server_send (con_sock, buf.buf, buf.len-1);
espik_debug_print ("ret: %d", ret);
free (buf.buf);
+// free (msg);
espik_leave();
}