[svn] GnuPG - r4233 - trunk/scd

svn author marcus cvs at cvs.gnupg.org
Fri Sep 1 15:57:33 CEST 2006


Author: marcus
Date: 2006-09-01 15:57:33 +0200 (Fri, 01 Sep 2006)
New Revision: 4233

Modified:
   trunk/scd/ChangeLog
   trunk/scd/command.c
Log:
2006-09-01  Marcus Brinkmann  <marcus at g10code.de>

	* command.c (cmd_getinfo): Handle status command.


Modified: trunk/scd/ChangeLog
===================================================================
--- trunk/scd/ChangeLog	2006-08-30 15:57:17 UTC (rev 4232)
+++ trunk/scd/ChangeLog	2006-09-01 13:57:33 UTC (rev 4233)
@@ -1,3 +1,7 @@
+2006-09-01  Marcus Brinkmann  <marcus at g10code.de>
+
+	* command.c (cmd_getinfo): Handle status command.
+
 2006-08-30  Marcus Brinkmann  <marcus at g10code.de>
 
 	* command.c (do_reset): Delay resetting CTRL->reader_slot until

Modified: trunk/scd/command.c
===================================================================
--- trunk/scd/command.c	2006-08-30 15:57:17 UTC (rev 4232)
+++ trunk/scd/command.c	2006-09-01 13:57:33 UTC (rev 4233)
@@ -295,7 +295,7 @@
 
 /* If the card has not yet been opened, do it.  Note that this
    function returns an Assuan error, so don't map the error a second
-   time */
+   time.  */
 static assuan_error_t
 open_card (ctrl_t ctrl, const char *apptype)
 {
@@ -1355,7 +1355,12 @@
    Supported values of WHAT are:
 
    socket_name - Return the name of the socket.
-
+   status - Return the status of the current slot (in the future, may
+   also return the status of all slots).  The status is a list of
+   one-character flags.  The following flags are currently defined:
+     'u'  Usable card present.  This is the normal state during operation.
+     'r'  Card removed.  A reset is necessary.
+   These flags are exclusive.
 */
 
 static int
@@ -1372,6 +1377,29 @@
       else
         rc = gpg_error (GPG_ERR_NO_DATA);
     }
+  else if (!strcmp (line, "status"))
+    {
+      ctrl_t ctrl = assuan_get_pointer (ctx);
+      int slot = ctrl->reader_slot;
+      char flag = 'r';
+
+      if (!ctrl->server_local->card_removed && slot != -1)
+	{
+	  struct slot_status_s *ss;
+	  
+	  if (!(slot >= 0 && slot < DIM(slot_table)))
+	    BUG ();
+
+	  ss = &slot_table[slot];
+
+	  if (!ss->valid)
+	    BUG ();
+
+	  if (ss->any && (ss->status & 1))
+	    flag = 'u';
+	}
+      rc = assuan_send_data (ctx, &flag, 1);
+    }
   else
     rc = set_error (Parameter_Error, "unknown value for WHAT");
   return rc;
@@ -1752,7 +1780,7 @@
              will set this on any card change because a reset or
              SERIALNO request must be done in any case.  */
           if (ss->any)
-            update_card_removed (ss->slot, 1);
+            update_card_removed (ss->slot, 1); /* XXX: MB: Should be idx? */
           
           ss->any = 1;
           ss->status = status;




More information about the Gnupg-commits mailing list