Switch to new UCI version

This commit is contained in:
Steven Barth 2008-08-27 15:00:12 +00:00
parent 12bb00a6a8
commit 86a3d500d1
2 changed files with 21 additions and 60 deletions

View file

@ -2,12 +2,12 @@ include ../../build/config.mk
include ../../build/gccconfig.mk include ../../build/gccconfig.mk
UCI_VERSION = 0.6.0 UCI_VERSION = 0.6.0
UCI_APPEND = +luci1 UCI_APPEND = +luci2
#UCI_SITE = http://mirror2.openwrt.org/sources #UCI_SITE = http://mirror2.openwrt.org/sources
#UCI_DIR = uci-$(UCI_VERSION) #UCI_DIR = uci-$(UCI_VERSION)
#UCI_FILE = $(UCI_DIR).tar.gz #UCI_FILE = $(UCI_DIR).tar.gz
#UCI_URL = $(UCI_SITE)/$(UCI_FILE) #UCI_URL = $(UCI_SITE)/$(UCI_FILE)
UCI_GITREV = 12c5b22102873e303e540f886489831461d54ea9 UCI_GITREV = a5256582f5a554c0cbcf45d19bb751e60ea42ce9
UCI_SITE = http://nbd.name UCI_SITE = http://nbd.name
UCI_DIR = uci.git UCI_DIR = uci.git
UCI_FILE = uci-$(UCI_VERSION)$(UCI_APPEND).tar.gz UCI_FILE = uci-$(UCI_VERSION)$(UCI_APPEND).tar.gz

View file

