[svn] gpgme - r1189 - trunk/assuan

svn author marcus cvs at cvs.gnupg.org
Wed Nov 29 17:25:47 CET 2006


Author: marcus
Date: 2006-11-29 17:25:46 +0100 (Wed, 29 Nov 2006)
New Revision: 1189

Removed:
   trunk/assuan/assuan-domain-connect.c
   trunk/assuan/assuan-domain-server.c
Modified:
   trunk/assuan/ChangeLog
   trunk/assuan/assuan-buffer.c
   trunk/assuan/assuan-client.c
   trunk/assuan/assuan-defs.h
   trunk/assuan/assuan-handler.c
   trunk/assuan/assuan-io.c
   trunk/assuan/assuan-pipe-server.c
   trunk/assuan/assuan-uds.c
   trunk/assuan/assuan-util.c
   trunk/assuan/assuan.h
   trunk/assuan/mkerrors
Log:
Update to rev 231 of libassuan.


Modified: trunk/assuan/ChangeLog
===================================================================
--- trunk/assuan/ChangeLog	2006-11-29 15:47:00 UTC (rev 1188)
+++ trunk/assuan/ChangeLog	2006-11-29 16:25:46 UTC (rev 1189)
@@ -1,3 +1,70 @@
+2006-11-22  Werner Koch  <wk at g10code.com>
+
+	* assuan-handler.c (fun1_cookie_write, fun2_cookie_write): New.
+	(assuan_get_data_fp) [HAVE_FUNOPEN]: Use it.
+
+2006-11-21  Werner Koch  <wk at g10code.com>
+
+	* Makefile.am (libassuan_pth_a_CFLAGS): New.
+
+	* assuan-pipe-server.c (_assuan_release_context): Free CMDTBL.
+
+2006-11-14  Werner Koch  <wk at g10code.com>
+
+	* libassuan.m4 (AM_CHECK_LIBASSUAN): New.
+
+	* assuan-handler.c (assuan_register_post_cmd_notify) 
+	(assuan_register_post_cmd_notify): New.
+	* assuan-util.c (assuan_set_io_monitor): New.
+	* assuan-buffer.c (_assuan_read_line): Use it.
+	(_assuan_write_line): Ditto.
+	(_assuan_cookie_write_data): Ditto.
+	(_assuan_cookie_write_flush): Ditto.
+
+2006-10-18  Werner Koch  <wk at g10code.com>
+
+	* libassuan.m4: Pass "pthread" to the common macro.  Reported by
+	Rex Dieter.
+
+2006-10-16  Werner Koch  <wk at g10code.com>
+
+	* mkerrors: Map ASSUAN_Not_Confirmed.
+
+2006-10-10  Werner Koch  <wk at g10code.com>
+
+	* libassuan.m4 (AM_PATH_LIBASSUAN_PTH)
+	(AM_PATH_LIBASSUAN_PTHREAD): Fixed.
+
+	* assuan-buffer.c (assuan_sendfd): Implement a runtime detection
+	of implemented descripotr passing.
+
+	* assuan-uds.c: Take care of USE_DESCRIPTOR_PASSING.
+
+	* assuan-defs.h: Add missing semicolon.
+
+2006-10-09  Werner Koch  <wk at g10code.com>
+
+	* assuan-handler.c (process_request): Use weak pragma for the sake
+	of old gcc's.  Reported by Alain Guibert.
+
+	* assuan-io.c: Removed Pth support.
+	* assuan-io-pth.c: New. Based on assuan-io.c
+
+2006-10-06  Werner Koch  <wk at g10code.com>
+
+	* libassuan-config.in: New options --api-version and --thread.
+
+2006-10-04  Werner Koch  <wk at g10code.com>
+
+	* assuan-client.c (assuan_transact): Need to map old assuan status
+	codes so that for example CANCELED is correctly mapped.
+
+2006-09-28  Marcus Brinkmann  <marcus at g10code.de>
+
+	* assuan-client.c (assuan_transact): Do not convert error on
+	status line, it is already a gpg-error.  Do convert
+	ASSUAN_Server_Fault.
+
 2006-09-19  Marcus Brinkmann  <marcus at g10code.de>
 
 	* assuan.h (assuan_init_socket_server_ext)

