PageRenderTime 20ms CodeModel.GetById 1ms app.highlight 14ms RepoModel.GetById 2ms app.codeStats 0ms

/security/nss/lib/ckfw/dbm/ckdbm.h

http://github.com/zpao/v8monkey
C Header | 284 lines | 206 code | 36 blank | 42 comment | 0 complexity | cb5ab8cac2340837b912274246d1d27d MD5 | raw file
  1/* ***** BEGIN LICENSE BLOCK *****
  2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  3 *
  4 * The contents of this file are subject to the Mozilla Public License Version
  5 * 1.1 (the "License"); you may not use this file except in compliance with
  6 * the License. You may obtain a copy of the License at
  7 * http://www.mozilla.org/MPL/
  8 *
  9 * Software distributed under the License is distributed on an "AS IS" basis,
 10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 11 * for the specific language governing rights and limitations under the
 12 * License.
 13 *
 14 * The Original Code is the Netscape security libraries.
 15 *
 16 * The Initial Developer of the Original Code is
 17 * Netscape Communications Corporation.
 18 * Portions created by the Initial Developer are Copyright (C) 1994-2000
 19 * the Initial Developer. All Rights Reserved.
 20 *
 21 * Contributor(s):
 22 *
 23 * Alternatively, the contents of this file may be used under the terms of
 24 * either the GNU General Public License Version 2 or later (the "GPL"), or
 25 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 26 * in which case the provisions of the GPL or the LGPL are applicable instead
 27 * of those above. If you wish to allow use of your version of this file only
 28 * under the terms of either the GPL or the LGPL, and not to allow others to
 29 * use your version of this file under the terms of the MPL, indicate your
 30 * decision by deleting the provisions above and replace them with the notice
 31 * and other provisions required by the GPL or the LGPL. If you do not delete
 32 * the provisions above, a recipient may use your version of this file under
 33 * the terms of any one of the MPL, the GPL or the LGPL.
 34 *
 35 * ***** END LICENSE BLOCK ***** */
 36
 37#ifdef DEBUG
 38static const char CKDBM_CVS_ID[] = "@(#) $RCSfile: ckdbm.h,v $ $Revision: 1.3 $ $Date: 2006/03/02 22:48:54 $";
 39#endif /* DEBUG */
 40
 41#ifndef CKDBM_H
 42#define CKDBM_H
 43
 44#include "nssckmdt.h"
 45#include "nssckfw.h"
 46
 47/*
 48 * I'm including this for access to the arena functions.
 49 * Looks like we should publish that API.
 50 */
 51#ifndef BASE_H
 52#include "base.h"
 53#endif /* BASE_H */
 54
 55/*
 56 * This is where the Netscape extensions live, at least for now.
 57 */
 58#ifndef CKT_H
 59#include "ckt.h"
 60#endif /* CKT_H */
 61
 62#include "mcom_db.h"
 63
 64NSS_EXTERN_DATA NSSCKMDInstance nss_dbm_mdInstance;
 65
 66typedef struct nss_dbm_db_struct nss_dbm_db_t;
 67struct nss_dbm_db_struct {
 68  DB *db;
 69  NSSCKFWMutex *crustylock;
 70};
 71
 72typedef struct nss_dbm_dbt_struct nss_dbm_dbt_t;
 73struct nss_dbm_dbt_struct {
 74  DBT dbt;
 75  nss_dbm_db_t *my_db;
 76};
 77
 78typedef struct nss_dbm_instance_struct nss_dbm_instance_t;
 79struct nss_dbm_instance_struct {
 80  NSSArena *arena;
 81  CK_ULONG nSlots;
 82  char **filenames;
 83  int *flags; /* e.g. O_RDONLY, O_RDWR */
 84};
 85
 86typedef struct nss_dbm_slot_struct nss_dbm_slot_t;
 87struct nss_dbm_slot_struct {
 88  nss_dbm_instance_t *instance;
 89  char *filename;
 90  int flags;
 91  nss_dbm_db_t *token_db;
 92};
 93
 94typedef struct nss_dbm_token_struct nss_dbm_token_t;
 95struct nss_dbm_token_struct {
 96  NSSArena *arena;
 97  nss_dbm_slot_t *slot;
 98  nss_dbm_db_t *session_db;
 99  NSSUTF8 *label;
100};
101
102struct nss_dbm_dbt_node {
103  struct nss_dbm_dbt_node *next;
104  nss_dbm_dbt_t *dbt;
105};
106
107typedef struct nss_dbm_session_struct nss_dbm_session_t;
108struct nss_dbm_session_struct {
109  NSSArena *arena;
110  nss_dbm_token_t *token;
111  CK_ULONG deviceError;
112  struct nss_dbm_dbt_node *session_objects;
113  NSSCKFWMutex *list_lock;
114};
115
116typedef struct nss_dbm_object_struct nss_dbm_object_t;
117struct nss_dbm_object_struct {
118  NSSArena *arena; /* token or session */
119  nss_dbm_dbt_t *handle;
120};
121
122typedef struct nss_dbm_find_struct nss_dbm_find_t;
123struct nss_dbm_find_struct {
124  NSSArena *arena;
125  struct nss_dbm_dbt_node *found;
126  NSSCKFWMutex *list_lock;
127};
128
129NSS_EXTERN NSSCKMDSlot *
130nss_dbm_mdSlot_factory
131(
132  nss_dbm_instance_t *instance,
133  char *filename,
134  int flags,
135  CK_RV *pError
136);
137
138NSS_EXTERN NSSCKMDToken *
139nss_dbm_mdToken_factory
140(
141  nss_dbm_slot_t *slot,
142  CK_RV *pError
143);
144
145NSS_EXTERN NSSCKMDSession *
146nss_dbm_mdSession_factory
147(
148  nss_dbm_token_t *token,
149  NSSCKFWSession *fwSession,
150  NSSCKFWInstance *fwInstance,
151  CK_BBOOL rw,
152  CK_RV *pError
153);
154
155NSS_EXTERN NSSCKMDObject *
156nss_dbm_mdObject_factory
157(
158  nss_dbm_object_t *object,
159  CK_RV *pError
160);
161
162NSS_EXTERN NSSCKMDFindObjects *
163nss_dbm_mdFindObjects_factory
164(
165  nss_dbm_find_t *find,
166  CK_RV *pError
167);
168
169NSS_EXTERN nss_dbm_db_t *
170nss_dbm_db_open
171(
172  NSSArena *arena,
173  NSSCKFWInstance *fwInstance,
174  char *filename,
175  int flags,
176  CK_RV *pError
177);
178
179NSS_EXTERN void
180nss_dbm_db_close
181(
182  nss_dbm_db_t *db
183);
184
185NSS_EXTERN CK_VERSION
186nss_dbm_db_get_format_version
187(
188  nss_dbm_db_t *db
189);
190
191NSS_EXTERN CK_RV
192nss_dbm_db_set_label
193(
194  nss_dbm_db_t *db,
195  NSSUTF8 *label
196);
197
198NSS_EXTERN NSSUTF8 *
199nss_dbm_db_get_label
200(
201  nss_dbm_db_t *db,
202  NSSArena *arena,
203  CK_RV *pError
204);
205
206NSS_EXTERN CK_RV
207nss_dbm_db_delete_object
208(
209  nss_dbm_dbt_t *dbt
210);
211
212NSS_EXTERN nss_dbm_dbt_t *
213nss_dbm_db_create_object
214(
215  NSSArena *arena,
216  nss_dbm_db_t *db,
217  CK_ATTRIBUTE_PTR pTemplate,
218  CK_ULONG ulAttributeCount,
219  CK_RV *pError,
220  CK_ULONG *pdbrv
221);
222
223NSS_EXTERN CK_RV
224nss_dbm_db_find_objects
225(
226  nss_dbm_find_t *find,
227  nss_dbm_db_t *db,
228  CK_ATTRIBUTE_PTR pTemplate,
229  CK_ULONG ulAttributeCount,
230  CK_ULONG *pdbrv
231);
232
233NSS_EXTERN CK_BBOOL
234nss_dbm_db_object_still_exists
235(
236  nss_dbm_dbt_t *dbt
237);
238
239NSS_EXTERN CK_ULONG
240nss_dbm_db_get_object_attribute_count
241(
242  nss_dbm_dbt_t *dbt,
243  CK_RV *pError,
244  CK_ULONG *pdbrv
245);
246
247NSS_EXTERN CK_RV
248nss_dbm_db_get_object_attribute_types
249(
250  nss_dbm_dbt_t *dbt,
251  CK_ATTRIBUTE_TYPE_PTR typeArray,
252  CK_ULONG ulCount,
253  CK_ULONG *pdbrv
254);
255
256NSS_EXTERN CK_ULONG
257nss_dbm_db_get_object_attribute_size
258(
259  nss_dbm_dbt_t *dbt,
260  CK_ATTRIBUTE_TYPE type,
261  CK_RV *pError,
262  CK_ULONG *pdbrv
263);
264
265NSS_EXTERN NSSItem *
266nss_dbm_db_get_object_attribute
267(
268  nss_dbm_dbt_t *dbt,
269  NSSArena *arena,
270  CK_ATTRIBUTE_TYPE type,
271  CK_RV *pError,
272  CK_ULONG *pdbrv
273);
274
275NSS_EXTERN CK_RV
276nss_dbm_db_set_object_attribute
277(
278  nss_dbm_dbt_t *dbt,
279  CK_ATTRIBUTE_TYPE type,
280  NSSItem *value,
281  CK_ULONG *pdbrv
282);
283
284#endif /* CKDBM_H */