diff options
Diffstat (limited to 'tbl_qcmd.c')
-rw-r--r-- | tbl_qcmd.c | 45 |
1 files changed, 43 insertions, 2 deletions
@@ -81,7 +81,7 @@ int tbl_exec_in_s(tbl_exec *tbl, char *cmd) return -1; } -int tbl_exec_run(tbl_exec *tbl, char *cmd, void **resp) +int tbl_exec_run(tbl_exec *tbl, char *cmd, char *user, char *mask, char *server, void **resp) { int ret=-1; void *clbk_data=NULL; @@ -90,6 +90,7 @@ int tbl_exec_run(tbl_exec *tbl, char *cmd, void **resp) int i; tble_exec *el=NULL; + //user,mask,server could be NULL if ((tbl == NULL) || (cmd == NULL) || (resp==NULL) || (*resp != NULL)) { PERM(); @@ -140,7 +141,47 @@ int tbl_exec_run(tbl_exec *tbl, char *cmd, void **resp) ret_resp = el->callback(clbk_data); //no params for now } else if (el->type == TBL_T_RPC) { - ERROR("Not implemented\n"); + rpc_call_request *req = NULL; + rpc_call_response *resp = NULL; + netbyte_store *nb_req=NULL, *nb_resp=NULL; + char *buf_nb = NULL, *resp_buf=NULL; + + nb_resp = malloc(sizeof(netbyte_store)); + nb_req = malloc(sizeof(netbyte_store)); + nb_init(nb_resp); + nb_init(nb_req); + + //create request + req = rpc_call_req_new(el->name, "asd", 1); + if (!req) PERM(); + if (user != NULL) + { + req->user = alloc_new_str(user); + } + if (mask != NULL) + { + req->mask = alloc_new_str(mask); + } + if (server != NULL) + { + req->server = alloc_new_str(server); + } + rpc_call_req_marsh(req, &nb_req); + buf_nb = nb_create(nb_req); + resp_buf = el->callback(buf_nb); + if (resp_buf!=NULL) + { + nb_load(nb_resp, resp_buf); + rpc_call_resp_unmarsh(nb_resp, &resp); + ret_resp = alloc_new_str(resp->result); + rpc_call_resp_free(resp); + } else + { + ERROR("No response from RPC command\n"); + } + FREE(buf_nb); + rpc_call_req_free(req); + } else if (el->type == TBL_T_LUA) { ERROR("Not implemented\n"); |