summaryrefslogtreecommitdiff
path: root/cmd/cmd_lua.c
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/cmd_lua.c')
-rw-r--r--cmd/cmd_lua.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/cmd/cmd_lua.c b/cmd/cmd_lua.c
index 105cb47..820620f 100644
--- a/cmd/cmd_lua.c
+++ b/cmd/cmd_lua.c
@@ -127,6 +127,7 @@ int lua_excute(const char *fname, rpc_call_request *req, rpc_call_response **res
{
int t;
int top = lua_gettop(L);
+ int len = lua_rawlen(L,1);
if (top == 1)
{
@@ -134,23 +135,26 @@ int lua_excute(const char *fname, rpc_call_request *req, rpc_call_response **res
if (t == LUA_TTABLE)
{
int j;
- int len = lua_rawlen(L,1);
+
const char *r_result;
const char *r_error;
int r_id;
size_t sz;
+
check_table_key_string(L, "result", &r_result, &sz);
- //resp->result = alloc_new_str(result);
- printf("RESULT:%s\n", r_result);
+
+ //printf("RESULT:%s\n", r_result);
check_table_key_integer(L, "id", &r_id);
- //resp->id = result_i;
- printf("ID:%d\n", r_id);
+
+ //printf("ID:%d\n", r_id);
check_table_key_string(L, "error", &r_error, &sz);
- //resp->error = alloc_new_str(result);
- printf("ERROR:%s\n", r_error);
- *resp = rpc_call_resp_new(alloc_new_str(r_result), alloc_new_str(r_error), 1);
+ //printf("ERROR:%s\n", r_error);
+
+ if (r_result == NULL) r_result = "!";
+ if (r_error == NULL) r_error = "!";
+ *resp = rpc_call_resp_new(alloc_new_str(r_result), alloc_new_str(r_error), r_id);
(*resp)->user = alloc_new_str(" ");
(*resp)->server = alloc_new_str(" ");
(*resp)->mask = alloc_new_str(" ");
@@ -215,13 +219,9 @@ void *cmd_lua(void *data)
//----------------------------------------------------------------------------
//main code
-
-
params = sdsnew(req->params);
tokens = sdssplitargs(params, &count);
-
-
if (-1 == lua_excute(tokens[1], req, &resp))
{
resp = rpc_call_resp_new(out_result,"None",1);
@@ -238,10 +238,8 @@ void *cmd_lua(void *data)
nb_resp = malloc(sizeof(netbyte_store));
nb_init(nb_resp);
- PNL();
rpc_call_resp_marsh(resp, &nb_resp);
- PNL();
nb_buf = (char *)nb_create(nb_resp);
if (nb_buf)
{