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:
Marcus Brinkmann 2010-05-07 01:06:14 +00:00
parent 9121a17238
commit 97df297ae2
6 changed files with 69 additions and 20 deletions

View File

@ -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> 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: * w32-glib-io.c, w32-io.c, w32-qt-io.cpp, w32-sema.c, w32-util.c:

View File

@ -41,11 +41,21 @@ my_usleep (assuan_context_t ctx, unsigned int usec)
__assuan_usleep (ctx, usec); __assuan_usleep (ctx, usec);
} }
/* Create a pipe with an inheritable end. */ /* Create a pipe with an inheritable end. */
static int static int
my_pipe (assuan_context_t ctx, assuan_fd_t fds[2], int inherit_idx) 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 static int
my_close (assuan_context_t ctx, assuan_fd_t fd) my_close (assuan_context_t ctx, assuan_fd_t fd)
{ {
return _gpgme_io_close (fd); return _gpgme_io_close ((int) fd);
} }
static ssize_t static ssize_t
my_read (assuan_context_t ctx, assuan_fd_t fd, void *buffer, size_t size) 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 static ssize_t
my_write (assuan_context_t ctx, assuan_fd_t fd, const void *buffer, size_t size) 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); gpg_err_set_errno (ENOSYS);
return -1; return -1;
#else #else
return _gpgme_io_recvmsg (fd, msg, flags); return _gpgme_io_recvmsg ((int) fd, msg, flags);
#endif #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); gpg_err_set_errno (ENOSYS);
return -1; return -1;
#else #else
return _gpgme_io_sendmsg (fd, msg, flags); return _gpgme_io_sendmsg ((int) fd, msg, flags);
#endif #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) 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; fd_items[i].dup_to = -1;
i++; i++;
} }
} }
if (fd_in != ASSUAN_INVALID_FD) 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; fd_items[i].dup_to = 0;
i++; i++;
} }
if (fd_out != ASSUAN_INVALID_FD) 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; fd_items[i].dup_to = 1;
i++; 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) 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++; i++;
} }
} }

View File

