1
/* This Source Code Form is subject to the terms of the Mozilla Public
2
* License, v. 2.0. If a copy of the MPL was not distributed with this
3
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
8
nss_dbm_mdSlot_Initialize
12
NSSCKMDInstance *mdInstance,
13
NSSCKFWInstance *fwInstance
16
nss_dbm_slot_t *slot = (nss_dbm_slot_t *)mdSlot->etc;
17
nss_dbm_instance_t *instance = (nss_dbm_instance_t *)mdInstance->etc;
20
slot->token_db = nss_dbm_db_open(instance->arena, fwInstance, slot->filename,
22
if( (nss_dbm_db_t *)NULL == slot->token_db ) {
23
if( CKR_TOKEN_NOT_PRESENT == rv ) {
24
/* This is not an error-- just means "the token isn't there" */
33
nss_dbm_mdSlot_Destroy
37
NSSCKMDInstance *mdInstance,
38
NSSCKFWInstance *fwInstance
41
nss_dbm_slot_t *slot = (nss_dbm_slot_t *)mdSlot->etc;
43
if( (nss_dbm_db_t *)NULL != slot->token_db ) {
44
nss_dbm_db_close(slot->token_db);
45
slot->token_db = (nss_dbm_db_t *)NULL;
50
nss_dbm_mdSlot_GetSlotDescription
54
NSSCKMDInstance *mdInstance,
55
NSSCKFWInstance *fwInstance,
63
nss_dbm_mdSlot_GetManufacturerID
67
NSSCKMDInstance *mdInstance,
68
NSSCKFWInstance *fwInstance,
76
nss_dbm_mdSlot_GetTokenPresent
80
NSSCKMDInstance *mdInstance,
81
NSSCKFWInstance *fwInstance
84
nss_dbm_slot_t *slot = (nss_dbm_slot_t *)mdSlot->etc;
86
if( (nss_dbm_db_t *)NULL == slot->token_db ) {
94
nss_dbm_mdSlot_GetRemovableDevice
98
NSSCKMDInstance *mdInstance,
99
NSSCKFWInstance *fwInstance
103
* Well, this supports "tokens" (databases) that aren't there, so in
104
* that sense they're removable. It'd be nice to handle databases
105
* that suddenly disappear (NFS-mounted home directories and network
106
* errors, for instance) but that's a harder problem. We'll say
107
* we support removable devices, badly.
113
/* nss_dbm_mdSlot_GetHardwareSlot defaults to CK_FALSE */
115
* nss_dbm_mdSlot_GetHardwareVersion
116
* nss_dbm_mdSlot_GetFirmwareVersion
118
* These are kinda fuzzy concepts here. I suppose we could return the
119
* Berkeley DB version for one of them, if we had an actual number we
120
* were confident in. But mcom's "dbm" has been hacked enough that I
121
* don't really know from what "real" version it stems..
124
static NSSCKMDToken *
125
nss_dbm_mdSlot_GetToken
129
NSSCKMDInstance *mdInstance,
130
NSSCKFWInstance *fwInstance,
134
nss_dbm_slot_t *slot = (nss_dbm_slot_t *)mdSlot->etc;
135
return nss_dbm_mdToken_factory(slot, pError);
138
NSS_IMPLEMENT NSSCKMDSlot *
139
nss_dbm_mdSlot_factory
141
nss_dbm_instance_t *instance,
147
nss_dbm_slot_t *slot;
150
slot = nss_ZNEW(instance->arena, nss_dbm_slot_t);
151
if( (nss_dbm_slot_t *)NULL == slot ) {
152
*pError = CKR_HOST_MEMORY;
153
return (NSSCKMDSlot *)NULL;
156
slot->instance = instance;
157
slot->filename = filename;
159
slot->token_db = (nss_dbm_db_t *)NULL;
161
rv = nss_ZNEW(instance->arena, NSSCKMDSlot);
162
if( (NSSCKMDSlot *)NULL == rv ) {
163
*pError = CKR_HOST_MEMORY;
164
return (NSSCKMDSlot *)NULL;
167
rv->etc = (void *)slot;
168
rv->Initialize = nss_dbm_mdSlot_Initialize;
169
rv->Destroy = nss_dbm_mdSlot_Destroy;
170
rv->GetSlotDescription = nss_dbm_mdSlot_GetSlotDescription;
171
rv->GetManufacturerID = nss_dbm_mdSlot_GetManufacturerID;
172
rv->GetTokenPresent = nss_dbm_mdSlot_GetTokenPresent;
173
rv->GetRemovableDevice = nss_dbm_mdSlot_GetRemovableDevice;
174
/* GetHardwareSlot */
175
/* GetHardwareVersion */
176
/* GetFirmwareVersion */
177
rv->GetToken = nss_dbm_mdSlot_GetToken;
178
rv->null = (void *)NULL;