aboutsummaryrefslogtreecommitdiffstats
path: root/assuan/assuan-pipe-server.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2002-01-21 12:03:14 +0000
committerWerner Koch <[email protected]>2002-01-21 12:03:14 +0000
commit416c0b7ea21b1c8703301a18f85fb7a25f6790ab (patch)
tree4801f2c82745dd80066a6f70968c791d87f49157 /assuan/assuan-pipe-server.c
parent* server.c (option_handler): New. (diff)
downloadgnupg-416c0b7ea21b1c8703301a18f85fb7a25f6790ab.tar.gz
gnupg-416c0b7ea21b1c8703301a18f85fb7a25f6790ab.zip
* 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.
Diffstat (limited to '')
-rw-r--r--assuan/assuan-pipe-server.c54
1 files changed, 38 insertions, 16 deletions
diff --git a/assuan/assuan-pipe-server.c b/assuan/assuan-pipe-server.c
index c283a925f..d15f54f5a 100644
--- a/assuan/assuan-pipe-server.c
+++ b/assuan/assuan-pipe-server.c
@@ -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);
}
}
-
-
-
-
-
-
-
-