mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-21 14:47:03 +01:00
common: Add function print_assuan_status.
* common/asshelp2.c: New. (print_assuan_status): New function. * common/Makefile.am (common_sources): Add asshelp2.c.
This commit is contained in:
parent
eb0faef81d
commit
1a0df85060
@ -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 \
|
||||
|
@ -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*/
|
||||
|
49
common/asshelp2.c
Normal file
49
common/asshelp2.c
Normal file
@ -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;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user