]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: pattern: import acl_find_match_name() into pattern.h
authorWilly Tarreau <w@1wt.eu>
Thu, 28 Nov 2013 21:24:25 +0000 (22:24 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 2 Dec 2013 22:31:33 +0000 (23:31 +0100)
It's only dedicated to pattern match lookups, so it was renamed
pat_find_match_name().

include/proto/pattern.h
src/acl.c

index ee7518cd5d6e51ade81683d6623781f69dc94d4a..29773f8b8c9115d894e3d4da3d5f8cad43dcf348 100644 (file)
@@ -22,6 +22,8 @@
 #ifndef _PROTO_PATTERN_H
 #define _PROTO_PATTERN_H
 
+#include <string.h>
+
 #include <common/config.h>
 #include <common/standard.h>
 #include <types/pattern.h>
  */
 int pattern_register(struct pattern_expr *expr, char *text, struct sample_storage *smp, struct pattern **pattern, int patflags, char **err);
 
+/* return the PAT_MATCH_* index for match name "name", or < 0 if not found */
+static inline int pat_find_match_name(const char *name)
+{
+       int i;
+
+       for (i = 0; i < PAT_MATCH_NUM; i++)
+               if (strcmp(name, pat_match_names[i]) == 0)
+                       return i;
+       return -1;
+}
+
 /* This function executes a pattern match on a sample. It applies pattern <expr>
  * to sample <smp>. If <sample> is not NULL, a pointer to an optional sample
  * associated to the matching patterned will be put there. The function returns
index 86a85971c3758853298b056b1ccec32b79580d3d..e8d4dc3ece063a72b6190e455298cb6bc6f334b0 100644 (file)
--- a/src/acl.c
+++ b/src/acl.c
@@ -38,17 +38,6 @@ static struct acl_kw_list acl_keywords = {
        .list = LIST_HEAD_INIT(acl_keywords.list)
 };
 
-/* return the PAT_MATCH_* index for match name "name", or < 0 if not found */
-static int acl_find_match_name(const char *name)
-{
-       int i;
-
-       for (i = 0; i < PAT_MATCH_NUM; i++)
-               if (strcmp(name, pat_match_names[i]) == 0)
-                       return i;
-       return -1;
-}
-
 /* input values are 0 or 3, output is the same */
 static inline enum acl_test_res pat2acl(enum pat_match_res res)
 {
@@ -474,7 +463,7 @@ struct acl_expr *parse_acl_expr(const char **args, char **err, struct arg_list *
                                goto out_free_expr;
                        }
 
-                       idx = acl_find_match_name(args[1]);
+                       idx = pat_find_match_name(args[1]);
                        if (idx < 0) {
                                memprintf(err, "unknown matching method '%s' when parsing ACL expression", args[1]);
                                goto out_free_expr;