just issue a warning in case of a missing attribute, patch supplied by Philipp Marek (with some changes from me)

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2094 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
nils 2005-01-23 19:48:48 +00:00
parent 02ff1ad9b9
commit f66913ca30
1 changed files with 13 additions and 5 deletions

View File

@ -171,6 +171,7 @@ static void get_token_info(CK_SLOT_ID, CK_TOKEN_INFO_PTR);
static CK_ULONG get_mechanisms(CK_SLOT_ID,
CK_MECHANISM_TYPE_PTR *, CK_FLAGS);
static void p11_fatal(const char *, CK_RV);
static void p11_warn(const char *, CK_RV);
static const char * p11_slot_info_flags(CK_FLAGS);
static const char * p11_token_info_flags(CK_FLAGS);
static const char * p11_utf8_to_local(CK_UTF8CHAR *, size_t);
@ -1142,7 +1143,7 @@ get##ATTR(CK_SESSION_HANDLE sess, CK_OBJECT_HANDLE obj) \
\
rv = p11->C_GetAttributeValue(sess, obj, &attr, 1); \
if (rv != CKR_OK) \
p11_fatal("C_GetAttributeValue(" #ATTR ")", rv); \
p11_warn("C_GetAttributeValue(" #ATTR ")", rv); \
return type; \
}
@ -1158,11 +1159,11 @@ get##ATTR(CK_SESSION_HANDLE sess, CK_OBJECT_HANDLE obj, CK_ULONG_PTR pulCount) \
if (!(attr.pValue = calloc(1, attr.ulValueLen + 1))) \
fatal("out of memory in get" #ATTR ": %m"); \
rv = p11->C_GetAttributeValue(sess, obj, &attr, 1); \
if (pulCount) \
*pulCount = attr.ulValueLen / sizeof(TYPE); \
} else {\
p11_warn("C_GetAttributeValue(" #ATTR ")", rv); \
} \
if (rv != CKR_OK) \
p11_fatal("C_GetAttributeValue(" #ATTR ")", rv); \
if (pulCount) \
*pulCount = attr.ulValueLen / sizeof(TYPE); \
return (TYPE *) attr.pValue; \
}
@ -2843,6 +2844,13 @@ p11_fatal(const char *func, CK_RV rv)
func, CKR2Str(rv), (unsigned int) rv);
}
void
p11_warn(const char *func, CK_RV rv)
{
warn("PKCS11 function %s failed: rv = %s (0x%0x)\n",
func, CKR2Str(rv), (unsigned int) rv);
}
void
p11_perror(const char *msg, CK_RV rv)
{