aboutsummaryrefslogtreecommitdiff
path: root/src/espik_irc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/espik_irc.c')
-rw-r--r--src/espik_irc.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/src/espik_irc.c b/src/espik_irc.c
index 731d7ad..cd3a572 100644
--- a/src/espik_irc.c
+++ b/src/espik_irc.c
@@ -9,9 +9,9 @@
#include "espik_irc.h"
#include "espik_error.h"
/*#include "espik_common_handler.h"*/
-#include "espik.h"
#include "espik_net.h"
#include "espik_debug.h"
+#include "espik.h"
char* current_chan;
@@ -46,6 +46,7 @@ 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++);
@@ -61,6 +62,7 @@ char** separate_commandline (char *msg)
}
while (*two_words[1] == ' ' || *two_words[1] == '\t');
+ espik_leave();
return (two_words);
}
@@ -68,6 +70,7 @@ char** separate_commandline (char *msg)
void string_upper (char *str)
{
unsigned int len, i;
+ espik_enter();
len = strlen (str);
@@ -77,27 +80,33 @@ void string_upper (char *str)
str[i] -= 0x20;
}
espik_debug_print ("string_upper: %s", str);
+ espik_leave();
}
#endif
unsigned short sendmsg_len (char* msg)
{
+ espik_enter();
+ espik_leave();
return (strlen (msg) + 2);
}
static buf_t make_buffer(int len)
{
buf_t buf;
+ espik_enter();
buf.buf = malloc (sizeof(char) * len);
buf.len = len;
+ 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> " */
@@ -105,12 +114,14 @@ char* irc_privmsg (char* chan, char* msg)
snprintf (out.buf, out.len, "PRIVMSG %s :%s", chan, 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 */
@@ -118,6 +129,7 @@ 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);
}
@@ -126,12 +138,14 @@ char* irc_join (char* chan __UNUSED__, char* msg)
snprintf (out.buf, out.len, "JOIN %s", msg);
+ espik_leave();
return (out.buf);
}
char* irc_part (char* chan, char* msg)
{
buf_t out;
+ espik_enter();
if (msg[0] != '#')
{
@@ -154,12 +168,14 @@ char* irc_part (char* chan, char* msg)
snprintf (out.buf, out.len, "PART %s :%s", sep[0], sep[1]);
}
+ 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) + 1); /* "<msg>EOF" */
@@ -175,16 +191,20 @@ char* irc_quit (char* chan __UNUSED__, char* msg)
irc_disconnect(sock);
*/
+ 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 " */
@@ -194,26 +214,32 @@ char* irc_nick (char* chan __UNUSED__, char* nick)
espik_debug_print ("NICK CHANGED REQUEST: %s", nick);
+ espik_leave();
return (out.buf);
}
#if 0
Ecore_Con_Server* irc_connect (char* host __UNUSED__, int port __UNUSED__)
{
+ espik_enter();
+ espik_leave();
return (NULL);
}
void irc_disconnect (Ecore_Con_Server *sock)
{
+ espik_enter();
espik_debug_print ("> irc_disconnect");
ecore_main_loop_quit ();
espik_debug_print ("< irc_disconnect");
+ espik_leave();
}
#endif
char* irc_send (char* msg)
{
char* out;
+ espik_enter();
out = NULL;
@@ -242,6 +268,7 @@ char* irc_send (char* msg)
if (!out)
{
espik_debug_print ("%s is not a know command", cmd_and_message[0]);
+ espik_leave();
return (0);
}
}
@@ -251,9 +278,13 @@ char* irc_send (char* msg)
}
if (!out)
+ {
+ espik_leave();
return (0);
+ }
espik_debug_print ("%sn", out);
+ espik_leave();
return (out);
}