mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-21 05:41:26 +02:00
MINOR: pattern: add pat_ref_gen_find_elt() function
pat_ref_gen_find_elt(ref, gen_id, key) tries to find <elt> element belonging to <gen_id> and matching <key> in <ref> reference. The goal is to be able to target a single subset from <ref>
This commit is contained in:
parent
c9d6af3c6d
commit
a131c542a6
@ -184,6 +184,7 @@ struct pat_ref *pat_ref_lookupid(int unique_id);
|
||||
struct pat_ref *pat_ref_new(const char *reference, const char *display, unsigned int flags);
|
||||
struct pat_ref *pat_ref_newid(int unique_id, const char *display, unsigned int flags);
|
||||
struct pat_ref_elt *pat_ref_find_elt(struct pat_ref *ref, const char *key);
|
||||
struct pat_ref_elt *pat_ref_gen_find_elt(struct pat_ref *ref, unsigned int gen_id, const char *key);
|
||||
struct pat_ref_elt *pat_ref_append(struct pat_ref *ref, const char *pattern, const char *sample, int line);
|
||||
struct pat_ref_elt *pat_ref_load(struct pat_ref *ref, unsigned int gen, const char *pattern, const char *sample, int line, char **err);
|
||||
int pat_ref_push(struct pat_ref_elt *elt, struct pattern_expr *expr, int patflags, char **err);
|
||||
|
@ -1636,6 +1636,28 @@ int pat_ref_delete(struct pat_ref *ref, const char *key)
|
||||
return found;
|
||||
}
|
||||
|
||||
/*
|
||||
* find and return an element <elt> belonging to <gen_id> and matching <key> in a
|
||||
* reference <ref> return NULL if not found
|
||||
*/
|
||||
struct pat_ref_elt *pat_ref_gen_find_elt(struct pat_ref *ref, unsigned int gen_id, const char *key)
|
||||
{
|
||||
struct ebmb_node *node;
|
||||
struct pat_ref_elt *elt;
|
||||
|
||||
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);
|
||||
}
|
||||
if (node)
|
||||
return ebmb_entry(node, struct pat_ref_elt, node);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* find and return an element <elt> matching <key> in a reference <ref>
|
||||
* return NULL if not found
|
||||
|
Loading…
x
Reference in New Issue
Block a user