From 4b86ab3af6e64c0c4bb533766c284507f0d3ee62 Mon Sep 17 00:00:00 2001 From: FreeArtMan Date: Sun, 19 Nov 2017 12:09:13 +0000 Subject: Now lua commands supported --- tbl_qcmd.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'tbl_qcmd.c') diff --git a/tbl_qcmd.c b/tbl_qcmd.c index 4db8344..ca8830f 100644 --- a/tbl_qcmd.c +++ b/tbl_qcmd.c @@ -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) -- cgit v1.2.3