summaryrefslogtreecommitdiffstats
path: root/g10/cpr.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2020-09-01 20:43:57 +0200
committerWerner Koch <wk@gnupg.org>2020-09-01 20:43:57 +0200
commit2cd8bae23d7382588cf096df3eed83e02331a2bf (patch)
tree33d1132e0e52cd80ddfd9d9b624676cc25a8f491 /g10/cpr.c
parentsm: Fix a bug in the rfc2253 parser (diff)
downloadgnupg2-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 'g10/cpr.c')
-rw-r--r--g10/cpr.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/g10/cpr.c b/g10/cpr.c
index d502e8b52..5a39913c5 100644
--- a/g10/cpr.c
+++ b/g10/cpr.c
@@ -181,6 +181,50 @@ write_status_strings (int no, const char *text, ...)
}
+/* 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
+write_status_strings2 (ctrl_t dummy, int no, ...)
+{
+ va_list arg_ptr;
+ const char *s;
+
+ (void)dummy;
+
+ if (!statusfp || !status_currently_allowed (no) )
+ return 0; /* Not enabled or allowed. */
+
+ 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);
+
+ va_end (arg_ptr);
+
+ if (es_fflush (statusfp) && opt.exit_on_status_write_error)
+ g10_exit (0);
+
+ return 0;
+}
+
+
void
write_status_text (int no, const char *text)
{