diff options
Diffstat (limited to 'tbl_qcmd.c')
-rw-r--r-- | tbl_qcmd.c | 43 |
1 files changed, 43 insertions, 0 deletions
@@ -188,6 +188,49 @@ int tbl_exec_run(tbl_exec *tbl, char *cmd, char *user, char *mask, char *server, } else if (el->type == TBL_T_LUA) { 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, cmd, 1); + if (!req) PERM(); + if (user != NULL) + { + PRINT("%s user\n", user); + req->user = alloc_new_str(user); + } + if (mask != NULL) + { + PRINT("%s mask\n", mask); + req->mask = alloc_new_str(mask); + } + if (server != NULL) + { + PRINT("%s server\n", server); + 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); } //return if (ret_resp != NULL) |