summaryrefslogtreecommitdiffstats
path: root/common/asshelp2.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2012-02-06 20:52:27 +0100
committerWerner Koch <wk@gnupg.org>2012-02-06 20:57:21 +0100
commit1a0df8506050448f16c63666850e3ae6d94a971b (patch)
tree3145413b6757e38a6236bd25e20a10b2cc6f33b3 /common/asshelp2.c
parentcommon: Add a global variable to for the default error source. (diff)
downloadgnupg2-1a0df8506050448f16c63666850e3ae6d94a971b.tar.xz
gnupg2-1a0df8506050448f16c63666850e3ae6d94a971b.zip
common: Add function print_assuan_status.
* common/asshelp2.c: New. (print_assuan_status): New function. * common/Makefile.am (common_sources): Add asshelp2.c.
Diffstat (limited to '')
-rw-r--r--common/asshelp2.c49
1 files changed, 49 insertions, 0 deletions
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;
+}