summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--common/Makefile.am2
-rw-r--r--common/asshelp.h11
-rw-r--r--common/asshelp2.c49
3 files changed, 61 insertions, 1 deletions
diff --git a/common/Makefile.am b/common/Makefile.am
index 2ff4ade48..b9cba1113 100644
--- a/common/Makefile.am
+++ b/common/Makefile.am
@@ -79,7 +79,7 @@ common_sources = \
membuf.c membuf.h \
iobuf.c iobuf.h \
ttyio.c ttyio.h \
- asshelp.c asshelp.h \
+ asshelp.c asshelp2.c asshelp.h \
exechelp.h \
signal.c \
audit.c audit.h \
diff --git a/common/asshelp.h b/common/asshelp.h
index 728c03949..68be28961 100644
--- a/common/asshelp.h
+++ b/common/asshelp.h
@@ -25,6 +25,8 @@
#include "session-env.h"
+/*-- asshelp.c --*/
+
void setup_libassuan_logging (unsigned int *debug_var_address);
void set_libassuan_log_cats (unsigned int newcats);
@@ -62,5 +64,14 @@ start_new_dirmngr (assuan_context_t *r_ctx,
ctrl_t status_cb_arg);
+/*-- asshelp2.c --*/
+
+/* Helper function to print an assuan status line using a printf
+ format string. */
+gpg_error_t print_assuan_status (assuan_context_t ctx,
+ const char *keyword,
+ const char *format,
+ ...) JNLIB_GCC_A_PRINTF(3,4);
+
#endif /*GNUPG_COMMON_ASSHELP_H*/
diff --git a/common/asshelp2.c b/common/asshelp2.c
new file mode 100644
index 000000000..762a14df6
--- /dev/null
+++ b/common/asshelp2.c
@@ -0,0 +1,49 @@
+/* asshelp2.c - More helper functions for Assuan
+ * Copyright (C) 2012 Free Software Foundation, Inc.
+ *
+ * This file is part of GnuPG.
+ *
+ * GnuPG is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GnuPG is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <assuan.h>
+
+#include "util.h"
+#include "asshelp.h"
+
+/* Helper function to print an assuan status line using a printf
+ format string. */
+gpg_error_t
+print_assuan_status (assuan_context_t ctx,
+ const char *keyword,
+ const char *format, ...)
+{
+ va_list arg_ptr;
+ int rc;
+ char *buf;
+
+ va_start (arg_ptr, format);
+ rc = estream_vasprintf (&buf, format, arg_ptr);
+ va_end (arg_ptr);
+ if (rc < 0)
+ return gpg_err_make (default_errsource, gpg_err_code_from_syserror ());
+ rc = assuan_write_status (ctx, keyword, buf);
+ xfree (buf);
+ return rc;
+}