[Pcsclite-cvs-commit] Drivers/ccid/src commands.c,1.7,1.8

rousseau@quantz.debian.org rousseau@quantz.debian.org
Thu, 15 Jan 2004 15:19:04 +0100


Update of /cvsroot/pcsclite/Drivers/ccid/src
In directory quantz:/tmp/cvs-serv23036

Modified Files:
	commands.c 
Log Message:
add SetParameters() CCID command


Index: commands.c
===================================================================
RCS file: /cvsroot/pcsclite/Drivers/ccid/src/commands.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- commands.c	15 Jan 2004 14:09:10 -0000	1.7
+++ commands.c	15 Jan 2004 14:19:02 -0000	1.8
@@ -433,6 +433,43 @@
 
 /*****************************************************************************
  *
+ *					SetParameters
+ *
+ ****************************************************************************/
+RESPONSECODE SetParameters(int lun, char protocol, int length, unsigned char buffer[])
+{
+	unsigned char cmd[10+CMD_BUF_SIZE];	/* CCID + APDU buffer */
+	_ccid_descriptor *ccid_descriptor = get_ccid_descriptor(lun);
+
+	DEBUG_COMM2("length: %d bytes", length);
+
+	cmd[0] = 0x61; /* SetParameters */
+	i2dw(length, cmd+1);	/* APDU length */
+	cmd[5] = 0;	/* slot number */
+	cmd[6] = ccid_descriptor->bSeq++;
+	cmd[7] = protocol;	/* bProtocolNum */
+	cmd[8] = cmd[9] = 0; /* RFU */
+	memcpy(cmd+10, buffer, length);
+
+	if (WritePort(lun, 10+length, cmd) != STATUS_SUCCESS)
+		return IFD_COMMUNICATION_ERROR;
+
+	length = sizeof(cmd);
+	if (ReadPort(lun, &length, cmd) != STATUS_SUCCESS)
+		return IFD_COMMUNICATION_ERROR;
+
+	if (cmd[STATUS_OFFSET] & CCID_COMMAND_FAILED)
+	{
+		ccid_error(cmd[ERROR_OFFSET], __FILE__, __LINE__);    /* bError */
+		return IFD_COMMUNICATION_ERROR;
+	}
+
+	return IFD_SUCCESS;
+} /* SetParameters */
+
+
+/*****************************************************************************
+ *
  *					i2dw
  *
  ****************************************************************************/