return p;
}
+static int
+lookup_extended(struct uci_context *ctx, struct uci_ptr *ptr, char *str, bool extended)
+{
+ int rv;
+ struct uci_ptr lookup;
+
+ /* use a copy of the passed ptr since failing lookups will
+ * clobber the state */
+ lookup = *ptr;
+ lookup.flags |= UCI_LOOKUP_EXTENDED;
+
+ rv = uci_lookup_ptr(ctx, &lookup, str, extended);
+
+ /* copy to passed ptr on success */
+ if (!rv)
+ *ptr = lookup;
+
+ return rv;
+}
+
+static int
+lookup_ptr(struct uci_context *ctx, struct uci_ptr *ptr, char *str, bool extended)
+{
+ if (ptr && !ptr->s && ptr->section && *ptr->section == '@')
+ return lookup_extended(ctx, ptr, str, extended);
+
+ return uci_lookup_ptr(ctx, ptr, str, extended);
+}
+
static int
lookup_args(lua_State *L, struct uci_context *ctx, int offset, struct uci_ptr *ptr, char **buf)
{
case 2:
ptr->section = luaL_checkstring(L, 2 + offset);
ptr->package = luaL_checkstring(L, 1 + offset);
- if (uci_lookup_ptr(ctx, ptr, NULL, true) != UCI_OK)
+ if (lookup_ptr(ctx, ptr, NULL, true) != UCI_OK)
goto error;
break;
case 1:
- if (uci_lookup_ptr(ctx, ptr, s, true) != UCI_OK)
+ if (lookup_ptr(ctx, ptr, s, true) != UCI_OK)
goto error;
break;
default:
if (lookup_args(L, ctx, offset, &ptr, &s))
goto error;
- uci_lookup_ptr(ctx, &ptr, NULL, true);
+ lookup_ptr(ctx, &ptr, NULL, true);
if (!all && !ptr.s) {
err = UCI_ERR_INVAL;
goto error;
goto error;
}
- err = uci_lookup_ptr(ctx, &ptr, NULL, true);
+ err = lookup_ptr(ctx, &ptr, NULL, true);
if (err)
goto error;
goto error;
}
- err = uci_lookup_ptr(ctx, &ptr, NULL, true);
+ err = lookup_ptr(ctx, &ptr, NULL, true);
if (err)
goto error;
goto error;
}
- err = uci_lookup_ptr(ctx, &ptr, NULL, true);
+ err = lookup_ptr(ctx, &ptr, NULL, true);
if (err)
goto error;
if (lookup_args(L, ctx, offset, &ptr, &s))
goto err;
- uci_lookup_ptr(ctx, &ptr, NULL, true);
+ lookup_ptr(ctx, &ptr, NULL, true);
uci_foreach_element_safe(&ctx->root, tmp, e) {
struct uci_package *p = uci_to_package(e);