diff options
Diffstat (limited to 'g10/status.c')
-rw-r--r-- | g10/status.c | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/g10/status.c b/g10/status.c index 5bbdb19b8..9ada277da 100644 --- a/g10/status.c +++ b/g10/status.c @@ -212,28 +212,43 @@ write_status_text ( int no, const char *text) /* - * Write a status line with a buffer using %XX escapes. - * If WRAP is > 0 wrap the line after this length. + * Write a status line with a buffer using %XX escapes. If WRAP is > + * 0 wrap the line after this length. If STRING is not NULL it will + * be prepended to the buffer, no escaping is done for string. + * A wrap of -1 forces spaces not to be encoded as %20. */ void -write_status_buffer ( int no, const char *buffer, size_t len, int wrap ) +write_status_text_and_buffer ( int no, const char *string, + const char *buffer, size_t len, int wrap ) { const char *s, *text; - int esc; + int esc, first; + int lower_limit = ' '; size_t n, count, dowrap; if( !statusfp ) return; /* not enabled */ + + if (wrap == -1) { + lower_limit--; + wrap = 0; + } text = get_status_string (no); - count = dowrap = 1; + count = dowrap = first = 1; do { if (dowrap) { fprintf (statusfp, "[GNUPG:] %s ", text ); count = dowrap = 0; + if (first && string) { + fputs (string, statusfp); + count += strlen (string); + } + first = 0; } for (esc=0, s=buffer, n=len; n && !esc; s++, n-- ) { - if ( *s == '%' || *(const byte*)s <= ' ' ) + if ( *s == '%' || *(const byte*)s <= lower_limit + || *(const byte*)s == 127 ) esc = 1; if ( wrap && ++count > wrap ) { dowrap=1; @@ -259,6 +274,13 @@ write_status_buffer ( int no, const char *buffer, size_t len, int wrap ) fflush (statusfp); } +void +write_status_buffer ( int no, const char *buffer, size_t len, int wrap ) +{ + write_status_text_and_buffer (no, NULL, buffer, len, wrap); +} + + #ifdef USE_SHM_COPROCESSING |