From 129a85b1552666012749e07f29a2c65c92b6defa Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Thu, 4 Aug 2016 21:47:42 +0200 Subject: Add debug output (socket communication) if -DDEBUG_MODE is used MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/libcoopgamma.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src') diff --git a/src/libcoopgamma.c b/src/libcoopgamma.c index c4f13ab..b72e856 100644 --- a/src/libcoopgamma.c +++ b/src/libcoopgamma.c @@ -1484,6 +1484,14 @@ int libcoopgamma_flush(libcoopgamma_context_t* restrict ctx) return -1; continue; } + +#ifdef DEBUG_MODE + fprintf(stderr, "\033[31m"); + fwrite(ctx->outbound + ctx->outbound_tail, (size_t)sent, 1, stderr); + fprintf(stderr, "\033[m"); + fflush(stderr); +#endif + ctx->outbound_tail += (size_t)sent; } @@ -1551,6 +1559,14 @@ int libcoopgamma_synchronise(libcoopgamma_context_t* restrict ctx, errno = ECONNRESET; return -1; } + +#ifdef DEBUG_MODE + fprintf(stderr, "\033[32m"); + fwrite(ctx->inbound + ctx->inbound_head, (size_t)got, 1, stderr); + fprintf(stderr, "\033[m"); + fflush(stderr); +#endif + ctx->inbound_head += (size_t)got; skip_recv: -- cgit v1.2.3-70-g09d2