summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--agni.c39
-rw-r--r--tbl_qcmd.c4
2 files changed, 21 insertions, 22 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
diff --git a/tbl_qcmd.c b/tbl_qcmd.c
index a8b42ab..874ad10 100644
--- a/tbl_qcmd.c
+++ b/tbl_qcmd.c
@@ -100,7 +100,7 @@ int tbl_exec_run(tbl_exec *tbl, char *cmd, void **resp)
for (i=0;i<tbl->size;i++)
{
el = tbl->cmd[i];
- PRINT("CALLBACK CMD %s\n",cmd);
+ //PRINT("CALLBACK CMD %s\n",cmd);
if (strncmp(el->cmd, cmd, strlen(el->cmd))==0)
{
void *ret_resp=NULL;
@@ -134,7 +134,7 @@ int tbl_exec_run(tbl_exec *tbl, char *cmd, void **resp)
}
}
- PRINT("CALLBACK PARAMS %s\n", clbk_data);
+ //PRINT("CALLBACK PARAMS %s\n", clbk_data);
ret_resp = el->callback(clbk_data); //no params for now