/*------------------------------------------------------------------------- * Function: parallel_print * * Purpose: wrapper for printf for use in parallel mode. * * Programmer: Leon Arber * * Date: December 1, 2004 * *------------------------------------------------------------------------- */ void parallel_print(const char* format, ...) { int bytes_written; va_list ap; HDva_start(ap, format); if(!g_Parallel) HDvprintf(format, ap); else { if(overflow_file == NULL) /*no overflow has occurred yet */ { #if 0 printf("calling HDvsnprintf: OUTBUFF_SIZE=%ld, outBuffOffset=%ld, ", (long)OUTBUFF_SIZE, (long)outBuffOffset); #endif bytes_written = HDvsnprintf(outBuff+outBuffOffset, OUTBUFF_SIZE-outBuffOffset, format, ap); #if 0 printf("bytes_written=%ld\n", (long)bytes_written); #endif HDva_end(ap); HDva_start(ap, format); #if 0 printf("Result: bytes_written=%ld, OUTBUFF_SIZE-outBuffOffset=%ld\n", (long)bytes_written, (long)OUTBUFF_SIZE-outBuffOffset); #endif if ((bytes_written < 0) || #ifdef H5_VSNPRINTF_WORKS (bytes_written >= (OUTBUFF_SIZE-outBuffOffset)) #else ((bytes_written+1) == (OUTBUFF_SIZE-outBuffOffset)) #endif ) { /* Terminate the outbuff at the end of the previous output */ outBuff[outBuffOffset] = '\0'; overflow_file = HDtmpfile(); if(overflow_file == NULL) HDfprintf(rawerrorstream, "warning: could not create overflow file. Output may be truncated.\n"); else bytes_written = HDvfprintf(overflow_file, format, ap); } else outBuffOffset += bytes_written; } else bytes_written = HDvfprintf(overflow_file, format, ap); } HDva_end(ap); }
/* * Function: error * Purpose: Display error message and exit. * Programmer: Bill Wendling, 05. June 2002 * Modifications: */ static void error(const char *fmt, ...) { va_list ap; va_start(ap, fmt); HDfprintf(stderr, "%s: error: ", prog); HDvfprintf(stderr, fmt, ap); HDfprintf(stderr, "\n"); va_end(ap); HDexit(EXIT_FAILURE); }
/*------------------------------------------------------------------------- * Function: warn_msg * * Purpose: Print a nicely formatted warning message to stderr flushing * the stdout stream first. * * Return: Nothing * * Programmer: Bill Wendling * Tuesday, 20. February 2001 * * Modifications: * *------------------------------------------------------------------------- */ void warn_msg(const char *fmt, ...) { va_list ap; HDva_start(ap, fmt); HDfflush(rawdatastream); HDfflush(rawoutstream); HDfprintf(rawerrorstream, "%s warning: ", h5tools_getprogname()); HDvfprintf(rawerrorstream, fmt, ap); HDva_end(ap); }