]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - contrib/subversion/subversion/libsvn_fs_base/bdb/dbt.h
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / contrib / subversion / subversion / libsvn_fs_base / bdb / dbt.h
1 /* dbt.h --- interface to DBT-frobbing functions
2  *
3  * ====================================================================
4  *    Licensed to the Apache Software Foundation (ASF) under one
5  *    or more contributor license agreements.  See the NOTICE file
6  *    distributed with this work for additional information
7  *    regarding copyright ownership.  The ASF licenses this file
8  *    to you under the Apache License, Version 2.0 (the
9  *    "License"); you may not use this file except in compliance
10  *    with the License.  You may obtain a copy of the License at
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
14  *    Unless required by applicable law or agreed to in writing,
15  *    software distributed under the License is distributed on an
16  *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17  *    KIND, either express or implied.  See the License for the
18  *    specific language governing permissions and limitations
19  *    under the License.
20  * ====================================================================
21  */
22
23 #ifndef SVN_LIBSVN_FS_DBT_H
24 #define SVN_LIBSVN_FS_DBT_H
25
26 #include <apr_pools.h>
27
28 #define SVN_WANT_BDB
29 #include "svn_private_config.h"
30
31 #include "svn_fs.h"
32 #include "private/svn_skel.h"
33
34 #ifdef __cplusplus
35 extern "C" {
36 #endif /* __cplusplus */
37
38 \f
39 /* Set all fields of DBT to zero.  Return DBT.  */
40 DBT *svn_fs_base__clear_dbt(DBT *dbt);
41
42
43 /* Set DBT to retrieve no data.  This is useful when you're just
44    probing the table to see if an entry exists, or to find a key, but
45    don't care what the value is.  Return DBT.  */
46 DBT *svn_fs_base__nodata_dbt(DBT *dbt);
47
48
49 /* Set DBT to refer to the SIZE bytes at DATA.  Return DBT.  */
50 DBT *svn_fs_base__set_dbt(DBT *dbt, const void *data, apr_size_t size);
51
52
53 /* Prepare DBT to hold data returned from Berkeley DB.  Return DBT.
54
55    Clear all its fields to zero, but set the DB_DBT_MALLOC flag,
56    requesting that Berkeley DB place the returned data in a freshly
57    malloc'd block.  If the database operation succeeds, the caller
58    then owns the data block, and is responsible for making sure it
59    gets freed.
60
61    You can use this with svn_fs_base__track_dbt:
62
63        svn_fs_base__result_dbt (&foo);
64        ... some Berkeley DB operation that puts data in foo ...
65        svn_fs_base__track_dbt (&foo, pool);
66
67    This arrangement is:
68    - thread-safe --- the returned data is allocated via malloc, and
69      won't be overwritten if some other thread performs an operation
70      on the same table.  See the explanation of ``Retrieved key/data
71      permanence'' in the section of the Berkeley DB manual on the DBT
72      type.
73    - pool-friendly --- the data returned by Berkeley DB is now guaranteed
74      to be freed when POOL is cleared.  */
75 DBT *svn_fs_base__result_dbt(DBT *dbt);
76
77 /* Arrange for POOL to `track' DBT's data: when POOL is cleared,
78    DBT->data will be freed, using `free'.  If DBT->data is zero,
79    do nothing.
80
81    This is meant for use with svn_fs_base__result_dbt; see the explanation
82    there.  */
83 DBT *svn_fs_base__track_dbt(DBT *dbt, apr_pool_t *pool);
84
85
86 /* Prepare DBT for use as a key into a RECNO table.  This call makes
87    DBT refer to the db_recno_t pointed to by RECNO as its buffer; the
88    record number you assign to *RECNO will be the table key.  */
89 DBT *svn_fs_base__recno_dbt(DBT *dbt, db_recno_t *recno);
90
91
92 /* Compare two DBT values in byte-by-byte lexicographic order.  */
93 int svn_fs_base__compare_dbt(const DBT *a, const DBT *b);
94
95
96 /* Set DBT to the unparsed form of ID; allocate memory from POOL.
97    Return DBT.  */
98 DBT *svn_fs_base__id_to_dbt(DBT *dbt, const svn_fs_id_t *id,
99                             apr_pool_t *pool);
100
101
102 /* Set DBT to the unparsed form of SKEL; allocate memory from POOL.
103    Return DBT.  */
104 DBT *svn_fs_base__skel_to_dbt(DBT *dbt, svn_skel_t *skel, apr_pool_t *pool);
105
106
107 /* Set DBT to the text of the null-terminated string STR.  DBT will
108    refer to STR's storage.  Return DBT.  */
109 DBT *svn_fs_base__str_to_dbt(DBT *dbt, const char *str);
110
111
112 /* Set DBT to the bytes contained by CHECKSUM.   DBT will refer to CHECKSUM's
113    storage.  Return DBT.*/
114 DBT *svn_fs_base__checksum_to_dbt(DBT* dbt, svn_checksum_t *checksum);
115
116 #ifdef __cplusplus
117 }
118 #endif /* __cplusplus */
119
120 #endif /* SVN_LIBSVN_FS_DBT_H */