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.
This commit is contained in:
Willy Tarreau 2020-05-27 16:21:26 +02:00
parent 6019faba50
commit eb6f701b99
34 changed files with 41 additions and 42 deletions

View File

@ -14,7 +14,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <common/ist.h> #include <import/ist.h>
#include <common/hpack-tbl.h> #include <common/hpack-tbl.h>
#include "../../src/hpack-tbl.c" #include "../../src/hpack-tbl.c"

View File

@ -29,7 +29,7 @@
#include <haproxy/api.h> #include <haproxy/api.h>
#include <common/buf.h> #include <common/buf.h>
#include <common/chunk.h> #include <common/chunk.h>
#include <common/ist.h> #include <import/ist.h>
#include <common/istbuf.h> #include <common/istbuf.h>
#include <common/memory.h> #include <common/memory.h>

View File

@ -27,7 +27,7 @@
#include <haproxy/api.h> #include <haproxy/api.h>
#include <common/buf.h> #include <common/buf.h>
#include <common/ist.h> #include <import/ist.h>
#include <common/memory.h> #include <common/memory.h>

View File

@ -26,7 +26,7 @@
#include <haproxy/api.h> #include <haproxy/api.h>
#include <common/standard.h> #include <common/standard.h>
#include <common/buf.h> #include <common/buf.h>
#include <common/ist.h> #include <import/ist.h>
/* FCGI protocol version */ /* FCGI protocol version */
#define FCGI_VERSION 0x1 #define FCGI_VERSION 0x1

View File

@ -26,7 +26,7 @@
#include <common/buffer.h> #include <common/buffer.h>
#include <common/http.h> #include <common/http.h>
#include <common/http-hdr.h> #include <common/http-hdr.h>
#include <common/ist.h> #include <import/ist.h>
#include <common/standard.h> #include <common/standard.h>

View File

@ -32,7 +32,7 @@
#include <haproxy/api.h> #include <haproxy/api.h>
#include <common/http-hdr.h> #include <common/http-hdr.h>
#include <common/htx.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 /* indexes of most important pseudo headers can be simplified to an almost

View File

@ -32,7 +32,7 @@
#include <haproxy/api.h> #include <haproxy/api.h>
#include <common/buf.h> #include <common/buf.h>
#include <common/http.h> #include <common/http.h>
#include <common/ist.h> #include <import/ist.h>
int hpack_encode_header(struct buffer *out, const struct ist n, int hpack_encode_header(struct buffer *out, const struct ist n,
const struct ist v); const struct ist v);

View File

