From a17189250170c45b66f7b8f88de9350c9eccd273 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Thu, 4 Jun 2020 16:25:31 +0200 Subject: [PATCH] REORG: include: move vars.h to haproxy/vars{,-t}.h A few includes (sessions.h, stream.h, api-t.h) were added for arguments that were first declared in function prototypes. --- include/haproxy/arg-t.h | 2 +- include/haproxy/vars-t.h | 57 ++++++++++++++++++++++++++++++++++++++++ include/haproxy/vars.h | 40 ++++++++++++++++++++++++++++ include/proto/vars.h | 16 ----------- include/types/global.h | 2 +- include/types/session.h | 2 +- include/types/stream.h | 2 +- include/types/vars.h | 37 -------------------------- src/checks.c | 2 +- src/dns.c | 2 +- src/flt_spoe.c | 2 +- src/haproxy.c | 2 +- src/hlua.c | 2 +- src/http_ana.c | 2 +- src/sample.c | 2 +- src/session.c | 2 +- src/ssl_sock.c | 2 +- src/stream.c | 2 +- src/vars.c | 4 +-- 19 files changed, 112 insertions(+), 70 deletions(-) create mode 100644 include/haproxy/vars-t.h create mode 100644 include/haproxy/vars.h delete mode 100644 include/proto/vars.h delete mode 100644 include/types/vars.h diff --git a/include/haproxy/arg-t.h b/include/haproxy/arg-t.h index d63d60f4e8..a283eff812 100644 --- a/include/haproxy/arg-t.h +++ b/include/haproxy/arg-t.h @@ -28,8 +28,8 @@ #include #include #include +#include -#include #include /* encoding of each arg type : up to 31 types are supported */ diff --git a/include/haproxy/vars-t.h b/include/haproxy/vars-t.h new file mode 100644 index 0000000000..0d8f337982 --- /dev/null +++ b/include/haproxy/vars-t.h @@ -0,0 +1,57 @@ +/* + * include/haproxy/vars-t.h + * Macros and structures definitions for variables. + * + * Copyright (C) 2015 Thierry FOURNIER + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation, version 2.1 + * exclusively. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef _HAPROXY_VARS_T_H +#define _HAPROXY_VARS_T_H + +#include +#include +#include + +enum vars_scope { + SCOPE_SESS = 0, + SCOPE_TXN, + SCOPE_REQ, + SCOPE_RES, + SCOPE_PROC, + SCOPE_CHECK, +}; + +struct vars { + struct list head; + enum vars_scope scope; + unsigned int size; + __decl_thread(HA_RWLOCK_T rwlock); +}; + +/* This struct describes a variable. */ +struct var_desc { + const char *name; /* Contains the normalized variable name. */ + enum vars_scope scope; +}; + +struct var { + struct list l; /* Used for chaining vars. */ + const char *name; /* Contains the variable name. */ + struct sample_data data; /* data storage. */ +}; + +#endif diff --git a/include/haproxy/vars.h b/include/haproxy/vars.h new file mode 100644 index 0000000000..32172a8da7 --- /dev/null +++ b/include/haproxy/vars.h @@ -0,0 +1,40 @@ +/* + * include/haproxy/vars.h + * Prototypes for variables. + * + * Copyright (C) 2015 Thierry FOURNIER + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation, version 2.1 + * exclusively. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef _HAPROXY_VARS_H +#define _HAPROXY_VARS_H + +#include +#include +#include +#include + +void vars_init(struct vars *vars, enum vars_scope scope); +void vars_prune(struct vars *vars, struct session *sess, struct stream *strm); +void vars_prune_per_sess(struct vars *vars); +int vars_get_by_name(const char *name, size_t len, struct sample *smp); +int vars_set_by_name_ifexist(const char *name, size_t len, struct sample *smp); +int vars_set_by_name(const char *name, size_t len, struct sample *smp); +int vars_unset_by_name_ifexist(const char *name, size_t len, struct sample *smp); +int vars_get_by_desc(const struct var_desc *var_desc, struct sample *smp); +int vars_check_arg(struct arg *arg, char **err); + +#endif diff --git a/include/proto/vars.h b/include/proto/vars.h deleted file mode 100644 index 81f99dfb3e..0000000000 --- a/include/proto/vars.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef _PROTO_VARS_H -#define _PROTO_VARS_H - -#include - -void vars_init(struct vars *vars, enum vars_scope scope); -void vars_prune(struct vars *vars, struct session *sess, struct stream *strm); -void vars_prune_per_sess(struct vars *vars); -int vars_get_by_name(const char *name, size_t len, struct sample *smp); -int vars_set_by_name_ifexist(const char *name, size_t len, struct sample *smp); -int vars_set_by_name(const char *name, size_t len, struct sample *smp); -int vars_unset_by_name_ifexist(const char *name, size_t len, struct sample *smp); -int vars_get_by_desc(const struct var_desc *var_desc, struct sample *smp); -int vars_check_arg(struct arg *arg, char **err); - -#endif diff --git a/include/types/global.h b/include/types/global.h index f753660423..56e7678a1f 100644 --- a/include/types/global.h +++ b/include/types/global.h @@ -26,11 +26,11 @@ #include #include +#include #include #include #include -#include #ifndef UNIX_MAX_PATH #define UNIX_MAX_PATH 108 diff --git a/include/types/session.h b/include/types/session.h index 66911f3d69..70d10a84cd 100644 --- a/include/types/session.h +++ b/include/types/session.h @@ -31,11 +31,11 @@ #include #include #include +#include #include #include #include -#include struct sess_srv_list { void *target; diff --git a/include/types/stream.h b/include/types/stream.h index e86b6d6141..88708428c4 100644 --- a/include/types/stream.h +++ b/include/types/stream.h @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -44,7 +45,6 @@ #include #include #include -#include /* Various Stream Flags, bits values 0x01 to 0x100 (shift 0) */ #define SF_DIRECT 0x00000001 /* connection made on the server matching the client cookie */ diff --git a/include/types/vars.h b/include/types/vars.h deleted file mode 100644 index d8ec71c61b..0000000000 --- a/include/types/vars.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef _TYPES_VARS_H -#define _TYPES_VARS_H - -#include -#include - -#include - -enum vars_scope { - SCOPE_SESS = 0, - SCOPE_TXN, - SCOPE_REQ, - SCOPE_RES, - SCOPE_PROC, - SCOPE_CHECK, -}; - -struct vars { - struct list head; - enum vars_scope scope; - unsigned int size; - __decl_thread(HA_RWLOCK_T rwlock); -}; - -/* This struct describes a variable. */ -struct var_desc { - const char *name; /* Contains the normalized variable name. */ - enum vars_scope scope; -}; - -struct var { - struct list l; /* Used for chaining vars. */ - const char *name; /* Contains the variable name. */ - struct sample_data data; /* data storage. */ -}; - -#endif diff --git a/src/checks.c b/src/checks.c index d742969684..0793a82a22 100644 --- a/src/checks.c +++ b/src/checks.c @@ -45,6 +45,7 @@ #include #include #include +#include #include #include @@ -64,7 +65,6 @@ #include #include #include -#include #include #include #include diff --git a/src/dns.c b/src/dns.c index e176b789d6..a3e02e9d10 100644 --- a/src/dns.c +++ b/src/dns.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -47,7 +48,6 @@ #include #include #include -#include struct list dns_resolvers = LIST_HEAD_INIT(dns_resolvers); struct list dns_srvrq_list = LIST_HEAD_INIT(dns_srvrq_list); diff --git a/src/flt_spoe.c b/src/flt_spoe.c index 010dac2a56..6acb9f412b 100644 --- a/src/flt_spoe.c +++ b/src/flt_spoe.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -41,7 +42,6 @@ #include #include #include -#include #if defined(DEBUG_SPOE) || defined(DEBUG_FULL) #define SPOE_PRINTF(x...) fprintf(x) diff --git a/src/haproxy.c b/src/haproxy.c index 60c5f65cb8..5a7cbf35b4 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -105,6 +105,7 @@ #include #include #include +#include #include #include @@ -132,7 +133,6 @@ #include #include #include -#include #include /* array of init calls for older platforms */ diff --git a/src/hlua.c b/src/hlua.c index 5b670c741a..fda7212bfe 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -39,6 +39,7 @@ #include #include #include +#include #include #include @@ -59,7 +60,6 @@ #include #include #include -#include /* Lua uses longjmp to perform yield or throwing errors. This * macro is used only for identifying the function that can diff --git a/src/http_ana.c b/src/http_ana.c index da160980be..f7e59321f6 100644 --- a/src/http_ana.c +++ b/src/http_ana.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -34,7 +35,6 @@ #include #include #include -#include #define TRACE_SOURCE &trace_strm diff --git a/src/sample.c b/src/sample.c index 8ee3407c2f..ef798341ed 100644 --- a/src/sample.c +++ b/src/sample.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -37,7 +38,6 @@ #include #include #include -#include #include #include diff --git a/src/session.c b/src/session.c index f752e07ece..afbcf2be17 100644 --- a/src/session.c +++ b/src/session.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -24,7 +25,6 @@ #include #include #include -#include DECLARE_POOL(pool_head_session, "session", sizeof(struct session)); DECLARE_POOL(pool_head_sess_srv_list, "session server list", diff --git a/src/ssl_sock.c b/src/ssl_sock.c index b9663081bc..6d9d713238 100644 --- a/src/ssl_sock.c +++ b/src/ssl_sock.c @@ -59,6 +59,7 @@ #include #include #include +#include #include #include @@ -85,7 +86,6 @@ #include #include #include -#include /* ***** READ THIS before adding code here! ***** * diff --git a/src/stream.c b/src/stream.c index b3e71480a9..248dfe25a4 100644 --- a/src/stream.c +++ b/src/stream.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -59,7 +60,6 @@ #include #include #include -#include DECLARE_POOL(pool_head_stream, "stream", sizeof(struct stream)); DECLARE_POOL(pool_head_uniqueid, "uniqueid", UNIQUEID_LEN); diff --git a/src/vars.c b/src/vars.c index f69dbbbcca..b9aea6ad6c 100644 --- a/src/vars.c +++ b/src/vars.c @@ -6,14 +6,12 @@ #include #include #include - -#include +#include #include #include #include #include -#include #include /* This contains a pool of struct vars */ -- 2.47.3