diff --git a/include/haproxy/pattern.h b/include/haproxy/pattern.h index db0a8a32f..159eca18b 100644 --- a/include/haproxy/pattern.h +++ b/include/haproxy/pattern.h @@ -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); diff --git a/src/pattern.c b/src/pattern.c index e8e995deb..01f27b669 100644 --- a/src/pattern.c +++ b/src/pattern.c @@ -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 the sample of all patterns matching + * and belonging to under . + */ +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 the sample of all patterns matching * under . */