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

Generated on Fri Aug 17 19:23:08 2007 for pcsc-lite by  doxygen 1.4.7