From: Felix Fietkau Date: Sun, 13 Apr 2008 12:42:48 +0000 (+0200) Subject: typechecking, add set_confdir and set_savedir X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fuci.git;a=commitdiff_plain;h=8032b67176854a7dcd37d3ded33a37e8e87c08bf typechecking, add set_confdir and set_savedir --- 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 }, };