diff options
author | Werner Koch <wk@gnupg.org> | 2020-09-01 20:43:57 +0200 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2020-09-01 20:43:57 +0200 |
commit | 2cd8bae23d7382588cf096df3eed83e02331a2bf (patch) | |
tree | 33d1132e0e52cd80ddfd9d9b624676cc25a8f491 /common/status.c | |
parent | sm: Fix a bug in the rfc2253 parser (diff) | |
download | gnupg2-2cd8bae23d7382588cf096df3eed83e02331a2bf.tar.xz gnupg2-2cd8bae23d7382588cf096df3eed83e02331a2bf.zip |
Use only one copy of the warn_server_mismatch function.
* common/asshelp.c (warn_server_version_mismatch): New. Actually a
slightly modified version of warn_version_mismatch found in other
modules.
* common/status.c (gnupg_status_strings): New.
* g10/cpr.c (write_status_strings2): New.
* g10/call-agent.c (warn_version_mismatch): Use the new unified
warn_server_version_mismatch function.
* g10/call-dirmngr.c (warn_version_mismatch): Ditto.
* g10/call-keyboxd.c (warn_version_mismatch): Ditto.
* sm/call-agent.c (warn_version_mismatch): Ditto.
* sm/call-dirmngr.c (warn_version_mismatch): Ditto.
* tools/card-call-scd.c (warn_version_mismatch): Ditto.
Signed-off-by: Werner Koch <wk@gnupg.org>
Diffstat (limited to 'common/status.c')
-rw-r--r-- | common/status.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/common/status.c b/common/status.c index 269ffea5d..b752c12c6 100644 --- a/common/status.c +++ b/common/status.c @@ -105,6 +105,47 @@ gnupg_status_printf (int no, const char *format, ...) } +/* Write a status line with code NO followed by the remaining + * arguments which must be a list of strings terminated by a NULL. + * Embedded CR and LFs in the strings are C-style escaped. All + * strings are printed with a space as delimiter. */ +gpg_error_t +gnupg_status_strings (ctrl_t dummy, int no, ...) +{ + va_list arg_ptr; + const char *s; + + (void)dummy; + + if (!statusfp) + return 0; /* Not enabled. */ + + va_start (arg_ptr, no); + + es_fputs ("[GNUPG:] ", statusfp); + es_fputs (get_status_string (no), statusfp); + while ((s = va_arg (arg_ptr, const char*))) + { + if (*s) + es_putc (' ', statusfp); + for (; *s; s++) + { + if (*s == '\n') + es_fputs ("\\n", statusfp); + else if (*s == '\r') + es_fputs ("\\r", statusfp); + else + es_fputc (*(const byte *)s, statusfp); + } + } + es_putc ('\n', statusfp); + es_fflush (statusfp); + + va_end (arg_ptr); + return 0; +} + + const char * get_inv_recpsgnr_code (gpg_error_t err) { |