michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "ckdbm.h" michael@0: michael@0: static void michael@0: nss_dbm_mdObject_Finalize michael@0: ( michael@0: NSSCKMDObject *mdObject, michael@0: NSSCKFWObject *fwObject, michael@0: NSSCKMDSession *mdSession, michael@0: NSSCKFWSession *fwSession, michael@0: NSSCKMDToken *mdToken, michael@0: NSSCKFWToken *fwToken, michael@0: NSSCKMDInstance *mdInstance, michael@0: NSSCKFWInstance *fwInstance michael@0: ) michael@0: { michael@0: ; michael@0: } michael@0: michael@0: static CK_RV michael@0: nss_dbm_mdObject_Destroy michael@0: ( michael@0: NSSCKMDObject *mdObject, michael@0: NSSCKFWObject *fwObject, michael@0: NSSCKMDSession *mdSession, michael@0: NSSCKFWSession *fwSession, michael@0: NSSCKMDToken *mdToken, michael@0: NSSCKFWToken *fwToken, michael@0: NSSCKMDInstance *mdInstance, michael@0: NSSCKFWInstance *fwInstance michael@0: ) michael@0: { michael@0: nss_dbm_object_t *object = (nss_dbm_object_t *)mdObject->etc; michael@0: return nss_dbm_db_delete_object(object->handle); michael@0: } michael@0: michael@0: static CK_ULONG michael@0: nss_dbm_mdObject_GetAttributeCount michael@0: ( michael@0: NSSCKMDObject *mdObject, michael@0: NSSCKFWObject *fwObject, michael@0: NSSCKMDSession *mdSession, michael@0: NSSCKFWSession *fwSession, michael@0: NSSCKMDToken *mdToken, michael@0: NSSCKFWToken *fwToken, michael@0: NSSCKMDInstance *mdInstance, michael@0: NSSCKFWInstance *fwInstance, michael@0: CK_RV *pError michael@0: ) michael@0: { michael@0: nss_dbm_object_t *object = (nss_dbm_object_t *)mdObject->etc; michael@0: nss_dbm_session_t *session = (nss_dbm_session_t *)mdSession->etc; michael@0: return nss_dbm_db_get_object_attribute_count(object->handle, pError, michael@0: &session->deviceError); michael@0: } michael@0: michael@0: static CK_RV michael@0: nss_dbm_mdObject_GetAttributeTypes michael@0: ( michael@0: NSSCKMDObject *mdObject, michael@0: NSSCKFWObject *fwObject, michael@0: NSSCKMDSession *mdSession, michael@0: NSSCKFWSession *fwSession, michael@0: NSSCKMDToken *mdToken, michael@0: NSSCKFWToken *fwToken, michael@0: NSSCKMDInstance *mdInstance, michael@0: NSSCKFWInstance *fwInstance, michael@0: CK_ATTRIBUTE_TYPE_PTR typeArray, michael@0: CK_ULONG ulCount michael@0: ) michael@0: { michael@0: nss_dbm_object_t *object = (nss_dbm_object_t *)mdObject->etc; michael@0: nss_dbm_session_t *session = (nss_dbm_session_t *)mdSession->etc; michael@0: return nss_dbm_db_get_object_attribute_types(object->handle, typeArray, michael@0: ulCount, &session->deviceError); michael@0: } michael@0: michael@0: static CK_ULONG michael@0: nss_dbm_mdObject_GetAttributeSize michael@0: ( michael@0: NSSCKMDObject *mdObject, michael@0: NSSCKFWObject *fwObject, michael@0: NSSCKMDSession *mdSession, michael@0: NSSCKFWSession *fwSession, michael@0: NSSCKMDToken *mdToken, michael@0: NSSCKFWToken *fwToken, michael@0: NSSCKMDInstance *mdInstance, michael@0: NSSCKFWInstance *fwInstance, michael@0: CK_ATTRIBUTE_TYPE attribute, michael@0: CK_RV *pError michael@0: ) michael@0: { michael@0: nss_dbm_object_t *object = (nss_dbm_object_t *)mdObject->etc; michael@0: nss_dbm_session_t *session = (nss_dbm_session_t *)mdSession->etc; michael@0: return nss_dbm_db_get_object_attribute_size(object->handle, attribute, pError, michael@0: &session->deviceError); michael@0: } michael@0: michael@0: static NSSItem * michael@0: nss_dbm_mdObject_GetAttribute michael@0: ( michael@0: NSSCKMDObject *mdObject, michael@0: NSSCKFWObject *fwObject, michael@0: NSSCKMDSession *mdSession, michael@0: NSSCKFWSession *fwSession, michael@0: NSSCKMDToken *mdToken, michael@0: NSSCKFWToken *fwToken, michael@0: NSSCKMDInstance *mdInstance, michael@0: NSSCKFWInstance *fwInstance, michael@0: CK_ATTRIBUTE_TYPE attribute, michael@0: CK_RV *pError michael@0: ) michael@0: { michael@0: nss_dbm_object_t *object = (nss_dbm_object_t *)mdObject->etc; michael@0: nss_dbm_session_t *session = (nss_dbm_session_t *)mdSession->etc; michael@0: return nss_dbm_db_get_object_attribute(object->handle, object->arena, attribute, michael@0: pError, &session->deviceError); michael@0: } michael@0: michael@0: static CK_RV michael@0: nss_dbm_mdObject_SetAttribute michael@0: ( michael@0: NSSCKMDObject *mdObject, michael@0: NSSCKFWObject *fwObject, michael@0: NSSCKMDSession *mdSession, michael@0: NSSCKFWSession *fwSession, michael@0: NSSCKMDToken *mdToken, michael@0: NSSCKFWToken *fwToken, michael@0: NSSCKMDInstance *mdInstance, michael@0: NSSCKFWInstance *fwInstance, michael@0: CK_ATTRIBUTE_TYPE attribute, michael@0: NSSItem *value michael@0: ) michael@0: { michael@0: nss_dbm_object_t *object = (nss_dbm_object_t *)mdObject->etc; michael@0: nss_dbm_session_t *session = (nss_dbm_session_t *)mdSession->etc; michael@0: return nss_dbm_db_set_object_attribute(object->handle, attribute, value, michael@0: &session->deviceError); michael@0: } michael@0: michael@0: NSS_IMPLEMENT NSSCKMDObject * michael@0: nss_dbm_mdObject_factory michael@0: ( michael@0: nss_dbm_object_t *object, michael@0: CK_RV *pError michael@0: ) michael@0: { michael@0: NSSCKMDObject *rv; michael@0: michael@0: rv = nss_ZNEW(object->arena, NSSCKMDObject); michael@0: if( (NSSCKMDObject *)NULL == rv ) { michael@0: *pError = CKR_HOST_MEMORY; michael@0: return (NSSCKMDObject *)NULL; michael@0: } michael@0: michael@0: rv->etc = (void *)object; michael@0: rv->Finalize = nss_dbm_mdObject_Finalize; michael@0: rv->Destroy = nss_dbm_mdObject_Destroy; michael@0: /* IsTokenObject can be deferred */ michael@0: rv->GetAttributeCount = nss_dbm_mdObject_GetAttributeCount; michael@0: rv->GetAttributeTypes = nss_dbm_mdObject_GetAttributeTypes; michael@0: rv->GetAttributeSize = nss_dbm_mdObject_GetAttributeSize; michael@0: rv->GetAttribute = nss_dbm_mdObject_GetAttribute; michael@0: rv->SetAttribute = nss_dbm_mdObject_SetAttribute; michael@0: /* GetObjectSize can be deferred */ michael@0: michael@0: return rv; michael@0: }