}
-
+/* Wrapper around assuan_command_parse_fd to also handle a
+ "file=FILENAME" argument. On success either a filename is returned
+ at FILENAME or a file descriptor at RFD; the other one is set to
+ NULL respective ASSUAN_INVALID_FD. */
static gpg_error_t
server_parse_fd (assuan_context_t ctx, char *line, assuan_fd_t *rfd,
char **filename)
/* assuan closes the input and output FDs for us when doing a RESET,
but we use this same function after commands, so repeat it
here. */
- assuan_close_input_fd (server->assuan_ctx);
- assuan_close_output_fd (server->assuan_ctx);
+ if (server->input_fd != ASSUAN_INVALID_FD)
+ {
+#if HAVE_W32_SYSTEM
+ CloseHandle (server->input_fd);
+#else
+ close (server->input_fd);
+#endif
+ server->input_fd = ASSUAN_INVALID_FD;
+ }
+ if (server->output_fd != ASSUAN_INVALID_FD)
+ {
+#if HAVE_W32_SYSTEM
+ CloseHandle (server->output_fd);
+#else
+ close (server->output_fd);
+#endif
+ server->output_fd = ASSUAN_INVALID_FD;
+ }
if (server->message_fd != ASSUAN_INVALID_FD)
{
/* FIXME: Assuan should provide a close function. */
gpgme_data_t inp_data;
gpgme_data_t out_data;
- inp_fd = assuan_get_input_fd (ctx);
+ inp_fd = server->input_fd;
inp_fn = server->input_filename;
if (inp_fd == ASSUAN_INVALID_FD && !inp_fn)
return GPG_ERR_ASS_NO_INPUT;
- out_fd = assuan_get_output_fd (ctx);
+ out_fd = server->output_fd;
out_fn = server->output_filename;
if (out_fd == ASSUAN_INVALID_FD && !out_fn)
return GPG_ERR_ASS_NO_OUTPUT;
if (strstr (line, "--expect-sign"))
flags |= GPGME_ENCRYPT_EXPECT_SIGN;
- inp_fd = assuan_get_input_fd (ctx);
+ inp_fd = server->input_fd;
inp_fn = server->input_filename;
- out_fd = assuan_get_output_fd (ctx);
+ out_fd = server->output_fd;
out_fn = server->output_filename;
if (inp_fd != ASSUAN_INVALID_FD || inp_fn)
{
if (strstr (line, "--detach"))
mode = GPGME_SIG_MODE_DETACH;
- inp_fd = assuan_get_input_fd (ctx);
+ inp_fd = server->input_fd;
inp_fn = server->input_filename;
if (inp_fd == ASSUAN_INVALID_FD && !inp_fn)
return GPG_ERR_ASS_NO_INPUT;
- out_fd = assuan_get_output_fd (ctx);
+ out_fd = server->output_fd;
out_fn = server->output_filename;
if (out_fd == ASSUAN_INVALID_FD && !out_fn)
return GPG_ERR_ASS_NO_OUTPUT;
gpgme_data_t msg_data = NULL;
gpgme_data_t out_data = NULL;
- inp_fd = assuan_get_input_fd (ctx);
+ inp_fd = server->input_fd;
inp_fn = server->input_filename;
if (inp_fd == ASSUAN_INVALID_FD && !inp_fn)
return GPG_ERR_ASS_NO_INPUT;
msg_fd = server->message_fd;
msg_fn = server->message_filename;
- out_fd = assuan_get_output_fd (ctx);
+ out_fd = server->output_fd;
out_fn = server->output_filename;
err = server_data_obj (inp_fd, inp_fn, 0, server->input_enc, &inp_data,
char *inp_fn;
gpgme_data_t inp_data;
- inp_fd = assuan_get_input_fd (ctx);
+ inp_fd = server->input_fd;
inp_fn = server->input_filename;
if (inp_fd == ASSUAN_INVALID_FD && !inp_fn)
return GPG_ERR_ASS_NO_INPUT;
gpgme_export_mode_t mode = 0;
const char *pattern[2];
- out_fd = assuan_get_output_fd (ctx);
+ out_fd = server->output_fd;
out_fn = server->output_filename;
if (out_fd == ASSUAN_INVALID_FD && !out_fn)
return GPG_ERR_ASS_NO_OUTPUT;
gpgme_data_t parms_data = NULL;
const char *parms;
- inp_fd = assuan_get_input_fd (ctx);
+ inp_fd = server->input_fd;
inp_fn = server->input_filename;
if (inp_fd == ASSUAN_INVALID_FD && !inp_fn)
return GPG_ERR_ASS_NO_INPUT;
- out_fd = assuan_get_output_fd (ctx);
+ out_fd = server->output_fd;
out_fn = server->output_filename;
err = server_data_obj (inp_fd, inp_fn, 0, server->input_enc, &inp_data,
gpgme_data_t out_data;
unsigned int flags = 0;
- out_fd = assuan_get_output_fd (ctx);
+ out_fd = server->output_fd;
out_fn = server->output_filename;
if (out_fd == ASSUAN_INVALID_FD && !out_fn)
return GPG_ERR_ASS_NO_OUTPUT;