REORG: include: move ist.h from common/ to import/
Fortunately that file wasn't made dependent upon haproxy since it was
integrated, better isolate it before it's too late. Its dependency on
api.h was the result of the change from config.h, which in turn wasn't
correct. It was changed back to stddef.h for size_t and sys/types.h for
ssize_t. The recently added reference to MAX() was changed as it was
placed only to avoid a zero length in the non-free-standing version and
was causing a build warning in the hpack encoder.
diff --git a/contrib/hpack/gen-enc.c b/contrib/hpack/gen-enc.c
index dfe4705..36b132b 100644
--- a/contrib/hpack/gen-enc.c
+++ b/contrib/hpack/gen-enc.c
@@ -14,7 +14,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
-#include <common/ist.h>
+#include <import/ist.h>
#include <common/hpack-tbl.h>
#include "../../src/hpack-tbl.c"
diff --git a/include/common/buffer.h b/include/common/buffer.h
index f7aa254..d90b94e 100644
--- a/include/common/buffer.h
+++ b/include/common/buffer.h
@@ -29,7 +29,7 @@
#include <haproxy/api.h>
#include <common/buf.h>
#include <common/chunk.h>
-#include <common/ist.h>
+#include <import/ist.h>
#include <common/istbuf.h>
#include <common/memory.h>
diff --git a/include/common/chunk.h b/include/common/chunk.h
index ae7ae85..d4f9ea2 100644
--- a/include/common/chunk.h
+++ b/include/common/chunk.h
@@ -27,7 +27,7 @@
#include <haproxy/api.h>
#include <common/buf.h>
-#include <common/ist.h>
+#include <import/ist.h>
#include <common/memory.h>
diff --git a/include/common/fcgi.h b/include/common/fcgi.h
index b9a752b..6d3c6eb 100644
--- a/include/common/fcgi.h
+++ b/include/common/fcgi.h
@@ -26,7 +26,7 @@
#include <haproxy/api.h>
#include <common/standard.h>
#include <common/buf.h>
-#include <common/ist.h>
+#include <import/ist.h>
/* FCGI protocol version */
#define FCGI_VERSION 0x1
diff --git a/include/common/h1.h b/include/common/h1.h
index 0bc0f48..f75ee11 100644
--- a/include/common/h1.h
+++ b/include/common/h1.h
@@ -26,7 +26,7 @@
#include <common/buffer.h>
#include <common/http.h>
#include <common/http-hdr.h>
-#include <common/ist.h>
+#include <import/ist.h>
#include <common/standard.h>
diff --git a/include/common/h2.h b/include/common/h2.h
index 5654a76..32f0206 100644
--- a/include/common/h2.h
+++ b/include/common/h2.h
@@ -32,7 +32,7 @@
#include <haproxy/api.h>
#include <common/http-hdr.h>
#include <common/htx.h>
-#include <common/ist.h>
+#include <import/ist.h>
/* indexes of most important pseudo headers can be simplified to an almost
diff --git a/include/common/hpack-enc.h b/include/common/hpack-enc.h
index f204853..f766063 100644
--- a/include/common/hpack-enc.h
+++ b/include/common/hpack-enc.h
@@ -32,7 +32,7 @@
#include <haproxy/api.h>
#include <common/buf.h>
#include <common/http.h>
-#include <common/ist.h>
+#include <import/ist.h>
int hpack_encode_header(struct buffer *out, const struct ist n,
const struct ist v);
diff --git a/include/common/hpack-tbl.h b/include/common/hpack-tbl.h
index cde7114..1d2a8bd 100644
--- a/include/common/hpack-tbl.h
+++ b/include/common/hpack-tbl.h
@@ -30,7 +30,7 @@
#include <stdlib.h>
#include <haproxy/api.h>
#include <common/http-hdr.h>
-#include <common/ist.h>
+#include <import/ist.h>
#include <common/memory.h>
/* Dynamic Headers Table, usable for tables up to 4GB long and values of 64kB-1.
diff --git a/include/common/http-hdr.h b/include/common/http-hdr.h
index ffca828..77997e3 100644
--- a/include/common/http-hdr.h
+++ b/include/common/http-hdr.h
@@ -28,7 +28,7 @@
#define _COMMON_HTTP_HDR_H
#include <inttypes.h>
-#include <common/ist.h>
+#include <import/ist.h>
/* a header field made of a name and a value. Such structure stores 4 longs so
* it takes 16 bytes on 32-bit systems and 32 bytes on 64-bit systems.
diff --git a/include/common/http.h b/include/common/http.h
index acf1990..86cf015 100644
--- a/include/common/http.h
+++ b/include/common/http.h
@@ -24,7 +24,7 @@
#define _COMMON_HTTP_H
#include <common/buf.h>
-#include <common/ist.h>
+#include <import/ist.h>
/*
* some macros mainly used when parsing header fields.
diff --git a/include/common/htx.h b/include/common/htx.h
index 5a13614..1a87cde 100644
--- a/include/common/htx.h
+++ b/include/common/htx.h
@@ -25,7 +25,7 @@
#include <stdio.h>
#include <haproxy/api.h>
#include <common/buf.h>
-#include <common/ist.h>
+#include <import/ist.h>
#include <common/http.h>
#include <common/http-hdr.h>
#include <common/standard.h>
diff --git a/include/common/istbuf.h b/include/common/istbuf.h
index a533c71..f9bf0b1 100644
--- a/include/common/istbuf.h
+++ b/include/common/istbuf.h
@@ -30,7 +30,7 @@
#include <inttypes.h>
#include <common/buf.h>
-#include <common/ist.h>
+#include <import/ist.h>
/* b_isteq() : returns > 0 if the first <n> characters of buffer <b> starting
diff --git a/include/common/ist.h b/include/import/ist.h
similarity index 98%
rename from include/common/ist.h
rename to include/import/ist.h
index d62924e..08e2119 100644
--- a/include/common/ist.h
+++ b/include/import/ist.h
@@ -1,8 +1,8 @@
/*
- * include/common/ist.h
+ * include/import/ist.h
* Very simple indirect string manipulation functions.
*
- * Copyright (C) 2014-2017 Willy Tarreau - w@1wt.eu
+ * Copyright (C) 2014-2020 Willy Tarreau - w@1wt.eu
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
@@ -25,19 +25,18 @@
* OTHER DEALINGS IN THE SOFTWARE.
*/
-#ifndef _COMMON_IST_H
-#define _COMMON_IST_H
+#ifndef _IMPORT_IST_H
+#define _IMPORT_IST_H
+#include <sys/types.h>
#include <ctype.h>
+#include <stddef.h>
#include <string.h>
-#include <unistd.h>
#ifndef IST_FREESTANDING
#include <stdlib.h>
#endif
-#include <haproxy/api.h>
-
/* ASCII to lower case conversion table */
#define _IST_LC ((const unsigned char[256]){ \
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, \
@@ -658,7 +657,7 @@
last += sizeof(long);
if (__builtin_expect(curr < last, 0)) {
do {
- if ((uint8_t)*curr < 0x20)
+ if ((unsigned char)*curr < 0x20)
return curr;
curr++;
} while (curr < last);
@@ -794,7 +793,7 @@
/* Allocate at least 1 byte to allow duplicating an empty string with
* malloc implementations that return NULL for a 0-size allocation.
*/
- struct ist dst = istalloc(MAX(src_size, 1));
+ struct ist dst = istalloc(src_size ? src_size : 1);
if (isttest(dst)) {
istcpy(&dst, src, src_size);
diff --git a/include/proto/connection.h b/include/proto/connection.h
index 9b1e3d8..2efd629 100644
--- a/include/proto/connection.h
+++ b/include/proto/connection.h
@@ -23,7 +23,7 @@
#define _PROTO_CONNECTION_H
#include <haproxy/api.h>
-#include <common/ist.h>
+#include <import/ist.h>
#include <common/memory.h>
#include <types/connection.h>
#include <types/listener.h>
diff --git a/include/proto/h1_htx.h b/include/proto/h1_htx.h
index a8fd886..13ba394 100644
--- a/include/proto/h1_htx.h
+++ b/include/proto/h1_htx.h
@@ -24,7 +24,7 @@
#define _PROTO_H1_HTX_H
#include <common/buf.h>
-#include <common/ist.h>
+#include <import/ist.h>
#include <common/h1.h>
int h1_parse_msg_hdrs(struct h1m *h1m, union h1_sl *h1sl, struct htx *dsthtx,
diff --git a/include/proto/http_htx.h b/include/proto/http_htx.h
index 557d34f..edbd8f1 100644
--- a/include/proto/http_htx.h
+++ b/include/proto/http_htx.h
@@ -24,7 +24,7 @@
#define _PROTO_HTTP_HTX_H
#include <common/buf.h>
-#include <common/ist.h>
+#include <import/ist.h>
#include <common/regex.h>
#include <types/http_htx.h>
diff --git a/include/proto/ring.h b/include/proto/ring.h
index 8adbb9c..6f393fe 100644
--- a/include/proto/ring.h
+++ b/include/proto/ring.h
@@ -23,7 +23,7 @@
#define _PROTO_RING_H
#include <stdlib.h>
-#include <common/ist.h>
+#include <import/ist.h>
#include <types/ring.h>
struct ring *ring_new(size_t size);
diff --git a/include/proto/trace.h b/include/proto/trace.h
index ef88079..f43faf5 100644
--- a/include/proto/trace.h
+++ b/include/proto/trace.h
@@ -24,7 +24,7 @@
#include <haproxy/api.h>
#include <common/buffer.h>
-#include <common/ist.h>
+#include <import/ist.h>
#include <common/mini-clist.h>
#include <types/log.h>
#include <types/sink.h>
diff --git a/include/types/checks.h b/include/types/checks.h
index b2be640..4b81770 100644
--- a/include/types/checks.h
+++ b/include/types/checks.h
@@ -17,7 +17,7 @@
#include <import/ebpttree.h>
#include <common/standard.h>
-#include <common/ist.h>
+#include <import/ist.h>
#include <common/mini-clist.h>
#include <common/regex.h>
#include <common/buf.h>
diff --git a/include/types/connection.h b/include/types/connection.h
index 7357174..601e505 100644
--- a/include/types/connection.h
+++ b/include/types/connection.h
@@ -26,7 +26,7 @@
#include <sys/socket.h>
#include <haproxy/api-t.h>
-#include <common/ist.h>
+#include <import/ist.h>
#include <types/listener.h>
#include <types/obj_type.h>
diff --git a/include/types/fcgi-app.h b/include/types/fcgi-app.h
index f0fcdc7..7fb20ee 100644
--- a/include/types/fcgi-app.h
+++ b/include/types/fcgi-app.h
@@ -23,7 +23,7 @@
#define _TYPES_HTTP_FCGI_H
#include <haproxy/api-t.h>
-#include <common/ist.h>
+#include <import/ist.h>
#include <common/fcgi.h>
#include <common/mini-clist.h>
#include <common/regex.h>
diff --git a/include/types/fd.h b/include/types/fd.h
index 0041d4d..7ec97bc 100644
--- a/include/types/fd.h
+++ b/include/types/fd.h
@@ -24,7 +24,7 @@
#include <haproxy/api-t.h>
#include <common/hathreads.h>
-#include <common/ist.h>
+#include <import/ist.h>
#include <types/port_range.h>
/* Direction for each FD event update */
diff --git a/include/types/http_htx.h b/include/types/http_htx.h
index 301034c..02b6b3b 100644
--- a/include/types/http_htx.h
+++ b/include/types/http_htx.h
@@ -28,7 +28,7 @@
#include <common/buf.h>
#include <common/http.h>
#include <common/htx.h>
-#include <common/ist.h>
+#include <import/ist.h>
/* Context used to find/remove an HTTP header. */
struct http_hdr_ctx {
diff --git a/include/types/ring.h b/include/types/ring.h
index ac93c12..f3b3987 100644
--- a/include/types/ring.h
+++ b/include/types/ring.h
@@ -24,7 +24,7 @@
#include <haproxy/api-t.h>
#include <common/buf.h>
-#include <common/ist.h>
+#include <import/ist.h>
/* The code below handles circular buffers with single-producer and multiple
* readers (up to 255). The buffer storage area must remain always allocated.
diff --git a/include/types/sink.h b/include/types/sink.h
index 64b0bca..b10cb89 100644
--- a/include/types/sink.h
+++ b/include/types/sink.h
@@ -24,7 +24,7 @@
#include <haproxy/api-t.h>
#include <common/buffer.h>
-#include <common/ist.h>
+#include <import/ist.h>
/* A sink may be of 4 distinct types :
* - file descriptor (such as stdout)
diff --git a/include/types/trace.h b/include/types/trace.h
index cd5e8be..ad9d7b6 100644
--- a/include/types/trace.h
+++ b/include/types/trace.h
@@ -24,7 +24,7 @@
#include <haproxy/api-t.h>
#include <common/buffer.h>
-#include <common/ist.h>
+#include <import/ist.h>
#include <common/mini-clist.h>
#include <types/sink.h>
diff --git a/src/debug.c b/src/debug.c
index 7f281f0..e1b9070 100644
--- a/src/debug.c
+++ b/src/debug.c
@@ -23,7 +23,7 @@
#include <common/buf.h>
#include <common/debug.h>
#include <common/hathreads.h>
-#include <common/ist.h>
+#include <import/ist.h>
#include <common/net_helper.h>
#include <common/standard.h>
diff --git a/src/h2.c b/src/h2.c
index 891c3e0..c94ea8e 100644
--- a/src/h2.c
+++ b/src/h2.c
@@ -29,7 +29,7 @@
#include <haproxy/api.h>
#include <common/h2.h>
#include <common/http-hdr.h>
-#include <common/ist.h>
+#include <import/ist.h>
#include <types/global.h>
struct h2_frame_definition h2_frame_definition[H2_FT_ENTRIES] = {
diff --git a/src/hpack-dec.c b/src/hpack-dec.c
index fa25ac4..50293d8 100644
--- a/src/hpack-dec.c
+++ b/src/hpack-dec.c
@@ -36,7 +36,7 @@
#include <common/hpack-tbl.h>
#include <common/chunk.h>
#include <common/h2.h>
-#include <common/ist.h>
+#include <import/ist.h>
#include <types/global.h>
diff --git a/src/hpack-enc.c b/src/hpack-enc.c
index 1a6fa1c..bf7336b 100644
--- a/src/hpack-enc.c
+++ b/src/hpack-enc.c
@@ -32,7 +32,7 @@
#include <common/hpack-enc.h>
#include <common/http-hdr.h>
-#include <common/ist.h>
+#include <import/ist.h>
#include <types/global.h>
diff --git a/src/hpack-tbl.c b/src/hpack-tbl.c
index effe5e0..31c24b2 100644
--- a/src/hpack-tbl.c
+++ b/src/hpack-tbl.c
@@ -32,7 +32,7 @@
#include <common/hpack-huff.h>
#include <common/hpack-tbl.h>
-#include <common/ist.h>
+#include <import/ist.h>
#include <types/global.h>
diff --git a/src/mux_fcgi.c b/src/mux_fcgi.c
index 5ce6f61..7ff3932 100644
--- a/src/mux_fcgi.c
+++ b/src/mux_fcgi.c
@@ -15,7 +15,7 @@
#include <common/fcgi.h>
#include <common/h1.h>
#include <common/htx.h>
-#include <common/ist.h>
+#include <import/ist.h>
#include <common/mini-clist.h>
#include <common/net_helper.h>
diff --git a/src/sink.c b/src/sink.c
index 20d3d79..7eb283f 100644
--- a/src/sink.c
+++ b/src/sink.c
@@ -20,7 +20,7 @@
#include <haproxy/api.h>
#include <common/cfgparse.h>
-#include <common/ist.h>
+#include <import/ist.h>
#include <common/mini-clist.h>
#include <common/time.h>
#include <proto/cli.h>
diff --git a/src/trace.c b/src/trace.c
index 667cd81..3f6ff05 100644
--- a/src/trace.c
+++ b/src/trace.c
@@ -20,7 +20,7 @@
#include <haproxy/api.h>
#include <common/buffer.h>
-#include <common/ist.h>
+#include <import/ist.h>
#include <common/mini-clist.h>
#include <proto/cli.h>
#include <proto/log.h>