[svn] assuan - r359 - in trunk: . src

svn author wk cvs at cvs.gnupg.org
Fri Mar 5 18:55:58 CET 2010


Author: wk
Date: 2010-03-05 18:55:57 +0100 (Fri, 05 Mar 2010)
New Revision: 359

Modified:
   trunk/README
   trunk/src/ChangeLog
   trunk/src/gpgcemgr.c
Log:
Add options and documentation for gpgcedev.


Modified: trunk/src/ChangeLog
===================================================================
--- trunk/src/ChangeLog	2010-02-25 13:03:16 UTC (rev 358)
+++ trunk/src/ChangeLog	2010-03-05 17:55:57 UTC (rev 359)
@@ -1,3 +1,7 @@
+2010-03-05  Werner Koch  <wk at g10code.com>
+
+	* gpgcemgr.c: Add options to register a device and activate it.
+
 2010-02-24  Werner Koch  <wk at g10code.com>
 
 	* gpgcemgr.c: New.

Modified: trunk/README
===================================================================
--- trunk/README	2010-02-25 13:03:16 UTC (rev 358)
+++ trunk/README	2010-03-05 17:55:57 UTC (rev 359)
@@ -13,3 +13,23 @@
 
 The primary FTP site is ftp://ftp.gnupg.org/gcrypt/libassuan.
 
+
+
+Notes for Windows CE:
+----------------------
+
+Libassuan supports WindowsCE (tested with WindowsMobile 6.5).  To
+install it, copy libassuan-0.dll into a location where DLL are found
+and install the included gpgcedev driver: First copy "gpgcedev.dll"
+into the root directory, second run the included program gpgcemgr on
+the device: "gpgcemgr --register".  This creates the necessary
+registry keys.  In case the copy step fails, the driver may still be
+in use: Close all applications using that driver, run "gpgcemgr
+--deactivate" to deactivate the running driver and try again.
+
+Registry keys created by "gpgcemgr --register" are:
+
+   Drivers\\GnuPG_Device\dll    -> "gpgcedev.dll"
+   Drivers\\GnuPG_Device\prefix -> "GPG"
+   Drivers\\GnuPG_Device\Index  -> 1      (dword)
+

Modified: trunk/src/gpgcemgr.c
===================================================================
--- trunk/src/gpgcemgr.c	2010-02-25 13:03:16 UTC (rev 358)
+++ trunk/src/gpgcemgr.c	2010-03-05 17:55:57 UTC (rev 359)
@@ -24,11 +24,45 @@
 
 #define PGM "gpgcemgr"
 
-#warning Fixme: Add support to create the device.
+#define GPGCEDEV_KEY_NAME L"Drivers\\GnuPG_Device"
+#define GPGCEDEV_DLL_NAME L"gpgcedev.dll"
+#define GPGCEDEV_PREFIX   L"GPG"
 
-int
-main (int argc, char **argv)
+
+static int
+install (void)
 {
+  HKEY handle;
+  DWORD disp, dw;
+  
+  if (RegCreateKeyEx (HKEY_LOCAL_MACHINE, GPGCEDEV_KEY_NAME, 0, NULL, 0,
+                      KEY_WRITE, NULL, &handle, &disp))
+    {
+      fprintf (stderr, PGM": error creating registry key: rc=%d\n", 
+               (int)GetLastError ());
+      return 1;
+    }
+
+  RegSetValueEx (handle, L"dll", 0, REG_SZ, 
+                 (void*)GPGCEDEV_DLL_NAME, sizeof (GPGCEDEV_DLL_NAME));
+  RegSetValueEx (handle, L"prefix", 0, REG_SZ,
+                 (void*)GPGCEDEV_PREFIX, sizeof (GPGCEDEV_PREFIX));
+
+  dw = 1;
+  RegSetValueEx (handle, L"Index", 0, REG_DWORD, (void*)&dw, sizeof dw);
+  
+  RegCloseKey (handle);
+
+  fprintf (stderr, PGM": registry key created\n");
+
+
+  return 0;
+}
+
+
+static int
+deinstall (void)
+{
   int result = 0;
   HANDLE shd;
   DEVMGR_DEVICE_INFORMATION dinfo;
@@ -63,6 +97,40 @@
         }
       FindClose (shd);
     }
+
+  return result;
+}
+
+
+
+int
+main (int argc, char **argv)
+{
+  int result = 0;
+
+  if (argc > 1 && !strcmp (argv[1], "--register"))
+    result = install ();
+  else if (argc > 1 && !strcmp (argv[1], "--deactivate"))
+    result = deinstall ();
+  else if (argc > 1 && !strcmp (argv[1], "--activate"))
+    {
+      /* This is mainly for testing.  The activation is usually done
+         right before the device is opened.  */
+      if (ActivateDevice (GPGCEDEV_DLL_NAME, 0) == INVALID_HANDLE_VALUE)
+        {
+          fprintf (stderr, PGM": ActivateDevice failed: rc=%d\n",
+                   (int)GetLastError ());
+          result = 1;
+        }
+      else
+        fprintf (stderr, PGM": device activated\n");
+    }
+  else
+    {
+      fprintf (stderr, "usage: " PGM " --register|--deactivate|--activate\n");
+      result = 1;
+    }
+
   fflush (stdout);
   fflush (stderr);
   Sleep (1000);




More information about the Gnupg-commits mailing list