pcsc-lite 1.5.5
|
00001 /* 00002 * MUSCLE SmartCard Development ( http://www.linuxnet.com ) 00003 * 00004 * Copyright (C) 1999-2002 00005 * David Corcoran <corcoran@linuxnet.com> 00006 * Copyright (C) 1999-2008 00007 * Ludovic Rousseau <ludovic.rousseau@free.fr> 00008 * 00009 * This file is dual licenced: 00010 * - BSD-like, see the COPYING file 00011 * - GNU Lesser General Licence 2.1 or (at your option) any later version. 00012 * 00013 * $Id: debuglog.c 1827 2006-01-24 14:49:52Z rousseau $ 00014 */ 00015 00021 #include <stdio.h> 00022 #include <sys/types.h> 00023 00024 #include "misc.h" 00025 #include "pcsclite.h" 00026 #include "strlcpycat.h" 00027 00046 PCSC_API char* pcsc_stringify_error(const long pcscError) 00047 { 00048 static char strError[75]; 00049 00050 switch (pcscError) 00051 { 00052 case SCARD_S_SUCCESS: 00053 (void)strlcpy(strError, "Command successful.", sizeof(strError)); 00054 break; 00055 case SCARD_E_CANCELLED: 00056 (void)strlcpy(strError, "Command cancelled.", sizeof(strError)); 00057 break; 00058 case SCARD_E_CANT_DISPOSE: 00059 (void)strlcpy(strError, "Cannot dispose handle.", sizeof(strError)); 00060 break; 00061 case SCARD_E_INSUFFICIENT_BUFFER: 00062 (void)strlcpy(strError, "Insufficient buffer.", sizeof(strError)); 00063 break; 00064 case SCARD_E_INVALID_ATR: 00065 (void)strlcpy(strError, "Invalid ATR.", sizeof(strError)); 00066 break; 00067 case SCARD_E_INVALID_HANDLE: 00068 (void)strlcpy(strError, "Invalid handle.", sizeof(strError)); 00069 break; 00070 case SCARD_E_INVALID_PARAMETER: 00071 (void)strlcpy(strError, "Invalid parameter given.", sizeof(strError)); 00072 break; 00073 case SCARD_E_INVALID_TARGET: 00074 (void)strlcpy(strError, "Invalid target given.", sizeof(strError)); 00075 break; 00076 case SCARD_E_INVALID_VALUE: 00077 (void)strlcpy(strError, "Invalid value given.", sizeof(strError)); 00078 break; 00079 case SCARD_E_NO_MEMORY: 00080 (void)strlcpy(strError, "Not enough memory.", sizeof(strError)); 00081 break; 00082 case SCARD_F_COMM_ERROR: 00083 (void)strlcpy(strError, "RPC transport error.", sizeof(strError)); 00084 break; 00085 case SCARD_F_INTERNAL_ERROR: 00086 (void)strlcpy(strError, "Internal error.", sizeof(strError)); 00087 break; 00088 case SCARD_F_UNKNOWN_ERROR: 00089 (void)strlcpy(strError, "Unknown error.", sizeof(strError)); 00090 break; 00091 case SCARD_F_WAITED_TOO_LONG: 00092 (void)strlcpy(strError, "Waited too long.", sizeof(strError)); 00093 break; 00094 case SCARD_E_UNKNOWN_READER: 00095 (void)strlcpy(strError, "Unknown reader specified.", sizeof(strError)); 00096 break; 00097 case SCARD_E_TIMEOUT: 00098 (void)strlcpy(strError, "Command timeout.", sizeof(strError)); 00099 break; 00100 case SCARD_E_SHARING_VIOLATION: 00101 (void)strlcpy(strError, "Sharing violation.", sizeof(strError)); 00102 break; 00103 case SCARD_E_NO_SMARTCARD: 00104 (void)strlcpy(strError, "No smart card inserted.", sizeof(strError)); 00105 break; 00106 case SCARD_E_UNKNOWN_CARD: 00107 (void)strlcpy(strError, "Unknown card.", sizeof(strError)); 00108 break; 00109 case SCARD_E_PROTO_MISMATCH: 00110 (void)strlcpy(strError, "Card protocol mismatch.", sizeof(strError)); 00111 break; 00112 case SCARD_E_NOT_READY: 00113 (void)strlcpy(strError, "Subsystem not ready.", sizeof(strError)); 00114 break; 00115 case SCARD_E_SYSTEM_CANCELLED: 00116 (void)strlcpy(strError, "System cancelled.", sizeof(strError)); 00117 break; 00118 case SCARD_E_NOT_TRANSACTED: 00119 (void)strlcpy(strError, "Transaction failed.", sizeof(strError)); 00120 break; 00121 case SCARD_E_READER_UNAVAILABLE: 00122 (void)strlcpy(strError, "Reader is unavailable.", sizeof(strError)); 00123 break; 00124 case SCARD_W_UNSUPPORTED_CARD: 00125 (void)strlcpy(strError, "Card is not supported.", sizeof(strError)); 00126 break; 00127 case SCARD_W_UNRESPONSIVE_CARD: 00128 (void)strlcpy(strError, "Card is unresponsive.", sizeof(strError)); 00129 break; 00130 case SCARD_W_UNPOWERED_CARD: 00131 (void)strlcpy(strError, "Card is unpowered.", sizeof(strError)); 00132 break; 00133 case SCARD_W_RESET_CARD: 00134 (void)strlcpy(strError, "Card was reset.", sizeof(strError)); 00135 break; 00136 case SCARD_W_REMOVED_CARD: 00137 (void)strlcpy(strError, "Card was removed.", sizeof(strError)); 00138 break; 00139 case SCARD_W_INSERTED_CARD: 00140 (void)strlcpy(strError, "Card was inserted.", sizeof(strError)); 00141 break; 00142 case SCARD_E_UNSUPPORTED_FEATURE: 00143 (void)strlcpy(strError, "Feature not supported.", sizeof(strError)); 00144 break; 00145 case SCARD_E_PCI_TOO_SMALL: 00146 (void)strlcpy(strError, "PCI struct too small.", sizeof(strError)); 00147 break; 00148 case SCARD_E_READER_UNSUPPORTED: 00149 (void)strlcpy(strError, "Reader is unsupported.", sizeof(strError)); 00150 break; 00151 case SCARD_E_DUPLICATE_READER: 00152 (void)strlcpy(strError, "Reader already exists.", sizeof(strError)); 00153 break; 00154 case SCARD_E_CARD_UNSUPPORTED: 00155 (void)strlcpy(strError, "Card is unsupported.", sizeof(strError)); 00156 break; 00157 case SCARD_E_NO_SERVICE: 00158 (void)strlcpy(strError, "Service not available.", sizeof(strError)); 00159 break; 00160 case SCARD_E_SERVICE_STOPPED: 00161 (void)strlcpy(strError, "Service was stopped.", sizeof(strError)); 00162 break; 00163 case SCARD_E_NO_READERS_AVAILABLE: 00164 (void)strlcpy(strError, "Cannot find a smart card reader.", sizeof(strError)); 00165 break; 00166 default: 00167 (void)snprintf(strError, sizeof(strError)-1, "Unkown error: 0x%08lX", 00168 pcscError); 00169 }; 00170 00171 /* add a null byte */ 00172 strError[sizeof(strError)-1] = '\0'; 00173 00174 return strError; 00175 } 00176