@ -1,7 +1,7 @@
Index: uci.git/lua/uci.c Index: uci.git/lua/uci.c
=================================================================== ===================================================================
--- uci.git.orig/lua/uci.c 2008-08-26 12:31:34.000000000 +0200 --- uci.git.orig/lua/uci.c 2008-08-27 16:45:56.000000000 +0200
+++ uci.git/lua/uci.c 2008-08-27 10:27:29.000000000 +0200 +++ uci.git/lua/uci.c 2008-08-27 16:55:30.000000000 +0200
@@ -24,7 +24,8 @@ @@ -24,7 +24,8 @@
#include <lauxlib.h> #include <lauxlib.h>
#include <uci.h> #include <uci.h>
@ -246,19 +246,7 @@ Index: uci.git/lua/uci.c
goto error; goto error;
uci_lookup_ptr(ctx, &ptr, NULL, false); uci_lookup_ptr(ctx, &ptr, NULL, false);
@@ -297,6 +346,11 @@ @@ -327,7 +376,7 @@
goto error;
}
+ if (!(ptr.flags & UCI_LOOKUP_COMPLETE)) {
+ err = UCI_ERR_NOTFOUND;
+ goto error;
+ }
+
err = UCI_OK;
e = ptr.last;
switch(e->type) {
@@ -323,7 +377,7 @@
switch(err) { switch(err) {
default: default:
ctx->err = err; ctx->err = err;
@ -267,7 +255,7 @@ Index: uci.git/lua/uci.c
/* fall through */ /* fall through */
case UCI_ERR_NOTFOUND: case UCI_ERR_NOTFOUND:
lua_pushnil(L); lua_pushnil(L);
@@ -348,6 +402,7 @@ @@ -352,6 +401,7 @@
static int static int
uci_lua_add(lua_State *L) uci_lua_add(lua_State *L)
{ {
@ -275,7 +263,7 @@ Index: uci.git/lua/uci.c
struct uci_section *s = NULL; struct uci_section *s = NULL;
struct uci_package *p; struct uci_package *p;
const char *package; const char *package;
@@ -355,9 +410,9 @@ @@ -359,9 +409,9 @@
const char *name = NULL; const char *name = NULL;
do { do {
@ -288,7 +276,7 @@ Index: uci.git/lua/uci.c
if (!p) if (!p)
break; break;
@@ -374,11 +429,11 @@ @@ -378,11 +428,11 @@
static int static int
uci_lua_delete(lua_State *L) uci_lua_delete(lua_State *L)
{ {
@ -302,7 +290,7 @@ Index: uci.git/lua/uci.c
goto error; goto error;
err = uci_delete(ctx, &ptr); err = uci_delete(ctx, &ptr);
@@ -387,7 +442,7 @@ @@ -391,7 +441,7 @@
if (s) if (s)
free(s); free(s);
if (err) if (err)
@ -311,7 +299,7 @@ Index: uci.git/lua/uci.c
lua_pushboolean(L, (err == 0)); lua_pushboolean(L, (err == 0));
return 1; return 1;
} }
@@ -395,6 +450,7 @@ @@ -399,6 +449,7 @@
static int static int
uci_lua_set(lua_State *L) uci_lua_set(lua_State *L)
{ {
@ -319,7 +307,7 @@ Index: uci.git/lua/uci.c
bool istable = false; bool istable = false;
struct uci_ptr ptr; struct uci_ptr ptr;
int err = UCI_ERR_MEM; int err = UCI_ERR_MEM;
@@ -402,14 +458,14 @@ @@ -406,14 +457,14 @@
int i, nargs; int i, nargs;
nargs = lua_gettop(L); nargs = lua_gettop(L);
@ -337,7 +325,7 @@ Index: uci.git/lua/uci.c
/* Format: uci.set("p", "s", "o", "v") */ /* Format: uci.set("p", "s", "o", "v") */
if (lua_istable(L, nargs)) { if (lua_istable(L, nargs)) {
if (lua_objlen(L, nargs) < 1) if (lua_objlen(L, nargs) < 1)
@@ -422,7 +478,7 @@ @@ -426,7 +477,7 @@
ptr.value = luaL_checkstring(L, nargs); ptr.value = luaL_checkstring(L, nargs);
} }
break; break;
@ -346,34 +334,7 @@ Index: uci.git/lua/uci.c
/* Format: uci.set("p", "s", "v") */ /* Format: uci.set("p", "s", "v") */
ptr.value = ptr.option; ptr.value = ptr.option;
ptr.option = NULL; ptr.option = NULL;
@@ -433,17 +489,23 @@ @@ -462,7 +513,7 @@
}
err = uci_lookup_ptr(ctx, &ptr, NULL, false);
- if (err)
+ if (err) {
goto error;
+ }
- if ((ptr.s == NULL) || (ptr.value == NULL)) {
+ /* TODO: IMPROVE CHECK
+ * unable to create named section with original check
+ * therefore temporarily added: && (nargs != 4)
+ */
+ if (((ptr.s == NULL) && (nargs != 4)) || (ptr.value == NULL)) {
err = UCI_ERR_INVAL;
goto error;
}
err = uci_set(ctx, &ptr);
- if (err)
+ if (err) {
goto error;
+ }
if (istable) {
for (i = 2; i <= lua_objlen(L, nargs); i++) {
@@ -458,7 +520,7 @@
error: error:
if (err) if (err)
@ -382,7 +343,7 @@ Index: uci.git/lua/uci.c
lua_pushboolean(L, (err == 0)); lua_pushboolean(L, (err == 0));
return 1; return 1;
} }
@@ -472,6 +534,7 @@ @@ -476,6 +527,7 @@
static int static int
uci_lua_package_cmd(lua_State *L, enum pkg_cmd cmd) uci_lua_package_cmd(lua_State *L, enum pkg_cmd cmd)
{ {
@ -390,7 +351,7 @@ Index: uci.git/lua/uci.c
struct uci_element *e, *tmp; struct uci_element *e, *tmp;
struct uci_ptr ptr; struct uci_ptr ptr;
char *s = NULL; char *s = NULL;
@@ -479,10 +542,10 @@ @@ -483,10 +535,10 @@
int nargs; int nargs;
nargs = lua_gettop(L); nargs = lua_gettop(L);
@ -403,7 +364,7 @@ Index: uci.git/lua/uci.c
goto err; goto err;
uci_lookup_ptr(ctx, &ptr, NULL, false); uci_lookup_ptr(ctx, &ptr, NULL, false);
@@ -562,16 +625,16 @@ @@ -566,16 +618,16 @@
} }
static void static void
@ -423,7 +384,7 @@ Index: uci.git/lua/uci.c
if (!p) if (!p)
return; return;
} }
@@ -596,6 +659,7 @@ @@ -600,6 +652,7 @@
static int static int
uci_lua_changes(lua_State *L) uci_lua_changes(lua_State *L)
{ {
@ -431,7 +392,7 @@ Index: uci.git/lua/uci.c
const char *package = NULL; const char *package = NULL;
char **config = NULL; char **config = NULL;
int nargs; int nargs;
@@ -603,9 +667,9 @@ @@ -607,9 +660,9 @@
nargs = lua_gettop(L); nargs = lua_gettop(L);
switch(nargs) { switch(nargs) {
@ -443,7 +404,7 @@ Index: uci.git/lua/uci.c
break; break;
default: default:
luaL_error(L, "invalid argument count"); luaL_error(L, "invalid argument count");
@@ -613,13 +677,13 @@ @@ -617,13 +670,13 @@
lua_newtable(L); lua_newtable(L);
if (package) { if (package) {
@ -459,7 +420,7 @@ Index: uci.git/lua/uci.c
} }
} }
@@ -628,29 +692,53 @@ @@ -632,29 +685,53 @@
} }
static int static int
@ -516,7 +477,7 @@ Index: uci.git/lua/uci.c
{ "load", uci_lua_load }, { "load", uci_lua_load },
{ "unload", uci_lua_unload }, { "unload", uci_lua_unload },
{ "get", uci_lua_get }, { "get", uci_lua_get },
@@ -663,25 +751,33 @@ @@ -667,25 +744,33 @@
{ "revert", uci_lua_revert }, { "revert", uci_lua_revert },
{ "changes", uci_lua_changes }, { "changes", uci_lua_changes },
{ "foreach", uci_lua_foreach }, { "foreach", uci_lua_foreach },