Fix compiler warning due to missing function prototype.
[svn.git] / subversion / libsvn_fs_base / bdb / env.h
blobbd29c86e66485fae53f9a3307ce2d5cf13c6b986
1 /* env.h : managing the BDB environment
3 * ====================================================================
4 * Copyright (c) 2000-2005 CollabNet. All rights reserved.
6 * This software is licensed as described in the file COPYING, which
7 * you should have received as part of this distribution. The terms
8 * are also available at http://subversion.tigris.org/license-1.html.
9 * If newer versions of this license are posted there, you may use a
10 * newer version instead, at your option.
12 * This software consists of voluntary contributions made by many
13 * individuals. For exact contribution history, see the revision
14 * history and logs, available at http://subversion.tigris.org/.
15 * ====================================================================
18 #ifndef SVN_LIBSVN_FS_BDB_ENV_H
19 #define SVN_LIBSVN_FS_BDB_ENV_H
21 #define APU_WANT_DB
22 #include <apu_want.h>
24 #include <apr_pools.h>
25 #include <apr_file_io.h>
27 #include "bdb_compat.h"
29 #ifdef __cplusplus
30 extern "C" {
31 #endif /* __cplusplus */
34 /* The name of the Berkeley DB config file. */
35 #define BDB_CONFIG_FILE "DB_CONFIG"
37 /* Prefix string for BDB errors. */
38 #define BDB_ERRPFX_STRING "svn (bdb): "
41 /* Opaque descriptor of an open BDB environment. */
42 typedef struct bdb_env_t bdb_env_t;
45 /* Thread-specific error info related to the bdb_env_t. */
46 typedef struct
48 /* We hold the extended info here until the Berkeley DB function returns.
49 It usually returns an error code, triggering the collection and
50 wrapping of the additional errors stored here.
52 Note: In some circumstances BDB will call the error function and not
53 go on to return an error code, so the caller must always check whether
54 pending_errors is non-NULL to avoid leaking errors. This behaviour
55 has been seen when running recovery on a repository upgraded to 4.3
56 that still has old 4.2 log files present, a typical error string is
57 "Skipping log file db/log.0000000002: historic log version 8" */
58 svn_error_t *pending_errors;
60 /* We permitted clients of our library to install a Berkeley BDB errcall.
61 Since we now use the errcall ourselves, we must store and invoke a user
62 errcall, to maintain our API guarantees. */
63 void (*user_callback)(const char *errpfx, char *msg);
65 /* The reference count. It counts the number of bdb_env_baton_t
66 instances that refer to this object. */
67 unsigned refcount;
69 } bdb_error_info_t;
72 /* The Berkeley DB environment baton. */
73 typedef struct
75 /* The Berkeley DB environment. This pointer must be identical to
76 the one in the bdb_env_t. */
77 DB_ENV *env;
79 /* The (opaque) cached environment descriptor. */
80 bdb_env_t *bdb;
82 /* The error info related to this baton. */
83 bdb_error_info_t *error_info;
84 } bdb_env_baton_t;
88 /* Flag combination for opening a shared BDB environment. */
89 #define SVN_BDB_STANDARD_ENV_FLAGS (DB_CREATE \
90 | DB_INIT_LOCK \
91 | DB_INIT_LOG \
92 | DB_INIT_MPOOL \
93 | DB_INIT_TXN \
94 | SVN_BDB_AUTO_RECOVER)
96 /* Flag combination for opening a private BDB environment. */
97 #define SVN_BDB_PRIVATE_ENV_FLAGS (DB_CREATE \
98 | DB_INIT_LOG \
99 | DB_INIT_MPOOL \
100 | DB_INIT_TXN \
101 | DB_PRIVATE)
104 /* Iniitalize the BDB back-end's private stuff. */
105 svn_error_t *svn_fs_bdb__init(apr_pool_t* pool);
108 /* Allocate the Berkeley DB descriptor BDB and open the environment.
110 * Allocate *BDBP from POOL and open (*BDBP)->env in PATH, using FLAGS
111 * and MODE. If applicable, set the BDB_AUTO_COMMIT flag for this
112 * environment.
114 * Use POOL for temporary allocation.
116 * Note: This function may return a bdb_env_baton_t object that refers
117 * to a previously opened environment. If FLAGS contains
118 * DB_PRIVATE and the environment is already open, the function
119 * will fail (this isn't a problem in practice, because a caller
120 * should obtain an exclusive lock on the repository before
121 * opening the environment).
124 svn_error_t *svn_fs_bdb__open(bdb_env_baton_t **bdb_batonp,
125 const char *path,
126 u_int32_t flags, int mode,
127 apr_pool_t *pool);
129 /* Close the Berkeley DB descriptor BDB.
131 * Note: This function might not actually close the environment if it
132 * has been opened more than once.
134 svn_error_t *svn_fs_bdb__close(bdb_env_baton_t *bdb_baton);
137 /* Get the panic state of the open BDB environment. */
138 svn_boolean_t svn_fs_bdb__get_panic(bdb_env_baton_t *bdb_baton);
140 /* Set the panic flag on the open BDB environment. */
141 void svn_fs_bdb__set_panic(bdb_env_baton_t *bdb_baton);
144 /* Remove the Berkeley DB environment at PATH.
146 * Use POOL for temporary allocation.
148 svn_error_t *svn_fs_bdb__remove(const char *path, apr_pool_t *pool);
150 #ifdef __cplusplus
152 #endif /* __cplusplus */
154 #endif /* SVN_LIBSVN_FS_BDB_ENV_H */