]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: actions: Merge (http|tcp)-(request|reponse) keywords structs
authorThierry FOURNIER <tfournier@arpalert.org>
Wed, 19 Aug 2015 07:01:53 +0000 (09:01 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 20 Aug 2015 15:13:47 +0000 (17:13 +0200)
This patch merges the conguration keyword struct. Each declared configuration
keyword struct are similar with the others. This patch simplify the code.

include/proto/proto_http.h
include/proto/proto_tcp.h
include/types/action.h
include/types/proto_http.h
include/types/proto_tcp.h
src/hlua.c
src/proto_http.c
src/proto_tcp.c
src/vars.c

index a3a261fa0966338f789527af4b7f71a822d265ca..0ebc61219631b36c284d5af55227f181e0d8672c 100644 (file)
@@ -129,16 +129,16 @@ int smp_fetch_base32(const struct arg *args, struct sample *smp, const char *kw,
 
 enum http_meth_t find_http_meth(const char *str, const int len);
 
-struct http_req_action_kw *action_http_req_custom(const char *kw);
-struct http_res_action_kw *action_http_res_custom(const char *kw);
+struct action_kw *action_http_req_custom(const char *kw);
+struct action_kw *action_http_res_custom(const char *kw);
 int val_hdr(struct arg *arg, char **err_msg);
 
-static inline void http_req_keywords_register(struct http_req_action_kw_list *kw_list)
+static inline void http_req_keywords_register(struct action_kw_list *kw_list)
 {
        LIST_ADDQ(&http_req_keywords.list, &kw_list->list);
 }
 
-static inline void http_res_keywords_register(struct http_res_action_kw_list *kw_list)
+static inline void http_res_keywords_register(struct action_kw_list *kw_list)
 {
        LIST_ADDQ(&http_res_keywords.list, &kw_list->list);
 }
index 312762538bb2228ee1b62c5a12438d401ca0fc84..5f589eac562b4c6b58771c990447e6d2dc7115de 100644 (file)
@@ -41,9 +41,9 @@ int tcp_inspect_response(struct stream *s, struct channel *rep, int an_bit);
 int tcp_exec_req_rules(struct session *sess);
 
 /* TCP keywords. */
-void tcp_req_conn_keywords_register(struct tcp_action_kw_list *kw_list);
-void tcp_req_cont_keywords_register(struct tcp_action_kw_list *kw_list);
-void tcp_res_cont_keywords_register(struct tcp_action_kw_list *kw_list);
+void tcp_req_conn_keywords_register(struct action_kw_list *kw_list);
+void tcp_req_cont_keywords_register(struct action_kw_list *kw_list);
+void tcp_res_cont_keywords_register(struct action_kw_list *kw_list);
 
 /* Export some samples. */
 int smp_fetch_src(const struct arg *args, struct sample *smp, const char *kw, void *private);
index 713631ed0619e369edc3ba6b85eaa56a5202a03c..9fb087889d7304dc7fe7fcb8d0799cae97055090 100644 (file)
@@ -132,4 +132,16 @@ struct act_rule {
        } arg;                                 /* arguments used by some actions */
 };
 
+struct action_kw {
+       const char *kw;
+       int (*parse)(const char **args, int *cur_arg, struct proxy *px,
+                    struct act_rule *rule, char **err);
+       int match_pfx;
+};
+
+struct action_kw_list {
+       struct list list;
+       struct action_kw kw[VAR_ARRAY];
+};
+
 #endif /* _TYPES_ACTION_H */
index 16be842df402097d931e61c562d6b761a916e81d..3f827b873c3eb9003ef67a0441465592a4b0e3d6 100644 (file)
@@ -397,30 +397,8 @@ struct http_method_name {
        int len;
 };
 
-struct http_req_action_kw {
-       const char *kw;
-       int (*parse)(const char **args, int *cur_arg, struct proxy *px, struct act_rule *rule, char **err);
-       int match_pfx;
-};
-
-struct http_res_action_kw {
-       const char *kw;
-       int (*parse)(const char **args, int *cur_arg, struct proxy *px, struct act_rule *rule, char **err);
-       int match_pfx;
-};
-
-struct http_req_action_kw_list {
-       struct list list;
-       struct http_req_action_kw kw[VAR_ARRAY];
-};
-
-struct http_res_action_kw_list {
-       struct list list;
-       struct http_res_action_kw kw[VAR_ARRAY];
-};
-
-extern struct http_req_action_kw_list http_req_keywords;
-extern struct http_res_action_kw_list http_res_keywords;
+extern struct action_kw_list http_req_keywords;
+extern struct action_kw_list http_res_keywords;
 
 extern const struct http_method_name http_known_methods[HTTP_METH_OTHER];
 
index df969a145bf0dd51a976b2977fc9b78e7f3a078c..9d888a7a20de1c402ddc18ea341b5593033cf3bf 100644 (file)
 #include <types/acl.h>
 #include <types/stream.h>
 
-struct tcp_action_kw {
-       const char *kw;
-       int (*parse)(const char **args, int *cur_arg, struct proxy *px,
-                    struct act_rule *rule, char **err);
-       int match_pfx;
-};
-
-struct tcp_action_kw_list {
-       struct list list;
-       struct tcp_action_kw kw[VAR_ARRAY];
-};
-
 #endif /* _TYPES_PROTO_TCP_H */
 
 /*
index 5395b6d303beee215890fbeb5c6a42a6c9e69d39..32f8df412c8a931eab511128a496abb731c12247 100644 (file)
@@ -4584,22 +4584,22 @@ static struct cfg_kw_list cfg_kws = {{ },{
        { 0, NULL, NULL },
 }};
 
-static struct http_req_action_kw_list http_req_kws = { { }, {
+static struct action_kw_list http_req_kws = { { }, {
        { "lua", http_req_action_register_lua },
        { NULL, NULL }
 }};
 
-static struct http_res_action_kw_list http_res_kws = { { }, {
+static struct action_kw_list http_res_kws = { { }, {
        { "lua", http_res_action_register_lua },
        { NULL, NULL }
 }};
 
-static struct tcp_action_kw_list tcp_req_cont_kws = { { }, {
+static struct action_kw_list tcp_req_cont_kws = { { }, {
        { "lua", tcp_req_action_register_lua },
        { NULL, NULL }
 }};
 
-static struct tcp_action_kw_list tcp_res_cont_kws = { { }, {
+static struct action_kw_list tcp_res_cont_kws = { { }, {
        { "lua", tcp_res_action_register_lua },
        { NULL, NULL }
 }};
index ce43ec5991ec81e08b2b4d9c8d009ed7e0cefe5a..69a1052d10adbbc9516f5db7bab824ef69a81f7d 100644 (file)
@@ -236,12 +236,12 @@ const char *stat_status_codes[STAT_STATUS_SIZE] = {
 
 
 /* List head of all known action keywords for "http-request" */
-struct http_req_action_kw_list http_req_keywords = {
+struct action_kw_list http_req_keywords = {
        .list = LIST_HEAD_INIT(http_req_keywords.list)
 };
 
 /* List head of all known action keywords for "http-response" */
-struct http_res_action_kw_list http_res_keywords = {
+struct action_kw_list http_res_keywords = {
        .list = LIST_HEAD_INIT(http_res_keywords.list)
 };
 
@@ -8934,7 +8934,7 @@ void free_http_req_rules(struct list *r)
 struct act_rule *parse_http_req_cond(const char **args, const char *file, int linenum, struct proxy *proxy)
 {
        struct act_rule *rule;
-       struct http_req_action_kw *custom = NULL;
+       struct action_kw *custom = NULL;
        int cur_arg;
        char *error;
 
@@ -9408,7 +9408,7 @@ struct act_rule *parse_http_req_cond(const char **args, const char *file, int li
 struct act_rule *parse_http_res_cond(const char **args, const char *file, int linenum, struct proxy *proxy)
 {
        struct act_rule *rule;
-       struct http_res_action_kw *custom = NULL;
+       struct action_kw *custom = NULL;
        int cur_arg;
        char *error;
 
@@ -12645,10 +12645,10 @@ int parse_http_res_capture(const char **args, int *orig_arg, struct proxy *px, s
 /*
  * Return the struct http_req_action_kw associated to a keyword.
  */
-struct http_req_action_kw *action_http_req_custom(const char *kw)
+struct action_kw *action_http_req_custom(const char *kw)
 {
        if (!LIST_ISEMPTY(&http_req_keywords.list)) {
-               struct http_req_action_kw_list *kw_list;
+               struct action_kw_list *kw_list;
                int i;
 
                list_for_each_entry(kw_list, &http_req_keywords.list, list) {
@@ -12667,10 +12667,10 @@ struct http_req_action_kw *action_http_req_custom(const char *kw)
 /*
  * Return the struct http_res_action_kw associated to a keyword.
  */
-struct http_res_action_kw *action_http_res_custom(const char *kw)
+struct action_kw *action_http_res_custom(const char *kw)
 {
        if (!LIST_ISEMPTY(&http_res_keywords.list)) {
-               struct http_res_action_kw_list *kw_list;
+               struct action_kw_list *kw_list;
                int i;
 
                list_for_each_entry(kw_list, &http_res_keywords.list, list) {
@@ -12911,7 +12911,7 @@ static struct sample_conv_kw_list sample_conv_kws = {ILH, {
 /************************************************************************/
 /*   All supported http-request action keywords must be declared here.  */
 /************************************************************************/
-struct http_req_action_kw_list http_req_actions = {
+struct action_kw_list http_req_actions = {
        .kw = {
                { "capture",    parse_http_req_capture },
                { "set-method", parse_set_req_line },
@@ -12922,7 +12922,7 @@ struct http_req_action_kw_list http_req_actions = {
        }
 };
 
-struct http_res_action_kw_list http_res_actions = {
+struct action_kw_list http_res_actions = {
        .kw = {
                { "capture",    parse_http_res_capture },
                { NULL, NULL }
index f797042fdcd0cb159a4dfeef339f1a2fecec4a92..8dd95fd2d7c0df0adcac521c5996595110fc8245 100644 (file)
@@ -117,17 +117,17 @@ static struct protocol proto_tcpv6 = {
 /*
  * Register keywords.
  */
-void tcp_req_conn_keywords_register(struct tcp_action_kw_list *kw_list)
+void tcp_req_conn_keywords_register(struct action_kw_list *kw_list)
 {
        LIST_ADDQ(&tcp_req_conn_keywords, &kw_list->list);
 }
 
-void tcp_req_cont_keywords_register(struct tcp_action_kw_list *kw_list)
+void tcp_req_cont_keywords_register(struct action_kw_list *kw_list)
 {
        LIST_ADDQ(&tcp_req_cont_keywords, &kw_list->list);
 }
 
-void tcp_res_cont_keywords_register(struct tcp_action_kw_list *kw_list)
+void tcp_res_cont_keywords_register(struct action_kw_list *kw_list)
 {
        LIST_ADDQ(&tcp_res_cont_keywords, &kw_list->list);
 }
@@ -135,9 +135,9 @@ void tcp_res_cont_keywords_register(struct tcp_action_kw_list *kw_list)
 /*
  * Return the struct http_req_action_kw associated to a keyword.
  */
-static struct tcp_action_kw *tcp_req_conn_action(const char *kw)
+static struct action_kw *tcp_req_conn_action(const char *kw)
 {
-       struct tcp_action_kw_list *kw_list;
+       struct action_kw_list *kw_list;
        int i;
 
        if (LIST_ISEMPTY(&tcp_req_conn_keywords))
@@ -155,9 +155,9 @@ static struct tcp_action_kw *tcp_req_conn_action(const char *kw)
        return NULL;
 }
 
-static struct tcp_action_kw *tcp_req_cont_action(const char *kw)
+static struct action_kw *tcp_req_cont_action(const char *kw)
 {
-       struct tcp_action_kw_list *kw_list;
+       struct action_kw_list *kw_list;
        int i;
 
        if (LIST_ISEMPTY(&tcp_req_cont_keywords))
@@ -175,9 +175,9 @@ static struct tcp_action_kw *tcp_req_cont_action(const char *kw)
        return NULL;
 }
 
-static struct tcp_action_kw *tcp_res_cont_action(const char *kw)
+static struct action_kw *tcp_res_cont_action(const char *kw)
 {
-       struct tcp_action_kw_list *kw_list;
+       struct action_kw_list *kw_list;
        int i;
 
        if (LIST_ISEMPTY(&tcp_res_cont_keywords))
@@ -1504,7 +1504,7 @@ static int tcp_parse_response_rule(char **args, int arg, int section_type,
                rule->action = ACT_TCP_CLOSE;
        }
        else {
-               struct tcp_action_kw *kw;
+               struct action_kw *kw;
                kw = tcp_res_cont_action(args[arg]);
                if (kw) {
                        arg++;
@@ -1707,7 +1707,7 @@ static int tcp_parse_request_rule(char **args, int arg, int section_type,
                rule->action = ACT_TCP_EXPECT_PX;
        }
        else {
-               struct tcp_action_kw *kw;
+               struct action_kw *kw;
                if (where & SMP_VAL_FE_CON_ACC) {
                        kw = tcp_req_conn_action(args[arg]);
                        rule->from = ACT_F_TCP_REQ_CON;
index 430801232ce09ea7c1c6b3c23b0606ec43b29039..88e31a8ac9582d3853e22da9a6f4a045d5c43855 100644 (file)
@@ -710,22 +710,22 @@ static struct sample_conv_kw_list sample_conv_kws = {ILH, {
        { /* END */ },
 }};
 
-static struct tcp_action_kw_list tcp_req_kws = { { }, {
+static struct action_kw_list tcp_req_kws = { { }, {
        { "set-var", parse_tcp_req_store, 1 },
        { /* END */ }
 }};
 
-static struct tcp_action_kw_list tcp_res_kws = { { }, {
+static struct action_kw_list tcp_res_kws = { { }, {
        { "set-var", parse_tcp_res_store, 1 },
        { /* END */ }
 }};
 
-static struct http_req_action_kw_list http_req_kws = { { }, {
+static struct action_kw_list http_req_kws = { { }, {
        { "set-var", parse_http_req_store, 1 },
        { /* END */ }
 }};
 
-static struct http_res_action_kw_list http_res_kws = { { }, {
+static struct action_kw_list http_res_kws = { { }, {
        { "set-var", parse_http_res_store, 1 },
        { /* END */ }
 }};