[Pkg-gnupg-commit] [libassuan] 53/437: 2002-09-05 Neal H. Walfield <neal at g10code.de>

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 94ed73759229876b70718836b2ce88475fc14d4a
Author: Neal Walfield <neal at walfield.org>
Date:   Tue Oct 29 00:12:31 2002 +0000

    2002-09-05  Neal H. Walfield  <neal at g10code.de>
    
    	* assuan-defs.h (_assuan_read_wrapper): Depreciated.
    	* assuan-util.c (_assuan_read_wrapper): Removed.
    	* assuan-defs.h (_assuan_write_wrapper): Depreciated.
    	* assuan-util.c (_assuan_write_wrapper): Removed.
    	* assuan.h (assuan_set_io_fun): Depreciated.
    	* assuan-util.c (assuan_set_io_fun): Removed.
    
    	* assuan-defs.h (_assuan_read): New function.
    	(_assuan_write): Likewise.
    	* assuan-io.c: New file.
    
    	* assuan-buffer.c (writen): Use _assuan_write rather than doing
    	the work here.
    	(readline): Likewise for _assuan_read.
    
    	* Makefile.am (libassuan_a_SOURCES): Add assuan-io.c.
    
    2002-09-05  Neal H. Walfield  <neal at cs.uml.edu>
    
    	* gpg-agent.c (main) [USE_GNU_PTH]: No need to call
    	assuan_set_io_func as assuan is smart.
