From 5471aea023f07ec47575064e885135b2a94ad62e Mon Sep 17 00:00:00 2001 From: vtarasov Date: Wed, 27 Apr 2011 14:28:03 +0000 Subject: [PATCH] libopensc: new error code macros -- 'corrupted data' and 'file end reached' git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5404 c6295689-39f2-0310-b995-f0e70906c6a9 --- src/libopensc/errors.c | 11 ++++++++++- src/libopensc/errors.h | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/libopensc/errors.c b/src/libopensc/errors.c index be01c422..e8bff61b 100644 --- a/src/libopensc/errors.c +++ b/src/libopensc/errors.c @@ -48,6 +48,7 @@ const char *sc_strerror(int error) "Reader in use by another application" }; const int rdr_base = -SC_ERROR_READER; + const char *card_errors[] = { "Card command failed", "File not found", @@ -67,8 +68,11 @@ const char *sc_strerror(int error) "File already exists", "Data object not found", "Not enough memory on card", + "Part of returned data may be corrupted", + "End of file/record reached before reading Le bytes" }; const int card_base = -SC_ERROR_CARD_CMD_FAILED; + const char *arg_errors[] = { "Invalid arguments", "UNUSED", @@ -78,6 +82,7 @@ const char *sc_strerror(int error) "Invalid data", }; const int arg_base = -SC_ERROR_INVALID_ARGUMENTS; + const char *int_errors[] = { "Internal error", "Invalid ASN.1 object", @@ -98,6 +103,7 @@ const char *sc_strerror(int error) "Not implemented" }; const int int_base = -SC_ERROR_INTERNAL; + const char *p15i_errors[] = { "Generic PKCS#15 initialization error", "Syntax error", @@ -112,12 +118,14 @@ const char *sc_strerror(int error) "File too small", }; const int p15i_base = -SC_ERROR_PKCS15INIT; + const char *misc_errors[] = { "Unknown error", "PKCS#15 compatible smart card not found", }; - const char *no_errors = "Success"; const int misc_base = -SC_ERROR_UNKNOWN; + + const char *no_errors = "Success"; const char **errors = NULL; int count = 0, err_base = 0; @@ -125,6 +133,7 @@ const char *sc_strerror(int error) return no_errors; if (error < 0) error = -error; + if (error >= misc_base) { errors = misc_errors; count = DIM(misc_errors); diff --git a/src/libopensc/errors.h b/src/libopensc/errors.h index b3b54033..f9ac4f03 100644 --- a/src/libopensc/errors.h +++ b/src/libopensc/errors.h @@ -65,6 +65,8 @@ extern "C" { #define SC_ERROR_FILE_ALREADY_EXISTS -1215 #define SC_ERROR_DATA_OBJECT_NOT_FOUND -1216 #define SC_ERROR_NOT_ENOUGH_MEMORY -1217 +#define SC_ERROR_CORRUPTED_DATA -1218 +#define SC_ERROR_FILE_END_REACHED -1219 /* Returned by OpenSC library when called with invalid arguments */ #define SC_ERROR_INVALID_ARGUMENTS -1300