[svn] GnuPG - r5491 - trunk/common

svn author wk cvs at cvs.gnupg.org
Thu Dec 2 14:56:28 CET 2010


Author: wk
Date: 2010-12-02 14:56:28 +0100 (Thu, 02 Dec 2010)
New Revision: 5491

Modified:
   trunk/common/ChangeLog
   trunk/common/logging.c
Log:
Add logging to GPG2: [W32CE].


Modified: trunk/common/ChangeLog
===================================================================
--- trunk/common/ChangeLog	2010-12-02 13:53:18 UTC (rev 5490)
+++ trunk/common/ChangeLog	2010-12-02 13:56:28 UTC (rev 5491)
@@ -1,3 +1,9 @@
+2010-12-02  Werner Koch  <wk at g10code.com>
+
+	* logging.c (fun_cookie_s) [W32CE]: Add field USE_WRITEFILE.
+	(fun_writer) [W32CE]: Make use of it.
+	(set_file_fd) [W32CE]: Implement special filename "GPG2:".
+
 2010-11-25  Werner Koch  <wk at g10code.com>
 
 	* asshelp.c (start_new_gpg_agent): Change style of startup info.

Modified: trunk/common/logging.c
===================================================================
--- trunk/common/logging.c	2010-12-02 13:53:18 UTC (rev 5490)
+++ trunk/common/logging.c	2010-12-02 13:56:28 UTC (rev 5491)
@@ -117,6 +117,9 @@
   int quiet;
   int want_socket;
   int is_socket;
+#ifdef HAVE_W32CE_SYSTEM
+  int use_writefile;
+#endif
   char name[1];
 };
 
@@ -356,9 +359,21 @@
     }
   
   log_socket = cookie->fd;
-  if (cookie->fd != -1 && !writen (cookie->fd, buffer, size, cookie->is_socket))
-    return (ssize_t)size; /* Okay. */ 
-  
+  if (cookie->fd != -1)
+    { 
+#ifdef HAVE_W32CE_SYSTEM
+      if (cookie->use_writefile)
+        {
+          DWORD nwritten;
+          
+          WriteFile ((HANDLE)cookie->fd, buffer, size, &nwritten, NULL);
+          return (ssize_t)size; /* Okay.  */
+        }
+#endif
+      if (!writen (cookie->fd, buffer, size, cookie->is_socket))
+        return (ssize_t)size; /* Okay. */ 
+    }
+
   if (!running_detached && cookie->fd != -1
       && isatty (es_fileno (es_stderr)))
     {
@@ -400,6 +415,9 @@
 {
   estream_t fp;
   int want_socket;
+#ifdef HAVE_W32CE_SYSTEM
+  int use_writefile = 0;
+#endif
   struct fun_cookie_s *cookie;
 
   /* Close an open log stream.  */
@@ -423,7 +441,24 @@
   else if (name && !strncmp (name, "socket://", 9) && name[9])
     want_socket = 2;
 #endif /*HAVE_W32_SYSTEM*/
+#ifdef HAVE_W32CE_SYSTEM
+  else if (name && !strcmp (name, "GPG2:"))
+    {
+      HANDLE hd;
 
+      ActivateDevice (L"Drivers\\GnuPG_Log", 0);
+      /* Ignore a filename and write the debug output to the GPG2:
+         device.  */
+      hd = CreateFile (L"GPG2:", GENERIC_WRITE,
+                       FILE_SHARE_READ | FILE_SHARE_WRITE,
+                       NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
+      fd = (hd == INVALID_HANDLE_VALUE)? -1 : (int)hd;
+      name = NULL;
+      force_prefixes = 1;
+      use_writefile = 1;
+    }
+#endif /*HAVE_W32CE_SYSTEM*/
+
   /* Setup a new stream.  */
 
   /* The xmalloc below is justified because we can expect that this
@@ -434,6 +469,9 @@
   cookie->quiet = 0;
   cookie->is_socket = 0;
   cookie->want_socket = want_socket;
+#ifdef HAVE_W32CE_SYSTEM
+  cookie->use_writefile = use_writefile;
+#endif
   if (!name)
     cookie->fd = fd;
   else if (want_socket)





More information about the Gnupg-commits mailing list