@ -630,16 +630,21 @@ static gpgme_error_t
start (engine_llass_t llass, const char *command) start (engine_llass_t llass, const char *command)
{ {
gpgme_error_t err; gpgme_error_t err;
assuan_fd_t afdlist[5];
int fdlist[5]; int fdlist[5];
int nfds; int nfds;
int i;
/* We need to know the fd used by assuan for reads. We do this by /* We need to know the fd used by assuan for reads. We do this by
using the assumption that the first returned fd from using the assumption that the first returned fd from
assuan_get_active_fds() is always this one. */ assuan_get_active_fds() is always this one. */
nfds = assuan_get_active_fds (llass->assuan_ctx, 0 /* read fds */, nfds = assuan_get_active_fds (llass->assuan_ctx, 0 /* read fds */,
fdlist, DIM (fdlist)); afdlist, DIM (afdlist));
if (nfds < 1) if (nfds < 1)
return gpg_error (GPG_ERR_GENERAL); /* FIXME */ 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 /* We "duplicate" the file descriptor, so we can close it here (we
can't close fdlist[0], as that is closed by libassuan, and can't close fdlist[0], as that is closed by libassuan, and

View File

@ -632,16 +632,21 @@ static gpgme_error_t
start (engine_g13_t g13, const char *command) start (engine_g13_t g13, const char *command)
{ {
gpgme_error_t err; gpgme_error_t err;
assuan_fd_t afdlist[5];
int fdlist[5]; int fdlist[5];
int nfds; int nfds;
int i;
/* We need to know the fd used by assuan for reads. We do this by /* We need to know the fd used by assuan for reads. We do this by
using the assumption that the first returned fd from using the assumption that the first returned fd from
assuan_get_active_fds() is always this one. */ assuan_get_active_fds() is always this one. */
nfds = assuan_get_active_fds (g13->assuan_ctx, 0 /* read fds */, nfds = assuan_get_active_fds (g13->assuan_ctx, 0 /* read fds */,
fdlist, DIM (fdlist)); afdlist, DIM (afdlist));
if (nfds < 1) if (nfds < 1)
return gpg_error (GPG_ERR_GENERAL); /* FIXME */ 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 /* We "duplicate" the file descriptor, so we can close it here (we
can't close fdlist[0], as that is closed by libassuan, and can't close fdlist[0], as that is closed by libassuan, and

View File

@ -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 (), (gpgsm->assuan_ctx, file_name ? file_name : _gpgme_get_gpgsm_path (),
argv, NULL, NULL, NULL, ASSUAN_PIPE_CONNECT_FDPASSING); argv, NULL, NULL, NULL, ASSUAN_PIPE_CONNECT_FDPASSING);
#else #else
{
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 err = assuan_pipe_connect
(gpgsm->assuan_ctx, file_name ? file_name : _gpgme_get_gpgsm_path (), (gpgsm->assuan_ctx, file_name ? file_name : _gpgme_get_gpgsm_path (),
argv, child_fds, NULL, NULL, 0); argv, achild_fds, NULL, NULL, 0);
}
/* On Windows, handles are inserted in the spawned process with /* On Windows, handles are inserted in the spawned process with
DuplicateHandle, and child_fds contains the server-local names 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) start (engine_gpgsm_t gpgsm, const char *command)
{ {
gpgme_error_t err; gpgme_error_t err;
assuan_fd_t afdlist[5];
int fdlist[5]; int fdlist[5];
int nfds; int nfds;
int i;
/* We need to know the fd used by assuan for reads. We do this by /* We need to know the fd used by assuan for reads. We do this by
using the assumption that the first returned fd from using the assumption that the first returned fd from
assuan_get_active_fds() is always this one. */ assuan_get_active_fds() is always this one. */
nfds = assuan_get_active_fds (gpgsm->assuan_ctx, 0 /* read fds */, nfds = assuan_get_active_fds (gpgsm->assuan_ctx, 0 /* read fds */,
fdlist, DIM (fdlist)); afdlist, DIM (afdlist));
if (nfds < 1) if (nfds < 1)
return gpg_error (GPG_ERR_GENERAL); /* FIXME */ 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 /* We "duplicate" the file descriptor, so we can close it here (we
can't close fdlist[0], as that is closed by libassuan, and can't close fdlist[0], as that is closed by libassuan, and

View File

@ -1879,7 +1879,8 @@ server_data_obj (assuan_fd_t fd, gpgme_data_encoding_t encoding,
{ {
gpgme_error_t err; 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) if (err)
return err; return err;
return gpgme_data_set_encoding (*data, encoding); return gpgme_data_set_encoding (*data, encoding);
@ -1894,11 +1895,15 @@ server_reset_fds (struct server *server)
here. */ here. */
assuan_close_input_fd (server->assuan_ctx); assuan_close_input_fd (server->assuan_ctx);
assuan_close_output_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. */ /* FIXME: Assuan should provide a close function. */
#if HAVE_W32_SYSTEM
CloseHandle (server->message_fd);
#else
close (server->message_fd); close (server->message_fd);
server->message_fd = -1; #endif
server->message_fd = ASSUAN_INVALID_FD;
} }
server->input_enc = GPGME_DATA_ENCODING_NONE; server->input_enc = GPGME_DATA_ENCODING_NONE;
server->output_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"); static const char hello[] = ("GPGME-Tool " VERSION " ready");
memset (&server, 0, sizeof (server)); memset (&server, 0, sizeof (server));
server.message_fd = -1; server.message_fd = ASSUAN_INVALID_FD;
server.input_enc = GPGME_DATA_ENCODING_NONE; server.input_enc = GPGME_DATA_ENCODING_NONE;
server.output_enc = GPGME_DATA_ENCODING_NONE; server.output_enc = GPGME_DATA_ENCODING_NONE;
server.message_enc = GPGME_DATA_ENCODING_NONE; server.message_enc = GPGME_DATA_ENCODING_NONE;