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/trace.c b/src/trace.c
index ede3d0e..96d422a 100644
--- a/src/trace.c
+++ b/src/trace.c
@@ -240,7 +240,7 @@
 	}
 
 	if (src->sink)
-		sink_write(src->sink, line, words, 0, 0, NULL);
+		sink_write(src->sink, 0, line, words, 0, 0, NULL);
 
  end:
 	/* check if we need to stop the trace now */