[svn] gpgme - r1205 - trunk/gpgme

svn author marcus cvs at cvs.gnupg.org
Thu Jan 18 18:59:27 CET 2007


Author: marcus
Date: 2007-01-18 18:59:26 +0100 (Thu, 18 Jan 2007)
New Revision: 1205

Modified:
   trunk/gpgme/ChangeLog
   trunk/gpgme/data-fd.c
   trunk/gpgme/data-mem.c
   trunk/gpgme/data-stream.c
   trunk/gpgme/data-user.c
   trunk/gpgme/data.c
   trunk/gpgme/data.h
   trunk/gpgme/engine-gpgsm.c
   trunk/gpgme/gpgme.h
Log:
2007-01-18  Marcus Brinkmann  <marcus at g10code.de>

	* data.h (_gpgme_data_get_fd): Add prototype.
	(gpgme_data_get_fd_cb): New type.
	(struct _gpgme_data_cbs): New member get_fd.
	* data.c (_gpgme_data_get_fd): New function.
	* data-fd.c (fd_get_fd): New function.
	(fd_cbs): Add fd_get_fd.
	* data-stream.c (stream_get_fd): New function.
	(stream_cbs): Add stream_get_fd.
	* data-mem.c (mem_cbs): Add NULL for get_fd callback.	
	* data-user.c (user_cbs): Likewise.
	* engine-gpgsm.c (gpgsm_set_fd) [USE_DESCRIPTOR_PASSING]: Try to
	short-cut by passing the data descriptor directly.


Modified: trunk/gpgme/ChangeLog
===================================================================
--- trunk/gpgme/ChangeLog	2007-01-17 19:38:29 UTC (rev 1204)
+++ trunk/gpgme/ChangeLog	2007-01-18 17:59:26 UTC (rev 1205)
@@ -1,3 +1,18 @@
+2007-01-18  Marcus Brinkmann  <marcus at g10code.de>
+
+	* data.h (_gpgme_data_get_fd): Add prototype.
+	(gpgme_data_get_fd_cb): New type.
+	(struct _gpgme_data_cbs): New member get_fd.
+	* data.c (_gpgme_data_get_fd): New function.
+	* data-fd.c (fd_get_fd): New function.
+	(fd_cbs): Add fd_get_fd.
+	* data-stream.c (stream_get_fd): New function.
+	(stream_cbs): Add stream_get_fd.
+	* data-mem.c (mem_cbs): Add NULL for get_fd callback.	
+	* data-user.c (user_cbs): Likewise.
+	* engine-gpgsm.c (gpgsm_set_fd) [USE_DESCRIPTOR_PASSING]: Try to
+	short-cut by passing the data descriptor directly.
+
 2007-01-17  Marcus Brinkmann  <marcus at g10code.de>
 
 	* w32-io.c (build_commandline): Quote all command line arguments.

Modified: trunk/gpgme/data-fd.c
===================================================================
--- trunk/gpgme/data-fd.c	2007-01-17 19:38:29 UTC (rev 1204)
+++ trunk/gpgme/data-fd.c	2007-01-18 17:59:26 UTC (rev 1205)
@@ -49,12 +49,20 @@
 }
 
 
+static int
+fd_get_fd (gpgme_data_t dh)
+{
+  return (dh->data.fd);
+}
+
+
 static struct _gpgme_data_cbs fd_cbs =
   {
     fd_read,
     fd_write,
     fd_seek,
-    NULL
+    NULL,
+    fd_get_fd
   };
 
 

Modified: trunk/gpgme/data-mem.c
===================================================================
--- trunk/gpgme/data-mem.c	2007-01-17 19:38:29 UTC (rev 1204)
+++ trunk/gpgme/data-mem.c	2007-01-18 17:59:26 UTC (rev 1205)
@@ -157,7 +157,8 @@
     mem_read,
     mem_write,
     mem_seek,
-    mem_release
+    mem_release,
+    NULL
   };
 
 

Modified: trunk/gpgme/data-stream.c
===================================================================
--- trunk/gpgme/data-stream.c	2007-01-17 19:38:29 UTC (rev 1204)
+++ trunk/gpgme/data-stream.c	2007-01-18 17:59:26 UTC (rev 1205)
@@ -71,12 +71,20 @@
 }
 
 
+static int
+stream_get_fd (gpgme_data_t dh)
+{
+  return fileno (dh->data.stream);
+}
+
+
 static struct _gpgme_data_cbs stream_cbs =
   {
     stream_read,
     stream_write,
     stream_seek,
-    NULL
+    NULL,
+    stream_get_fd
   };
 
 