@ -30,7 +30,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <haproxy/api.h> #include <haproxy/api.h>
#include <common/http-hdr.h> #include <common/http-hdr.h>
#include <common/ist.h> #include <import/ist.h>
#include <common/memory.h> #include <common/memory.h>
/* Dynamic Headers Table, usable for tables up to 4GB long and values of 64kB-1. /* Dynamic Headers Table, usable for tables up to 4GB long and values of 64kB-1.

View File

@ -28,7 +28,7 @@
#define _COMMON_HTTP_HDR_H #define _COMMON_HTTP_HDR_H
#include <inttypes.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 /* 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. * it takes 16 bytes on 32-bit systems and 32 bytes on 64-bit systems.

View File

@ -24,7 +24,7 @@
#define _COMMON_HTTP_H #define _COMMON_HTTP_H
#include <common/buf.h> #include <common/buf.h>
#include <common/ist.h> #include <import/ist.h>
/* /*
* some macros mainly used when parsing header fields. * some macros mainly used when parsing header fields.

View File

@ -25,7 +25,7 @@
#include <stdio.h> #include <stdio.h>
#include <haproxy/api.h> #include <haproxy/api.h>
#include <common/buf.h> #include <common/buf.h>
#include <common/ist.h> #include <import/ist.h>
#include <common/http.h> #include <common/http.h>
#include <common/http-hdr.h> #include <common/http-hdr.h>
#include <common/standard.h> #include <common/standard.h>

View File

@ -30,7 +30,7 @@
#include <inttypes.h> #include <inttypes.h>
#include <common/buf.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 /* b_isteq() : returns > 0 if the first <n> characters of buffer <b> starting

View File

@ -1,8 +1,8 @@
/* /*
* include/common/ist.h * include/import/ist.h
* Very simple indirect string manipulation functions. * 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 * Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the * a copy of this software and associated documentation files (the
@ -25,19 +25,18 @@
* OTHER DEALINGS IN THE SOFTWARE. * OTHER DEALINGS IN THE SOFTWARE.
*/ */
#ifndef _COMMON_IST_H #ifndef _IMPORT_IST_H
#define _COMMON_IST_H #define _IMPORT_IST_H
#include <sys/types.h>
#include <ctype.h> #include <ctype.h>
#include <stddef.h>
#include <string.h> #include <string.h>
#include <unistd.h>
#ifndef IST_FREESTANDING #ifndef IST_FREESTANDING
#include <stdlib.h> #include <stdlib.h>
#endif #endif
#include <haproxy/api.h>
/* ASCII to lower case conversion table */ /* ASCII to lower case conversion table */
#define _IST_LC ((const unsigned char[256]){ \ #define _IST_LC ((const unsigned char[256]){ \
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, \ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, \
@ -658,7 +657,7 @@ static inline const char *ist_find_ctl(const struct ist ist)
last += sizeof(long); last += sizeof(long);
if (__builtin_expect(curr < last, 0)) { if (__builtin_expect(curr < last, 0)) {
do { do {
if ((uint8_t)*curr < 0x20) if ((unsigned char)*curr < 0x20)
return curr; return curr;
curr++; curr++;
} while (curr < last); } while (curr < last);
@ -794,7 +793,7 @@ static inline struct ist istdup(const struct ist src)
/* Allocate at least 1 byte to allow duplicating an empty string with /* Allocate at least 1 byte to allow duplicating an empty string with
* malloc implementations that return NULL for a 0-size allocation. * 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)) { if (isttest(dst)) {
istcpy(&dst, src, src_size); istcpy(&dst, src, src_size);

View File

@ -23,7 +23,7 @@
#define _PROTO_CONNECTION_H #define _PROTO_CONNECTION_H
#include <haproxy/api.h> #include <haproxy/api.h>
#include <common/ist.h> #include <import/ist.h>
#include <common/memory.h> #include <common/memory.h>
#include <types/connection.h> #include <types/connection.h>
#include <types/listener.h> #include <types/listener.h>

View File

@ -24,7 +24,7 @@
#define _PROTO_H1_HTX_H #define _PROTO_H1_HTX_H
#include <common/buf.h> #include <common/buf.h>
#include <common/ist.h> #include <import/ist.h>
#include <common/h1.h> #include <common/h1.h>
int h1_parse_msg_hdrs(struct h1m *h1m, union h1_sl *h1sl, struct htx *dsthtx, int h1_parse_msg_hdrs(struct h1m *h1m, union h1_sl *h1sl, struct htx *dsthtx,

View File

@ -24,7 +24,7 @@
#define _PROTO_HTTP_HTX_H #define _PROTO_HTTP_HTX_H
#include <common/buf.h> #include <common/buf.h>
#include <common/ist.h> #include <import/ist.h>
#include <common/regex.h> #include <common/regex.h>
#include <types/http_htx.h> #include <types/http_htx.h>

View File

@ -23,7 +23,7 @@
#define _PROTO_RING_H #define _PROTO_RING_H
#include <stdlib.h> #include <stdlib.h>
#include <common/ist.h> #include <import/ist.h>
#include <types/ring.h> #include <types/ring.h>
struct ring *ring_new(size_t size); struct ring *ring_new(size_t size);

View File

@ -24,7 +24,7 @@
#include <haproxy/api.h> #include <haproxy/api.h>
#include <common/buffer.h> #include <common/buffer.h>
#include <common/ist.h> #include <import/ist.h>
#include <common/mini-clist.h> #include <common/mini-clist.h>
#include <types/log.h> #include <types/log.h>
#include <types/sink.h> #include <types/sink.h>

View File

@ -17,7 +17,7 @@
#include <import/ebpttree.h> #include <import/ebpttree.h>
#include <common/standard.h> #include <common/standard.h>
#include <common/ist.h> #include <import/ist.h>
#include <common/mini-clist.h> #include <common/mini-clist.h>
#include <common/regex.h> #include <common/regex.h>
#include <common/buf.h> #include <common/buf.h>

View File

@ -26,7 +26,7 @@
#include <sys/socket.h> #include <sys/socket.h>
#include <haproxy/api-t.h> #include <haproxy/api-t.h>
#include <common/ist.h> #include <import/ist.h>
#include <types/listener.h> #include <types/listener.h>
#include <types/obj_type.h> #include <types/obj_type.h>

View File

@ -23,7 +23,7 @@
#define _TYPES_HTTP_FCGI_H #define _TYPES_HTTP_FCGI_H
#include <haproxy/api-t.h> #include <haproxy/api-t.h>
#include <common/ist.h> #include <import/ist.h>
#include <common/fcgi.h> #include <common/fcgi.h>
#include <common/mini-clist.h> #include <common/mini-clist.h>
#include <common/regex.h> #include <common/regex.h>

View File

@ -24,7 +24,7 @@
#include <haproxy/api-t.h> #include <haproxy/api-t.h>
#include <common/hathreads.h> #include <common/hathreads.h>
#include <common/ist.h> #include <import/ist.h>
#include <types/port_range.h> #include <types/port_range.h>
/* Direction for each FD event update */ /* Direction for each FD event update */

View File

@ -28,7 +28,7 @@
#include <common/buf.h> #include <common/buf.h>
#include <common/http.h> #include <common/http.h>
#include <common/htx.h> #include <common/htx.h>
#include <common/ist.h> #include <import/ist.h>
/* Context used to find/remove an HTTP header. */ /* Context used to find/remove an HTTP header. */
struct http_hdr_ctx { struct http_hdr_ctx {

View File

@ -24,7 +24,7 @@
#include <haproxy/api-t.h> #include <haproxy/api-t.h>
#include <common/buf.h> #include <common/buf.h>
#include <common/ist.h> #include <import/ist.h>
/* The code below handles circular buffers with single-producer and multiple /* The code below handles circular buffers with single-producer and multiple
* readers (up to 255). The buffer storage area must remain always allocated. * readers (up to 255). The buffer storage area must remain always allocated.

View File

@ -24,7 +24,7 @@
#include <haproxy/api-t.h> #include <haproxy/api-t.h>
#include <common/buffer.h> #include <common/buffer.h>
#include <common/ist.h> #include <import/ist.h>
/* A sink may be of 4 distinct types : /* A sink may be of 4 distinct types :
* - file descriptor (such as stdout) * - file descriptor (such as stdout)

View File

@ -24,7 +24,7 @@
#include <haproxy/api-t.h> #include <haproxy/api-t.h>
#include <common/buffer.h> #include <common/buffer.h>
#include <common/ist.h> #include <import/ist.h>
#include <common/mini-clist.h> #include <common/mini-clist.h>
#include <types/sink.h> #include <types/sink.h>

View File

@ -23,7 +23,7 @@
#include <common/buf.h> #include <common/buf.h>
#include <common/debug.h> #include <common/debug.h>
#include <common/hathreads.h> #include <common/hathreads.h>
#include <common/ist.h> #include <import/ist.h>
#include <common/net_helper.h> #include <common/net_helper.h>
#include <common/standard.h> #include <common/standard.h>

View File

@ -29,7 +29,7 @@
#include <haproxy/api.h> #include <haproxy/api.h>
#include <common/h2.h> #include <common/h2.h>
#include <common/http-hdr.h> #include <common/http-hdr.h>
#include <common/ist.h> #include <import/ist.h>
#include <types/global.h> #include <types/global.h>
struct h2_frame_definition h2_frame_definition[H2_FT_ENTRIES] = { struct h2_frame_definition h2_frame_definition[H2_FT_ENTRIES] = {

View File

@ -36,7 +36,7 @@
#include <common/hpack-tbl.h> #include <common/hpack-tbl.h>
#include <common/chunk.h> #include <common/chunk.h>
#include <common/h2.h> #include <common/h2.h>
#include <common/ist.h> #include <import/ist.h>
#include <types/global.h> #include <types/global.h>

View File

@ -32,7 +32,7 @@
#include <common/hpack-enc.h> #include <common/hpack-enc.h>
#include <common/http-hdr.h> #include <common/http-hdr.h>
#include <common/ist.h> #include <import/ist.h>
#include <types/global.h> #include <types/global.h>

View File

@ -32,7 +32,7 @@
#include <common/hpack-huff.h> #include <common/hpack-huff.h>
#include <common/hpack-tbl.h> #include <common/hpack-tbl.h>
#include <common/ist.h> #include <import/ist.h>
#include <types/global.h> #include <types/global.h>

View File

@ -15,7 +15,7 @@
#include <common/fcgi.h> #include <common/fcgi.h>
#include <common/h1.h> #include <common/h1.h>
#include <common/htx.h> #include <common/htx.h>
#include <common/ist.h> #include <import/ist.h>
#include <common/mini-clist.h> #include <common/mini-clist.h>
#include <common/net_helper.h> #include <common/net_helper.h>

View File

@ -20,7 +20,7 @@
#include <haproxy/api.h> #include <haproxy/api.h>
#include <common/cfgparse.h> #include <common/cfgparse.h>
#include <common/ist.h> #include <import/ist.h>
#include <common/mini-clist.h> #include <common/mini-clist.h>
#include <common/time.h> #include <common/time.h>
#include <proto/cli.h> #include <proto/cli.h>

View File

@ -20,7 +20,7 @@
#include <haproxy/api.h> #include <haproxy/api.h>
#include <common/buffer.h> #include <common/buffer.h>
#include <common/ist.h> #include <import/ist.h>
#include <common/mini-clist.h> #include <common/mini-clist.h>
#include <proto/cli.h> #include <proto/cli.h>
#include <proto/log.h> #include <proto/log.h>