From afb3657fa2cbc6bd9e5901d6c5590b09d15c2d89 Mon Sep 17 00:00:00 2001 From: FreeArtMan Date: Wed, 22 Nov 2017 21:42:17 +0000 Subject: Added todo file size max 1MB and 64 todo's per user --- cmd/cmd_lua.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'cmd/cmd_lua.c') 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) { -- cgit v1.2.3