Modified: trunk/gpgme/data-user.c
===================================================================
--- trunk/gpgme/data-user.c	2007-01-17 19:38:29 UTC (rev 1204)
+++ trunk/gpgme/data-user.c	2007-01-18 17:59:26 UTC (rev 1205)
@@ -71,7 +71,8 @@
     user_read,
     user_write,
     user_seek,
-    user_release
+    user_release,
+    NULL
   };
 
 

Modified: trunk/gpgme/data.c
===================================================================
--- trunk/gpgme/data.c	2007-01-17 19:38:29 UTC (rev 1204)
+++ trunk/gpgme/data.c	2007-01-18 17:59:26 UTC (rev 1205)
@@ -280,3 +280,14 @@
   dh->pending_len -= nwritten;
   return 0;
 }
+
+
+/* Get the file descriptor associated with DH, if possible.  Otherwise
+   return -1.  */
+int
+_gpgme_data_get_fd (gpgme_data_t dh)
+{
+  if (!dh || !dh->cbs->get_fd)
+    return -1;
+  return (*dh->cbs->get_fd) (dh);
+}

Modified: trunk/gpgme/data.h
===================================================================
--- trunk/gpgme/data.h	2007-01-17 19:38:29 UTC (rev 1204)
+++ trunk/gpgme/data.h	2007-01-18 17:59:26 UTC (rev 1205)
@@ -52,12 +52,16 @@
 /* Release the data object with the handle DH.  */
 typedef void (*gpgme_data_release_cb) (gpgme_data_t dh);
 
+/* Get the FD associated with the handle DH, or -1.  */
+typedef int (*gpgme_data_get_fd_cb) (gpgme_data_t dh);
+
 struct _gpgme_data_cbs
 {
   gpgme_data_read_cb read;
   gpgme_data_write_cb write;
   gpgme_data_seek_cb seek;
   gpgme_data_release_cb release;
+  gpgme_data_get_fd_cb get_fd;
 };
 
 struct gpgme_data
@@ -121,4 +125,8 @@
 
 void _gpgme_data_release (gpgme_data_t dh);
 
+/* Get the file descriptor associated with DH, if possible.  Otherwise
+   return -1.  */
+int _gpgme_data_get_fd (gpgme_data_t dh);
+
 #endif	/* DATA_H */

Modified: trunk/gpgme/engine-gpgsm.c
===================================================================
--- trunk/gpgme/engine-gpgsm.c	2007-01-17 19:38:29 UTC (rev 1204)
+++ trunk/gpgme/engine-gpgsm.c	2007-01-18 17:59:26 UTC (rev 1205)
@@ -692,22 +692,26 @@
   dir = iocb_data->dir;
 
 #if USE_DESCRIPTOR_PASSING
-  {
-    int fds[2];
+  /* We try to short-cut the communication by giving GPGSM direct
+     access to the file descriptor, rather than using a pipe.  */
+  iocb_data->server_fd = _gpgme_data_get_fd (iocb_data->data);
+  if (iocb_data->server_fd < 0)
+    {
+      int fds[2];
 
-    if (_gpgme_io_pipe (fds, 0) < 0)
-      return gpg_error_from_errno (errno);
+      if (_gpgme_io_pipe (fds, 0) < 0)
+	return gpg_error_from_errno (errno);
 
-    iocb_data->fd = dir ? fds[0] : fds[1];
-    iocb_data->server_fd = dir ? fds[1] : fds[0];
+      iocb_data->fd = dir ? fds[0] : fds[1];
+      iocb_data->server_fd = dir ? fds[1] : fds[0];
 
-    if (_gpgme_io_set_close_notify (iocb_data->fd,
-				    close_notify_handler, gpgsm))
-      {
-	err = gpg_error (GPG_ERR_GENERAL);
-	goto leave_set_fd;
-      }
-  }
+      if (_gpgme_io_set_close_notify (iocb_data->fd,
+				      close_notify_handler, gpgsm))
+	{
+	  err = gpg_error (GPG_ERR_GENERAL);
+	  goto leave_set_fd;
+	}
+    }
 #endif
 
   fd = iocb_data->server_fd;

Modified: trunk/gpgme/gpgme.h
===================================================================
--- trunk/gpgme/gpgme.h	2007-01-17 19:38:29 UTC (rev 1204)
+++ trunk/gpgme/gpgme.h	2007-01-18 17:59:26 UTC (rev 1205)
@@ -72,7 +72,7 @@
    AM_PATH_GPGME macro) check that this header matches the installed
    library.  Warning: Do not edit the next line.  configure will do
    that for you!  */
-#define GPGME_VERSION "1.1.3-cvs1200"
+#define GPGME_VERSION "1.1.3-cvs1202"
 
 
 




More information about the Gnupg-commits mailing list