Modified: trunk/assuan/assuan-buffer.c
===================================================================
--- trunk/assuan/assuan-buffer.c	2006-11-29 15:47:00 UTC (rev 1188)
+++ trunk/assuan/assuan-buffer.c	2006-11-29 16:25:46 UTC (rev 1189)
@@ -1,5 +1,5 @@
 /* assuan-buffer.c - read and send data
- *	Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+ * Copyright (C) 2001, 2002, 2003, 2004, 2006 Free Software Foundation, Inc.
  *
  * This file is part of Assuan.
  *
@@ -159,7 +159,9 @@
 
   if (endp)
     {
+      unsigned monitor_result;
       int n = endp - line + 1;
+
       if (n < nread)
 	/* LINE contains more than one line.  We copy it to the attic
 	   now as handlers are allowed to modify the passed
@@ -176,7 +178,16 @@
       *endp = 0;
 
       ctx->inbound.linelen = endp - line;
-      if (ctx->log_fp)
+
+      monitor_result = (ctx->io_monitor
+                        ? ctx->io_monitor (ctx, 0,
+                                           ctx->inbound.line,
+                                           ctx->inbound.linelen)
+                        : 0);
+      if ( (monitor_result & 2) )
+        ctx->inbound.linelen = 0;
+      
+      if (ctx->log_fp && !(monitor_result & 1))
 	{
 	  fprintf (ctx->log_fp, "%s[%u.%d] DBG: <- ",
 		   assuan_get_assuan_log_prefix (),
@@ -245,6 +256,7 @@
 {
   assuan_error_t rc = 0;
   size_t prefixlen = prefix? strlen (prefix):0;
+  unsigned int monitor_result;
 
   /* Make sure that the line is short enough. */
   if (len + prefixlen + 2 > ASSUAN_LINELENGTH)
@@ -260,8 +272,12 @@
         len = ASSUAN_LINELENGTH - prefixlen - 2 - 1;
     }
 
+  monitor_result = (ctx->io_monitor
+                    ? ctx->io_monitor (ctx, 1, line, len)
+                    : 0);
+
   /* Fixme: we should do some kind of line buffering.  */
