X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fuci.git;a=blobdiff_plain;f=lua%2Fuci.c;h=c69cf834b1fd7ba6bc223bdefc2cdec21d2da110;hp=0a751d677a7d6193d1aad1368de93c6535cf8736;hb=8032b67176854a7dcd37d3ded33a37e8e87c08bf;hpb=4837364113f30c793b373073d27508fec6234ed3;ds=sidebyside diff --git a/lua/uci.c b/lua/uci.c index 0a751d6..c69cf83 100644 --- a/lua/uci.c +++ b/lua/uci.c @@ -68,7 +68,7 @@ uci_lua_unload(lua_State *L) struct uci_package *p; const char *s; - luaL_checkany(L, 1); + luaL_checkstring(L, 1); s = lua_tostring(L, -1); p = find_package(s); if (p) { @@ -112,7 +112,7 @@ uci_lua_get(lua_State *L) char *s; int err = UCI_ERR_MEM; - luaL_checkany(L, 1); + luaL_checkstring(L, 1); s = strdup(lua_tostring(L, -1)); if (!s) goto error; @@ -163,10 +163,35 @@ error: } +static int +uci_lua_set_confdir(lua_State *L) +{ + int ret; + + luaL_checkstring(L, 1); + ret = uci_set_confdir(ctx, lua_tostring(L, -1)); + lua_pushboolean(L, (ret == 0)); + return 1; +} + +static int +uci_lua_set_savedir(lua_State *L) +{ + int ret; + + luaL_checkstring(L, 1); + ret = uci_set_savedir(ctx, lua_tostring(L, -1)); + lua_pushboolean(L, (ret == 0)); + + return 1; +} + static const luaL_Reg uci[] = { { "load", uci_lua_load }, { "unload", uci_lua_unload }, { "get", uci_lua_get }, + { "set_confdir", uci_lua_set_confdir }, + { "set_savedir", uci_lua_set_savedir }, { NULL, NULL }, };