Textual output of SC_ERROR_* return codes in debug messages.

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4948 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
andre 2010-12-14 03:08:17 +00:00
parent eeee3f926f
commit 3cfe542813
3 changed files with 11 additions and 4 deletions

View File

@ -116,7 +116,7 @@ const char *sc_strerror(int error)
"Unknown error",
"PKCS#15 compatible smart card not found",
};
const char *no_errors = "No errors";
const char *no_errors = "Success";
const int misc_base = -SC_ERROR_UNKNOWN;
const char **errors = NULL;
int count = 0, err_base = 0;

View File

@ -65,14 +65,21 @@ char * sc_dump_hex(const u8 * in, size_t count);
#define SC_FUNC_RETURN(ctx, level, r) do { \
int _ret = r; \
sc_do_log(ctx, level, __FILE__, __LINE__, __FUNCTION__, "returning with: %d\n", _ret); \
if (_ret <= 0) { \
sc_do_log(ctx, level, __FILE__, __LINE__, __FUNCTION__, \
"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
} else { \
sc_do_log(ctx, level, __FILE__, __LINE__, __FUNCTION__, \
"returning with: %d\n", _ret); \
} \
return _ret; \
} while(0)
#define SC_TEST_RET(ctx, level, r, text) do { \
int _ret = (r); \
if (_ret < 0) { \
sc_do_log(ctx, level, __FILE__, __LINE__, __FUNCTION__, "%s: %s\n", (text), sc_strerror(_ret)); \
sc_do_log(ctx, level, __FILE__, __LINE__, __FUNCTION__, \
"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
return _ret; \
} \
} while(0)

View File

@ -56,7 +56,7 @@ void strcpy_bp(u8 * dst, const char *src, size_t dstsize)
static CK_RV sc_to_cryptoki_error_common(int rc)
{
sc_debug(context, SC_LOG_DEBUG_NORMAL, "opensc error: %s (%d)\n", sc_strerror(rc), rc);
sc_debug(context, SC_LOG_DEBUG_NORMAL, "libopensc return value: %d (%s)\n", rc, sc_strerror(rc));
switch (rc) {
case SC_SUCCESS:
return CKR_OK;