From 28df8ea36e7038a777570d5bc6698d4c3a615c9a Mon Sep 17 00:00:00 2001 From: Olaf Bergmann Date: Mon, 26 Jul 2010 17:10:29 +0200 Subject: [PATCH] flush stdout after debug output generation --- debug.c | 5 +++-- net.c | 15 ++++++++------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/debug.c b/debug.c index 9e9015dc..a0c8e751 100644 --- a/debug.c +++ b/debug.c @@ -19,9 +19,10 @@ void debug(char *format, ...) { tmp = localtime(&now); if ( strftime(timebuf,sizeof(timebuf), "%b %d %H:%M:%S", tmp) ) - fprintf(stderr,"%s ", timebuf); + printf("%s ", timebuf); va_start(ap, format); - vfprintf(stderr,format, ap); + vprintf(format, ap); va_end(ap); + fflush(stdout); } diff --git a/net.c b/net.c index ad1f7700..4bf581eb 100644 --- a/net.c +++ b/net.c @@ -84,7 +84,7 @@ void show( coap_opt_t *opt, unsigned char type, unsigned int len, const unsigned char *data ) { static unsigned char buf[COAP_MAX_PDU_SIZE]; print_readable( data, len, buf, COAP_MAX_PDU_SIZE ); - fprintf(stderr, " %d:'%s'", type, buf ); + printf(" %d:'%s'", type, buf ); } void @@ -92,25 +92,26 @@ show_data( coap_pdu_t *pdu ) { static unsigned char buf[COAP_MAX_PDU_SIZE]; unsigned int len = (int)( (unsigned char *)pdu->hdr + pdu->length - pdu->data ); print_readable( pdu->data, len, buf, COAP_MAX_PDU_SIZE ); - fprintf(stderr,"'%s'", buf); + printf("'%s'", buf); } void coap_show_pdu( coap_pdu_t *pdu ) { - fprintf(stderr,"pdu (%d bytes)", pdu->length); - fprintf(stderr," v:%d t:%d oc:%d c:%d id:%u", pdu->hdr->version, pdu->hdr->type, + printf("pdu (%d bytes)", pdu->length); + printf(" v:%d t:%d oc:%d c:%d id:%u", pdu->hdr->version, pdu->hdr->type, pdu->hdr->optcnt, pdu->hdr->code, ntohs(pdu->hdr->id)); if ( pdu->hdr->optcnt ) { - fprintf(stderr," o:"); + printf(" o:"); for_each_option ( pdu, show ); } if ( pdu->data < (unsigned char *)pdu->hdr + pdu->length ) { - fprintf(stderr,"\n data:"); + printf("\n data:"); show_data ( pdu ); } - fprintf(stderr,"\n"); + printf("\n"); + fflush(stdout); } /************************************************************************/