diff options
-rw-r--r-- | fetchmail.h | 2 | ||||
-rw-r--r-- | report.c | 19 |
2 files changed, 18 insertions, 3 deletions
diff --git a/fetchmail.h b/fetchmail.h index 35dfa223..4b32a889 100644 --- a/fetchmail.h +++ b/fetchmail.h @@ -472,6 +472,8 @@ const char *norm_charmap(const char *name); /* error.c: Error reporting */ #if defined(HAVE_STDARG_H) void report_init(int foreground); + /** Flush partial message, suppress program name tag for next report printout. */ +void report_flush(FILE *fp); void report (FILE *fp, const char *format, ...) __attribute__ ((format (printf, 2, 3))) ; @@ -1,4 +1,4 @@ -/* report.c -- report function for noninteractive utilities +/** \file report.c report function for noninteractive utilities * * For license terms, see the file COPYING in this directory. * @@ -43,6 +43,8 @@ static unsigned int partial_message_size = 0; static unsigned int partial_message_size_used = 0; static char *partial_message; +static int partial_suppress_tag = 0; + static unsigned unbuffered; static unsigned int use_syslog; @@ -123,13 +125,14 @@ report (FILE *errfp, message, va_alist) else /* i. e. not using syslog */ #endif { - fflush (errfp); if ( *message == '\n' ) { fputc( '\n', errfp ); ++message; } - fprintf (errfp, "%s: ", program_name); + if (!partial_suppress_tag) + fprintf (errfp, "%s: ", program_name); + partial_suppress_tag = 0; #ifdef VA_START VA_START (args, message); @@ -266,6 +269,16 @@ report_build (FILE *errfp, message, va_alist) } } +void report_flush(FILE *errfp) +{ + if (partial_message_size_used != 0) + { + partial_message_size_used = 0; + report(errfp, partial_message); + partial_suppress_tag = 1; + } +} + /* Complete a report message by appending MESSAGE, which is a printf-style format string with optional args, to the existing report message (which may be empty.) The completed report message is then printed (and reset to |