-  if (ctx->log_fp)
+  if (ctx->log_fp && !(monitor_result & 1))
     {
       fprintf (ctx->log_fp, "%s[%u.%d] DBG: -> ",
 	       assuan_get_assuan_log_prefix (),
@@ -277,13 +293,13 @@
       putc ('\n', ctx->log_fp);
     }
 
-  if (prefixlen)
+  if (prefixlen && !(monitor_result & 2))
     {
       rc = writen (ctx, prefix, prefixlen);
       if (rc)
         rc = _assuan_error (ASSUAN_Write_Error);
     }
-  if (!rc)
+  if (!rc && !(monitor_result & 2))
     {
       rc = writen (ctx, line, len);
       if (rc)
@@ -325,7 +341,7 @@
 
 
 /* Write out the data in buffer as datalines with line wrapping and
-   percent escaping.  This function is used for GNU's custom streams */
+   percent escaping.  This function is used for GNU's custom streams. */
 int
 _assuan_cookie_write_data (void *cookie, const char *buffer, size_t orig_size)
 {
@@ -342,7 +358,9 @@
   line += linelen;
   while (size)
     {
-      /* insert data line header */
+      unsigned int monitor_result;
+
+      /* Insert data line header. */
       if (!linelen)
         {
           *line++ = 'D';
@@ -350,7 +368,7 @@
           linelen += 2;
         }
       
-      /* copy data, keep some space for the CRLF and to escape one character */
+      /* Copy data, keep space for the CRLF and to escape one character. */
       while (size && linelen < LINELENGTH-2-2)
         {
           if (*buffer == '%' || *buffer == '\r' || *buffer == '\n')
@@ -368,9 +386,15 @@
           size--;
         }
       
+      
+      monitor_result = (ctx->io_monitor
+                        ? ctx->io_monitor (ctx, 1,
+                                           ctx->outbound.data.line, linelen)
+                        : 0);
+
       if (linelen >= LINELENGTH-2-2)
         {
-          if (ctx->log_fp)
+          if (ctx->log_fp && !(monitor_result & 1))
             {
 	      fprintf (ctx->log_fp, "%s[%u.%d] DBG: -> ",
 		       assuan_get_assuan_log_prefix (),
@@ -386,7 +410,8 @@
             }
           *line++ = '\n';
           linelen++;
-          if (writen (ctx, ctx->outbound.data.line, linelen))
+          if ( !(monitor_result & 2)
+               && writen (ctx, ctx->outbound.data.line, linelen))
             {
               ctx->outbound.data.error = _assuan_error (ASSUAN_Write_Error);
               return 0;
@@ -409,6 +434,7 @@
   assuan_context_t ctx = cookie;
   char *line;
   size_t linelen;
+  unsigned int monitor_result;
 
   if (ctx->outbound.data.error)
     return 0;
@@ -416,9 +442,15 @@
   line = ctx->outbound.data.line;
   linelen = ctx->outbound.data.linelen;
   line += linelen;
+
+  monitor_result = (ctx->io_monitor
+                    ? ctx->io_monitor (ctx, 1,
+                                       ctx->outbound.data.line, linelen)
+                    : 0);
+  
   if (linelen)
     {
-      if (ctx->log_fp)
+      if (ctx->log_fp && !(monitor_result & 1))
 	{
 	  fprintf (ctx->log_fp, "%s[%u.%d] DBG: -> ",
 		   assuan_get_assuan_log_prefix (),
@@ -432,7 +464,8 @@
 	}
       *line++ = '\n';
       linelen++;
-      if (writen (ctx, ctx->outbound.data.line, linelen))
+      if ( !(monitor_result & 2)
+           && writen (ctx, ctx->outbound.data.line, linelen))
         {
           ctx->outbound.data.error = _assuan_error (ASSUAN_Write_Error);
           return 0;
@@ -490,6 +523,15 @@
 assuan_error_t
 assuan_sendfd (assuan_context_t ctx, int fd)
 {
+  /* It is explicitly allowed to use (NULL, -1) as a runtime test to
+     check whether descriptor passing is available. */
+  if (!ctx && fd == -1)
+#ifdef USE_DESCRIPTOR_PASSING
+    return 0;
+#else
+    return _assuan_error (ASSUAN_Not_Implemented);
+#endif
+
   if (! ctx->io->sendfd)
     return set_error (ctx, Not_Implemented,
 		      "server does not support sending and receiving "

Modified: trunk/assuan/assuan-client.c
===================================================================
--- trunk/assuan/assuan-client.c	2006-11-29 15:47:00 UTC (rev 1188)
+++ trunk/assuan/assuan-client.c	2006-11-29 16:25:46 UTC (rev 1189)
@@ -161,9 +161,11 @@
 
   if (!okay)
     {
-      rc = _assuan_error (atoi (line));
-      if (rc < 100)
-        rc = ASSUAN_Server_Fault;
+      rc = atoi (line);
+      if (rc > 0 && rc < 100)
+        rc = _assuan_error (ASSUAN_Server_Fault);
+      else if (rc > 0 && rc <= 128)
+        rc = _assuan_error (rc);
     }
   else if (okay == 2)
     {

Modified: trunk/assuan/assuan-defs.h
===================================================================
--- trunk/assuan/assuan-defs.h	2006-11-29 15:47:00 UTC (rev 1188)
+++ trunk/assuan/assuan-defs.h	2006-11-29 16:25:46 UTC (rev 1189)
@@ -179,6 +179,20 @@
   void (*input_notify_fnc)(assuan_context_t, const char *);
   void (*output_notify_fnc)(assuan_context_t, const char *);
 
+  /* This function is called right after a command has been processed.
+     It may be used to command related cleanup.  */
+  void (*post_cmd_notify_fnc)(assuan_context_t, int);
+
+  /* If set, this is called right before logging an I/O line.  With
+     DIRECTION set to 1 it is called for an output oeration; 0 means
+     an input operation. If bit 0 is set in the return value, the
+     logging of the will be suppressed.  With bit 1 set, the entire
+     line will be ignored. */
+  unsigned int (*io_monitor)(assuan_context_t ctx,
+                             int direction,
+                             const char *line,
+                             size_t linelen);
+
   int input_fd;   /* set by INPUT command */
   int output_fd;  /* set by OUTPUT command */
 
@@ -299,7 +313,7 @@
 int setenv (const char *name, const char *value, int replace);
 #endif
 #ifndef HAVE_PUTC_UNLOCKED
-int putc_unlocked (int c, FILE *stream)
+int putc_unlocked (int c, FILE *stream);
 #endif
 
 #define DIM(v)		     (sizeof(v)/sizeof((v)[0]))

Deleted: trunk/assuan/assuan-domain-connect.c

Deleted: trunk/assuan/assuan-domain-server.c

Modified: trunk/assuan/assuan-handler.c
===================================================================
--- trunk/assuan/assuan-handler.c	2006-11-29 15:47:00 UTC (rev 1188)
+++ trunk/assuan/assuan-handler.c	2006-11-29 16:25:46 UTC (rev 1189)
@@ -292,6 +292,16 @@
 }
 
 int
+assuan_register_post_cmd_notify (assuan_context_t ctx,
+                                 void (*fnc)(assuan_context_t, int))
+{
+  if (!ctx)
+    return _assuan_error (ASSUAN_Invalid_Value);
+  ctx->post_cmd_notify_fnc = fnc;
+  return 0;
+}
+
+int
 assuan_register_bye_notify (assuan_context_t ctx,
                             void (*fnc)(assuan_context_t))
 {
@@ -506,14 +516,20 @@
              problem if they are not available.  We need to make sure
              that we are using ELF because only this guarantees that
              weak symbol support is available in case GNU ld is not
-             used. */
+             used.  It seems that old gcc versions don't implement the
+             weak attribute properly but it works with the weak
+             pragma. */
+
           unsigned int source, code;
 
           int gpg_strerror_r (unsigned int err, char *buf, size_t buflen)
             __attribute__ ((weak));
-
           const char *gpg_strsource (unsigned int err)
             __attribute__ ((weak));
+#if !defined(HAVE_W32_SYSTEM) && __GNUC__ < 3
+#pragma weak gpg_strerror_r
+#pragma weak gpg_strsource
+#endif
 
           source = ((rc >> 24) & 0xff);
           code = (rc & 0x00ffffff);
@@ -537,6 +553,9 @@
       rc = assuan_write_line (ctx, errline);
     }
 
+  if (ctx->post_cmd_notify_fnc)
+    ctx->post_cmd_notify_fnc (ctx, rc);
+
   ctx->confidential = 0;
   if (ctx->okay_line)
     {
@@ -633,6 +652,23 @@
   return n;
 }
 
+
+/* Two simple wrappers to make the expected function types match. */
+#ifdef HAVE_FUNOPEN
+static int
+fun1_cookie_write (void *cookie, const char *buffer, int orig_size)
+{
+  return _assuan_cookie_write_data (cookie, buffer, orig_size);
+}
+#endif /*HAVE_FUNOPEN*/
+#ifdef HAVE_FOPENCOOKIE
+static ssize_t
+fun2_cookie_write (void *cookie, const char *buffer, size_t orig_size)
+{
+  return _assuan_cookie_write_data (cookie, buffer, orig_size);
+}
+#endif /*HAVE_FOPENCOOKIE*/
+
 /* Return a FP to be used for data output.  The FILE pointer is valid
    until the end of a handler.  So a close is not needed.  Assuan does
    all the buffering needed to insert the status line as well as the
@@ -648,10 +684,14 @@
   if (ctx->outbound.data.fp)
     return ctx->outbound.data.fp;
   
+#ifdef HAVE_FUNOPEN
+  ctx->outbound.data.fp = funopen (ctx, 0, fun1_cookie_write,
+				   0, _assuan_cookie_write_flush);
+#else
+  ctx->outbound.data.fp = funopen (ctx, 0, fun2_cookie_write,
+				   0, _assuan_cookie_write_flush);
+#endif                                   
 
-  ctx->outbound.data.fp = funopen (ctx, 0,
-				   _assuan_cookie_write_data,
-				   0, _assuan_cookie_write_flush);
   ctx->outbound.data.error = 0;
   return ctx->outbound.data.fp;
 #else

Modified: trunk/assuan/assuan-io.c
===================================================================
--- trunk/assuan/assuan-io.c	2006-11-29 15:47:00 UTC (rev 1188)
+++ trunk/assuan/assuan-io.c	2006-11-29 16:25:46 UTC (rev 1189)
@@ -23,12 +23,9 @@
 #include <config.h>
 #endif
 
+#include <sys/time.h>
 #include <sys/types.h>
 #include <sys/socket.h>
-#include <sys/wait.h>
-#if HAVE_SYS_UIO_H
-# include <sys/uio.h>
-#endif
 #include <unistd.h>
 #include <errno.h>
 #ifdef HAVE_W32_SYSTEM
@@ -39,65 +36,12 @@
 
 #include "assuan-defs.h"
 
-/* We can't include pth.h and we are not sure whether other headers
-   already included it.  This we define macros with the same
-   values. */
-#define MY_PTH_FDMODE_ERROR    (-1)
-#define MY_PTH_FDMODE_POLL     0
-#define MY_PTH_FDMODE_BLOCK    1
-#define MY_PTH_FDMODE_NONBLOCK 2
 
-
-#ifndef _ASSUAN_NO_PTH
-extern pid_t   pth_waitpid (pid_t pid, int *status, int options);
-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);
-extern int     pth_fdmode (int, int);
-extern int     pth_select(int, fd_set*, fd_set*, fd_set*, struct timeval*);
-
 #ifndef HAVE_W32_SYSTEM
-#pragma weak pth_waitpid
-#pragma weak pth_read
-#pragma weak pth_write
-#pragma weak pth_fdmode
-#pragma weak pth_select
-#endif
-#endif /*!_ASSUAN_NO_PTH*/
-
-#ifndef _ASSUAN_NO_PTH
-/* Wrapper around pth_fdmode. */
-static int
-my_pth_fdmode (int fd, int mode)
-{
-  if (pth_fdmode)
-    return pth_fdmode (fd, mode);
-  else
-    return MY_PTH_FDMODE_NONBLOCK; /* This is okay, given the way we use it. */
-}
-#endif /*_ASSUAN_NO_PTH*/
-
-#ifndef _ASSUAN_NO_PTH
-/* Wrapper around pth_select. */
-static int 
-my_pth_select (int nfd, fd_set *rfds, fd_set *wfds, fd_set *efds,
-               struct timeval *timeout)
-{
-  if (pth_select)
-    return pth_select (nfd, rfds, wfds, efds, timeout);
-  else
-    return 1; /* Fake one fd ready; this is okay, given the way we use it. */
-}
-#endif /*_ASSUAN_NO_PTH*/
-
-#ifndef HAVE_W32_SYSTEM
 pid_t 
 _assuan_waitpid (pid_t pid, int *status, int options)
 {
-#ifdef _ASSUAN_NO_PTH
   return waitpid (pid, status, options);
-#else
-  return (pth_waitpid ? pth_waitpid : waitpid) (pid, status, options);
-#endif
 }
 #endif
 
@@ -105,72 +49,26 @@
 ssize_t
 _assuan_simple_read (assuan_context_t ctx, void *buffer, size_t size)
 {
-#ifdef _ASSUAN_NO_PTH
   return read (ctx->inbound.fd, buffer, size);
-#else
-# ifndef HAVE_W32_SYSTEM
-  return (pth_read ? pth_read : read) (ctx->inbound.fd, buffer, size);
-# else
-  return pth_read ? pth_read (ctx->inbound.fd, buffer, size)
-                  : recv (ctx->inbound.fd, buffer, size, 0);
-# endif
-#endif
 }
 
 ssize_t
 _assuan_simple_write (assuan_context_t ctx, const void *buffer, size_t size)
 {
-#ifdef _ASSUAN_NO_PTH
   return write (ctx->outbound.fd, buffer, size);
-#else
-# ifndef HAVE_W32_SYSTEM
-  return (pth_write ? pth_write : write) (ctx->outbound.fd, buffer, size);
-# else
-  return pth_write ? pth_write (ctx->outbound.fd, buffer, size)
-                   : send (ctx->outbound.fd, buffer, size, 0);
-# endif
-#endif
 }
 
 
 ssize_t
 _assuan_simple_sendmsg (assuan_context_t ctx, struct msghdr *msg)
 {
-#if defined(HAVE_W32_SYSTEM)
+#ifdef HAVE_W32_SYSTEM
   return _assuan_error (ASSUAN_Not_Implemented);
-#elif defined(_ASSUAN_NO_PTH)
+#else
   int ret;
   while ( (ret = sendmsg (ctx->outbound.fd, msg, 0)) == -1 && errno == EINTR)
     ;
   return ret;
-#else
-  /* Pth does not provide a sendmsg function.  Thus we implement it here.  */
-  int ret;
-  int fd = ctx->outbound.fd;
-  int fdmode;
-
-  fdmode = my_pth_fdmode (fd, MY_PTH_FDMODE_POLL);
-  if (fdmode == MY_PTH_FDMODE_ERROR)
-    {
-      errno = EBADF;
-      return -1;
-    }
-  if (fdmode == MY_PTH_FDMODE_BLOCK)
-    {
-      fd_set fds;
-
-      FD_ZERO (&fds);
-      FD_SET (fd, &fds);
-      while ( (ret = my_pth_select (fd+1, NULL, &fds, NULL, NULL)) < 0
-              && errno == EINTR)
-        ;
-      if (ret < 0)
-        return -1;
-    }
-
-  while ((ret = sendmsg (fd, msg, 0)) == -1 && errno == EINTR)
-    ;
-  return ret;
 #endif
 }
 
@@ -178,40 +76,12 @@
 ssize_t
 _assuan_simple_recvmsg (assuan_context_t ctx, struct msghdr *msg)
 {
-#if defined(HAVE_W32_SYSTEM)
+#ifdef HAVE_W32_SYSTEM
   return _assuan_error (ASSUAN_Not_Implemented);
-#elif defined(_ASSUAN_NO_PTH)
+#else
   int ret;
   while ( (ret = recvmsg (ctx->inbound.fd, msg, 0)) == -1 && errno == EINTR)
     ;
   return ret;
-#else
-  /* Pth does not provide a recvmsg function.  Thus we implement it here.  */
-  int ret;
-  int fd = ctx->inbound.fd;
-  int fdmode;
-
-  fdmode = my_pth_fdmode (fd, MY_PTH_FDMODE_POLL);
-  if (fdmode == MY_PTH_FDMODE_ERROR)
-    {
-      errno = EBADF;
-      return -1;
-    }
-  if (fdmode == MY_PTH_FDMODE_BLOCK)
-    {
-      fd_set fds;
-
-      FD_ZERO (&fds);
-      FD_SET (fd, &fds);
-      while ( (ret = my_pth_select (fd+1, &fds, NULL, NULL, NULL)) < 0
-              && errno == EINTR)
-        ;
-      if (ret < 0)
-        return -1;
-    }
-
-  while ((ret = recvmsg (fd, msg, 0)) == -1 && errno == EINTR)
-    ;
-  return ret;
 #endif
 }

Modified: trunk/assuan/assuan-pipe-server.c
===================================================================
--- trunk/assuan/assuan-pipe-server.c	2006-11-29 15:47:00 UTC (rev 1188)
+++ trunk/assuan/assuan-pipe-server.c	2006-11-29 16:25:46 UTC (rev 1189)
@@ -168,6 +168,7 @@
     {
       xfree (ctx->hello_line);
       xfree (ctx->okay_line);
+      xfree (ctx->cmdtbl);
       xfree (ctx);
     }
 }

Modified: trunk/assuan/assuan-uds.c
===================================================================
--- trunk/assuan/assuan-uds.c	2006-11-29 15:47:00 UTC (rev 1188)
+++ trunk/assuan/assuan-uds.c	2006-11-29 16:25:46 UTC (rev 1189)
@@ -44,7 +44,27 @@
 
 #include "assuan-defs.h"
 
+#ifdef USE_DESCRIPTOR_PASSING
+/* Provide replacement for missing CMSG maccros.  We assume that
+   size_t matches the alignment requirement. */
+#define MY_ALIGN(n) ((((n))+ sizeof(size_t)-1) & (size_t)~(sizeof(size_t)-1))
+#ifndef CMSG_SPACE
+#define CMSG_SPACE(n) (MY_ALIGN(sizeof(struct cmsghdr)) + MY_ALIGN((n)))
+#endif 
+#ifndef CMSG_LEN
+#define CMSG_LEN(n) (MY_ALIGN(sizeof(struct cmsghdr)) + (n))
+#endif 
+#ifndef CMSG_FIRSTHDR
+#define CMSG_FIRSTHDR(mhdr) \
+  ((size_t)(mhdr)->msg_controllen >= sizeof (struct cmsghdr)		      \
+   ? (struct cmsghdr*) (mhdr)->msg_control : (struct cmsghdr*)NULL)
+#endif
+#ifndef CMSG_DATA
+#define CMSG_DATA(cmsg) ((unsigned char*)((struct cmsghdr*)(cmsg)+1))
+#endif
+#endif /*USE_DESCRIPTOR_PASSING*/
 
+
 /* Read from a unix domain socket using sendmsg. 
 
    FIXME: We don't need the buffering. It is a leftover from the time
@@ -55,7 +75,6 @@
   int len = ctx->uds.buffersize;
 
 #ifndef HAVE_W32_SYSTEM
-
   if (!ctx->uds.bufferallocated)
     {
       ctx->uds.buffer = xtrymalloc (2048);
@@ -68,11 +87,13 @@
     {
       struct msghdr msg;
       struct iovec iovec;
+#ifdef USE_DESCRIPTOR_PASSING
       union {
         struct cmsghdr cm;
         char control[CMSG_SPACE(sizeof (int))];
       } control_u;
       struct cmsghdr *cmptr;
+#endif /*USE_DESCRIPTOR_PASSING*/
 
       memset (&msg, 0, sizeof (msg));
 
@@ -82,8 +103,10 @@
       msg.msg_iovlen = 1;
       iovec.iov_base = ctx->uds.buffer;
       iovec.iov_len = ctx->uds.bufferallocated;
+#ifdef USE_DESCRIPTOR_PASSING
       msg.msg_control = control_u.control;
       msg.msg_controllen = sizeof (control_u.control);
+#endif
 
       len = _assuan_simple_recvmsg (ctx, &msg);
       if (len < 0)
@@ -92,6 +115,7 @@
       ctx->uds.buffersize = len;
       ctx->uds.bufferoffset = 0;
 
+#ifdef USE_DESCRIPTOR_PASSING
       cmptr = CMSG_FIRSTHDR (&msg);
       if (cmptr && cmptr->cmsg_len == CMSG_LEN (sizeof(int)))
         {
@@ -112,9 +136,13 @@
                 ctx->uds.pendingfds[ctx->uds.pendingfdscount++] = fd;
             }
 	}
+#endif /*USE_DESCRIPTOR_PASSING*/
     }
+
 #else /*HAVE_W32_SYSTEM*/
+
   len = recvfrom (ctx->inbound.fd, buf, buflen, 0, NULL, NULL);
+
 #endif /*HAVE_W32_SYSTEM*/
 
   /* Return some data to the user.  */
@@ -149,8 +177,6 @@
   msg.msg_iov = &iovec;
   iovec.iov_base = (void*)buf;
   iovec.iov_len = buflen;
-  msg.msg_control = 0;
-  msg.msg_controllen = 0;
 
   len = _assuan_simple_sendmsg (ctx, &msg);
 #else /*HAVE_W32_SYSTEM*/
@@ -167,7 +193,7 @@
 static assuan_error_t
 uds_sendfd (assuan_context_t ctx, int fd)
 {
-#ifndef HAVE_W32_SYSTEM
+#ifdef USE_DESCRIPTOR_PASSING
   struct msghdr msg;
   struct iovec iovec;
   union {
@@ -217,7 +243,7 @@
 static assuan_error_t
 uds_receivefd (assuan_context_t ctx, int *fd)
 {
-#ifndef HAVE_W32_SYSTEM
+#ifdef USE_DESCRIPTOR_PASSING
   int i;
 
   if (!ctx->uds.pendingfdscount)

Modified: trunk/assuan/assuan-util.c
===================================================================
--- trunk/assuan/assuan-util.c	2006-11-29 15:47:00 UTC (rev 1188)
+++ trunk/assuan/assuan-util.c	2006-11-29 16:25:46 UTC (rev 1189)
@@ -125,7 +125,22 @@
 }
 
 
+void 
+assuan_set_io_monitor (assuan_context_t ctx,
+                       unsigned int (*monitor)(assuan_context_t ctx,
+                                               int direction,
+                                               const char *line,
+                                               size_t linelen))
+{
+  if (ctx)
+    {
+      ctx->io_monitor = monitor;
+    }
+}
 
+
+
+
 /* For context CTX, set the flag FLAG to VALUE.  Values for flags
    are usually 1 or 0 but certain flags might allow for other values;
    see the description of the type assuan_flag_t for details. */

Modified: trunk/assuan/assuan.h
===================================================================
--- trunk/assuan/assuan.h	2006-11-29 15:47:00 UTC (rev 1188)
+++ trunk/assuan/assuan.h	2006-11-29 16:25:46 UTC (rev 1189)
@@ -95,6 +95,8 @@
 #define _ASSUAN_PREFIX(x) _ASSUAN_PREFIX2(_ASSUAN_EXT_SYM_PREFIX,x)
 #define assuan_ _ASSUAN_PREFIX(assuan_)
 #define assuan_register_command _ASSUAN_PREFIX(assuan_register_command)
+#define assuan_register_post_cmd_notify \
+  _ASSUAN_PREFIX(assuan_register_post_cmd_notify)
 #define assuan_register_bye_notify _ASSUAN_PREFIX(assuan_register_bye_notify)
 #define assuan_register_reset_notify \
   _ASSUAN_PREFIX(assuan_register_reset_notify)
@@ -146,6 +148,7 @@
 #define assuan_set_error _ASSUAN_PREFIX(assuan_set_error)
 #define assuan_set_pointer _ASSUAN_PREFIX(assuan_set_pointer)
 #define assuan_get_pointer _ASSUAN_PREFIX(assuan_get_pointer)
+#define assuan_set_io_monitor _ASSUAN_PREFIX(assuan_set_io_monitor)
 #define assuan_begin_confidential _ASSUAN_PREFIX(assuan_begin_confidential)
 #define assuan_end_confidential _ASSUAN_PREFIX(assuan_end_confidential)
 #define assuan_strerror _ASSUAN_PREFIX(assuan_strerror)
@@ -282,9 +285,11 @@
 #define  ASSUAN_Unexpected_Data 125
 #define  ASSUAN_Invalid_Status 126
 #define  ASSUAN_Locale_Problem 127
+#endif
 #define  ASSUAN_Not_Confirmed 128
 
   /* Warning: Don't use the Error codes, below they are deprecated. */
+#ifndef _ASSUAN_IN_LIBASSUAN
 #define  ASSUAN_Bad_Certificate 201
 #define  ASSUAN_Bad_Certificate_Chain 202
 #define  ASSUAN_Missing_Certificate 203
@@ -367,6 +372,8 @@
 int assuan_register_command (assuan_context_t ctx,
                              const char *cmd_string,
                              int (*handler)(assuan_context_t, char *));
+int assuan_register_post_cmd_notify (assuan_context_t ctx,
+                                     void (*fnc)(assuan_context_t, int));
 int assuan_register_bye_notify (assuan_context_t ctx,
                                 void (*fnc)(assuan_context_t));
 int assuan_register_reset_notify (assuan_context_t ctx,
@@ -497,6 +504,12 @@
 void assuan_begin_confidential (assuan_context_t ctx);
 void assuan_end_confidential (assuan_context_t ctx);
 
+void assuan_set_io_monitor (assuan_context_t ctx,
+                            unsigned int (*monitor)(assuan_context_t ctx,
+                                                    int direction,
+                                                    const char *line,
+                                                    size_t linelen));
+
 /* For context CTX, set the flag FLAG to VALUE.  Values for flags
    are usually 1 or 0 but certain flags might allow for other values;
    see the description of the type assuan_flag_t for details. */

Modified: trunk/assuan/mkerrors
===================================================================
--- trunk/assuan/mkerrors	2006-11-29 15:47:00 UTC (rev 1188)
+++ trunk/assuan/mkerrors	2006-11-29 16:25:46 UTC (rev 1189)
@@ -84,6 +84,7 @@
     case ASSUAN_Unknown_Command:         n = 275; break;
     case ASSUAN_Canceled:                n = 277; break;
     case ASSUAN_No_Secret_Key:           n =  17; break;
+    case ASSUAN_Not_Confirmed:           n = 114; break;
 
     case ASSUAN_Read_Error:
       switch (errno)
@@ -200,6 +201,7 @@
               case 274: n = ASSUAN_Unexpected_Command     ; break;
               case 275: n = ASSUAN_Unknown_Command        ; break;
               case 277: n = ASSUAN_Canceled               ; break;
+              case 114: n = ASSUAN_Not_Confirmed          ; break;
               case ((1<<15)|86): n = ASSUAN_Out_Of_Core   ; break;
               default:  n = 0; break;
               }




More information about the Gnupg-commits mailing list