/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. #ifdef DEBUG
  37. static const char CKDBM_CVS_ID[] = "@(#) $RCSfile: ckdbm.h,v $ $Revision: 1.3 $ $Date: 2006/03/02 22:48:54 $";
  38. #endif /* DEBUG */
  39. #ifndef CKDBM_H
  40. #define CKDBM_H
  41. #include "nssckmdt.h"
  42. #include "nssckfw.h"
  43. /*
  44. * I'm including this for access to the arena functions.
  45. * Looks like we should publish that API.
  46. */
  47. #ifndef BASE_H
  48. #include "base.h"
  49. #endif /* BASE_H */
  50. /*
  51. * This is where the Netscape extensions live, at least for now.
  52. */
  53. #ifndef CKT_H
  54. #include "ckt.h"
  55. #endif /* CKT_H */
  56. #include "mcom_db.h"
  57. NSS_EXTERN_DATA NSSCKMDInstance nss_dbm_mdInstance;
  58. typedef struct nss_dbm_db_struct nss_dbm_db_t;
  59. struct nss_dbm_db_struct {
  60. DB *db;
  61. NSSCKFWMutex *crustylock;
  62. };
  63. typedef struct nss_dbm_dbt_struct nss_dbm_dbt_t;
  64. struct nss_dbm_dbt_struct {
  65. DBT dbt;
  66. nss_dbm_db_t *my_db;
  67. };
  68. typedef struct nss_dbm_instance_struct nss_dbm_instance_t;
  69. struct nss_dbm_instance_struct {
  70. NSSArena *arena;
  71. CK_ULONG nSlots;
  72. char **filenames;
  73. int *flags; /* e.g. O_RDONLY, O_RDWR */
  74. };
  75. typedef struct nss_dbm_slot_struct nss_dbm_slot_t;
  76. struct nss_dbm_slot_struct {
  77. nss_dbm_instance_t *instance;
  78. char *filename;
  79. int flags;
  80. nss_dbm_db_t *token_db;
  81. };
  82. typedef struct nss_dbm_token_struct nss_dbm_token_t;
  83. struct nss_dbm_token_struct {
  84. NSSArena *arena;
  85. nss_dbm_slot_t *slot;
  86. nss_dbm_db_t *session_db;
  87. NSSUTF8 *label;
  88. };
  89. struct nss_dbm_dbt_node {
  90. struct nss_dbm_dbt_node *next;
  91. nss_dbm_dbt_t *dbt;
  92. };
  93. typedef struct nss_dbm_session_struct nss_dbm_session_t;
  94. struct nss_dbm_session_struct {
  95. NSSArena *arena;
  96. nss_dbm_token_t *token;
  97. CK_ULONG deviceError;
  98. struct nss_dbm_dbt_node *session_objects;
  99. NSSCKFWMutex *list_lock;
  100. };
  101. typedef struct nss_dbm_object_struct nss_dbm_object_t;
  102. struct nss_dbm_object_struct {
  103. NSSArena *arena; /* token or session */
  104. nss_dbm_dbt_t *handle;
  105. };
  106. typedef struct nss_dbm_find_struct nss_dbm_find_t;
  107. struct nss_dbm_find_struct {
  108. NSSArena *arena;
  109. struct nss_dbm_dbt_node *found;
  110. NSSCKFWMutex *list_lock;
  111. };
  112. NSS_EXTERN NSSCKMDSlot *
  113. nss_dbm_mdSlot_factory
  114. (
  115. nss_dbm_instance_t *instance,
  116. char *filename,
  117. int flags,
  118. CK_RV *pError
  119. );
  120. NSS_EXTERN NSSCKMDToken *
  121. nss_dbm_mdToken_factory
  122. (
  123. nss_dbm_slot_t *slot,
  124. CK_RV *pError
  125. );
  126. NSS_EXTERN NSSCKMDSession *
  127. nss_dbm_mdSession_factory
  128. (
  129. nss_dbm_token_t *token,
  130. NSSCKFWSession *fwSession,
  131. NSSCKFWInstance *fwInstance,
  132. CK_BBOOL rw,
  133. CK_RV *pError
  134. );
  135. NSS_EXTERN NSSCKMDObject *
  136. nss_dbm_mdObject_factory
  137. (
  138. nss_dbm_object_t *object,
  139. CK_RV *pError
  140. );
  141. NSS_EXTERN NSSCKMDFindObjects *
  142. nss_dbm_mdFindObjects_factory
  143. (
  144. nss_dbm_find_t *find,
  145. CK_RV *pError
  146. );
  147. NSS_EXTERN nss_dbm_db_t *
  148. nss_dbm_db_open
  149. (
  150. NSSArena *arena,
  151. NSSCKFWInstance *fwInstance,
  152. char *filename,
  153. int flags,
  154. CK_RV *pError
  155. );
  156. NSS_EXTERN void
  157. nss_dbm_db_close
  158. (
  159. nss_dbm_db_t *db
  160. );
  161. NSS_EXTERN CK_VERSION
  162. nss_dbm_db_get_format_version
  163. (
  164. nss_dbm_db_t *db
  165. );
  166. NSS_EXTERN CK_RV
  167. nss_dbm_db_set_label
  168. (
  169. nss_dbm_db_t *db,
  170. NSSUTF8 *label
  171. );
  172. NSS_EXTERN NSSUTF8 *
  173. nss_dbm_db_get_label
  174. (
  175. nss_dbm_db_t *db,
  176. NSSArena *arena,
  177. CK_RV *pError
  178. );
  179. NSS_EXTERN CK_RV
  180. nss_dbm_db_delete_object
  181. (
  182. nss_dbm_dbt_t *dbt
  183. );
  184. NSS_EXTERN nss_dbm_dbt_t *
  185. nss_dbm_db_create_object
  186. (
  187. NSSArena *arena,
  188. nss_dbm_db_t *db,
  189. CK_ATTRIBUTE_PTR pTemplate,
  190. CK_ULONG ulAttributeCount,
  191. CK_RV *pError,
  192. CK_ULONG *pdbrv
  193. );
  194. NSS_EXTERN CK_RV
  195. nss_dbm_db_find_objects
  196. (
  197. nss_dbm_find_t *find,
  198. nss_dbm_db_t *db,
  199. CK_ATTRIBUTE_PTR pTemplate,
  200. CK_ULONG ulAttributeCount,
  201. CK_ULONG *pdbrv
  202. );
  203. NSS_EXTERN CK_BBOOL
  204. nss_dbm_db_object_still_exists
  205. (
  206. nss_dbm_dbt_t *dbt
  207. );
  208. NSS_EXTERN CK_ULONG
  209. nss_dbm_db_get_object_attribute_count
  210. (
  211. nss_dbm_dbt_t *dbt,
  212. CK_RV *pError,
  213. CK_ULONG *pdbrv
  214. );
  215. NSS_EXTERN CK_RV
  216. nss_dbm_db_get_object_attribute_types
  217. (
  218. nss_dbm_dbt_t *dbt,
  219. CK_ATTRIBUTE_TYPE_PTR typeArray,
  220. CK_ULONG ulCount,
  221. CK_ULONG *pdbrv
  222. );
  223. NSS_EXTERN CK_ULONG
  224. nss_dbm_db_get_object_attribute_size
  225. (
  226. nss_dbm_dbt_t *dbt,
  227. CK_ATTRIBUTE_TYPE type,
  228. CK_RV *pError,
  229. CK_ULONG *pdbrv
  230. );
  231. NSS_EXTERN NSSItem *
  232. nss_dbm_db_get_object_attribute
  233. (
  234. nss_dbm_dbt_t *dbt,
  235. NSSArena *arena,
  236. CK_ATTRIBUTE_TYPE type,
  237. CK_RV *pError,
  238. CK_ULONG *pdbrv
  239. );
  240. NSS_EXTERN CK_RV
  241. nss_dbm_db_set_object_attribute
  242. (
  243. nss_dbm_dbt_t *dbt,
  244. CK_ATTRIBUTE_TYPE type,
  245. NSSItem *value,
  246. CK_ULONG *pdbrv
  247. );
  248. #endif /* CKDBM_H */