The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
|
Structures and prototypes for editing lists. More...
#include <freeradius-devel/util/pair.h>
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 |
Structures and prototypes for editing lists.
Definition in file edit.h.
#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) |
typedef struct fr_edit_list_s fr_edit_list_t |
void fr_edit_list_abort | ( | fr_edit_list_t * | el | ) |
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.
ctx | talloc context. Ignored if parent!=NULL |
hint | how many edits we are likely to allocate |
parent | a parent edit list |
Definition at line 790 of file edit.c.
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.
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.
void fr_edit_list_commit | ( | fr_edit_list_t * | el | ) |
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.
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.
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.
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.
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.
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.
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.
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.