diff options
Diffstat (limited to 'agni.c')
-rw-r--r-- | agni.c | 39 |
1 files changed, 31 insertions, 8 deletions
@@ -379,27 +379,50 @@ int th_start_client(void *data) char *user = alloc_new_str(cmd->ircident); //BUGGY user[sep-cmd->ircident] = 0x0; char *resp_user = token_new_str(cmd->tok, 2); - PRINT("resp_user %s\n",resp_user); + //PRINT("resp_user %s\n",resp_user); + int formated_size = -1; + + int count; + sds str_out; + sds *tokens; + int out_i; if (resp_user[0]=='#') { //printf("RESPONSE :%s PRIVMSG %s :%s\n", cfg->user, user, resp->result); - int fret = snprintf(cmd_buf, TH_CONN_BUF_SZ,":%s PRIVMSG %s :%s \r\n", cfg->user, resp_user, resp->result); - PRINT("%s\n",cmd_buf); - write(conn.conn_fd, cmd_buf, fret); + //formated_size = snprintf(cmd_buf, TH_CONN_BUF_SZ,":%s PRIVMSG %s :%s \r\n", cfg->user, resp_user, resp->result); + snprintf(cmd_buf, TH_CONN_BUF_SZ,":%s PRIVMSG %s :", cfg->user, resp_user); + //PRINT("%s\n",cmd_buf); + } else { //printf("RESPONSE :%s PRIVMSG %s :%s\n", user, resp_user, resp->result); - int fret = snprintf(cmd_buf, TH_CONN_BUF_SZ,":%s PRIVMSG %s :%s \r\n", resp_user, user, resp->result); - PRINT("%s\n",cmd_buf); - write(conn.conn_fd, cmd_buf, fret); + //formated_size = snprintf(cmd_buf, TH_CONN_BUF_SZ,":%s PRIVMSG %s :%s \r\n", resp_user, user, resp->result); + snprintf(cmd_buf, TH_CONN_BUF_SZ,":%s PRIVMSG %s :", resp_user, user); + //PRINT("%s\n",cmd_buf); } + str_out = sdsnew(resp->result); + tokens = sdssplitlen(str_out,sdslen(str_out),"\n",1,&count); + + for (out_i=0; out_i<count; out_i++) + { + sds sending = sdsnew(cmd_buf); + sending = sdscat(sending, tokens[out_i]); + sending = sdscat(sending," \r\n"); + printf("SEND>>>>%s",sending); + write(conn.conn_fd, sending, sdslen(sending)); + sdsfree(sending); + } + + sdsfreesplitres(tokens, count); + sdsfree(str_out); + FREE(user); FREE(resp_user); //remove command by id - //for now just remove command without checkings its state + //for now just remove command without checkings its state tbl_qcmd_del_by_id(qtbl, cmd_id); } } |