#include <stdlib.h>
#include <string.h>
-#include <sys/types.h>
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
#include <assert.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+#ifdef HAVE_LOCALE_H
#include <locale.h>
+#endif
#include <fcntl.h> /* FIXME */
#include <errno.h>
struct gpgme_io_cbs io_cbs;
- /* Internal callbacks. */
- engine_assuan_result_cb_t result_cb;
- void *result_cb_value;
-
/* User provided callbacks. */
struct {
gpgme_assuan_data_cb_t data_cb;
gpgme_error_t err = 0;
engine_g13_t g13;
int argc;
- char *argv[5];
+ const char *argv[5];
char *dft_display = NULL;
char dft_ttyname[64];
char *dft_ttytype = NULL;
/* FIXME: If value is NULL, we need to reset the option to default.
But we can't do this. So we error out here. G13 needs support
for this. */
- if (category == LC_CTYPE)
+ if (0)
+ ;
+#ifdef LC_CTYPE
+ else if (category == LC_CTYPE)
{
catstr = "lc-ctype";
if (!value && g13->lc_ctype_set)
if (value)
g13->lc_ctype_set = 1;
}
+#endif
#ifdef LC_MESSAGES
else if (category == LC_MESSAGES)
{
}
+#if USE_DESCRIPTOR_PASSING
static gpgme_error_t
g13_assuan_simple_command (assuan_context_t ctx, char *cmd,
- engine_status_handler_t status_fnc,
- void *status_fnc_value)
+ engine_status_handler_t status_fnc,
+ void *status_fnc_value)
{
gpg_error_t err;
char *line;
return err;
}
+#endif
static gpgme_error_t
"fd 0x%x: ERR line: %s",
fd, err ? gpg_strerror (err) : "ok");
- /* In g13, command execution errors are not fatal, as we use
+ /* Command execution errors are not fatal, as we use
a session based protocol. */
- if (g13->result_cb)
- err = g13->result_cb (g13->result_cb_value, err);
- else
- err = 0;
- if (!err)
- {
- _gpgme_io_close (g13->status_cb.fd);
- return 0;
- }
+ data->op_err = err;
+
+ /* The caller will do the rest (namely, call cancel_op,
+ which closes status_fd). */
+ return 0;
}
else if (linelen >= 2
&& line[0] == 'O' && line[1] == 'K'
{
TRACE1 (DEBUG_CTX, "gpgme:status_handler", g13,
"fd 0x%x: OK line", fd);
- if (g13->result_cb)
- err = g13->result_cb (g13->result_cb_value, 0);
- else
- err = 0;
- if (!err)
- {
- _gpgme_io_close (g13->status_cb.fd);
- return 0;
- }
+
+ _gpgme_io_close (g13->status_cb.fd);
+ return 0;
}
else if (linelen > 2
&& line[0] == 'D' && line[1] == ' ')
start (engine_g13_t g13, const char *command)
{
gpgme_error_t err;
+ assuan_fd_t afdlist[5];
int fdlist[5];
int nfds;
+ int i;
/* We need to know the fd used by assuan for reads. We do this by
using the assumption that the first returned fd from
assuan_get_active_fds() is always this one. */
nfds = assuan_get_active_fds (g13->assuan_ctx, 0 /* read fds */,
- fdlist, DIM (fdlist));
+ afdlist, DIM (afdlist));
if (nfds < 1)
return gpg_error (GPG_ERR_GENERAL); /* FIXME */
+ /* For now... */
+ for (i = 0; i < nfds; i++)
+ fdlist[i] = (int) afdlist[i];
/* We "duplicate" the file descriptor, so we can close it here (we
can't close fdlist[0], as that is closed by libassuan, and
static gpgme_error_t
g13_transact (void *engine,
const char *command,
- engine_assuan_result_cb_t result_cb,
- void *result_cb_value,
gpgme_assuan_data_cb_t data_cb,
void *data_cb_value,
gpgme_assuan_inquire_cb_t inq_cb,
if (!g13 || !command || !*command)
return gpg_error (GPG_ERR_INV_VALUE);
- g13->result_cb = result_cb;
- g13->result_cb_value = result_cb_value;
g13->user.data_cb = data_cb;
g13->user.data_cb_value = data_cb_value;
g13->user.inq_cb = inq_cb;
NULL, /* set_command_handler */
NULL, /* set_colon_line_handler */
g13_set_locale,
+ NULL, /* set_protocol */
NULL, /* decrypt */
+ NULL, /* decrypt_verify */
NULL, /* delete */
NULL, /* edit */
NULL, /* encrypt */