From: Willy Tarreau Date: Fri, 18 Jun 2010 15:26:50 +0000 (+0200) Subject: [MINOR] stick-table: provide a table lookup function X-Git-Tag: v1.5-dev8~527 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4a0347add08ba3463a3104f83b7a7fb2531060ab;p=thirdparty%2Fhaproxy.git [MINOR] stick-table: provide a table lookup function We'll often need to lookup a table by its name. This will change in the future once we can resolve these names on startup. --- diff --git a/include/proto/stick_table.h b/include/proto/stick_table.h index 813b3b9716..38ec9ae8f2 100644 --- a/include/proto/stick_table.h +++ b/include/proto/stick_table.h @@ -46,6 +46,7 @@ struct stktable_key *stktable_fetch_key(struct proxy *px, struct session *l4, unsigned long table_type); int stktable_compatible_pattern(struct pattern_expr *expr, unsigned long table_type); int stktable_get_data_type(char *name); +struct proxy *find_stktable(const char *name); /* reserve some space for data type . Return non-0 if OK, or 0 if already * allocated (or impossible type). diff --git a/src/stick_table.c b/src/stick_table.c index f490384234..a5e41bf73d 100644 --- a/src/stick_table.c +++ b/src/stick_table.c @@ -544,3 +544,14 @@ int stktable_get_data_type(char *name) return -1; } +/* Returns pointer to proxy containing table or NULL if not found */ +struct proxy *find_stktable(const char *name) +{ + struct proxy *px; + + for (px = proxy; px; px = px->next) { + if (px->table.size && strcmp(px->id, name) == 0) + return px; + } + return NULL; +}