mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-03 22:56:33 +02:00
* assuan-connect.c: Move all except assuan_get_pid to...
* assuan-pipe-connect.c: this. (assuan_pipe_disconnect): Removed. (do_finish, do_deinit): New (assuan_pipe_connect): and set them into the context. * assuan-socket-connect.c: New. * assuan-util.c (_assuan_log_sanitized_string): New. * assuan-pipe-server.c (assuan_init_pipe_server): Factored most code out to ... (_assuan_new_context): new func. (_assuan_release_context): New * assuan-connect.c (assuan_pipe_connect): Use the new functions.
This commit is contained in:
parent
c3885e0995
commit
416c0b7ea2
9 changed files with 547 additions and 223 deletions
|
@ -45,8 +45,10 @@ finish_connection (ASSUAN_CONTEXT ctx)
|
|||
}
|
||||
|
||||
|
||||
/* Create a new context. Note that the handlers are set up for a pipe
|
||||
server/client - this wau we don't need extra dummy functions */
|
||||
int
|
||||
assuan_init_pipe_server (ASSUAN_CONTEXT *r_ctx, int filedes[2])
|
||||
_assuan_new_context (ASSUAN_CONTEXT *r_ctx)
|
||||
{
|
||||
ASSUAN_CONTEXT ctx;
|
||||
int rc;
|
||||
|
@ -55,15 +57,14 @@ assuan_init_pipe_server (ASSUAN_CONTEXT *r_ctx, int filedes[2])
|
|||
ctx = xtrycalloc (1, sizeof *ctx);
|
||||
if (!ctx)
|
||||
return ASSUAN_Out_Of_Core;
|
||||
ctx->is_server = 1;
|
||||
ctx->input_fd = -1;
|
||||
ctx->output_fd = -1;
|
||||
|
||||
ctx->inbound.fd = filedes[0];
|
||||
ctx->outbound.fd = filedes[1];
|
||||
ctx->inbound.fd = -1;
|
||||
ctx->outbound.fd = -1;
|
||||
|
||||
ctx->pipe_mode = 1;
|
||||
ctx->listen_fd = -1;
|
||||
/* use the pipe server handler as a default */
|
||||
ctx->deinit_handler = deinit_pipe_server;
|
||||
ctx->accept_handler = accept_connection;
|
||||
ctx->finish_handler = finish_connection;
|
||||
|
@ -77,6 +78,37 @@ assuan_init_pipe_server (ASSUAN_CONTEXT *r_ctx, int filedes[2])
|
|||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
assuan_init_pipe_server (ASSUAN_CONTEXT *r_ctx, int filedes[2])
|
||||
{
|
||||
int rc;
|
||||
|
||||
rc = _assuan_new_context (r_ctx);
|
||||
if (!rc)
|
||||
{
|
||||
ASSUAN_CONTEXT ctx = *r_ctx;
|
||||
|
||||
ctx->is_server = 1;
|
||||
ctx->inbound.fd = filedes[0];
|
||||
ctx->outbound.fd = filedes[1];
|
||||
ctx->pipe_mode = 1;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
_assuan_release_context (ASSUAN_CONTEXT ctx)
|
||||
{
|
||||
if (ctx)
|
||||
{
|
||||
xfree (ctx->hello_line);
|
||||
xfree (ctx->okay_line);
|
||||
xfree (ctx);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
assuan_deinit_server (ASSUAN_CONTEXT ctx)
|
||||
{
|
||||
|
@ -86,16 +118,6 @@ assuan_deinit_server (ASSUAN_CONTEXT ctx)
|
|||
when not needed but still allow for a generic deinit function */
|
||||
ctx->deinit_handler (ctx);
|
||||
ctx->deinit_handler = NULL;
|
||||
xfree (ctx->hello_line);
|
||||
xfree (ctx->okay_line);
|
||||
xfree (ctx);
|
||||
_assuan_release_context (ctx);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue