+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);
+}
+