MEDIUM: actions: Merge (http|tcp)-(request|reponse) keywords structs
This patch merges the conguration keyword struct. Each declared configuration
keyword struct are similar with the others. This patch simplify the code.
diff --git a/include/proto/proto_http.h b/include/proto/proto_http.h
index a3a261f..0ebc612 100644
--- a/include/proto/proto_http.h
+++ b/include/proto/proto_http.h
@@ -129,16 +129,16 @@
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);
}
diff --git a/include/proto/proto_tcp.h b/include/proto/proto_tcp.h
index 3127625..5f589ea 100644
--- a/include/proto/proto_tcp.h
+++ b/include/proto/proto_tcp.h
@@ -41,9 +41,9 @@
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);
diff --git a/include/types/action.h b/include/types/action.h
index 713631e..9fb0878 100644
--- a/include/types/action.h
+++ b/include/types/action.h
@@ -132,4 +132,16 @@
} 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 */
diff --git a/include/types/proto_http.h b/include/types/proto_http.h
index 16be842..3f827b8 100644
--- a/include/types/proto_http.h
+++ b/include/types/proto_http.h
@@ -397,30 +397,8 @@
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];
diff --git a/include/types/proto_tcp.h b/include/types/proto_tcp.h
index df969a1..9d888a7 100644
--- a/include/types/proto_tcp.h
+++ b/include/types/proto_tcp.h
@@ -29,18 +29,6 @@
#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 */
/*
diff --git a/src/hlua.c b/src/hlua.c
index 5395b6d..32f8df4 100644
--- a/src/hlua.c
+++ b/src/hlua.c
@@ -4584,22 +4584,22 @@
{ 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 }
}};
diff --git a/src/proto_http.c b/src/proto_http.c
index ce43ec5..69a1052 100644
--- a/src/proto_http.c
+++ b/src/proto_http.c
@@ -236,12 +236,12 @@
/* 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 @@
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_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 @@
/*
* 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 @@
/*
* 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 @@
/************************************************************************/
/* 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_res_action_kw_list http_res_actions = {
+struct action_kw_list http_res_actions = {
.kw = {
{ "capture", parse_http_res_capture },
{ NULL, NULL }
diff --git a/src/proto_tcp.c b/src/proto_tcp.c
index f797042..8dd95fd 100644
--- a/src/proto_tcp.c
+++ b/src/proto_tcp.c
@@ -117,17 +117,17 @@
/*
* 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 @@
/*
* 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 @@
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 @@
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 @@
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 @@
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;
diff --git a/src/vars.c b/src/vars.c
index 4308012..88e31a8 100644
--- a/src/vars.c
+++ b/src/vars.c
@@ -710,22 +710,22 @@
{ /* 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 */ }
}};