[SmartcardServices-Changes] [37] trunk/SmartCardServices/src/PCSC
source_changes at macosforge.org
source_changes at macosforge.org
Thu Jul 30 03:59:13 PDT 2009
Revision: 37
http://trac.macosforge.org/projects/smartcardservices/changeset/37
Author: ludovic.rousseau at gmail.com
Date: 2009-07-30 03:59:13 -0700 (Thu, 30 Jul 2009)
Log Message:
-----------
move pcsc_stringify_error() definition in its own file
Modified Paths:
--------------
trunk/SmartCardServices/src/PCSC/debuglog.c
Added Paths:
-----------
trunk/SmartCardServices/src/PCSC/error.c
Modified: trunk/SmartCardServices/src/PCSC/debuglog.c
===================================================================
--- trunk/SmartCardServices/src/PCSC/debuglog.c 2009-07-30 10:56:49 UTC (rev 36)
+++ trunk/SmartCardServices/src/PCSC/debuglog.c 2009-07-30 10:59:13 UTC (rev 37)
@@ -297,130 +297,3 @@
} /* debug_xxd */
#endif
-char *pcsc_stringify_error(const int32_t Error)
-{
-
- static char strError[75];
-
- switch (Error)
- {
- case SCARD_S_SUCCESS:
- strcpy(strError, "Command successful.");
- break;
- case SCARD_E_CANCELLED:
- strcpy(strError, "Command cancelled.");
- break;
- case SCARD_E_CANT_DISPOSE:
- strcpy(strError, "Cannot dispose handle.");
- break;
- case SCARD_E_INSUFFICIENT_BUFFER:
- strcpy(strError, "Insufficient buffer.");
- break;
- case SCARD_E_INVALID_ATR:
- strcpy(strError, "Invalid ATR.");
- break;
- case SCARD_E_INVALID_HANDLE:
- strcpy(strError, "Invalid handle.");
- break;
- case SCARD_E_INVALID_PARAMETER:
- strcpy(strError, "Invalid parameter given.");
- break;
- case SCARD_E_INVALID_TARGET:
- strcpy(strError, "Invalid target given.");
- break;
- case SCARD_E_INVALID_VALUE:
- strcpy(strError, "Invalid value given.");
- break;
- case SCARD_E_NO_MEMORY:
- strcpy(strError, "Not enough memory.");
- break;
- case SCARD_F_COMM_ERROR:
- strcpy(strError, "RPC transport error.");
- break;
- case SCARD_F_INTERNAL_ERROR:
- strcpy(strError, "Unknown internal error.");
- break;
- case SCARD_F_UNKNOWN_ERROR:
- strcpy(strError, "Unknown internal error.");
- break;
- case SCARD_F_WAITED_TOO_LONG:
- strcpy(strError, "Waited too long.");
- break;
- case SCARD_E_UNKNOWN_READER:
- strcpy(strError, "Unknown reader specified.");
- break;
- case SCARD_E_TIMEOUT:
- strcpy(strError, "Command timeout.");
- break;
- case SCARD_E_SHARING_VIOLATION:
- strcpy(strError, "Sharing violation.");
- break;
- case SCARD_E_NO_SMARTCARD:
- strcpy(strError, "No smartcard inserted.");
- break;
- case SCARD_E_UNKNOWN_CARD:
- strcpy(strError, "Unknown card.");
- break;
- case SCARD_E_PROTO_MISMATCH:
- strcpy(strError, "Card protocol mismatch.");
- break;
- case SCARD_E_NOT_READY:
- strcpy(strError, "Subsystem not ready.");
- break;
- case SCARD_E_SYSTEM_CANCELLED:
- strcpy(strError, "System cancelled.");
- break;
- case SCARD_E_NOT_TRANSACTED:
- strcpy(strError, "Transaction failed.");
- break;
- case SCARD_E_READER_UNAVAILABLE:
- strcpy(strError, "Reader/s is unavailable.");
- break;
- case SCARD_W_UNSUPPORTED_CARD:
- strcpy(strError, "Card is not supported.");
- break;
- case SCARD_W_UNRESPONSIVE_CARD:
- strcpy(strError, "Card is unresponsive.");
- break;
- case SCARD_W_UNPOWERED_CARD:
- strcpy(strError, "Card is unpowered.");
- break;
- case SCARD_W_RESET_CARD:
- strcpy(strError, "Card was reset.");
- break;
- case SCARD_W_REMOVED_CARD:
- strcpy(strError, "Card was removed.");
- break;
- case SCARD_W_INSERTED_CARD:
- strcpy(strError, "Card was inserted.");
- break;
- case SCARD_E_UNSUPPORTED_FEATURE:
- strcpy(strError, "Feature not supported.");
- break;
- case SCARD_E_PCI_TOO_SMALL:
- strcpy(strError, "PCI struct too small.");
- break;
- case SCARD_E_READER_UNSUPPORTED:
- strcpy(strError, "Reader is unsupported.");
- break;
- case SCARD_E_DUPLICATE_READER:
- strcpy(strError, "Reader already exists.");
- break;
- case SCARD_E_CARD_UNSUPPORTED:
- strcpy(strError, "Card is unsupported.");
- break;
- case SCARD_E_NO_SERVICE:
- strcpy(strError, "Service not available.");
- break;
- case SCARD_E_SERVICE_STOPPED:
- strcpy(strError, "Service was stopped.");
- break;
- default:
- sprintf(strError, "Unknown PCSC error: %d [0x%08X]", Error, Error);
- break;
-
- };
-
- return strError;
-}
-
Added: trunk/SmartCardServices/src/PCSC/error.c
===================================================================
--- trunk/SmartCardServices/src/PCSC/error.c (rev 0)
+++ trunk/SmartCardServices/src/PCSC/error.c 2009-07-30 10:59:13 UTC (rev 37)
@@ -0,0 +1,176 @@
+/*
+ * MUSCLE SmartCard Development ( http://www.linuxnet.com )
+ *
+ * Copyright (C) 1999-2002
+ * David Corcoran <corcoran at linuxnet.com>
+ * Copyright (C) 1999-2008
+ * Ludovic Rousseau <ludovic.rousseau at free.fr>
+ *
+ * This file is dual licenced:
+ * - BSD-like, see the COPYING file
+ * - GNU Lesser General Licence 2.1 or (at your option) any later version.
+ *
+ * $Id: debuglog.c 1827 2006-01-24 14:49:52Z rousseau $
+ */
+
+/**
+ * @file
+ * @brief This handles pcsc_stringify_error()
+ */
+
+#include <stdio.h>
+#include <sys/types.h>
+
+#include "pcscexport.h"
+#include "pcsclite.h"
+#include "string.h"
+
+/**
+ * @brief This function return a human readable text for the given PC/SC error
+ * code.
+ *
+ * @ingroup API
+ * @param[in] pcscError Error code to be translated to text.
+ *
+ * @return Text representing the error code passed.
+ *
+ * @code
+ * SCARDCONTEXT hContext;
+ * LONG rv;
+ * rv = SCardEstablishContext(SCARD_SCOPE_SYSTEM, NULL, NULL, &hContext);
+ * if (rv != SCARD_S_SUCCESS)
+ * printf("SCardReleaseContext: %s (0x%lX)\n",
+ * pcsc_stringify_error(rv), rv);
+ * @endcode
+ */
+PCSC_API char* pcsc_stringify_error(int32_t pcscError)
+{
+ static char strError[75];
+
+ switch (pcscError)
+ {
+ case SCARD_S_SUCCESS:
+ (void)strlcpy(strError, "Command successful.", sizeof(strError));
+ break;
+ case SCARD_E_CANCELLED:
+ (void)strlcpy(strError, "Command cancelled.", sizeof(strError));
+ break;
+ case SCARD_E_CANT_DISPOSE:
+ (void)strlcpy(strError, "Cannot dispose handle.", sizeof(strError));
+ break;
+ case SCARD_E_INSUFFICIENT_BUFFER:
+ (void)strlcpy(strError, "Insufficient buffer.", sizeof(strError));
+ break;
+ case SCARD_E_INVALID_ATR:
+ (void)strlcpy(strError, "Invalid ATR.", sizeof(strError));
+ break;
+ case SCARD_E_INVALID_HANDLE:
+ (void)strlcpy(strError, "Invalid handle.", sizeof(strError));
+ break;
+ case SCARD_E_INVALID_PARAMETER:
+ (void)strlcpy(strError, "Invalid parameter given.", sizeof(strError));
+ break;
+ case SCARD_E_INVALID_TARGET:
+ (void)strlcpy(strError, "Invalid target given.", sizeof(strError));
+ break;
+ case SCARD_E_INVALID_VALUE:
+ (void)strlcpy(strError, "Invalid value given.", sizeof(strError));
+ break;
+ case SCARD_E_NO_MEMORY:
+ (void)strlcpy(strError, "Not enough memory.", sizeof(strError));
+ break;
+ case SCARD_F_COMM_ERROR:
+ (void)strlcpy(strError, "RPC transport error.", sizeof(strError));
+ break;
+ case SCARD_F_INTERNAL_ERROR:
+ (void)strlcpy(strError, "Internal error.", sizeof(strError));
+ break;
+ case SCARD_F_UNKNOWN_ERROR:
+ (void)strlcpy(strError, "Unknown error.", sizeof(strError));
+ break;
+ case SCARD_F_WAITED_TOO_LONG:
+ (void)strlcpy(strError, "Waited too long.", sizeof(strError));
+ break;
+ case SCARD_E_UNKNOWN_READER:
+ (void)strlcpy(strError, "Unknown reader specified.", sizeof(strError));
+ break;
+ case SCARD_E_TIMEOUT:
+ (void)strlcpy(strError, "Command timeout.", sizeof(strError));
+ break;
+ case SCARD_E_SHARING_VIOLATION:
+ (void)strlcpy(strError, "Sharing violation.", sizeof(strError));
+ break;
+ case SCARD_E_NO_SMARTCARD:
+ (void)strlcpy(strError, "No smart card inserted.", sizeof(strError));
+ break;
+ case SCARD_E_UNKNOWN_CARD:
+ (void)strlcpy(strError, "Unknown card.", sizeof(strError));
+ break;
+ case SCARD_E_PROTO_MISMATCH:
+ (void)strlcpy(strError, "Card protocol mismatch.", sizeof(strError));
+ break;
+ case SCARD_E_NOT_READY:
+ (void)strlcpy(strError, "Subsystem not ready.", sizeof(strError));
+ break;
+ case SCARD_E_SYSTEM_CANCELLED:
+ (void)strlcpy(strError, "System cancelled.", sizeof(strError));
+ break;
+ case SCARD_E_NOT_TRANSACTED:
+ (void)strlcpy(strError, "Transaction failed.", sizeof(strError));
+ break;
+ case SCARD_E_READER_UNAVAILABLE:
+ (void)strlcpy(strError, "Reader is unavailable.", sizeof(strError));
+ break;
+ case SCARD_W_UNSUPPORTED_CARD:
+ (void)strlcpy(strError, "Card is not supported.", sizeof(strError));
+ break;
+ case SCARD_W_UNRESPONSIVE_CARD:
+ (void)strlcpy(strError, "Card is unresponsive.", sizeof(strError));
+ break;
+ case SCARD_W_UNPOWERED_CARD:
+ (void)strlcpy(strError, "Card is unpowered.", sizeof(strError));
+ break;
+ case SCARD_W_RESET_CARD:
+ (void)strlcpy(strError, "Card was reset.", sizeof(strError));
+ break;
+ case SCARD_W_REMOVED_CARD:
+ (void)strlcpy(strError, "Card was removed.", sizeof(strError));
+ break;
+ case SCARD_W_INSERTED_CARD:
+ (void)strlcpy(strError, "Card was inserted.", sizeof(strError));
+ break;
+ case SCARD_E_UNSUPPORTED_FEATURE:
+ (void)strlcpy(strError, "Feature not supported.", sizeof(strError));
+ break;
+ case SCARD_E_PCI_TOO_SMALL:
+ (void)strlcpy(strError, "PCI struct too small.", sizeof(strError));
+ break;
+ case SCARD_E_READER_UNSUPPORTED:
+ (void)strlcpy(strError, "Reader is unsupported.", sizeof(strError));
+ break;
+ case SCARD_E_DUPLICATE_READER:
+ (void)strlcpy(strError, "Reader already exists.", sizeof(strError));
+ break;
+ case SCARD_E_CARD_UNSUPPORTED:
+ (void)strlcpy(strError, "Card is unsupported.", sizeof(strError));
+ break;
+ case SCARD_E_NO_SERVICE:
+ (void)strlcpy(strError, "Service not available.", sizeof(strError));
+ break;
+ case SCARD_E_SERVICE_STOPPED:
+ (void)strlcpy(strError, "Service was stopped.", sizeof(strError));
+ break;
+ case SCARD_E_NO_READERS_AVAILABLE:
+ (void)strlcpy(strError, "Cannot find a smart card reader.", sizeof(strError));
+ break;
+ default:
+ (void)snprintf(strError, sizeof(strError)-1, "Unkown error: 0x%08X",
+ pcscError);
+ };
+
+ /* add a null byte */
+ strError[sizeof(strError)-1] = '\0';
+
+ return strError;
+}
+
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/smartcardservices-changes/attachments/20090730/d4570733/attachment-0001.html>
More information about the SmartcardServices-Changes
mailing list