mirror of
git://git.gnupg.org/gnupg.git
synced 2025-02-01 16:33:02 +01:00
agent: New function agent_print_status.
* common/asshelp2.c (vprint_assuan_status): New. (print_assuan_status): Re-implement using above func. * agent/command.c (agent_print_status): New.
This commit is contained in:
parent
508ffb4e02
commit
e78585cd0f
@ -288,6 +288,9 @@ int map_pk_openpgp_to_gcry (int openpgp_algo);
|
||||
gpg_error_t agent_inq_pinentry_launched (ctrl_t ctrl, unsigned long pid);
|
||||
gpg_error_t agent_write_status (ctrl_t ctrl, const char *keyword, ...)
|
||||
GNUPG_GCC_A_SENTINEL(0);
|
||||
gpg_error_t agent_print_status (ctrl_t ctrl, const char *keyword,
|
||||
const char *format, ...)
|
||||
JNLIB_GCC_A_PRINTF(3,4);
|
||||
void bump_key_eventcounter (void);
|
||||
void bump_card_eventcounter (void);
|
||||
void start_command_handler (ctrl_t, gnupg_fd_t, gnupg_fd_t);
|
||||
|
@ -413,6 +413,22 @@ agent_write_status (ctrl_t ctrl, const char *keyword, ...)
|
||||
}
|
||||
|
||||
|
||||
/* This function is similar to print_assuan_status but takes a CTRL
|
||||
arg instead of an assuan context as first argument. */
|
||||
gpg_error_t
|
||||
agent_print_status (ctrl_t ctrl, const char *keyword, const char *format, ...)
|
||||
{
|
||||
gpg_error_t err;
|
||||
va_list arg_ptr;
|
||||
assuan_context_t ctx = ctrl->server_local->assuan_ctx;
|
||||
|
||||
va_start (arg_ptr, format);
|
||||
err = vprint_assuan_status (ctx, keyword, format, arg_ptr);
|
||||
va_end (arg_ptr);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
/* Helper to notify the client about a launched Pinentry. Because
|
||||
that might disturb some older clients, this is only done if enabled
|
||||
via an option. Returns an gpg error code. */
|
||||
|
@ -72,6 +72,10 @@ gpg_error_t print_assuan_status (assuan_context_t ctx,
|
||||
const char *keyword,
|
||||
const char *format,
|
||||
...) JNLIB_GCC_A_PRINTF(3,4);
|
||||
gpg_error_t vprint_assuan_status (assuan_context_t ctx,
|
||||
const char *keyword,
|
||||
const char *format,
|
||||
va_list arg_ptr) JNLIB_GCC_A_PRINTF(3,0);
|
||||
|
||||
|
||||
#endif /*GNUPG_COMMON_ASSHELP_H*/
|
||||
|
@ -30,20 +30,34 @@
|
||||
/* 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, ...)
|
||||
vprint_assuan_status (assuan_context_t ctx,
|
||||
const char *keyword,
|
||||
const char *format, va_list arg_ptr)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
/* 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;
|
||||
gpg_error_t err;
|
||||
|
||||
va_start (arg_ptr, format);
|
||||
err = vprint_assuan_status (ctx, keyword, format, arg_ptr);
|
||||
va_end (arg_ptr);
|
||||
return err;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user