00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
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_F_INTERNAL_ERROR:
00056 (void)strlcpy(strError, "Internal error.", sizeof(strError));
00057 break;
00058 case SCARD_E_CANCELLED:
00059 (void)strlcpy(strError, "Command cancelled.", sizeof(strError));
00060 break;
00061 case SCARD_E_INVALID_HANDLE:
00062 (void)strlcpy(strError, "Invalid handle.", sizeof(strError));
00063 break;
00064 case SCARD_E_INVALID_PARAMETER:
00065 (void)strlcpy(strError, "Invalid parameter given.", sizeof(strError));
00066 break;
00067 case SCARD_E_INVALID_TARGET:
00068 (void)strlcpy(strError, "Invalid target given.", sizeof(strError));
00069 break;
00070 case SCARD_E_NO_MEMORY:
00071 (void)strlcpy(strError, "Not enough memory.", sizeof(strError));
00072 break;
00073 case SCARD_F_WAITED_TOO_LONG:
00074 (void)strlcpy(strError, "Waited too long.", sizeof(strError));
00075 break;
00076 case SCARD_E_INSUFFICIENT_BUFFER:
00077 (void)strlcpy(strError, "Insufficient buffer.", sizeof(strError));
00078 break;
00079 case SCARD_E_UNKNOWN_READER:
00080 (void)strlcpy(strError, "Unknown reader specified.", sizeof(strError));
00081 break;
00082 case SCARD_E_TIMEOUT:
00083 (void)strlcpy(strError, "Command timeout.", sizeof(strError));
00084 break;
00085 case SCARD_E_SHARING_VIOLATION:
00086 (void)strlcpy(strError, "Sharing violation.", sizeof(strError));
00087 break;
00088 case SCARD_E_NO_SMARTCARD:
00089 (void)strlcpy(strError, "No smart card inserted.", sizeof(strError));
00090 break;
00091 case SCARD_E_UNKNOWN_CARD:
00092 (void)strlcpy(strError, "Unknown card.", sizeof(strError));
00093 break;
00094 case SCARD_E_CANT_DISPOSE:
00095 (void)strlcpy(strError, "Cannot dispose handle.", sizeof(strError));
00096 break;
00097 case SCARD_E_PROTO_MISMATCH:
00098 (void)strlcpy(strError, "Card protocol mismatch.", sizeof(strError));
00099 break;
00100 case SCARD_E_NOT_READY:
00101 (void)strlcpy(strError, "Subsystem not ready.", sizeof(strError));
00102 break;
00103 case SCARD_E_INVALID_VALUE:
00104 (void)strlcpy(strError, "Invalid value given.", sizeof(strError));
00105 break;
00106 case SCARD_E_SYSTEM_CANCELLED:
00107 (void)strlcpy(strError, "System cancelled.", sizeof(strError));
00108 break;
00109 case SCARD_F_COMM_ERROR:
00110 (void)strlcpy(strError, "RPC transport error.", sizeof(strError));
00111 break;
00112 case SCARD_F_UNKNOWN_ERROR:
00113 (void)strlcpy(strError, "Unknown error.", sizeof(strError));
00114 break;
00115 case SCARD_E_INVALID_ATR:
00116 (void)strlcpy(strError, "Invalid ATR.", 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
00125 case SCARD_E_PCI_TOO_SMALL:
00126 (void)strlcpy(strError, "PCI struct too small.", sizeof(strError));
00127 break;
00128 case SCARD_E_READER_UNSUPPORTED:
00129 (void)strlcpy(strError, "Reader is unsupported.", sizeof(strError));
00130 break;
00131 case SCARD_E_DUPLICATE_READER:
00132 (void)strlcpy(strError, "Reader already exists.", sizeof(strError));
00133 break;
00134 case SCARD_E_CARD_UNSUPPORTED:
00135 (void)strlcpy(strError, "Card is unsupported.", sizeof(strError));
00136 break;
00137 case SCARD_E_NO_SERVICE:
00138 (void)strlcpy(strError, "Service not available.", sizeof(strError));
00139 break;
00140 case SCARD_E_SERVICE_STOPPED:
00141 (void)strlcpy(strError, "Service was stopped.", sizeof(strError));
00142 break;
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156 case SCARD_E_NO_READERS_AVAILABLE:
00157 (void)strlcpy(strError, "Cannot find a smart card reader.", sizeof(strError));
00158 break;
00159
00160
00161
00162 case SCARD_W_UNSUPPORTED_CARD:
00163 (void)strlcpy(strError, "Card is not supported.", sizeof(strError));
00164 break;
00165 case SCARD_W_UNRESPONSIVE_CARD:
00166 (void)strlcpy(strError, "Card is unresponsive.", sizeof(strError));
00167 break;
00168 case SCARD_W_UNPOWERED_CARD:
00169 (void)strlcpy(strError, "Card is unpowered.", sizeof(strError));
00170 break;
00171 case SCARD_W_RESET_CARD:
00172 (void)strlcpy(strError, "Card was reset.", sizeof(strError));
00173 break;
00174 case SCARD_W_REMOVED_CARD:
00175 (void)strlcpy(strError, "Card was removed.", sizeof(strError));
00176 break;
00177
00178
00179
00180
00181
00182
00183
00184 case SCARD_E_UNSUPPORTED_FEATURE:
00185 (void)strlcpy(strError, "Feature not supported.", sizeof(strError));
00186 break;
00187 default:
00188 (void)snprintf(strError, sizeof(strError)-1, "Unkown error: 0x%08lX",
00189 pcscError);
00190 };
00191
00192
00193 strError[sizeof(strError)-1] = '\0';
00194
00195 return strError;
00196 }
00197