aboutsummaryrefslogtreecommitdiffstats
path: root/agni.c
diff options
context:
space:
mode:
authorFreeArtMan <dos21h@gmail.com>2017-05-07 23:29:37 +0100
committerFreeArtMan <dos21h@gmail.com>2017-05-07 23:29:37 +0100
commitd43cf6e4704da5414c80e32da06060ad06511f62 (patch)
treea186407e73525c66a29ffa4f8c734cae7a5db385 /agni.c
parent67664bcf54a128bd9cfb76f4fc047131e740cbc2 (diff)
downloadagni-d43cf6e4704da5414c80e32da06060ad06511f62.tar.gz
agni-d43cf6e4704da5414c80e32da06060ad06511f62.zip
Fixed bug with not sending correctly PONG to response to PING
Diffstat (limited to 'agni.c')
-rw-r--r--agni.c39
1 files changed, 19 insertions, 20 deletions
diff --git a/agni.c b/agni.c
index e0055be..2bdba8b 100644
--- a/agni.c
+++ b/agni.c
@@ -389,22 +389,31 @@ int th_start_client(void *data)
//recieve irc commands and pass to MQ, save command to table
//fix this by allowing drain just chunks, not whole buffer
- //memset(conn_buf, 0, TH_CONN_BUF_SZ);
+ memset(conn_buf, 0, TH_CONN_BUF_SZ);
if((cret = read(conn,conn_buf, 256))>0)
{
irc_buf_puts(ib, conn_buf, cret);
while (irc_buf_ready(ib) == 1)
{
+
irc_line = irc_buf_line(ib);
if (irc_line)
{
- printf("PARSE>>%s\n",irc_line);
+ printf("PARSE>>%s<<\n",irc_line);
+
+
if (memcmp(irc_line,"PING",4)==0)
{
- write(conn,"PONG",strlen("PONG"));
- printf("OUT>>PONG\n");
+ int fret;
+ const int pong_buf_sz = 128;
+ char pong_buf[pong_buf_sz];
+ snprintf(pong_buf,pong_buf_sz,"PONG %s\n",cfg->user);
+ PRINT("%s",pong_buf)
+ fret = write(conn,pong_buf,strlen(pong_buf));
+ printf("OUT>>PONG %d\n",fret);
}
+
itok = irc_parse(irc_line,strlen(irc_line));
if (itok != NULL)
{
@@ -418,12 +427,6 @@ int th_start_client(void *data)
{
}
- if (token_cmp(itok,1,"PING")==1)
- {
- int fret;
- fret = write(conn,"PONG",strlen("PONG"));
- printf("OUT<<Send %d\n", fret);
- }
//something is sended to cbot
if (token_cmp(itok,1,"PRIVMSG") == 1)
{
@@ -508,7 +511,12 @@ int th_start_client(void *data)
token_destroy(itok);
itok = NULL;
}
- FREE(irc_line);
+ if (irc_line!=NULL)
+ {
+ memset(irc_line,0,strlen(irc_line));
+ free(irc_line);
+ irc_line = NULL;
+ }
__irc_buf_drain_io(ib);
}
@@ -672,15 +680,6 @@ int th_event_manager(void *data)
{
printf("QUIT recieved lets quit main loop\n");
break;
- } else if (mq_cmd_o_cmp_cmd(recv_cmd,"PING") == 0)
- {
- printf("Its fine im working\n");
-
- //create command and send to mq
- char msg[] = "PONG";
- mq_cmd *privcmd = mq_cmd_create(mq_cmd_id(recv_cmd),"PRIVMSG",strlen("PRIVMSG"),msg,strlen(msg));
-
- mq_cmd_free(privcmd);
} else if (mq_cmd_o_cmp_cmd(recv_cmd,"PRIVMSG") == 0)
{
//check if command callback excists