From: Felix Fietkau Date: Sun, 13 Apr 2008 11:32:16 +0000 (+0200) Subject: add uci.unload to the lua plugin X-Git-Url: http://pilppa.com/gitweb/?a=commitdiff_plain;h=4837364113f30c793b373073d27508fec6234ed3;p=uci.git add uci.unload to the lua plugin --- diff --git a/lua/uci.c b/lua/uci.c index 026569f..0a751d6 100644 --- a/lua/uci.c +++ b/lua/uci.c @@ -63,7 +63,7 @@ done: } static int -uci_lua_load(lua_State *L) +uci_lua_unload(lua_State *L) { struct uci_package *p; const char *s; @@ -73,8 +73,23 @@ uci_lua_load(lua_State *L) p = find_package(s); if (p) { uci_unload(ctx, p); - p = NULL; + lua_pushboolean(L, 1); + } else { + lua_pushboolean(L, 0); } + return 1; +} + +static int +uci_lua_load(lua_State *L) +{ + struct uci_package *p = NULL; + const char *s; + + uci_lua_unload(L); + lua_pop(L, 1); /* bool ret value of unload */ + s = lua_tostring(L, -1); + if (uci_load(ctx, s, &p)) { uci_lua_perror(L, "uci.load"); lua_pushboolean(L, 0); @@ -150,6 +165,7 @@ error: static const luaL_Reg uci[] = { { "load", uci_lua_load }, + { "unload", uci_lua_unload }, { "get", uci_lua_get }, { NULL, NULL }, };