From bcce4af00413691f516383bb0a8b8a5ce91a0ea3 Mon Sep 17 00:00:00 2001 From: Neal Walfield Date: Sat, 23 Nov 2002 19:55:23 +0000 Subject: 2002-11-23 Neal H. Walfield * Makefile.am (libassuan_a_SOURCES): Add assuan-io.c. * assuan-io.c: Restore. (_assuan_simple_read): Rename from _assuan_read. (_assuan_simple_write): Rename from _assuan_write. * assuan-defs.h (_assuan_simple_read): New prototype. (_assuan_simple_write): Likewise. * assuan-pipe-server.c (pipe_reader): Remove. (pipe_writer): Remove. (_assuan_new_context): Initialize IO is with _assuan_simple_read and _assuan_simple_write. * assuan-socket-connect.c (socket_reader): Remove. (socket_writer): Remove. (assuan_socket_connect): Initialize IO is with _assuan_simple_read and _assuan_simple_write. * assuan-socket-server.c (io): New local variable. (assuan_init_socket_server): Initialize CTX->io. (assuan_init_connected_socket_server): Likewise. --- src/assuan-io.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/assuan-io.c (limited to 'src/assuan-io.c') diff --git a/src/assuan-io.c b/src/assuan-io.c new file mode 100644 index 0000000..924a4ec --- /dev/null +++ b/src/assuan-io.c @@ -0,0 +1,41 @@ +/* assuan-buffer.c - Wraps the read and write functions. + * Copyright (C) 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#include "assuan-defs.h" +#include +#include + +extern ssize_t pth_read (int fd, void *buffer, size_t size); +extern ssize_t pth_write (int fd, const void *buffer, size_t size); + +#pragma weak pth_read +#pragma weak pth_write + +ssize_t +_assuan_simple_read (ASSUAN_CONTEXT ctx, void *buffer, size_t size) +{ + return (pth_read ? pth_read : read) (ctx->inbound.fd, buffer, size); +} + +ssize_t +_assuan_simple_write (ASSUAN_CONTEXT ctx, const void *buffer, size_t size) +{ + return (pth_write ? pth_write : write) (ctx->outbound.fd, buffer, size); +} -- cgit v1.2.3