2
* The contents of this file are subject to the Mozilla Public
3
* License Version 1.1 (the "License"); you may not use this file
4
* except in compliance with the License. You may obtain a copy of
5
* the License at http://www.mozilla.org/MPL/
7
* Software distributed under the License is distributed on an "AS
8
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
9
* implied. See the License for the specific language governing
10
* rights and limitations under the License.
12
* The Original Code is the Netscape security libraries.
14
* The Initial Developer of the Original Code is Netscape
15
* Communications Corporation. Portions created by Netscape are
16
* Copyright (C) 1994-2000 Netscape Communications Corporation. All
21
* Alternatively, the contents of this file may be used under the
22
* terms of the GNU General Public License Version 2 or later (the
23
* "GPL"), in which case the provisions of the GPL are applicable
24
* instead of those above. If you wish to allow use of your
25
* version of this file only under the terms of the GPL and not to
26
* allow others to use your version of this file under the MPL,
27
* indicate your decision by deleting the provisions above and
28
* replace them with the notice and other provisions required by
29
* the GPL. If you do not delete the provisions above, a recipient
30
* may use your version of this file under either the MPL or the
35
static const char CVS_ID[] = "@(#) $RCSfile: slot.c,v $ $Revision: 1.1 $ $Date: 2000/05/15 20:39:57 $ $Name: FIREFOX_1_0_RELEASE $";
41
nss_dbm_mdSlot_Initialize
45
NSSCKMDInstance *mdInstance,
46
NSSCKFWInstance *fwInstance
49
nss_dbm_slot_t *slot = (nss_dbm_slot_t *)mdSlot->etc;
50
nss_dbm_instance_t *instance = (nss_dbm_instance_t *)mdInstance->etc;
53
slot->token_db = nss_dbm_db_open(instance->arena, fwInstance, slot->filename,
55
if( (nss_dbm_db_t *)NULL == slot->token_db ) {
56
if( CKR_TOKEN_NOT_PRESENT == rv ) {
57
/* This is not an error-- just means "the token isn't there" */
66
nss_dbm_mdSlot_Destroy
70
NSSCKMDInstance *mdInstance,
71
NSSCKFWInstance *fwInstance
74
nss_dbm_slot_t *slot = (nss_dbm_slot_t *)mdSlot->etc;
76
if( (nss_dbm_db_t *)NULL != slot->token_db ) {
77
nss_dbm_db_close(slot->token_db);
78
slot->token_db = (nss_dbm_db_t *)NULL;
83
nss_dbm_mdSlot_GetSlotDescription
87
NSSCKMDInstance *mdInstance,
88
NSSCKFWInstance *fwInstance,
96
nss_dbm_mdSlot_GetManufacturerID
100
NSSCKMDInstance *mdInstance,
101
NSSCKFWInstance *fwInstance,
109
nss_dbm_mdSlot_GetTokenPresent
113
NSSCKMDInstance *mdInstance,
114
NSSCKFWInstance *fwInstance
117
nss_dbm_slot_t *slot = (nss_dbm_slot_t *)mdSlot->etc;
119
if( (nss_dbm_db_t *)NULL == slot->token_db ) {
127
nss_dbm_mdSlot_GetRemovableDevice
131
NSSCKMDInstance *mdInstance,
132
NSSCKFWInstance *fwInstance
136
* Well, this supports "tokens" (databases) that aren't there, so in
137
* that sense they're removable. It'd be nice to handle databases
138
* that suddenly disappear (NFS-mounted home directories and network
139
* errors, for instance) but that's a harder problem. We'll say
140
* we support removable devices, badly.
146
/* nss_dbm_mdSlot_GetHardwareSlot defaults to CK_FALSE */
148
* nss_dbm_mdSlot_GetHardwareVersion
149
* nss_dbm_mdSlot_GetFirmwareVersion
151
* These are kinda fuzzy concepts here. I suppose we could return the
152
* Berkeley DB version for one of them, if we had an actual number we
153
* were confident in. But mcom's "dbm" has been hacked enough that I
154
* don't really know from what "real" version it stems..
157
static NSSCKMDToken *
158
nss_dbm_mdSlot_GetToken
162
NSSCKMDInstance *mdInstance,
163
NSSCKFWInstance *fwInstance,
167
nss_dbm_slot_t *slot = (nss_dbm_slot_t *)mdSlot->etc;
168
return nss_dbm_mdToken_factory(slot, pError);
171
NSS_IMPLEMENT NSSCKMDSlot *
172
nss_dbm_mdSlot_factory
174
nss_dbm_instance_t *instance,
180
nss_dbm_slot_t *slot;
183
slot = nss_ZNEW(instance->arena, nss_dbm_slot_t);
184
if( (nss_dbm_slot_t *)NULL == slot ) {
185
*pError = CKR_HOST_MEMORY;
186
return (NSSCKMDSlot *)NULL;
189
slot->instance = instance;
190
slot->filename = filename;
192
slot->token_db = (nss_dbm_db_t *)NULL;
194
rv = nss_ZNEW(instance->arena, NSSCKMDSlot);
195
if( (NSSCKMDSlot *)NULL == rv ) {
196
*pError = CKR_HOST_MEMORY;
197
return (NSSCKMDSlot *)NULL;
200
rv->etc = (void *)slot;
201
rv->Initialize = nss_dbm_mdSlot_Initialize;
202
rv->Destroy = nss_dbm_mdSlot_Destroy;
203
rv->GetSlotDescription = nss_dbm_mdSlot_GetSlotDescription;
204
rv->GetManufacturerID = nss_dbm_mdSlot_GetManufacturerID;
205
rv->GetTokenPresent = nss_dbm_mdSlot_GetTokenPresent;
206
rv->GetRemovableDevice = nss_dbm_mdSlot_GetRemovableDevice;
207
/* GetHardwareSlot */
208
/* GetHardwareVersion */
209
/* GetFirmwareVersion */
210
rv->GetToken = nss_dbm_mdSlot_GetToken;
211
rv->null = (void *)NULL;