2 * err.h : interface to routines for returning Berkeley DB errors
4 * ====================================================================
5 * Copyright (c) 2000-2004 CollabNet. All rights reserved.
7 * This software is licensed as described in the file COPYING, which
8 * you should have received as part of this distribution. The terms
9 * are also available at http://subversion.tigris.org/license-1.html.
10 * If newer versions of this license are posted there, you may use a
11 * newer version instead, at your option.
13 * This software consists of voluntary contributions made by many
14 * individuals. For exact contribution history, see the revision
15 * history and logs, available at http://subversion.tigris.org/.
16 * ====================================================================
21 #ifndef SVN_LIBSVN_FS_BDB_ERR_H
22 #define SVN_LIBSVN_FS_BDB_ERR_H
24 #include <apr_pools.h>
26 #include "svn_error.h"
33 #endif /* __cplusplus */
36 /* Return an svn_error_t object that reports a Berkeley DB error.
37 DB_ERR is the error value returned by the Berkeley DB routine.
38 Wrap and consume pending errors in BDB. */
39 svn_error_t
*svn_fs_bdb__dberr(bdb_env_baton_t
*bdb_baton
, int db_err
);
42 /* Allocate an error object for a Berkeley DB error, with a formatted message.
43 Wrap and consume pending errors in BDB.
45 DB_ERR is the Berkeley DB error code.
46 FMT is a printf-style format string, describing how to format any
49 The svn_error_t object returned has a message consisting of:
50 - the text specified by FMT and the subsequent arguments, and
51 - the Berkeley DB error message for the error code DB_ERR.
53 There is no separator between the two messages; if you want one,
54 you should include it in FMT. */
55 svn_error_t
*svn_fs_bdb__dberrf(bdb_env_baton_t
*bdb_baton
, int db_err
,
57 __attribute__((format(printf
, 3, 4)));
60 /* Clear errors associated with BDB. */
61 void svn_fs_bdb__clear_err(bdb_env_t
*bdb
);
64 /* Check the return status from the Berkeley DB operation. If the
65 operation succeeded, return zero. Otherwise, construct an
66 appropriate Subversion error object describing what went wrong.
67 - FS is the Subversion filesystem we're operating on.
68 - OPERATION is a gerund clause describing what we were trying to do.
69 - BDB_ERR is the return status from the Berkeley DB function. */
70 svn_error_t
*svn_fs_bdb__wrap_db(svn_fs_t
*fs
,
71 const char *operation
,
75 /* A terse wrapper for svn_fs_bdb__wrap_db. */
76 #define BDB_WRAP(fs, op, err) (svn_fs_bdb__wrap_db((fs), (op), (err)))
78 /* If EXPR returns a non-zero value, pass that value to
79 svn_fs_bdb__dberr and return that function's value. This is like
80 SVN_ERR, but is used by functions that return a Subversion error
81 and call other functions that return a Berkeley DB error code. */
82 #define SVN_BDB_ERR(bdb, expr) \
84 int db_err__temp = (expr); \
86 return svn_fs_bdb__dberr((bdb), db_err__temp); \
87 svn_error_clear((bdb)->error_info->pending_errors); \
88 (bdb)->error_info->pending_errors = NULL; \
92 /* If EXPR returns a non-zero value, return it. This is like SVN_ERR,
93 but for functions that return a Berkeley DB error code. */
94 #define BDB_ERR(expr) \
96 int db_err__temp = (expr); \
98 return db_err__temp; \
102 /* Verify that FS refers to an open database; return an appropriate
103 error if this is not the case. */
104 svn_error_t
*svn_fs_bdb__check_fs(svn_fs_t
*fs
);
108 #endif /* __cplusplus */
110 #endif /* SVN_LIBSVN_FS_BDB_ERR_H */