X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=lua%2Fubus.c;h=77624d73e38693ebaabedc3f351db763fba0421c;hb=bf566871bd6a633e4504c60c6fc55b2a97305a50;hp=899a8bd3dcadc9ace66e8e5683cad1833b60855c;hpb=c382792d9893ed1b0c1e1b0db2ad9a7eaa7a78e1;p=oweals%2Fubus.git diff --git a/lua/ubus.c b/lua/ubus.c index 899a8bd..77624d7 100644 --- a/lua/ubus.c +++ b/lua/ubus.c @@ -67,7 +67,6 @@ ubus_lua_parse_blob(lua_State *L, struct blob_attr *attr, bool table) int len; int off = 0; void *data; - char buf[32]; if (!blobmsg_check_attr(attr, false)) return 0; @@ -96,9 +95,7 @@ ubus_lua_parse_blob(lua_State *L, struct blob_attr *attr, bool table) break; case BLOBMSG_TYPE_INT64: - /* NB: Lua cannot handle 64bit, format value as string and push that */ - sprintf(buf, "%lld", (long long int) be64_to_cpu(*(uint64_t *)data)); - lua_pushstring(L, buf); + lua_pushnumber(L, (double) be64_to_cpu(*(uint64_t *)data)); break; case BLOBMSG_TYPE_STRING: @@ -137,7 +134,7 @@ ubus_lua_format_blob_is_array(lua_State *L) if (lua_type(L, -2) != LUA_TNUMBER) #endif { - lua_pop(L, 1); + lua_pop(L, 2); return false; } @@ -145,7 +142,7 @@ ubus_lua_format_blob_is_array(lua_State *L) if ((cur - 1) != prv) { - lua_pop(L, 1); + lua_pop(L, 2); return false; } @@ -290,7 +287,11 @@ ubus_method_handler(struct ubus_context *ctx, struct ubus_object *obj, if (lua_isfunction(state, -1)) { lua_pushlightuserdata(state, req); - lua_call(state, 1, 0); + if (!msg) + lua_pushnil(state); + else + ubus_lua_parse_blob_array(state, blob_data(msg), blob_len(msg), true); + lua_call(state, 2, 0); } return 0; }