The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Macros | Typedefs | Functions
edit.h File Reference

Structures and prototypes for editing lists. More...

#include <freeradius-devel/util/pair.h>
+ Include dependency graph for edit.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define fr_edit_list_insert_list_head(_el, _list, _to_insert)   fr_edit_list_insert_list_after(_el, _list, NULL, _to_insert)
 
#define fr_edit_list_insert_list_tail(_el, _list, _to_insert)   fr_edit_list_insert_list_after(_el, _list, fr_pair_list_tail(_list), _to_insert)
 
#define fr_edit_list_insert_pair_before(_el, _list, _pos, _vp)   fr_edit_list_insert_pair_after(_el, _list, fr_pair_list_prev(_list, _pos), _vp)
 
#define fr_edit_list_insert_pair_head(_el, _list, _vp)   fr_edit_list_insert_pair_after(_el, _list, NULL, _vp)
 
#define fr_edit_list_insert_pair_tail(_el, _list, _vp)   fr_edit_list_insert_pair_after(_el, _list, fr_pair_list_tail(_list), _vp)
 

Typedefs

typedef struct fr_edit_list_s fr_edit_list_t
 

Functions

void fr_edit_list_abort (fr_edit_list_t *el)
 Abort the entries in an edit list. More...
 
fr_edit_list_tfr_edit_list_alloc (TALLOC_CTX *ctx, int hint, fr_edit_list_t *parent)
 Allocate an edit list. More...
 
int fr_edit_list_apply_list_assignment (fr_edit_list_t *el, fr_pair_t *dst, fr_token_t op, fr_pair_list_t *src, bool copy))
 Apply operators to lists. More...
 
int fr_edit_list_apply_pair_assignment (fr_edit_list_t *el, fr_pair_t *vp, fr_token_t op, fr_value_box_t const *in)
 Apply operators to pairs. More...
 
void fr_edit_list_commit (fr_edit_list_t *el)
 Commit an edit list. More...
 
int fr_edit_list_free_pair_children (fr_edit_list_t *el, fr_pair_t *vp))
 Free children of a structural pair. More...
 
int fr_edit_list_insert_list_after (fr_edit_list_t *el, fr_pair_list_t *list, fr_pair_t *pos, fr_pair_list_t *to_insert))
 Notes. More...
 
int fr_edit_list_insert_pair_after (fr_edit_list_t *el, fr_pair_list_t *list, fr_pair_t *pos, fr_pair_t *vp))
 Insert a new VP after an existing one. More...
 
int fr_edit_list_pair_delete (fr_edit_list_t *el, fr_pair_list_t *list, fr_pair_t *vp))
 Delete a VP. More...
 
int fr_edit_list_pair_delete_by_da (fr_edit_list_t *el, fr_pair_list_t *list, fr_dict_attr_t const *da))
 Delete VPs with a matching da. More...
 
int fr_edit_list_replace_pair (fr_edit_list_t *el, fr_pair_list_t *list, fr_pair_t *to_replace, fr_pair_t *vp))
 Replace a pair with another one. More...
 
int fr_edit_list_replace_pair_value (fr_edit_list_t *el, fr_pair_t *vp, fr_value_box_t *box))
 Write a new value to the fr_value_box_t. More...
 
int fr_edit_list_save_pair_value (fr_edit_list_t *el, fr_pair_t *vp))
 Record the value of a leaf fr_value_box_t. More...
 

Detailed Description

Structures and prototypes for editing lists.

Id
5e2ebb782a62d217d5e7f9d5b7f5fa70d57a7944
Id
2a5fd474dece04a0807cc5fdc5b48fed7369f810

Definition in file edit.h.

Macro Definition Documentation

◆ fr_edit_list_insert_list_head

#define fr_edit_list_insert_list_head (   _el,
  _list,
  _to_insert 
)    fr_edit_list_insert_list_after(_el, _list, NULL, _to_insert)

Definition at line 72 of file edit.h.

◆ fr_edit_list_insert_list_tail

#define fr_edit_list_insert_list_tail (   _el,
  _list,
  _to_insert 
)    fr_edit_list_insert_list_after(_el, _list, fr_pair_list_tail(_list), _to_insert)

Definition at line 74 of file edit.h.

◆ fr_edit_list_insert_pair_before

#define fr_edit_list_insert_pair_before (   _el,
  _list,
  _pos,
  _vp 
)    fr_edit_list_insert_pair_after(_el, _list, fr_pair_list_prev(_list, _pos), _vp)

Definition at line 45 of file edit.h.

◆ fr_edit_list_insert_pair_head

#define fr_edit_list_insert_pair_head (   _el,
  _list,
  _vp 
)    fr_edit_list_insert_pair_after(_el, _list, NULL, _vp)

Definition at line 49 of file edit.h.

◆ fr_edit_list_insert_pair_tail

#define fr_edit_list_insert_pair_tail (   _el,
  _list,
  _vp 
)    fr_edit_list_insert_pair_after(_el, _list, fr_pair_list_tail(_list), _vp)

Definition at line 51 of file edit.h.

Typedef Documentation

◆ fr_edit_list_t

Definition at line 1 of file edit.h.

Function Documentation

◆ fr_edit_list_abort()

void fr_edit_list_abort ( fr_edit_list_t el)

