[Pkg-gnupg-commit] [libassuan] 60/437: 2002-11-23 Neal H. Walfield <neal at cs.uml.edu>
Eric Dorland
eric at moszumanska.debian.org
Fri May 22 05:33:23 UTC 2015
This is an automated email from the git hooks/post-receive script.
eric pushed a commit to branch master
in repository libassuan.
commit bcce4af00413691f516383bb0a8b8a5ce91a0ea3
Author: Neal Walfield <neal at walfield.org>
Date: Sat Nov 23 19:55:23 2002 +0000
2002-11-23 Neal H. Walfield <neal at cs.uml.edu>
* 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/ChangeLog | 20 ++++++++++++++++++++
src/Makefile.am | 4 ++--
src/assuan-defs.h | 26 +++++++++++++++++++++++++-
src/assuan-io.c | 41 +++++++++++++++++++++++++++++++++++++++++
src/assuan-pipe-server.c | 24 ++----------------------
src/assuan-socket-connect.c | 9 +++++----
src/assuan-socket-server.c | 7 ++++++-
7 files changed, 101 insertions(+), 30 deletions(-)
diff --git a/src/ChangeLog b/src/ChangeLog
index 7931b2a..0057cd8 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,23 @@
+2002-11-23 Neal H. Walfield <neal at cs.uml.edu>
+
+ * 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.
+
2002-11-23 Neal H. Walfield <neal at g10code.de>
* assuan-buffer.c (readline): Use memrchr.
diff --git a/src/Makefile.am b/src/Makefile.am
index a97352d..a095d2f 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -42,8 +42,8 @@ libassuan_a_SOURCES = \
assuan-pipe-server.c \
assuan-socket-server.c \
assuan-pipe-connect.c \
- assuan-socket-connect.c
-
+ assuan-socket-connect.c \
+ assuan-io.c
assuan-errors.c : assuan.h
$(srcdir)/mkerrors < $(srcdir)/assuan.h > assuan-errors.c
diff --git a/src/assuan-defs.h b/src/assuan-defs.h
index a5cd64c..3a705ec 100644
--- a/src/assuan-defs.h
+++ b/src/assuan-defs.h
@@ -22,11 +22,15 @@
#define ASSUAN_DEFS_H
#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+
#include "assuan.h"
#define LINELENGTH ASSUAN_LINELENGTH
-struct cmdtbl_s {
+struct cmdtbl_s
+{
const char *name;
int cmd_id;
int (*handler)(ASSUAN_CONTEXT, char *line);
@@ -90,6 +94,20 @@ struct assuan_context_s
pid_t client_pid; /* for a socket server the PID of the client or -1
if not available */
+ /* Used for Unix domain sockets. */
+ struct sockaddr_un myaddr;
+ struct sockaddr_un serveraddr;
+ /* When reading from datagram sockets, we must read an entire
+ message at a time. This means that we have to do our own
+ buffering to be able to get the semantics of read. */
+ void *domainbuffer;
+ /* Offset of start of buffer. */
+ int domainbufferoffset;
+ /* Bytes buffered. */
+ int domainbuffersize;
+ /* Memory allocated. */
+ int domainbufferallocated;
+
void (*deinit_handler)(ASSUAN_CONTEXT);
int (*accept_handler)(ASSUAN_CONTEXT);
int (*finish_handler)(ASSUAN_CONTEXT);
@@ -147,5 +165,11 @@ void _assuan_free (void *p);
void _assuan_log_print_buffer (FILE *fp, const void *buffer, size_t length);
void _assuan_log_sanitized_string (const char *string);
+/*-- assuan-io.c --*/
+ssize_t _assuan_simple_read (ASSUAN_CONTEXT ctx, void *buffer, size_t size);
+ssize_t _assuan_simple_write (ASSUAN_CONTEXT ctx, const void *buffer,
+ size_t size);
+
+
#endif /*ASSUAN_DEFS_H*/
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 <sys/types.h>
+#include <unistd.h>
+
+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);
+}
diff --git a/src/assuan-pipe-server.c b/src/assuan-pipe-server.c
index 73d9de2..a0bb3bd 100644
--- a/src/assuan-pipe-server.c
+++ b/src/assuan-pipe-server.c
@@ -45,33 +45,13 @@ finish_connection (ASSUAN_CONTEXT ctx)
return 0;
}
-/* Read from the pipe server. */
-static ssize_t
-pipe_reader (ASSUAN_CONTEXT ctx, void *buf, size_t buflen)
-{
-#pragma weak pth_read
- extern ssize_t pth_read (int, void *, size_t);
-
- return (pth_read ? pth_read : read) (ctx->inbound.fd, buf, buflen);
-}
-
-/* Write to the pipe server. */
-static ssize_t
-pipe_writer (ASSUAN_CONTEXT ctx, const void *buf, size_t buflen)
-{
-#pragma weak pth_write
-
- extern ssize_t pth_write (int, const void *, size_t);
-
- return (pth_write ? pth_write : write) (ctx->outbound.fd, buf, buflen);
-}
-
/* 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 *r_ctx)
{
- static struct assuan_io io = { pipe_reader, pipe_writer };
+ static struct assuan_io io = { _assuan_simple_read,
+ _assuan_simple_write };
ASSUAN_CONTEXT ctx;
int rc;
diff --git a/src/assuan-socket-connect.c b/src/assuan-socket-connect.c
index f6c5cae..a1bec84 100644
--- a/src/assuan-socket-connect.c
+++ b/src/assuan-socket-connect.c
@@ -91,7 +91,8 @@ AssuanError
assuan_socket_connect (ASSUAN_CONTEXT *r_ctx,
const char *name, pid_t server_pid)
{
- static struct assuan_io io = { socket_reader, socket_writer };
+ static struct assuan_io io = { _assuan_simple_read,
+ _assuan_simple_write };
AssuanError err;
ASSUAN_CONTEXT ctx;
@@ -127,9 +128,9 @@ assuan_socket_connect (ASSUAN_CONTEXT *r_ctx,
memset (&srvr_addr, 0, sizeof srvr_addr );
srvr_addr.sun_family = AF_LOCAL;
- strcpy (srvr_addr.sun_path, name);
- len = (offsetof (struct sockaddr_un, sun_path)
- + strlen (srvr_addr.sun_path) + 1);
+ len = strlen (srvr_addr.sun_path) + 1;
+ memcpy (srvr_addr.sun_path, name, len);
+ len += (offsetof (struct sockaddr_un, sun_path));
if (connect (fd, (struct sockaddr*)&srvr_addr, len) == -1)
{
diff --git a/src/assuan-socket-server.c b/src/assuan-socket-server.c
index c0a9a25..8d23a6b 100644
--- a/src/assuan-socket-server.c
+++ b/src/assuan-socket-server.c
@@ -98,7 +98,8 @@ deinit_socket_server (ASSUAN_CONTEXT ctx)
finish_connection (ctx);
}
-
+static struct assuan_io io = { _assuan_simple_read,
+ _assuan_simple_write };
/* Initialize a server for the socket LISTEN_FD which has already be
put into listen mode */
@@ -125,6 +126,8 @@ assuan_init_socket_server (ASSUAN_CONTEXT *r_ctx, int listen_fd)
ctx->accept_handler = accept_connection;
ctx->finish_handler = finish_connection;
+ ctx->io = &io;
+
rc = _assuan_register_std_commands (ctx);
if (rc)
xfree (ctx);
@@ -152,6 +155,8 @@ assuan_init_connected_socket_server (ASSUAN_CONTEXT *r_ctx, int fd)
ctx->inbound.fd = -1;
ctx->outbound.fd = -1;
+ ctx->io = &io;
+
ctx->listen_fd = -1;
ctx->connected_fd = fd;
ctx->deinit_handler = deinit_socket_server;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/libassuan.git
More information about the Pkg-gnupg-commit
mailing list