diff options
author | Marcus Brinkmann <[email protected]> | 2009-10-20 15:39:15 +0000 |
---|---|---|
committer | Marcus Brinkmann <[email protected]> | 2009-10-20 15:39:15 +0000 |
commit | e782b1ab06a2d3325bc487c28ab678c95d9675b3 (patch) | |
tree | 87aacb82e59e4d7d8b60d2c55d66b12eed01af2e /assuan/assuan-pipe-server.c | |
parent | Add new debug helper (diff) | |
download | gpgme-e782b1ab06a2d3325bc487c28ab678c95d9675b3.tar.gz gpgme-e782b1ab06a2d3325bc487c28ab678c95d9675b3.zip |
2009-10-20 Marcus Brinkmann <[email protected]>
* configure.ac: Replace internal libassuan by external libassuan.
* m4/libassuan.m4: New file.
* Makefile.am (assuan): Remove variable.
(SUBDIRS): Remove ${assuan}.
* assuan/: Removed.
src/
2009-10-20 Marcus Brinkmann <[email protected]>
* Makefile.am (assuan_cppflags, assuan_libobjs): Removed.
(gpgsm_components): Move engine-assuan.c to ...
(assuan_components): ... this new variable.
(main_sources): Add this new variable.
(AM_CPPFLAGS): Remove $(assuan_cppflags).
(AM_CFLAGS): Add @LIBASSUAN_CFLAGS@.
(libgpgme_la_DEPENDENCIES, libgpgme_pth_la_DEPENDENCIES)
(libgpgme_glib_la_DEPENDENCIES, libgpgme_qt_la_DEPENDENCIES)
(libgpgme_pthread_la_DEPENDENCIES): Remove $(assuan_libobjs).
(libgpgme_la_LIBADD, libgpgme_pth_la_LIBADD)
(libgpgme_glib_la_LIBADD, libgpgme_qt_la_LIBADD))
(libgpgme_pthread_la_LIBADD): Replace $(assuan_libobjs) by
@LIBASSUAN_LIBS@.
* priv-io.h [!HAVE_W32_SYSTEM]: Declare _gpgme_io_recvmsg,
_gpgme_io_sendmsg, _gpgme_io_waitpid.
* engine-backend.h: Define with [ENABLE_ASSUAN] instead
of [ENABLE_GPGSM].
* posix-io.c (_gpgme_io_waitpid): Make non-static.
* util.h (ENABLE_ASSUAN): Declar _gpgme_assuan_system_hooks,
_gpgme_assuan_malloc_hooks, _gpgme_assuan_log_cb.
* engine-gpgsm.c: Don't map assuan error codes. Use
assuan_release instead of assuan_disconnect.
(map_assuan_error): Remove function.
(gpgsm_new): Use new assuan context interface.
* engine-assuan.c: Use assuan_release instead of
assuan_disconnect.
(llass_new): Use new assuan context interface.
Diffstat (limited to 'assuan/assuan-pipe-server.c')
-rw-r--r-- | assuan/assuan-pipe-server.c | 189 |
1 files changed, 0 insertions, 189 deletions
diff --git a/assuan/assuan-pipe-server.c b/assuan/assuan-pipe-server.c deleted file mode 100644 index 70404144..00000000 --- a/assuan/assuan-pipe-server.c +++ /dev/null @@ -1,189 +0,0 @@ -/* assuan-pipe-server.c - Assuan server working over a pipe - * Copyright (C) 2001, 2002 Free Software Foundation, Inc. - * - * This file is part of Assuan. - * - * Assuan is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * Assuan is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, see <http://www.gnu.org/licenses/>. - */ - -#include <config.h> -#include <stdlib.h> -#include <stdio.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <unistd.h> -#ifdef HAVE_W32_SYSTEM -#include <windows.h> -#include <fcntl.h> -#endif - -#include "assuan-defs.h" - - -static void -deinit_pipe_server (assuan_context_t ctx) -{ - /* nothing to do for this simple server */ -} - -static int -accept_connection (assuan_context_t ctx) -{ - /* This is a NOP for a pipe server */ - return 0; -} - -static int -finish_connection (assuan_context_t 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 way we don't need extra dummy functions */ -int -_assuan_new_context (assuan_context_t *r_ctx) -{ - static struct assuan_io io = { _assuan_simple_read, - _assuan_simple_write, - 0, 0 }; - - assuan_context_t ctx; - int rc; - - *r_ctx = NULL; - ctx = xtrycalloc (1, sizeof *ctx); - if (!ctx) - return _assuan_error (ASSUAN_Out_Of_Core); - ctx->input_fd = ASSUAN_INVALID_FD; - ctx->output_fd = ASSUAN_INVALID_FD; - - ctx->inbound.fd = ASSUAN_INVALID_FD; - ctx->outbound.fd = ASSUAN_INVALID_FD; - ctx->io = &io; - - ctx->listen_fd = ASSUAN_INVALID_FD; - /* 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) - xfree (ctx); - else - *r_ctx = ctx; - return rc; -} - - -/* Returns true if atoi(S) denotes a valid socket. */ -#ifndef HAVE_W32_SYSTEM -static int -is_valid_socket (const char *s) -{ - struct stat buf; - - if ( fstat (atoi (s), &buf ) ) - return 0; - return S_ISSOCK (buf.st_mode); -} -#endif /*!HAVE_W32_SYSTEM*/ - - -int -assuan_init_pipe_server (assuan_context_t *r_ctx, int filedes[2]) -{ - int rc; - - rc = _assuan_new_context (r_ctx); - if (!rc) - { - assuan_context_t ctx = *r_ctx; - const char *s; - unsigned long ul; - - ctx->is_server = 1; -#ifdef HAVE_W32_SYSTEM - /* MS Windows has so many different types of handle that one - needs to tranlsate them at many place forth and back. Also - make sure that the file descriptors are in binary mode. */ - setmode (filedes[0], O_BINARY); - setmode (filedes[1], O_BINARY); - ctx->inbound.fd = (void*)_get_osfhandle (filedes[0]); - ctx->outbound.fd = (void*)_get_osfhandle (filedes[1]); -#else - s = getenv ("_assuan_connection_fd"); - if (s && *s && is_valid_socket (s) ) - { - /* Well, we are called with an bi-directional file - descriptor. Prepare for using sendmsg/recvmsg. In this - case we ignore the passed file descriptors. */ - ctx->inbound.fd = ctx->outbound.fd = atoi (s); - _assuan_init_uds_io (ctx); - ctx->deinit_handler = _assuan_uds_deinit; - } - else if (filedes && filedes[0] != ASSUAN_INVALID_FD - && filedes[1] != ASSUAN_INVALID_FD ) - { - /* Standard pipe server. */ - ctx->inbound.fd = filedes[0]; - ctx->outbound.fd = filedes[1]; - } - else - { - _assuan_release_context (*r_ctx); - *r_ctx = NULL; - return ASSUAN_Problem_Starting_Server; - } -#endif - ctx->pipe_mode = 1; - - s = getenv ("_assuan_pipe_connect_pid"); - if (s && (ul=strtoul (s, NULL, 10)) && ul) - ctx->pid = (pid_t)ul; - else - ctx->pid = (pid_t)-1; - - } - return rc; -} - - -void -_assuan_release_context (assuan_context_t ctx) -{ - if (ctx) - { - _assuan_inquire_release (ctx); - xfree (ctx->hello_line); - xfree (ctx->okay_line); - xfree (ctx->cmdtbl); - xfree (ctx); - } -} - -void -assuan_deinit_server (assuan_context_t 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); - } -} |