From: Willy Tarreau Date: Fri, 5 Jun 2020 14:54:16 +0000 (+0200) Subject: CLEANUP: include: move sample_data out of sample-t.h X-Git-Tag: v2.2-dev9~10 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=251c2aae06a8aa6117ce7dcf2eb7a3fe02378344;p=thirdparty%2Fhaproxy.git CLEANUP: include: move sample_data out of sample-t.h The struct sample_data is used by pattern, map and vars, and currently requires to include sample-t which comes with many other dependencies. Let's move sample_data into its own file to shorten the dependency tree. This revealed a number of issues in adjacent files which were hidden by the fact that sample-t.h brought everything that was missing. --- diff --git a/include/haproxy/acl-t.h b/include/haproxy/acl-t.h index 8418ca95ff..a96aa428d9 100644 --- a/include/haproxy/acl-t.h +++ b/include/haproxy/acl-t.h @@ -22,14 +22,9 @@ #ifndef _HAPROXY_ACL_T_H #define _HAPROXY_ACL_T_H -#include - -#include #include #include -#include -#include - +#include /* ACL test result. * diff --git a/include/haproxy/pattern-t.h b/include/haproxy/pattern-t.h index a977527a17..592de81bca 100644 --- a/include/haproxy/pattern-t.h +++ b/include/haproxy/pattern-t.h @@ -29,7 +29,7 @@ #include #include -#include +#include /* Pattern matching function result. @@ -206,7 +206,9 @@ struct pattern_expr_list { struct pattern_expr *expr; /* The used expr. */ }; -/* This struct contain a list of pattern expr */ + +/* This struct contains a list of pattern expr */ +struct sample; struct pattern_head { int (*parse)(const char *text, struct pattern *pattern, int flags, char **err); int (*parse_smp)(const char *text, struct sample_data *data); diff --git a/include/haproxy/pattern.h b/include/haproxy/pattern.h index 6be2474bb6..e1c246c54f 100644 --- a/include/haproxy/pattern.h +++ b/include/haproxy/pattern.h @@ -26,6 +26,7 @@ #include #include +#include /* pattern management function arrays */ extern char *pat_match_names[PAT_MATCH_NUM]; diff --git a/include/haproxy/sample-t.h b/include/haproxy/sample-t.h index 9403d7bff2..0f38f186bf 100644 --- a/include/haproxy/sample-t.h +++ b/include/haproxy/sample-t.h @@ -23,13 +23,9 @@ #ifndef _HAPROXY_SAMPLE_T_H #define _HAPROXY_SAMPLE_T_H -#include -#include - -#include -#include -#include #include +#include +#include /* input and output sample types */ enum { @@ -225,26 +221,6 @@ union smp_ctx { void *a[8]; /* any array of up to 8 pointers */ }; -/* Note: the strings below make use of chunks. Chunks may carry an allocated - * size in addition to the length. The size counts from the beginning (str) - * to the end. If the size is unknown, it MUST be zero, in which case the - * sample will automatically be duplicated when a change larger than has - * to be performed. Thus it is safe to always set size to zero. - */ -union sample_value { - long long int sint; /* used for signed 64bits integers */ - struct in_addr ipv4; /* used for ipv4 addresses */ - struct in6_addr ipv6; /* used for ipv6 addresses */ - struct buffer str; /* used for char strings or buffers */ - struct http_meth meth; /* used for http method */ -}; - -/* Used to store sample constant */ -struct sample_data { - int type; /* SMP_T_* */ - union sample_value u; /* sample data */ -}; - /* a sample is a typed data extracted from a stream. It has a type, contents, * validity constraints, a context for use in iterative calls. */ diff --git a/include/haproxy/sample_data-t.h b/include/haproxy/sample_data-t.h new file mode 100644 index 0000000000..2546028769 --- /dev/null +++ b/include/haproxy/sample_data-t.h @@ -0,0 +1,51 @@ +/* + * include/haproxy/sample_data-t.h + * Definitions of sample data + * + * Copyright (C) 2009-2010 EXCELIANCE, Emeric Brun + * Copyright (C) 2020 Willy Tarreau + * + * 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_SAMPLE_DATA_T_H +#define _HAPROXY_SAMPLE_DATA_T_H + +#include +#include +#include +#include + +/* Note: the strings below make use of chunks. Chunks may carry an allocated + * size in addition to the length. The size counts from the beginning (str) + * to the end. If the size is unknown, it MUST be zero, in which case the + * sample will automatically be duplicated when a change larger than has + * to be performed. Thus it is safe to always set size to zero. + */ +union sample_value { + long long int sint; /* used for signed 64bits integers */ + struct in_addr ipv4; /* used for ipv4 addresses */ + struct in6_addr ipv6; /* used for ipv6 addresses */ + struct buffer str; /* used for char strings or buffers */ + struct http_meth meth; /* used for http method */ +}; + +/* Used to store sample constant */ +struct sample_data { + int type; /* SMP_T_* */ + union sample_value u; /* sample data */ +}; + +#endif /* _HAPROXY_SAMPLE_DATA_T_H */ diff --git a/include/haproxy/vars-t.h b/include/haproxy/vars-t.h index 0d8f337982..388d208120 100644 --- a/include/haproxy/vars-t.h +++ b/include/haproxy/vars-t.h @@ -23,7 +23,7 @@ #define _HAPROXY_VARS_T_H #include -#include +#include #include enum vars_scope {