diff --git a/src/xmppipe.c b/src/xmppipe.c index ac58fcb..0a2a1a1 100644 --- a/src/xmppipe.c +++ b/src/xmppipe.c @@ -89,7 +89,7 @@ int main(int argc, char **argv) { state = xmppipe_calloc(1, sizeof(xmppipe_state_t)); xmppipe_next_state(state, XMPPIPE_S_CONNECTING); - state->bufsz = 2049; + state->bufsz = -1; state->poll = 10; state->keepalive = 60 * 1000; state->keepalive_limit = 3; @@ -240,6 +240,17 @@ int main(int argc, char **argv) { exit(2); } + if (state->bufsz == -1) { + switch (state->format) { + case XMPPIPE_FMT_CSV: + state->bufsz = 6144 + 1; + break; + default: + state->bufsz = 2048 + 1; + break; + } + } + if (state->encode && BASE64_LENGTH(state->bufsz) + 1 > 0xffff) { usage(state); exit(2); diff --git a/src/xmppipe.h b/src/xmppipe.h index 9b1afce..bb4f95f 100644 --- a/src/xmppipe.h +++ b/src/xmppipe.h @@ -85,7 +85,7 @@ typedef struct { keepalive_fail; /* number of consecutive keepalives without a reply */ u_int32_t keepalive_limit; /* number of keepalives without a reply */ u_int32_t interval; /* time since last keepalive (milliseconds) */ - size_t bufsz; /* size of read buffer */ + ssize_t bufsz; /* size of read buffer */ int sm_enabled; /* stanzas: iq, message, presence */