]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: include: move sample_data out of sample-t.h
authorWilly Tarreau <w@1wt.eu>
Fri, 5 Jun 2020 14:54:16 +0000 (16:54 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 11 Jun 2020 08:18:59 +0000 (10:18 +0200)
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.

include/haproxy/acl-t.h
include/haproxy/pattern-t.h
include/haproxy/pattern.h
include/haproxy/sample-t.h
include/haproxy/sample_data-t.h [new file with mode: 0644]
include/haproxy/vars-t.h

index 8418ca95ff1db4c6b40940316d7910ef566c8407..a96aa428d958eae57ec5d278299d4ad960d2f0dd 100644 (file)
 #ifndef _HAPROXY_ACL_T_H
 #define _HAPROXY_ACL_T_H
 
-#include <import/ebmbtree.h>
-
-#include <haproxy/arg-t.h>
 #include <haproxy/list-t.h>
 #include <haproxy/pattern-t.h>
-#include <haproxy/server-t.h>
-#include <haproxy/api-t.h>
-
+#include <haproxy/sample-t.h>
 
 /* ACL test result.
  *
index a977527a17077e83088778b2bfa26d33f769a435..592de81bcaf943539fffa1df7c918e401dd07428 100644 (file)
@@ -29,7 +29,7 @@
 #include <haproxy/thread-t.h>
 #include <haproxy/api-t.h>
 
-#include <haproxy/sample-t.h>
+#include <haproxy/sample_data-t.h>
 
 
 /* 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);
index 6be2474bb654e006206e0e33e2959981ab97515a..e1c246c54f28f74ae81cc22919e301da7a56ced8 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <haproxy/api.h>
 #include <haproxy/pattern-t.h>
+#include <haproxy/sample-t.h>
 
 /* pattern management function arrays */
 extern char *pat_match_names[PAT_MATCH_NUM];
index 9403d7bff288b0a8922a0c4d23008e9e4fb6dfe4..0f38f186bfbf1d43309d2d17aa7832cd67865a06 100644 (file)
 #ifndef _HAPROXY_SAMPLE_T_H
 #define _HAPROXY_SAMPLE_T_H
 
-#include <sys/socket.h>
-#include <netinet/in.h>
-
-#include <haproxy/api-t.h>
-#include <haproxy/buf-t.h>
-#include <haproxy/http-t.h>
 #include <haproxy/list-t.h>
+#include <haproxy/api-t.h>
+#include <haproxy/sample_data-t.h>
 
 /* 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 <len> 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 (file)
index 0000000..2546028
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * include/haproxy/sample_data-t.h
+ * Definitions of sample data
+ *
+ * Copyright (C) 2009-2010 EXCELIANCE, Emeric Brun <ebrun@exceliance.fr>
+ * Copyright (C) 2020 Willy Tarreau <w@1wt.eu>
+ *
+ * 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 <sys/socket.h>
+#include <netinet/in.h>
+#include <haproxy/buf-t.h>
+#include <haproxy/http-t.h>
+
+/* 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 <len> 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 */
index 0d8f3379829ba4fdb980c80e84a38bc8b45ebca9..388d20812055a92abf60754227dd4830aee71a90 100644 (file)
@@ -23,7 +23,7 @@
 #define _HAPROXY_VARS_T_H
 
 #include <haproxy/list-t.h>
-#include <haproxy/sample-t.h>
+#include <haproxy/sample_data-t.h>
 #include <haproxy/thread-t.h>
 
 enum vars_scope {