MINOR: sink/api: pass explicit maxlen parameter to sink_write()

sink_write() currently relies on sink->maxlen to know when to stop
writing a given payload.

But it could be useful to pass a smaller, explicit value to sink_write()
to stop before the ring maxlen, for instance if the ring is shared between
multiple feeders.

sink_write() now takes an optional maxlen parameter:
  if maxlen is > 0, then sink_write will stop writing at maxlen if maxlen
  is smaller than ring->maxlen, else only ring->maxlen will be considered.

[for haproxy <= 2.7, patch must be applied by hand: that is:
__sink_write() and sink_write() should be patched to take maxlen into
account and function calls to sink_write() should use 0 as second argument
to keep original behavior]

(cherry picked from commit b6e2d62fb3c3015f2da87e2c78cc562b3a0fc391)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 5bab37ef46d9db6653fc08fa03619c2cb35a66ae)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit ce691552a45387dd96b3ae1d5a5d3b323c6d69c8)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit d9aff564ef1a55cea2eeaefd96f23f84138984c3)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
diff --git a/src/sample.c b/src/sample.c
index d9ae4c1..33628ae 100644
--- a/src/sample.c
+++ b/src/sample.c
@@ -1528,7 +1528,7 @@
 
  done:
 	line = ist2(buf->area, buf->data);
-	sink_write(sink, &line, 1, 0, 0, NULL);
+	sink_write(sink, 0, &line, 1, 0, 0, NULL);
  end:
 	free_trash_chunk(buf);
 	return 1;