1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-23 10:29:58 +01:00

scd: New function send_keyinfo to assist in backporting.

* scd/command.c (send_keyinfo): New.
This commit is contained in:
Werner Koch 2021-04-29 12:18:48 +02:00
parent 3db99b8861
commit 0eed0ced9b
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
2 changed files with 30 additions and 0 deletions

View File

@ -1846,6 +1846,34 @@ scd_command_handler (ctrl_t ctrl, int fd)
} }
/* Send a keyinfo string. If DATA is true the string is emitted as a
* data line, else as a status line. */
void
send_keyinfo (ctrl_t ctrl, int data, const char *keygrip_str,
const char *serialno, const char *idstr)
{
char *string;
assuan_context_t ctx = ctrl->server_local->assuan_ctx;
string = xtryasprintf ("%s T %s %s%s", keygrip_str,
serialno? serialno : "-",
idstr? idstr : "-",
data? "\n" : "");
if (!string)
return;
if (!data)
assuan_write_status (ctx, "KEYINFO", string);
else
assuan_send_data (ctx, string, strlen (string));
xfree (string);
return;
}
/* Send a line with status information via assuan and escape all given /* Send a line with status information via assuan and escape all given
buffers. The variable elements are pairs of (char *, size_t), buffers. The variable elements are pairs of (char *, size_t),
terminated with a (NULL, 0). */ terminated with a (NULL, 0). */

View File

@ -122,6 +122,8 @@ const char *scd_get_socket_name (void);
/*-- command.c --*/ /*-- command.c --*/
gpg_error_t initialize_module_command (void); gpg_error_t initialize_module_command (void);
int scd_command_handler (ctrl_t, int); int scd_command_handler (ctrl_t, int);
void send_keyinfo (ctrl_t ctrl, int data, const char *keygrip_str,
const char *serialno, const char *idstr);
void send_status_info (ctrl_t ctrl, const char *keyword, ...) void send_status_info (ctrl_t ctrl, const char *keyword, ...)
GPGRT_ATTR_SENTINEL(1); GPGRT_ATTR_SENTINEL(1);
gpg_error_t send_status_direct (ctrl_t ctrl, const char *keyword, gpg_error_t send_status_direct (ctrl_t ctrl, const char *keyword,