projects
/
project
/
uci.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
a01f401
)
add 2 and 3 argument versions of uci.get()
author
Felix Fietkau
<nbd@openwrt.org>
Thu, 1 May 2008 11:38:15 +0000
(13:38 +0200)
committer
Felix Fietkau
<nbd@openwrt.org>
Thu, 1 May 2008 11:38:15 +0000
(13:38 +0200)
lua/uci.c
patch
|
blob
|
history
diff --git
a/lua/uci.c
b/lua/uci.c
index
397a36d
..
00cfc0e
100644
(file)
--- a/
lua/uci.c
+++ b/
lua/uci.c
@@
-182,19
+182,29
@@
uci_lua_get_any(lua_State *L, bool all)
{
struct uci_element *e = NULL;
struct uci_package *p = NULL;
{
struct uci_element *e = NULL;
struct uci_package *p = NULL;
- char *package = NULL;
- char *section = NULL;
- char *option = NULL;
+ c
onst c
har *package = NULL;
+ c
onst c
har *section = NULL;
+ c
onst c
har *option = NULL;
char *s;
int err = UCI_ERR_MEM;
char *s;
int err = UCI_ERR_MEM;
+ int n;
+
+ n = lua_gettop(L);
luaL_checkstring(L, 1);
luaL_checkstring(L, 1);
- s = strdup(lua_tostring(L,
-
1));
+ s = strdup(lua_tostring(L, 1));
if (!s)
goto error;
if (!s)
goto error;
- if ((err = uci_parse_tuple(ctx, s, &package, §ion, &option, NULL)))
- goto error;
+ if (n > 1) {
+ package = luaL_checkstring(L, 1);
+ section = luaL_checkstring(L, 2);
+ if (n > 2)
+ option = luaL_checkstring(L, 3);
+ } else {
+ if ((err = uci_parse_tuple(ctx, s, (char **) &package, (char **) §ion, (char **) &option, NULL)))
+ goto error;
+ }
if (!all && (section == NULL)) {
err = UCI_ERR_INVAL;
if (!all && (section == NULL)) {
err = UCI_ERR_INVAL;