MINOR: channel: add new function co_getdelim() to support multiple delimiters
authorWilly Tarreau <w@1wt.eu>
Wed, 19 Jan 2022 16:19:52 +0000 (17:19 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 26 Jan 2022 03:36:15 +0000 (04:36 +0100)
commit9cd2049e292aad1457f457f1694879c28cc31d18
tree7fb7f9e1b6047ee5c3b2b2c88271d50eb82a670b
parentec91650b88e1ef11decbca4b1eb11913bd7ccf03
MINOR: channel: add new function co_getdelim() to support multiple delimiters

For now we have co_getline() which reads a buffer and stops on LF, and
co_getword() which reads a buffer and stops on one arbitrary delimiter.
But sometimes we'd need to stop on a set of delimiters (CR and LF, etc).

This patch adds a new function co_getdelim() which takes a set of delimiters
as a string, and constructs a small map (32 bytes) that's looked up during
parsing to stop after the first delimiter found within the set. It also
supports an optional escape character that skips a delimiter (typically a
backslash). For the rest it works exactly like the two other variants.

(cherry picked from commit c5143653177368a40f3153dcf79d145284a5495e)
Signed-off-by: Willy Tarreau <w@1wt.eu>
include/haproxy/channel.h
src/channel.c