Back to index

lightning-sunbird  0.9+nobinonly
ckdbm.h
Go to the documentation of this file.
00001 /* ***** BEGIN LICENSE BLOCK *****
00002  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00003  *
00004  * The contents of this file are subject to the Mozilla Public License Version
00005  * 1.1 (the "License"); you may not use this file except in compliance with
00006  * the License. You may obtain a copy of the License at
00007  * http://www.mozilla.org/MPL/
00008  *
00009  * Software distributed under the License is distributed on an "AS IS" basis,
00010  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00011  * for the specific language governing rights and limitations under the
00012  * License.
00013  *
00014  * The Original Code is the Netscape security libraries.
00015  *
00016  * The Initial Developer of the Original Code is
00017  * Netscape Communications Corporation.
00018  * Portions created by the Initial Developer are Copyright (C) 1994-2000
00019  * the Initial Developer. All Rights Reserved.
00020  *
00021  * Contributor(s):
00022  *
00023  * Alternatively, the contents of this file may be used under the terms of
00024  * either the GNU General Public License Version 2 or later (the "GPL"), or
00025  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00026  * in which case the provisions of the GPL or the LGPL are applicable instead
00027  * of those above. If you wish to allow use of your version of this file only
00028  * under the terms of either the GPL or the LGPL, and not to allow others to
00029  * use your version of this file under the terms of the MPL, indicate your
00030  * decision by deleting the provisions above and replace them with the notice
00031  * and other provisions required by the GPL or the LGPL. If you do not delete
00032  * the provisions above, a recipient may use your version of this file under
00033  * the terms of any one of the MPL, the GPL or the LGPL.
00034  *
00035  * ***** END LICENSE BLOCK ***** */
00036 
00037 #ifdef DEBUG
00038 static const char CKDBM_CVS_ID[] = "@(#) $RCSfile: ckdbm.h,v $ $Revision: 1.2.28.1 $ $Date: 2006/03/02 22:45:13 $";
00039 #endif /* DEBUG */
00040 
00041 #ifndef CKDBM_H
00042 #define CKDBM_H
00043 
00044 #include "nssckmdt.h"
00045 #include "nssckfw.h"
00046 
00047 /*
00048  * I'm including this for access to the arena functions.
00049  * Looks like we should publish that API.
00050  */
00051 #ifndef BASE_H
00052 #include "base.h"
00053 #endif /* BASE_H */
00054 
00055 /*
00056  * This is where the Netscape extensions live, at least for now.
00057  */
00058 #ifndef CKT_H
00059 #include "ckt.h"
00060 #endif /* CKT_H */
00061 
00062 #include "mcom_db.h"
00063 
00064 NSS_EXTERN_DATA NSSCKMDInstance nss_dbm_mdInstance;
00065 
00066 typedef struct nss_dbm_db_struct nss_dbm_db_t;
00067 struct nss_dbm_db_struct {
00068   DB *db;
00069   NSSCKFWMutex *crustylock;
00070 };
00071 
00072 typedef struct nss_dbm_dbt_struct nss_dbm_dbt_t;
00073 struct nss_dbm_dbt_struct {
00074   DBT dbt;
00075   nss_dbm_db_t *my_db;
00076 };
00077 
00078 typedef struct nss_dbm_instance_struct nss_dbm_instance_t;
00079 struct nss_dbm_instance_struct {
00080   NSSArena *arena;
00081   CK_ULONG nSlots;
00082   char **filenames;
00083   int *flags; /* e.g. O_RDONLY, O_RDWR */
00084 };
00085 
00086 typedef struct nss_dbm_slot_struct nss_dbm_slot_t;
00087 struct nss_dbm_slot_struct {
00088   nss_dbm_instance_t *instance;
00089   char *filename;
00090   int flags;
00091   nss_dbm_db_t *token_db;
00092 };
00093 
00094 typedef struct nss_dbm_token_struct nss_dbm_token_t;
00095 struct nss_dbm_token_struct {
00096   NSSArena *arena;
00097   nss_dbm_slot_t *slot;
00098   nss_dbm_db_t *session_db;
00099   NSSUTF8 *label;
00100 };
00101 
00102 struct nss_dbm_dbt_node {
00103   struct nss_dbm_dbt_node *next;
00104   nss_dbm_dbt_t *dbt;
00105 };
00106 
00107 typedef struct nss_dbm_session_struct nss_dbm_session_t;
00108 struct nss_dbm_session_struct {
00109   NSSArena *arena;
00110   nss_dbm_token_t *token;
00111   CK_ULONG deviceError;
00112   struct nss_dbm_dbt_node *session_objects;
00113   NSSCKFWMutex *list_lock;
00114 };
00115 
00116 typedef struct nss_dbm_object_struct nss_dbm_object_t;
00117 struct nss_dbm_object_struct {
00118   NSSArena *arena; /* token or session */
00119   nss_dbm_dbt_t *handle;
00120 };
00121 
00122 typedef struct nss_dbm_find_struct nss_dbm_find_t;
00123 struct nss_dbm_find_struct {
00124   NSSArena *arena;
00125   struct nss_dbm_dbt_node *found;
00126   NSSCKFWMutex *list_lock;
00127 };
00128 
00129 NSS_EXTERN NSSCKMDSlot *
00130 nss_dbm_mdSlot_factory
00131 (
00132   nss_dbm_instance_t *instance,
00133   char *filename,
00134   int flags,
00135   CK_RV *pError
00136 );
00137 
00138 NSS_EXTERN NSSCKMDToken *
00139 nss_dbm_mdToken_factory
00140 (
00141   nss_dbm_slot_t *slot,
00142   CK_RV *pError
00143 );
00144 
00145 NSS_EXTERN NSSCKMDSession *
00146 nss_dbm_mdSession_factory
00147 (
00148   nss_dbm_token_t *token,
00149   NSSCKFWSession *fwSession,
00150   NSSCKFWInstance *fwInstance,
00151   CK_BBOOL rw,
00152   CK_RV *pError
00153 );
00154 
00155 NSS_EXTERN NSSCKMDObject *
00156 nss_dbm_mdObject_factory
00157 (
00158   nss_dbm_object_t *object,
00159   CK_RV *pError
00160 );
00161 
00162 NSS_EXTERN NSSCKMDFindObjects *
00163 nss_dbm_mdFindObjects_factory
00164 (
00165   nss_dbm_find_t *find,
00166   CK_RV *pError
00167 );
00168 
00169 NSS_EXTERN nss_dbm_db_t *
00170 nss_dbm_db_open
00171 (
00172   NSSArena *arena,
00173   NSSCKFWInstance *fwInstance,
00174   char *filename,
00175   int flags,
00176   CK_RV *pError
00177 );
00178 
00179 NSS_EXTERN void
00180 nss_dbm_db_close
00181 (
00182   nss_dbm_db_t *db
00183 );
00184 
00185 NSS_EXTERN CK_VERSION
00186 nss_dbm_db_get_format_version
00187 (
00188   nss_dbm_db_t *db
00189 );
00190 
00191 NSS_EXTERN CK_RV
00192 nss_dbm_db_set_label
00193 (
00194   nss_dbm_db_t *db,
00195   NSSUTF8 *label
00196 );
00197 
00198 NSS_EXTERN NSSUTF8 *
00199 nss_dbm_db_get_label
00200 (
00201   nss_dbm_db_t *db,
00202   NSSArena *arena,
00203   CK_RV *pError
00204 );
00205 
00206 NSS_EXTERN CK_RV
00207 nss_dbm_db_delete_object
00208 (
00209   nss_dbm_dbt_t *dbt
00210 );
00211 
00212 NSS_EXTERN nss_dbm_dbt_t *
00213 nss_dbm_db_create_object
00214 (
00215   NSSArena *arena,
00216   nss_dbm_db_t *db,
00217   CK_ATTRIBUTE_PTR pTemplate,
00218   CK_ULONG ulAttributeCount,
00219   CK_RV *pError,
00220   CK_ULONG *pdbrv
00221 );
00222 
00223 NSS_EXTERN CK_RV
00224 nss_dbm_db_find_objects
00225 (
00226   nss_dbm_find_t *find,
00227   nss_dbm_db_t *db,
00228   CK_ATTRIBUTE_PTR pTemplate,
00229   CK_ULONG ulAttributeCount,
00230   CK_ULONG *pdbrv
00231 );
00232 
00233 NSS_EXTERN CK_BBOOL
00234 nss_dbm_db_object_still_exists
00235 (
00236   nss_dbm_dbt_t *dbt
00237 );
00238 
00239 NSS_EXTERN CK_ULONG
00240 nss_dbm_db_get_object_attribute_count
00241 (
00242   nss_dbm_dbt_t *dbt,
00243   CK_RV *pError,
00244   CK_ULONG *pdbrv
00245 );
00246 
00247 NSS_EXTERN CK_RV
00248 nss_dbm_db_get_object_attribute_types
00249 (
00250   nss_dbm_dbt_t *dbt,
00251   CK_ATTRIBUTE_TYPE_PTR typeArray,
00252   CK_ULONG ulCount,
00253   CK_ULONG *pdbrv
00254 );
00255 
00256 NSS_EXTERN CK_ULONG
00257 nss_dbm_db_get_object_attribute_size
00258 (
00259   nss_dbm_dbt_t *dbt,
00260   CK_ATTRIBUTE_TYPE type,
00261   CK_RV *pError,
00262   CK_ULONG *pdbrv
00263 );
00264 
00265 NSS_EXTERN NSSItem *
00266 nss_dbm_db_get_object_attribute
00267 (
00268   nss_dbm_dbt_t *dbt,
00269   NSSArena *arena,
00270   CK_ATTRIBUTE_TYPE type,
00271   CK_RV *pError,
00272   CK_ULONG *pdbrv
00273 );
00274 
00275 NSS_EXTERN CK_RV
00276 nss_dbm_db_set_object_attribute
00277 (
00278   nss_dbm_dbt_t *dbt,
00279   CK_ATTRIBUTE_TYPE type,
00280   NSSItem *value,
00281   CK_ULONG *pdbrv
00282 );
00283 
00284 #endif /* CKDBM_H */