diff options
author | FreeArtMan <dos21h@gmail.com> | 2017-09-07 23:00:20 +0100 |
---|---|---|
committer | FreeArtMan <dos21h@gmail.com> | 2017-09-07 23:00:20 +0100 |
commit | fc6970fcd404305c3e16d2e90d6d0dec4b03c160 (patch) | |
tree | ccd7caaf37ee746f71b09e6e80ef5ebe5d7db6f1 | |
parent | 08f96759f9b1d5e8b1dd300971d23f833b819e7c (diff) | |
download | agni-fc6970fcd404305c3e16d2e90d6d0dec4b03c160.tar.gz agni-fc6970fcd404305c3e16d2e90d6d0dec4b03c160.zip |
Basic stat command implemented
-rw-r--r-- | agni.c | 39 | ||||
-rw-r--r-- | cmd/cmd_stat.c | 2 |
2 files changed, 32 insertions, 9 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); } } diff --git a/cmd/cmd_stat.c b/cmd/cmd_stat.c index ce19085..73b7fa6 100644 --- a/cmd/cmd_stat.c +++ b/cmd/cmd_stat.c @@ -37,7 +37,7 @@ void *cmd_stat(void *data) snprintf(buf,buf_size,"| IPC_RX | %08s |\n", tokens[3]); out_result = sdscat(out_result, buf); - out_result = sdscat(out_result,"+----------+----------+\n"); + out_result = sdscat(out_result,"+----------+----------+"); sdsfreesplitres(tokens, count); |