From 1a0df8506050448f16c63666850e3ae6d94a971b Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Mon, 6 Feb 2012 20:52:27 +0100 Subject: common: Add function print_assuan_status. * common/asshelp2.c: New. (print_assuan_status): New function. * common/Makefile.am (common_sources): Add asshelp2.c. --- common/asshelp2.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 common/asshelp2.c (limited to 'common/asshelp2.c') 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 . + */ + +#include +#include +#include +#include +#include +#include + +#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; +} -- cgit v1.2.3