]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
commented-out code to use dcursors for list removal
authorAlan T. DeKok <aland@freeradius.org>
Thu, 28 Jul 2022 13:51:07 +0000 (09:51 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Fri, 29 Jul 2022 01:58:15 +0000 (21:58 -0400)
We'd like to do:

&reply -= &Reply-Message

except that means changing the default list context of the RHS
from "request" to "reply" (i.e. the LHS list)

And it means NUM_ANY is really an equivalent for NUM_ALL.

Using dcursors means we have to instead do:

&reply -= &reply.Reply-Message[*]

which is a bit surprising.

src/lib/unlang/edit.c

index adf0fbd2bf01c9c4f1aba6713c652944701c5d27..5802bcb5313ba99fe47d575428f533de29deff7c 100644 (file)
@@ -214,6 +214,53 @@ static int template_realize(TALLOC_CTX *ctx, fr_value_box_list_t *list, request_
        return -1;
 }
 
+#if 0
+/** Remove VPs via a dcursor
+ *
+ *  Except you can't do:  &reply -= &Reply-Message
+ *  Instead, you need    &reply -= &reply.Reply-Message[*]
+ *
+ *  Which is a bit annoying.
+ */
+static int remove_vps(request_t *request, edit_map_t *current)
+{
+       fr_pair_t *vp, *next;
+       tmpl_dcursor_ctx_t cc;
+       fr_dcursor_t cursor;
+
+       fr_assert(tmpl_is_attr(current->rhs.vpt));
+       fr_assert(current->lhs.vp != NULL);
+       fr_assert(fr_type_is_structural(current->lhs.vp->vp_type));
+
+       RDEBUG2("%s %s %s", current->lhs.vpt->name, fr_tokens[T_OP_SUB_EQ], current->rhs.vpt->name);
+
+       vp = tmpl_dcursor_init(NULL, request, &cc, &cursor, request, current->rhs.vpt);
+
+       while (vp) {
+               fr_pair_list_t *list;
+
+               next = fr_dcursor_next(&cursor);
+
+               list = fr_pair_parent_list(vp);
+               fr_assert(list != NULL);
+
+               RINDENT();
+               RDEBUG2("%s %s %pV", current->lhs.vpt->name, fr_tokens[T_OP_SUB_EQ], &vp->data);
+               REXDENT();
+
+               if (fr_edit_list_pair_delete(current->el, list, vp) < 0) {
+                       tmpl_dursor_clear(&cc);
+                       return -1;
+               }
+
+               vp = next;
+       }
+
+       tmpl_dursor_clear(&cc);
+       return 0;
+}
+#endif
+
 /** Remove VPs for laziness
  *
  *     @todo - replace this with a dcursor, and remove everything which matches the dcursor.