Main Page | Data Structures | File List | Data Fields | Globals | Related Pages

error.c

Go to the documentation of this file.
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-2005
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 
00045 PCSC_API char* pcsc_stringify_error(long pcscError)
00046 {
00047     static char strError[75];
00048 
00049     switch (pcscError)
00050     {
00051     case SCARD_S_SUCCESS:
00052         strlcpy(strError, "Command successful.", sizeof(strError));
00053         break;
00054     case SCARD_E_CANCELLED:
00055         strlcpy(strError, "Command cancelled.", sizeof(strError));
00056         break;
00057     case SCARD_E_CANT_DISPOSE:
00058         strlcpy(strError, "Cannot dispose handle.", sizeof(strError));
00059         break;
00060     case SCARD_E_INSUFFICIENT_BUFFER:
00061         strlcpy(strError, "Insufficient buffer.", sizeof(strError));
00062         break;
00063     case SCARD_E_INVALID_ATR:
00064         strlcpy(strError, "Invalid ATR.", sizeof(strError));
00065         break;
00066     case SCARD_E_INVALID_HANDLE:
00067         strlcpy(strError, "Invalid handle.", sizeof(strError));
00068         break;
00069     case SCARD_E_INVALID_PARAMETER:
00070         strlcpy(strError, "Invalid parameter given.", sizeof(strError));
00071         break;
00072     case SCARD_E_INVALID_TARGET:
00073         strlcpy(strError, "Invalid target given.", sizeof(strError));
00074         break;
00075     case SCARD_E_INVALID_VALUE:
00076         strlcpy(strError, "Invalid value given.", sizeof(strError));
00077         break;
00078     case SCARD_E_NO_MEMORY:
00079         strlcpy(strError, "Not enough memory.", sizeof(strError));
00080         break;
00081     case SCARD_F_COMM_ERROR:
00082         strlcpy(strError, "RPC transport error.", sizeof(strError));
00083         break;
00084     case SCARD_F_INTERNAL_ERROR:
00085         strlcpy(strError, "Internal error.", sizeof(strError));
00086         break;
00087     case SCARD_F_UNKNOWN_ERROR:
00088         strlcpy(strError, "Unknown error.", sizeof(strError));
00089         break;
00090     case SCARD_F_WAITED_TOO_LONG:
00091         strlcpy(strError, "Waited too long.", sizeof(strError));
00092         break;
00093     case SCARD_E_UNKNOWN_READER:
00094         strlcpy(strError, "Unknown reader specified.", sizeof(strError));
00095         break;
00096     case SCARD_E_TIMEOUT:
00097         strlcpy(strError, "Command timeout.", sizeof(strError));
00098         break;
00099     case SCARD_E_SHARING_VIOLATION:
00100         strlcpy(strError, "Sharing violation.", sizeof(strError));
00101         break;
00102     case SCARD_E_NO_SMARTCARD:
00103         strlcpy(strError, "No smart card inserted.", sizeof(strError));
00104         break;
00105     case SCARD_E_UNKNOWN_CARD:
00106         strlcpy(strError, "Unknown card.", sizeof(strError));
00107         break;
00108     case SCARD_E_PROTO_MISMATCH:
00109         strlcpy(strError, "Card protocol mismatch.", sizeof(strError));
00110         break;
00111     case SCARD_E_NOT_READY:
00112         strlcpy(strError, "Subsystem not ready.", sizeof(strError));
00113         break;
00114     case SCARD_E_SYSTEM_CANCELLED:
00115         strlcpy(strError, "System cancelled.", sizeof(strError));
00116         break;
00117     case SCARD_E_NOT_TRANSACTED:
00118         strlcpy(strError, "Transaction failed.", sizeof(strError));
00119         break;
00120     case SCARD_E_READER_UNAVAILABLE:
00121         strlcpy(strError, "Reader is unavailable.", sizeof(strError));
00122         break;
00123     case SCARD_W_UNSUPPORTED_CARD:
00124         strlcpy(strError, "Card is not supported.", sizeof(strError));
00125         break;
00126     case SCARD_W_UNRESPONSIVE_CARD:
00127         strlcpy(strError, "Card is unresponsive.", sizeof(strError));
00128         break;
00129     case SCARD_W_UNPOWERED_CARD:
00130         strlcpy(strError, "Card is unpowered.", sizeof(strError));
00131         break;
00132     case SCARD_W_RESET_CARD:
00133         strlcpy(strError, "Card was reset.", sizeof(strError));
00134         break;
00135     case SCARD_W_REMOVED_CARD:
00136         strlcpy(strError, "Card was removed.", sizeof(strError));
00137         break;
00138     case SCARD_W_INSERTED_CARD:
00139         strlcpy(strError, "Card was inserted.", sizeof(strError));
00140         break;
00141     case SCARD_E_UNSUPPORTED_FEATURE:
00142         strlcpy(strError, "Feature not supported.", sizeof(strError));
00143         break;
00144     case SCARD_E_PCI_TOO_SMALL:
00145         strlcpy(strError, "PCI struct too small.", sizeof(strError));
00146         break;
00147     case SCARD_E_READER_UNSUPPORTED:
00148         strlcpy(strError, "Reader is unsupported.", sizeof(strError));
00149         break;
00150     case SCARD_E_DUPLICATE_READER:
00151         strlcpy(strError, "Reader already exists.", sizeof(strError));
00152         break;
00153     case SCARD_E_CARD_UNSUPPORTED:
00154         strlcpy(strError, "Card is unsupported.", sizeof(strError));
00155         break;
00156     case SCARD_E_NO_SERVICE:
00157         strlcpy(strError, "Service not available.", sizeof(strError));
00158         break;
00159     case SCARD_E_SERVICE_STOPPED:
00160         strlcpy(strError, "Service was stopped.", sizeof(strError));
00161         break;
00162     default:
00163         snprintf(strError, sizeof(strError)-1, "Unkown error: 0x%08lX",
00164             pcscError);
00165     };
00166 
00167     /* add a null byte */
00168     strError[sizeof(strError)-1] = '\0';
00169 
00170     return strError;
00171 }
00172 
00173 

Generated on Fri Jan 26 22:54:53 2007 for pcsc-lite by  doxygen 1.3.9.1