2 * err.h : interface to routines for returning Berkeley DB errors
4 * ====================================================================
5 * Licensed to the Apache Software Foundation (ASF) under one
6 * or more contributor license agreements. See the NOTICE file
7 * distributed with this work for additional information
8 * regarding copyright ownership. The ASF licenses this file
9 * to you under the Apache License, Version 2.0 (the
10 * "License"); you may not use this file except in compliance
11 * with the License. You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing,
16 * software distributed under the License is distributed on an
17 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18 * KIND, either express or implied. See the License for the
19 * specific language governing permissions and limitations
21 * ====================================================================
26 #ifndef SVN_LIBSVN_FS_BDB_ERR_H
27 #define SVN_LIBSVN_FS_BDB_ERR_H
29 #include <apr_pools.h>
31 #include "svn_error.h"
38 #endif /* __cplusplus */
41 /* Return an svn_error_t object that reports a Berkeley DB error.
42 DB_ERR is the error value returned by the Berkeley DB routine.
43 Wrap and consume pending errors in BDB. */
44 svn_error_t *svn_fs_bdb__dberr(bdb_env_baton_t *bdb_baton, int db_err);
47 /* Allocate an error object for a Berkeley DB error, with a formatted message.
48 Wrap and consume pending errors in BDB.
50 DB_ERR is the Berkeley DB error code.
51 FMT is a printf-style format string, describing how to format any
54 The svn_error_t object returned has a message consisting of:
55 - the text specified by FMT and the subsequent arguments, and
56 - the Berkeley DB error message for the error code DB_ERR.
58 There is no separator between the two messages; if you want one,
59 you should include it in FMT. */
60 svn_error_t *svn_fs_bdb__dberrf(bdb_env_baton_t *bdb_baton, int db_err,
62 __attribute__((format(printf, 3, 4)));
65 /* Clear errors associated with BDB. */
66 void svn_fs_bdb__clear_err(bdb_env_t *bdb);
69 /* Check the return status from the Berkeley DB operation. If the
70 operation succeeded, return zero. Otherwise, construct an
71 appropriate Subversion error object describing what went wrong.
72 - FS is the Subversion filesystem we're operating on.
73 - OPERATION is a gerund clause describing what we were trying to do.
74 - BDB_ERR is the return status from the Berkeley DB function. */
75 svn_error_t *svn_fs_bdb__wrap_db(svn_fs_t *fs,
76 const char *operation,
80 /* A terse wrapper for svn_fs_bdb__wrap_db. */
81 #define BDB_WRAP(fs, op, err) (svn_fs_bdb__wrap_db((fs), (op), (err)))
83 /* If EXPR returns a non-zero value, pass that value to
84 svn_fs_bdb__dberr and return that function's value. This is like
85 SVN_ERR, but is used by functions that return a Subversion error
86 and call other functions that return a Berkeley DB error code. */
87 #define SVN_BDB_ERR(bdb, expr) \
89 int db_err__temp = (expr); \
91 return svn_fs_bdb__dberr((bdb), db_err__temp); \
92 svn_error_clear((bdb)->error_info->pending_errors); \
93 (bdb)->error_info->pending_errors = NULL; \
97 /* If EXPR returns a non-zero value, return it. This is like SVN_ERR,
98 but for functions that return a Berkeley DB error code. */
99 #define BDB_ERR(expr) \
101 int db_err__temp = (expr); \
103 return db_err__temp; \
107 /* Verify that FS refers to an open database; return an appropriate
108 error if this is not the case. */
109 svn_error_t *svn_fs_bdb__check_fs(svn_fs_t *fs);
113 #endif /* __cplusplus */
115 #endif /* SVN_LIBSVN_FS_BDB_ERR_H */