---
 src/ChangeLog               | 19 ++++++++++++++
 src/Makefile.am             |  3 ++-
 src/assuan-buffer.c         | 27 +++++++-------------
 src/assuan-defs.h           |  9 ++++---
 src/assuan-io.c             | 60 +++++++++++++++++++++++++++++++++++++++++++++
 src/assuan-socket-connect.c |  2 +-
 src/assuan-util.c           | 18 --------------
 src/assuan.h                |  2 --
 8 files changed, 97 insertions(+), 43 deletions(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index 670f7ef..7fe3c40 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,22 @@
+2002-09-05  Neal H. Walfield  <neal at g10code.de>
+
+	* assuan-defs.h (_assuan_read_wrapper): Depreciated.
+	* assuan-util.c (_assuan_read_wrapper): Removed.
+	* assuan-defs.h (_assuan_write_wrapper): Depreciated.
+	* assuan-util.c (_assuan_write_wrapper): Removed.
+	* assuan.h (assuan_set_io_fun): Depreciated.
+	* assuan-util.c (assuan_set_io_fun): Removed.
+
+	* assuan-defs.h (_assuan_read): New function.
+	(_assuan_write): Likewise.
+	* assuan-io.c: New file.
+
+	* assuan-buffer.c (writen): Use _assuan_write rather than doing
+	the work here.
+	(readline): Likewise for _assuan_read.
+
+	* Makefile.am (libassuan_a_SOURCES): Add assuan-io.c.
+
 2002-08-16  Werner Koch  <wk at gnupg.org>
 
 	* assuan.h: Renamed Bad_Certificate_Path to Bad_Certificate_Chain.
diff --git a/src/Makefile.am b/src/Makefile.am
index 71560c9..2207145 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -42,7 +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
diff --git a/src/assuan-buffer.c b/src/assuan-buffer.c
index df50575..8017183 100644
--- a/src/assuan-buffer.c
+++ b/src/assuan-buffer.c
@@ -48,9 +48,7 @@ writen ( int fd, const char *buffer, size_t length )
 {
   while (length)
     {
-      int nwritten = _assuan_write_wrapper?
-        _assuan_write_wrapper (fd, buffer, length):
-        write (fd, buffer, length);
+      ssize_t nwritten = _assuan_write (fd, buffer, length);
       
       if (nwritten < 0)
         {
@@ -75,9 +73,7 @@ readline (int fd, char *buf, size_t buflen, int *r_nread, int *eof)
   *r_nread = 0;
   while (nleft > 0)
     {
-      int n = _assuan_read_wrapper?
-        _assuan_read_wrapper (fd, buf, nleft):
-        read (fd, buf, nleft);
+      ssize_t n = _assuan_read (fd, buf, nleft);
 
       if (n < 0)
         {
@@ -204,13 +200,12 @@ _assuan_read_line (ASSUAN_CONTEXT ctx)
 
 
 /* Read the next line from the client or server and return a pointer
-   to a buffer with holding that line.  linelen returns the length of
-   the line.  This buffer is valid until another read operation is
-   done on this buffer.  The caller is allowed to modify this buffer.
-   He should only use the buffer if the function returns without an
-   error.
+   in *LINE to a buffer holding the line.  LINELEN is the length of
+   *LINE.  The buffer is valid until the next read operation on it.
+   The caller may modify the buffer.  The buffer is invalid (i.e. must
+   not be used) if an error is returned.
 
-   Returns: 0 on success or an assuan error code
+   Returns 0 on success or an assuan error code.
    See also: assuan_pending_line().
 */
 AssuanError
@@ -228,8 +223,8 @@ assuan_read_line (ASSUAN_CONTEXT ctx, char **line, size_t *linelen)
 }
 
 
-/* Return true when a full line is pending for a read, without the need
-   for actual IO */
+/* Return true if a full line is buffered (i.e. an entire line may be
+   read without any I/O).  */
 int
 assuan_pending_line (ASSUAN_CONTEXT ctx)
 {
@@ -437,7 +432,3 @@ assuan_send_data (ASSUAN_CONTEXT ctx, const void *buffer, size_t length)
 
   return 0;
 }
-
-
-
-
diff --git a/src/assuan-defs.h b/src/assuan-defs.h
index 3e408b1..f885869 100644
--- a/src/assuan-defs.h
+++ b/src/assuan-defs.h
@@ -121,9 +121,6 @@ AssuanError _assuan_read_from_server (ASSUAN_CONTEXT ctx, int *okay, int *off);
 
 
 /*-- assuan-util.c --*/
-extern ssize_t (*_assuan_read_wrapper)(int,void*,size_t);
-extern ssize_t (*_assuan_write_wrapper)(int,const void*,size_t);
-
 void *_assuan_malloc (size_t n);
 void *_assuan_calloc (size_t n, size_t m);
 void *_assuan_realloc (void *p, size_t n);
@@ -139,6 +136,12 @@ 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 --*/
+
+/* Wraps the standard read and write functions to do the Right
+   Thing depending on our linkage.  */
+ssize_t _assuan_read (int fd, void *buffer, size_t size);
+ssize_t _assuan_write (int fd, 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..135cb02
--- /dev/null
+++ b/src/assuan-io.c
@@ -0,0 +1,60 @@
+/* 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 <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_read (int fd, void *buffer, size_t size)
+{
+  static ssize_t (*reader) (int, void *, size_t);
+
+  if (! reader)
+    {
+      if (pth_read)
+	reader = pth_read;
+      else
+	reader = read;
+    }
+
+  return reader (fd, buffer, size);
+}
+
+ssize_t
+_assuan_write (int fd, const void *buffer, size_t size)
+{
+  static ssize_t (*writer) (int, const void *, size_t);
+
+  if (! writer)
+    {
+      if (pth_write)
+	writer = pth_write;
+      else
+	writer = write;
+    }
+
+  return writer (fd, buffer, size);
+}
diff --git a/src/assuan-socket-connect.c b/src/assuan-socket-connect.c
index 53f4a02..64a22bf 100644
--- a/src/assuan-socket-connect.c
+++ b/src/assuan-socket-connect.c
@@ -66,7 +66,7 @@ do_deinit (ASSUAN_CONTEXT ctx)
 
 /* Make a connection to the Unix domain socket NAME and return a new
    Assuan context in CTX.  SERVER_PID is currently not used but may
-   becode handy in future. */
+   become handy in the future. */
 AssuanError
 assuan_socket_connect (ASSUAN_CONTEXT *r_ctx,
                        const char *name, pid_t server_pid)
diff --git a/src/assuan-util.c b/src/assuan-util.c
index a335b09..24a9799 100644
--- a/src/assuan-util.c
+++ b/src/assuan-util.c
@@ -29,16 +29,10 @@
 #include "../jnlib/logging.h"
 #endif
 
-ssize_t (*_assuan_read_wrapper)(int,void*,size_t) = NULL;
-ssize_t (*_assuan_write_wrapper)(int,const void*,size_t) = NULL;
-
-
 static void *(*alloc_func)(size_t n) = malloc;
 static void *(*realloc_func)(void *p, size_t n) = realloc;
 static void (*free_func)(void*) = free;
 
-
-
 void
 assuan_set_malloc_hooks ( void *(*new_alloc_func)(size_t n),
                           void *(*new_realloc_func)(void *p, size_t n),
@@ -77,18 +71,6 @@ _assuan_free (void *p)
     free_func (p);
 }
 
-/* For use with Pth it is required to have special read and write
-   functions.  We can't assume an ELF based system so we have to
-   explicitly set them if we are going to use Pth. */
-void
-assuan_set_io_func (ssize_t (*r)(int,void*,size_t),
-                    ssize_t (*w)(int,const void*,size_t))
-{
-  _assuan_read_wrapper = r;
-  _assuan_write_wrapper = w;
-}
-
-
 

 /* Store the error in the context so that the error sending function
   can take out a descriptive text.  Inside the assuan code, use the
diff --git a/src/assuan.h b/src/assuan.h
index 51f648a..d8b874e 100644
--- a/src/assuan.h
+++ b/src/assuan.h
@@ -214,8 +214,6 @@ AssuanError assuan_send_data (ASSUAN_CONTEXT ctx,
 void assuan_set_malloc_hooks ( void *(*new_alloc_func)(size_t n),
                                void *(*new_realloc_func)(void *p, size_t n),
                                void (*new_free_func)(void*) );
-void assuan_set_io_func (ssize_t (*r)(int,void*,size_t),
-                         ssize_t (*w)(int,const void*,size_t));
 void assuan_set_log_stream (ASSUAN_CONTEXT ctx, FILE *fp);
 int assuan_set_error (ASSUAN_CONTEXT ctx, int err, const char *text);
 void assuan_set_pointer (ASSUAN_CONTEXT ctx, void *pointer);

-- 
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