[Pcsclite-cvs-commit] r1953 - trunk/PCSC/src
Ludovic Rousseau
rousseau at costa.debian.org
Tue Mar 21 14:46:29 CET 2006
Author: rousseau
Date: 2006-03-21 13:46:28 +0000 (Tue, 21 Mar 2006)
New Revision: 1953
Added:
trunk/PCSC/src/error.c
Modified:
trunk/PCSC/src/debuglog.c
Log:
move pcsc_stringify_error() in its own file
Modified: trunk/PCSC/src/debuglog.c
===================================================================
--- trunk/PCSC/src/debuglog.c 2006-03-21 10:08:23 UTC (rev 1952)
+++ trunk/PCSC/src/debuglog.c 2006-03-21 13:46:28 UTC (rev 1953)
@@ -250,151 +250,6 @@
log_xxd(PCSC_LOG_INFO, "SW: ", (const unsigned char *)buffer, len);
}
-/**
- * @brief This function return a human readable text for the given PC/SC error code.
- *
- * @param[in] pcscError Error code to be translated to text.
- *
- * @return Text representing de error code passed.
- *
- * @test
- * @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
- */
-char* pcsc_stringify_error(long pcscError)
-{
- static char strError[75];
-
- switch (pcscError)
- {
- case SCARD_S_SUCCESS:
- strlcpy(strError, "Command successful.", sizeof(strError));
- break;
- case SCARD_E_CANCELLED:
- strlcpy(strError, "Command cancelled.", sizeof(strError));
- break;
- case SCARD_E_CANT_DISPOSE:
- strlcpy(strError, "Cannot dispose handle.", sizeof(strError));
- break;
- case SCARD_E_INSUFFICIENT_BUFFER:
- strlcpy(strError, "Insufficient buffer.", sizeof(strError));
- break;
- case SCARD_E_INVALID_ATR:
- strlcpy(strError, "Invalid ATR.", sizeof(strError));
- break;
- case SCARD_E_INVALID_HANDLE:
- strlcpy(strError, "Invalid handle.", sizeof(strError));
- break;
- case SCARD_E_INVALID_PARAMETER:
- strlcpy(strError, "Invalid parameter given.", sizeof(strError));
- break;
- case SCARD_E_INVALID_TARGET:
- strlcpy(strError, "Invalid target given.", sizeof(strError));
- break;
- case SCARD_E_INVALID_VALUE:
- strlcpy(strError, "Invalid value given.", sizeof(strError));
- break;
- case SCARD_E_NO_MEMORY:
- strlcpy(strError, "Not enough memory.", sizeof(strError));
- break;
- case SCARD_F_COMM_ERROR:
- strlcpy(strError, "RPC transport error.", sizeof(strError));
- break;
- case SCARD_F_INTERNAL_ERROR:
- strlcpy(strError, "Internal error.", sizeof(strError));
- break;
- case SCARD_F_UNKNOWN_ERROR:
- strlcpy(strError, "Unknown error.", sizeof(strError));
- break;
- case SCARD_F_WAITED_TOO_LONG:
- strlcpy(strError, "Waited too long.", sizeof(strError));
- break;
- case SCARD_E_UNKNOWN_READER:
- strlcpy(strError, "Unknown reader specified.", sizeof(strError));
- break;
- case SCARD_E_TIMEOUT:
- strlcpy(strError, "Command timeout.", sizeof(strError));
- break;
- case SCARD_E_SHARING_VIOLATION:
- strlcpy(strError, "Sharing violation.", sizeof(strError));
- break;
- case SCARD_E_NO_SMARTCARD:
- strlcpy(strError, "No smart card inserted.", sizeof(strError));
- break;
- case SCARD_E_UNKNOWN_CARD:
- strlcpy(strError, "Unknown card.", sizeof(strError));
- break;
- case SCARD_E_PROTO_MISMATCH:
- strlcpy(strError, "Card protocol mismatch.", sizeof(strError));
- break;
- case SCARD_E_NOT_READY:
- strlcpy(strError, "Subsystem not ready.", sizeof(strError));
- break;
- case SCARD_E_SYSTEM_CANCELLED:
- strlcpy(strError, "System cancelled.", sizeof(strError));
- break;
- case SCARD_E_NOT_TRANSACTED:
- strlcpy(strError, "Transaction failed.", sizeof(strError));
- break;
- case SCARD_E_READER_UNAVAILABLE:
- strlcpy(strError, "Reader is unavailable.", sizeof(strError));
- break;
- case SCARD_W_UNSUPPORTED_CARD:
- strlcpy(strError, "Card is not supported.", sizeof(strError));
- break;
- case SCARD_W_UNRESPONSIVE_CARD:
- strlcpy(strError, "Card is unresponsive.", sizeof(strError));
- break;
- case SCARD_W_UNPOWERED_CARD:
- strlcpy(strError, "Card is unpowered.", sizeof(strError));
- break;
- case SCARD_W_RESET_CARD:
- strlcpy(strError, "Card was reset.", sizeof(strError));
- break;
- case SCARD_W_REMOVED_CARD:
- strlcpy(strError, "Card was removed.", sizeof(strError));
- break;
- case SCARD_W_INSERTED_CARD:
- strlcpy(strError, "Card was inserted.", sizeof(strError));
- break;
- case SCARD_E_UNSUPPORTED_FEATURE:
- strlcpy(strError, "Feature not supported.", sizeof(strError));
- break;
- case SCARD_E_PCI_TOO_SMALL:
- strlcpy(strError, "PCI struct too small.", sizeof(strError));
- break;
- case SCARD_E_READER_UNSUPPORTED:
- strlcpy(strError, "Reader is unsupported.", sizeof(strError));
- break;
- case SCARD_E_DUPLICATE_READER:
- strlcpy(strError, "Reader already exists.", sizeof(strError));
- break;
- case SCARD_E_CARD_UNSUPPORTED:
- strlcpy(strError, "Card is unsupported.", sizeof(strError));
- break;
- case SCARD_E_NO_SERVICE:
- strlcpy(strError, "Service not available.", sizeof(strError));
- break;
- case SCARD_E_SERVICE_STOPPED:
- strlcpy(strError, "Service was stopped.", sizeof(strError));
- break;
- default:
- snprintf(strError, sizeof(strError)-1, "Unkown error: 0x%08lX",
- pcscError);
- };
-
- /* add a null byte */
- strError[sizeof(strError)] = '\0';
-
- return strError;
-}
-
/*
* old function supported for backward object code compatibility
* defined only for pcscd
Added: trunk/PCSC/src/error.c
===================================================================
--- trunk/PCSC/src/error.c 2006-03-21 10:08:23 UTC (rev 1952)
+++ trunk/PCSC/src/error.c 2006-03-21 13:46:28 UTC (rev 1953)
@@ -0,0 +1,169 @@
+/*
+ * MUSCLE SmartCard Development ( http://www.linuxnet.com )
+ *
+ * Copyright (C) 1999-2002
+ * David Corcoran <corcoran at linuxnet.com>
+ * Copyright (C) 1999-2005
+ * Ludovic Rousseau <ludovic.rousseau at free.fr>
+ *
+ * $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 "misc.h"
+#include "pcsclite.h"
+#include "strlcpycat.h"
+
+/**
+ * @brief This function return a human readable text for the given PC/SC error code.
+ *
+ * @param[in] pcscError Error code to be translated to text.
+ *
+ * @return Text representing de error code passed.
+ *
+ * @test
+ * @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(long pcscError)
+{
+ static char strError[75];
+
+ switch (pcscError)
+ {
+ case SCARD_S_SUCCESS:
+ strlcpy(strError, "Command successful.", sizeof(strError));
+ break;
+ case SCARD_E_CANCELLED:
+ strlcpy(strError, "Command cancelled.", sizeof(strError));
+ break;
+ case SCARD_E_CANT_DISPOSE:
+ strlcpy(strError, "Cannot dispose handle.", sizeof(strError));
+ break;
+ case SCARD_E_INSUFFICIENT_BUFFER:
+ strlcpy(strError, "Insufficient buffer.", sizeof(strError));
+ break;
+ case SCARD_E_INVALID_ATR:
+ strlcpy(strError, "Invalid ATR.", sizeof(strError));
+ break;
+ case SCARD_E_INVALID_HANDLE:
+ strlcpy(strError, "Invalid handle.", sizeof(strError));
+ break;
+ case SCARD_E_INVALID_PARAMETER:
+ strlcpy(strError, "Invalid parameter given.", sizeof(strError));
+ break;
+ case SCARD_E_INVALID_TARGET:
+ strlcpy(strError, "Invalid target given.", sizeof(strError));
+ break;
+ case SCARD_E_INVALID_VALUE:
+ strlcpy(strError, "Invalid value given.", sizeof(strError));
+ break;
+ case SCARD_E_NO_MEMORY:
+ strlcpy(strError, "Not enough memory.", sizeof(strError));
+ break;
+ case SCARD_F_COMM_ERROR:
+ strlcpy(strError, "RPC transport error.", sizeof(strError));
+ break;
+ case SCARD_F_INTERNAL_ERROR:
+ strlcpy(strError, "Internal error.", sizeof(strError));
+ break;
+ case SCARD_F_UNKNOWN_ERROR:
+ strlcpy(strError, "Unknown error.", sizeof(strError));
+ break;
+ case SCARD_F_WAITED_TOO_LONG:
+ strlcpy(strError, "Waited too long.", sizeof(strError));
+ break;
+ case SCARD_E_UNKNOWN_READER:
+ strlcpy(strError, "Unknown reader specified.", sizeof(strError));
+ break;
+ case SCARD_E_TIMEOUT:
+ strlcpy(strError, "Command timeout.", sizeof(strError));
+ break;
+ case SCARD_E_SHARING_VIOLATION:
+ strlcpy(strError, "Sharing violation.", sizeof(strError));
+ break;
+ case SCARD_E_NO_SMARTCARD:
+ strlcpy(strError, "No smart card inserted.", sizeof(strError));
+ break;
+ case SCARD_E_UNKNOWN_CARD:
+ strlcpy(strError, "Unknown card.", sizeof(strError));
+ break;
+ case SCARD_E_PROTO_MISMATCH:
+ strlcpy(strError, "Card protocol mismatch.", sizeof(strError));
+ break;
+ case SCARD_E_NOT_READY:
+ strlcpy(strError, "Subsystem not ready.", sizeof(strError));
+ break;
+ case SCARD_E_SYSTEM_CANCELLED:
+ strlcpy(strError, "System cancelled.", sizeof(strError));
+ break;
+ case SCARD_E_NOT_TRANSACTED:
+ strlcpy(strError, "Transaction failed.", sizeof(strError));
+ break;
+ case SCARD_E_READER_UNAVAILABLE:
+ strlcpy(strError, "Reader is unavailable.", sizeof(strError));
+ break;
+ case SCARD_W_UNSUPPORTED_CARD:
+ strlcpy(strError, "Card is not supported.", sizeof(strError));
+ break;
+ case SCARD_W_UNRESPONSIVE_CARD:
+ strlcpy(strError, "Card is unresponsive.", sizeof(strError));
+ break;
+ case SCARD_W_UNPOWERED_CARD:
+ strlcpy(strError, "Card is unpowered.", sizeof(strError));
+ break;
+ case SCARD_W_RESET_CARD:
+ strlcpy(strError, "Card was reset.", sizeof(strError));
+ break;
+ case SCARD_W_REMOVED_CARD:
+ strlcpy(strError, "Card was removed.", sizeof(strError));
+ break;
+ case SCARD_W_INSERTED_CARD:
+ strlcpy(strError, "Card was inserted.", sizeof(strError));
+ break;
+ case SCARD_E_UNSUPPORTED_FEATURE:
+ strlcpy(strError, "Feature not supported.", sizeof(strError));
+ break;
+ case SCARD_E_PCI_TOO_SMALL:
+ strlcpy(strError, "PCI struct too small.", sizeof(strError));
+ break;
+ case SCARD_E_READER_UNSUPPORTED:
+ strlcpy(strError, "Reader is unsupported.", sizeof(strError));
+ break;
+ case SCARD_E_DUPLICATE_READER:
+ strlcpy(strError, "Reader already exists.", sizeof(strError));
+ break;
+ case SCARD_E_CARD_UNSUPPORTED:
+ strlcpy(strError, "Card is unsupported.", sizeof(strError));
+ break;
+ case SCARD_E_NO_SERVICE:
+ strlcpy(strError, "Service not available.", sizeof(strError));
+ break;
+ case SCARD_E_SERVICE_STOPPED:
+ strlcpy(strError, "Service was stopped.", sizeof(strError));
+ break;
+ default:
+ snprintf(strError, sizeof(strError)-1, "Unkown error: 0x%08lX",
+ pcscError);
+ };
+
+ /* add a null byte */
+ strError[sizeof(strError)] = '\0';
+
+ return strError;
+}
+
+
More information about the Pcsclite-cvs-commit
mailing list