2010-05-07 Marcus Brinkmann <marcus@g10code.de>
* engine-gpgsm.c (gpgsm_new, start): Cast between int and assuan_fd_t. * assuan-support.c (my_pipe, my_close, my_read, my_write): Likewise. * gpgme-tool.c (server_data_obj, server_reset_fds, gpgme_server), (my_recvmsg, my_sendmsg, my_spawn): Likewise. * engine-assuan.c (start): Likewise. * engine-g13.c (start): Likewise.
This commit is contained in:
parent
9121a17238
commit
97df297ae2
@ -1,3 +1,13 @@
|
||||
2010-05-07 Marcus Brinkmann <marcus@g10code.de>
|
||||
|
||||
* engine-gpgsm.c (gpgsm_new, start): Cast between int and
|
||||
assuan_fd_t.
|
||||
* assuan-support.c (my_pipe, my_close, my_read, my_write): Likewise.
|
||||
* gpgme-tool.c (server_data_obj, server_reset_fds, gpgme_server),
|
||||
(my_recvmsg, my_sendmsg, my_spawn): Likewise.
|
||||
* engine-assuan.c (start): Likewise.
|
||||
* engine-g13.c (start): Likewise.
|
||||
|
||||
2010-05-06 Marcus Brinkmann <marcus@g10code.de>
|
||||
|
||||
* w32-glib-io.c, w32-io.c, w32-qt-io.cpp, w32-sema.c, w32-util.c:
|
||||
|
@ -41,11 +41,21 @@ my_usleep (assuan_context_t ctx, unsigned int usec)
|
||||
__assuan_usleep (ctx, usec);
|
||||
}
|
||||
|
||||
|
||||
/* Create a pipe with an inheritable end. */
|
||||
static int
|
||||
my_pipe (assuan_context_t ctx, assuan_fd_t fds[2], int inherit_idx)
|
||||
{
|
||||
return _gpgme_io_pipe (fds, inherit_idx);
|
||||
int res;
|
||||
int gfds[2];
|
||||
|
||||
res = _gpgme_io_pipe (gfds, inherit_idx);
|
||||
|
||||
/* For now... */
|
||||
fds[0] = (assuan_fd_t) gfds[0];
|
||||
fds[1] = (assuan_fd_t) gfds[1];
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
@ -54,21 +64,21 @@ my_pipe (assuan_context_t ctx, assuan_fd_t fds[2], int inherit_idx)
|
||||
static int
|
||||
my_close (assuan_context_t ctx, assuan_fd_t fd)
|
||||
{
|
||||
return _gpgme_io_close (fd);
|
||||
return _gpgme_io_close ((int) fd);
|
||||
}
|
||||
|
||||
|
||||
static ssize_t
|
||||
my_read (assuan_context_t ctx, assuan_fd_t fd, void *buffer, size_t size)
|
||||
{
|
||||
return _gpgme_io_read (fd, buffer, size);
|
||||
return _gpgme_io_read ((int) fd, buffer, size);
|
||||
}
|
||||
|
||||
|
||||
static ssize_t
|
||||
my_write (assuan_context_t ctx, assuan_fd_t fd, const void *buffer, size_t size)
|
||||
{
|
||||
return _gpgme_io_write (fd, buffer, size);
|
||||
return _gpgme_io_write ((int) fd, buffer, size);
|
||||
}
|
||||
|
||||
|
||||
@ -80,7 +90,7 @@ my_recvmsg (assuan_context_t ctx, assuan_fd_t fd, assuan_msghdr_t msg,
|
||||
gpg_err_set_errno (ENOSYS);
|
||||
return -1;
|
||||
#else
|
||||
return _gpgme_io_recvmsg (fd, msg, flags);
|
||||
return _gpgme_io_recvmsg ((int) fd, msg, flags);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -94,7 +104,7 @@ my_sendmsg (assuan_context_t ctx, assuan_fd_t fd, const assuan_msghdr_t msg,
|
||||
gpg_err_set_errno (ENOSYS);
|
||||
return -1;
|
||||
#else
|
||||
return _gpgme_io_sendmsg (fd, msg, flags);
|
||||
return _gpgme_io_sendmsg ((int) fd, msg, flags);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -138,20 +148,20 @@ my_spawn (assuan_context_t ctx, pid_t *r_pid, const char *name,
|
||||
{
|
||||
while (fd_child_list[i] != ASSUAN_INVALID_FD)
|
||||
{
|
||||
fd_items[i].fd = fd_child_list[i];
|
||||
fd_items[i].fd = (int) fd_child_list[i];
|
||||
fd_items[i].dup_to = -1;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
if (fd_in != ASSUAN_INVALID_FD)
|
||||
{
|
||||
fd_items[i].fd = fd_in;
|
||||
fd_items[i].fd = (int) fd_in;
|
||||
fd_items[i].dup_to = 0;
|
||||
i++;
|
||||
}
|
||||
if (fd_out != ASSUAN_INVALID_FD)
|
||||
{
|
||||
fd_items[i].fd = fd_out;
|
||||
fd_items[i].fd = (int) fd_out;
|
||||
fd_items[i].dup_to = 1;
|
||||
i++;
|
||||
}
|
||||
@ -168,7 +178,7 @@ my_spawn (assuan_context_t ctx, pid_t *r_pid, const char *name,
|
||||
{
|
||||
while (fd_child_list[i] != ASSUAN_INVALID_FD)
|
||||
{
|
||||
fd_child_list[i] = fd_items[i].peer_name;
|
||||
fd_child_list[i] = (assuan_fd_t) fd_items[i].peer_name;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
@ -630,16 +630,21 @@ static gpgme_error_t
|
||||
start (engine_llass_t llass, 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 (llass->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
|
||||
|
@ -632,16 +632,21 @@ static gpgme_error_t
|
||||
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
|
||||
|
@ -338,9 +338,18 @@ gpgsm_new (void **engine, const char *file_name, const char *home_dir)
|
||||
(gpgsm->assuan_ctx, file_name ? file_name : _gpgme_get_gpgsm_path (),
|
||||
argv, NULL, NULL, NULL, ASSUAN_PIPE_CONNECT_FDPASSING);
|
||||
#else
|
||||
err = assuan_pipe_connect
|
||||
(gpgsm->assuan_ctx, file_name ? file_name : _gpgme_get_gpgsm_path (),
|
||||
argv, child_fds, NULL, NULL, 0);
|
||||
{
|
||||
assuan_fd_t achild_fds[4];
|
||||
int i;
|
||||
|
||||
/* For now... */
|
||||
for (i = 0; i < 4; i++)
|
||||
achild_fds[i] = (assuan_fd_t) child_fds[i];
|
||||
|
||||
err = assuan_pipe_connect
|
||||
(gpgsm->assuan_ctx, file_name ? file_name : _gpgme_get_gpgsm_path (),
|
||||
argv, achild_fds, NULL, NULL, 0);
|
||||
}
|
||||
|
||||
/* On Windows, handles are inserted in the spawned process with
|
||||
DuplicateHandle, and child_fds contains the server-local names
|
||||
@ -997,16 +1006,21 @@ static gpgme_error_t
|
||||
start (engine_gpgsm_t gpgsm, 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 (gpgsm->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
|
||||
|
@ -1879,7 +1879,8 @@ server_data_obj (assuan_fd_t fd, gpgme_data_encoding_t encoding,
|
||||
{
|
||||
gpgme_error_t err;
|
||||
|
||||
err = gpgme_data_new_from_fd (data, fd);
|
||||
/* For now... */
|
||||
err = gpgme_data_new_from_fd (data, (int) fd);
|
||||
if (err)
|
||||
return err;
|
||||
return gpgme_data_set_encoding (*data, encoding);
|
||||
@ -1894,11 +1895,15 @@ server_reset_fds (struct server *server)
|
||||
here. */
|
||||
assuan_close_input_fd (server->assuan_ctx);
|
||||
assuan_close_output_fd (server->assuan_ctx);
|
||||
if (server->message_fd != -1)
|
||||
if (server->message_fd != ASSUAN_INVALID_FD)
|
||||
{
|
||||
/* FIXME: Assuan should provide a close function. */
|
||||
#if HAVE_W32_SYSTEM
|
||||
CloseHandle (server->message_fd);
|
||||
#else
|
||||
close (server->message_fd);
|
||||
server->message_fd = -1;
|
||||
#endif
|
||||
server->message_fd = ASSUAN_INVALID_FD;
|
||||
}
|
||||
server->input_enc = GPGME_DATA_ENCODING_NONE;
|
||||
server->output_enc = GPGME_DATA_ENCODING_NONE;
|
||||
@ -2777,7 +2782,7 @@ gpgme_server (gpgme_tool_t gt)
|
||||
static const char hello[] = ("GPGME-Tool " VERSION " ready");
|
||||
|
||||
memset (&server, 0, sizeof (server));
|
||||
server.message_fd = -1;
|
||||
server.message_fd = ASSUAN_INVALID_FD;
|
||||
server.input_enc = GPGME_DATA_ENCODING_NONE;
|
||||
server.output_enc = GPGME_DATA_ENCODING_NONE;
|
||||
server.message_enc = GPGME_DATA_ENCODING_NONE;
|
||||
|
Loading…
Reference in New Issue
Block a user