mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-07 07:37:02 +02:00
MINOR: pattern: add pat_ref_gen_set() function
pat_ref_gen_set(ref, gen_id, value, err) modifies to <value> the sample of all patterns matching <key> and belonging to <gen_id> (generation id) under <ref> The goal is to be able to target a single subset from <ref>
This commit is contained in:
parent
3d250b3be8
commit
c9d6af3c6d
@ -190,6 +190,7 @@ int pat_ref_push(struct pat_ref_elt *elt, struct pattern_expr *expr, int patflag
|
||||
int pat_ref_add(struct pat_ref *ref, const char *pattern, const char *sample, char **err);
|
||||
int pat_ref_set(struct pat_ref *ref, const char *pattern, const char *sample, char **err);
|
||||
int pat_ref_set_elt_duplicate(struct pat_ref *ref, struct pat_ref_elt *elt, const char *value, char **err);
|
||||
int pat_ref_gen_set(struct pat_ref *ref, unsigned int gen_id, const char *key, const char *value, char **err);
|
||||
int pat_ref_set_by_id(struct pat_ref *ref, struct pat_ref_elt *refelt, const char *value, char **err);
|
||||
int pat_ref_delete(struct pat_ref *ref, const char *key);
|
||||
void pat_ref_delete_by_ptr(struct pat_ref *ref, struct pat_ref_elt *elt);
|
||||
|
@ -1788,6 +1788,26 @@ int pat_ref_set_elt_duplicate(struct pat_ref *ref, struct pat_ref_elt *elt, cons
|
||||
return pat_ref_set_from_node(ref, &elt->node, value, err);
|
||||
}
|
||||
|
||||
/* This function modifies to <value> the sample of all patterns matching <key>
|
||||
* and belonging to <gen_id> under <ref>.
|
||||
*/
|
||||
int pat_ref_gen_set(struct pat_ref *ref, unsigned int gen_id,
|
||||
const char *key, const char *value, char **err)
|
||||
{
|
||||
struct ebmb_node *node;
|
||||
struct pat_ref_elt *elt;
|
||||
|
||||
/* Look for pattern in the reference. */
|
||||
node = ebst_lookup(&ref->ebmb_root, key);
|
||||
while (node) {
|
||||
elt = ebmb_entry(node, struct pat_ref_elt, node);
|
||||
if (elt->gen_id == gen_id)
|
||||
break;
|
||||
node = ebmb_next_dup(node);
|
||||
}
|
||||
return pat_ref_set_from_node(ref, node, value, err);
|
||||
}
|
||||
|
||||
/* This function modifies to <value> the sample of all patterns matching <key>
|
||||
* under <ref>.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user