diff options
author | Marcus Brinkmann <[email protected]> | 2002-01-22 16:29:12 +0000 |
---|---|---|
committer | Marcus Brinkmann <[email protected]> | 2002-01-22 16:29:12 +0000 |
commit | b863cea7d70e32d0b0bcd84f87f5350818722242 (patch) | |
tree | 92bb4b2448f5b2eb5651a730b47e3a71f8f438ce /assuan/assuan-pipe-server.c | |
parent | Remove obsolete item. (diff) | |
download | gpgme-b863cea7d70e32d0b0bcd84f87f5350818722242.tar.gz gpgme-b863cea7d70e32d0b0bcd84f87f5350818722242.zip |
Update to current version in newpg module.
Diffstat (limited to 'assuan/assuan-pipe-server.c')
-rw-r--r-- | assuan/assuan-pipe-server.c | 80 |
1 files changed, 65 insertions, 15 deletions
diff --git a/assuan/assuan-pipe-server.c b/assuan/assuan-pipe-server.c index 2a9b829a..d15f54f5 100644 --- a/assuan/assuan-pipe-server.c +++ b/assuan/assuan-pipe-server.c @@ -24,9 +24,31 @@ #include "assuan-defs.h" +static void +deinit_pipe_server (ASSUAN_CONTEXT ctx) +{ + /* nothing to do for this simple server */ +} + +static int +accept_connection (ASSUAN_CONTEXT ctx) +{ + /* This is a NOP for a pipe server */ + return 0; +} +static int +finish_connection (ASSUAN_CONTEXT ctx) +{ + /* This is a NOP for a pipe server */ + return 0; +} + + +/* 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; @@ -35,14 +57,17 @@ 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; rc = _assuan_register_std_commands (ctx); if (rc) @@ -52,22 +77,47 @@ assuan_init_pipe_server (ASSUAN_CONTEXT *r_ctx, int filedes[2]) return rc; } + + +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_deinit_pipe_server (ASSUAN_CONTEXT ctx) +_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) +{ + if (ctx) + { + /* We use this function pointer to avoid linking other server + when not needed but still allow for a generic deinit function */ + ctx->deinit_handler (ctx); + ctx->deinit_handler = NULL; + _assuan_release_context (ctx); + } +} |