diff options
Diffstat (limited to 'agni.c')
-rw-r--r-- | agni.c | 90 |
1 files changed, 0 insertions, 90 deletions
@@ -24,7 +24,6 @@ #include "darray.h" #include "buf.h" -#include "mq_cmd.h" #include "mq_ntf.h" #include "tbl_qcmd.h" #include "util.h" @@ -197,7 +196,6 @@ int th_start_client(void *data) server_cfg *cfg = data; mq_ntf_mdt *mq = cfg->mq; - mq_cmd *recv_cmd = NULL; // for recieved cmd from mq struct mq_attr out_attr, *ptr_out_attr=&out_attr; struct mq_attr in_attr, *ptr_in_attr=&in_attr; char *out_buf = NULL; @@ -350,91 +348,6 @@ int th_start_client(void *data) //recieve commands from queue if (mq_event == 1) { - /* - recv_cmd = mq_cmd_creates(in_buf, in_attr.mq_msgsize, -1); - if (recv_cmd != NULL) - { - if (mq_cmd_o_cmp_cmd(recv_cmd,"QUIT") == 0) - { - printf("QUIT recieved lets quit main loop\n"); - break; - } else if (mq_cmd_o_cmp_cmd(recv_cmd,"PRIVMSG:") == 0) - { - //PRINT("Response\n") - char *paramPtr; - size_t paramSz; - mq_cmd_param(recv_cmd, ¶mPtr, ¶mSz); - printf("ID:%d Recieved response [%s]%zu\n",mq_cmd_id(recv_cmd), paramPtr, paramSz); - - //wrong - tble_cmd_resp *match_resp = malloc(sizeof(tble_cmd_resp)); - memset(match_resp, 0, sizeof(tble_cmd_resp)); - if (match_resp != NULL) - { - match_resp->qid = mq_cmd_id(recv_cmd); - //for now any type is ok, make time consistant, for this usage - //match_cmd->type = QCMD_NONE - match_resp->resp = alloc_new_str_s(paramPtr, paramSz); - - //check if command match - int cmd_id = tbl_qcmd_resp(qtbl, match_resp); - if (cmd_id > 0) - { - tble_qcmd *cmd = tbl_qcmd_match_id(qtbl, cmd_id); - if (cmd != NULL) - { - - //PRINT("Found ID in qcmd table %d\n", cmd_id); - char *resp_user = token_new_str(cmd->tok,0); - char *dest_user = token_new_str(cmd->tok,2); - char *sep = strchr(resp_user,'!'); - resp_user[sep-resp_user] = 0x0; - - memset(cmd_buf, 0, TH_CONN_BUF_SZ); - - if (dest_user[0] == '#') - { - //response for chan PRIVMSG - //prepare response - int fret = snprintf(cmd_buf, TH_CONN_BUF_SZ,":%s PRIVMSG %s :%s \r\n", cfg->user, dest_user, match_resp->resp); - PRINT("%s\n",cmd_buf); - write(conn.conn_fd, cmd_buf, fret); - } - else - { - //response for user PRIVMSG - - //prepare response - int fret = snprintf(cmd_buf, TH_CONN_BUF_SZ,":%s PRIVMSG %s :%s \r\n", dest_user, resp_user, match_resp->resp); - PRINT("%s\n",cmd_buf); - write(conn.conn_fd, cmd_buf, fret); - } - - FREE(dest_user); - FREE(resp_user); - - //remove command by id - //for now just remove command without checkings its state - tbl_qcmd_del_by_id(qtbl, cmd_id); //no error check - - } - - } - - tbl_cmd_resp_free(match_resp); - } - - //lets memleak here - - } else - { - PRINT("Unknown command\n"); - } - } - mq_cmd_free(recv_cmd); - recv_cmd = NULL; - */ - nb_init(nb_resp); nb_load(nb_resp, in_buf); rpc_resp_unmarsh(nb_resp, &resp); @@ -732,10 +645,7 @@ int th_event_manager(void *data) int run; int mq_event; - - //read any command - mq_cmd *recv_cmd = NULL; // for recieved cmd from mq struct mq_attr out_attr, *ptr_out_attr=&out_attr; struct mq_attr in_attr, *ptr_in_attr=&in_attr; |