1192811Srmacklem/* checksum-reps-table.h : internal interface to ops on `checksum-reps' table
2192811Srmacklem *
3192811Srmacklem * ====================================================================
4192811Srmacklem *    Licensed to the Apache Software Foundation (ASF) under one
5192811Srmacklem *    or more contributor license agreements.  See the NOTICE file
6192811Srmacklem *    distributed with this work for additional information
7192811Srmacklem *    regarding copyright ownership.  The ASF licenses this file
8192811Srmacklem *    to you under the Apache License, Version 2.0 (the
9192811Srmacklem *    "License"); you may not use this file except in compliance
10192811Srmacklem *    with the License.  You may obtain a copy of the License at
11192811Srmacklem *
12192811Srmacklem *      http://www.apache.org/licenses/LICENSE-2.0
13192811Srmacklem *
14192811Srmacklem *    Unless required by applicable law or agreed to in writing,
15192811Srmacklem *    software distributed under the License is distributed on an
16192811Srmacklem *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17192811Srmacklem *    KIND, either express or implied.  See the License for the
18192811Srmacklem *    specific language governing permissions and limitations
19192811Srmacklem *    under the License.
20192811Srmacklem * ====================================================================
21192811Srmacklem */
22192811Srmacklem
23192811Srmacklem#ifndef SVN_LIBSVN_FS_CHECKSUM_REPS_TABLE_H
24192811Srmacklem#define SVN_LIBSVN_FS_CHECKSUM_REPS_TABLE_H
25192811Srmacklem
26192811Srmacklem#include "svn_fs.h"
27192811Srmacklem#include "svn_error.h"
28192811Srmacklem#include "svn_checksum.h"
29192811Srmacklem#include "../trail.h"
30192811Srmacklem#include "../fs.h"
31192811Srmacklem
32192811Srmacklem#ifdef __cplusplus
33192811Srmacklemextern "C" {
34192811Srmacklem#endif /* __cplusplus */
35192811Srmacklem
36192811Srmacklem
37192811Srmacklem/* Open a `checksum-reps' table in ENV.  If CREATE is non-zero, create
38192811Srmacklem   one if it doesn't exist.  Set *CHECKSUM_REPS_P to the new table.
39192811Srmacklem   Return a Berkeley DB error code.  */
40192811Srmacklemint svn_fs_bdb__open_checksum_reps_table(DB **checksum_reps_p,
41192811Srmacklem                                         DB_ENV *env,
42192811Srmacklem                                         svn_boolean_t create);
43192811Srmacklem
44192811Srmacklem/* Set *REP_KEY to the representation key stored as the value of key
45192811Srmacklem   CHECKSUM in the `checksum-reps' table.  Do this as part of TRAIL.
46192811Srmacklem   Use POOL for allocations.
47192811Srmacklem
48192811Srmacklem   If no such node revision ID is stored for CHECKSUM, return
49192811Srmacklem   SVN_ERR_FS_NO_SUCH_CHECKSUM_REP.  */
50192811Srmacklemsvn_error_t *svn_fs_bdb__get_checksum_rep(const char **rep_key,
51192811Srmacklem                                          svn_fs_t *fs,
52192811Srmacklem                                          svn_checksum_t *checksum,
53192811Srmacklem                                          trail_t *trail,
54192811Srmacklem                                          apr_pool_t *pool);
55192811Srmacklem
56192811Srmacklem/* Store in the `checksum-reps' table a mapping of CHECKSUM to
57192811Srmacklem   representation key REP_KEY in FS.  Do this as part of TRAIL.  Use
58192811Srmacklem   POOL for temporary allocations.
59192811Srmacklem
60192811Srmacklem   WARNING: NEVER store a record that maps a checksum to a mutable
61192811Srmacklem   representation.  Ever.  Under pain of dismemberment and death.  */
62192811Srmacklemsvn_error_t *svn_fs_bdb__set_checksum_rep(svn_fs_t *fs,
63192811Srmacklem                                          svn_checksum_t *checksum,
64192811Srmacklem                                          const char *rep_key,
65                                          trail_t *trail,
66                                          apr_pool_t *pool);
67
68/* Delete from the `checksum-reps' table the mapping of CHECKSUM to a
69   representation key in FS.  Do this as part of TRAIL.  Use POOL for
70   temporary allocations.  */
71svn_error_t *svn_fs_bdb__delete_checksum_rep(svn_fs_t *fs,
72                                             svn_checksum_t *checksum,
73                                             trail_t *trail,
74                                             apr_pool_t *pool);
75
76/* Reserve a unique reuse ID in the `checksum-reps' table in FS for a
77   new instance of a re-used representation as part of TRAIL.  Return
78   the slot's id in *REUSE_ID_P, allocated in POOL.  */
79svn_error_t *svn_fs_bdb__reserve_rep_reuse_id(const char **reuse_id_p,
80                                              svn_fs_t *fs,
81                                              trail_t *trail,
82                                              apr_pool_t *pool);
83
84
85#ifdef __cplusplus
86}
87#endif /* __cplusplus */
88
89#endif /* SVN_LIBSVN_FS_CHECKSUM_REPS_TABLE_H */
90