Abort the entries in an edit list.

After this call, the input list(s) are unchanged from before any edits were made.

the caller does not have to call talloc_free(el);

Definition at line 194 of file edit.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_edit_list_alloc()

fr_edit_list_t* fr_edit_list_alloc ( TALLOC_CTX *  ctx,
int  hint,
fr_edit_list_t parent 
)

Allocate an edit list.

Edit lists can be nested. If the child list commits, then it does nothing until the parent list commits. On the other hand, if the child list aborts, then the parent list might continue.

Parameters
ctxtalloc context. Ignored if parent!=NULL
hinthow many edits we are likely to allocate
parenta parent edit list

Definition at line 790 of file edit.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_edit_list_apply_list_assignment()

int fr_edit_list_apply_list_assignment ( fr_edit_list_t el,
fr_pair_t dst,
fr_token_t  op,
fr_pair_list_t src,
bool  copy 
)

Apply operators to lists.

= is "if found vp, do nothing. Otherwise call fr_edit_list_insert_pair_tail()

The src list is sorted, but is otherwise not modified.

Definition at line 1487 of file edit.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_edit_list_apply_pair_assignment()

int fr_edit_list_apply_pair_assignment ( fr_edit_list_t el,
fr_pair_t vp,
fr_token_t  op,
fr_value_box_t const *  in 
)

Apply operators to pairs.

:= is "if found vp, call fr_edit_list_pair_replace(). Otherwise call fr_edit_list_insert_pair_tail() = is "if found vp, do nothing. Otherwise call fr_edit_list_insert_pair_tail()

Definition at line 976 of file edit.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_edit_list_commit()

void fr_edit_list_commit ( fr_edit_list_t el)

Commit an edit list.

If there are nested transactions, then this transaction is committed only when the parent transaction has been committed.

Definition at line 841 of file edit.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_edit_list_free_pair_children()

int fr_edit_list_free_pair_children ( fr_edit_list_t el,
fr_pair_t vp 
)

Free children of a structural pair.

This function mirrors fr_pair_replace().

After this function returns, the new VP has replaced the old one, and the new one can be edited.

Definition at line 709 of file edit.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_edit_list_insert_list_after()

int fr_edit_list_insert_list_after ( fr_edit_list_t el,
fr_pair_list_t list,
fr_pair_t pos,
fr_pair_list_t to_insert 
)

Notes.

Unlike "update" sections, edits are not hierarchical. If we're editing values a list, then the list has to exist. If we're inserting pairs in a list, then we find the lowest existing pair, and add pairs there.

The functions tmpl_extents_find() and tmpl_extents_build_to_leaf_parent() should help us figure out where the VPs exist or not.

The overall "update" algorithm is now:

alloc(edit list)

foreach entry in the things to do
    expand LHS if needed to local TMPL
    expand RHS if needed to local box / cursor / TMPL

    use LHS/RHS cursors to find VPs
    edit VPs, recording edits

free temporary map
commit(edit list)

Insert a list after a particular point in another list.

This function mirrors fr_pair_list_append(), but with a bit more control over where the to_insert list ends up.

There's nothing magical about this function, it's just easier to have it here than in multiple places in the code.

Definition at line 888 of file edit.c.

+ Here is the call graph for this function:

◆ fr_edit_list_insert_pair_after()

int fr_edit_list_insert_pair_after ( fr_edit_list_t el,
fr_pair_list_t list,
fr_pair_t pos,
fr_pair_t vp 
)

Insert a new VP after an existing one.

This function mirrors fr_pair_insert_after().

After this function returns, the new VP has been inserted into the list.

Definition at line 562 of file edit.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_edit_list_pair_delete()

int fr_edit_list_pair_delete ( fr_edit_list_t el,
fr_pair_list_t list,
fr_pair_t vp 
)

Delete a VP.

This function mirrors fr_pair_delete()

After this function returns, the VP has been removed from the list.

Definition at line 575 of file edit.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_edit_list_pair_delete_by_da()

int fr_edit_list_pair_delete_by_da ( fr_edit_list_t el,
fr_pair_list_t list,
fr_dict_attr_t const *  da 
)

Delete VPs with a matching da.

This function mirrors fr_pair_delete_by_da()

Definition at line 594 of file edit.c.

+ Here is the call graph for this function:

◆ fr_edit_list_replace_pair()

int fr_edit_list_replace_pair ( fr_edit_list_t el,
fr_pair_list_t list,
fr_pair_t to_replace,
fr_pair_t vp 
)

Replace a pair with another one.

This function mirrors fr_pair_replace().

After this function returns, the new VP has replaced the old one, and the new one can be edited.

Definition at line 658 of file edit.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_edit_list_replace_pair_value()

int fr_edit_list_replace_pair_value ( fr_edit_list_t el,
fr_pair_t vp,
fr_value_box_t box 
)

Write a new value to the fr_value_box_t.

After this function returns, the value has been updated.

Definition at line 635 of file edit.c.

+ Here is the call graph for this function:

◆ fr_edit_list_save_pair_value()

int fr_edit_list_save_pair_value ( fr_edit_list_t el,
fr_pair_t vp 
)

Record the value of a leaf fr_value_box_t.

After this function returns, it's safe to edit the pair.

Definition at line 622 of file edit.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function: