1251881Speter/* checksum-reps-table.h : internal interface to ops on `checksum-reps' table
2251881Speter *
3251881Speter * ====================================================================
4251881Speter *    Licensed to the Apache Software Foundation (ASF) under one
5251881Speter *    or more contributor license agreements.  See the NOTICE file
6251881Speter *    distributed with this work for additional information
7251881Speter *    regarding copyright ownership.  The ASF licenses this file
8251881Speter *    to you under the Apache License, Version 2.0 (the
9251881Speter *    "License"); you may not use this file except in compliance
10251881Speter *    with the License.  You may obtain a copy of the License at
11251881Speter *
12251881Speter *      http://www.apache.org/licenses/LICENSE-2.0
13251881Speter *
14251881Speter *    Unless required by applicable law or agreed to in writing,
15251881Speter *    software distributed under the License is distributed on an
16251881Speter *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17251881Speter *    KIND, either express or implied.  See the License for the
18251881Speter *    specific language governing permissions and limitations
19251881Speter *    under the License.
20251881Speter * ====================================================================
21251881Speter */
22251881Speter
23251881Speter#ifndef SVN_LIBSVN_FS_CHECKSUM_REPS_TABLE_H
24251881Speter#define SVN_LIBSVN_FS_CHECKSUM_REPS_TABLE_H
25251881Speter
26251881Speter#include "svn_fs.h"
27251881Speter#include "svn_error.h"
28251881Speter#include "svn_checksum.h"
29251881Speter#include "../trail.h"
30251881Speter#include "../fs.h"
31251881Speter
32251881Speter#ifdef __cplusplus
33251881Speterextern "C" {
34251881Speter#endif /* __cplusplus */
35251881Speter
36251881Speter
37251881Speter/* Open a `checksum-reps' table in ENV.  If CREATE is non-zero, create
38251881Speter   one if it doesn't exist.  Set *CHECKSUM_REPS_P to the new table.
39251881Speter   Return a Berkeley DB error code.  */
40251881Speterint svn_fs_bdb__open_checksum_reps_table(DB **checksum_reps_p,
41251881Speter                                         DB_ENV *env,
42251881Speter                                         svn_boolean_t create);
43251881Speter
44251881Speter/* Set *REP_KEY to the representation key stored as the value of key
45251881Speter   CHECKSUM in the `checksum-reps' table.  Do this as part of TRAIL.
46251881Speter   Use POOL for allocations.
47251881Speter
48251881Speter   If no such node revision ID is stored for CHECKSUM, return
49251881Speter   SVN_ERR_FS_NO_SUCH_CHECKSUM_REP.  */
50251881Spetersvn_error_t *svn_fs_bdb__get_checksum_rep(const char **rep_key,
51251881Speter                                          svn_fs_t *fs,
52251881Speter                                          svn_checksum_t *checksum,
53251881Speter                                          trail_t *trail,
54251881Speter                                          apr_pool_t *pool);
55251881Speter
56251881Speter/* Store in the `checksum-reps' table a mapping of CHECKSUM to
57251881Speter   representation key REP_KEY in FS.  Do this as part of TRAIL.  Use
58251881Speter   POOL for temporary allocations.
59251881Speter
60251881Speter   WARNING: NEVER store a record that maps a checksum to a mutable
61251881Speter   representation.  Ever.  Under pain of dismemberment and death.  */
62251881Spetersvn_error_t *svn_fs_bdb__set_checksum_rep(svn_fs_t *fs,
63251881Speter                                          svn_checksum_t *checksum,
64251881Speter                                          const char *rep_key,
65251881Speter                                          trail_t *trail,
66251881Speter                                          apr_pool_t *pool);
67251881Speter
68251881Speter/* Delete from the `checksum-reps' table the mapping of CHECKSUM to a
69251881Speter   representation key in FS.  Do this as part of TRAIL.  Use POOL for
70251881Speter   temporary allocations.  */
71251881Spetersvn_error_t *svn_fs_bdb__delete_checksum_rep(svn_fs_t *fs,
72251881Speter                                             svn_checksum_t *checksum,
73251881Speter                                             trail_t *trail,
74251881Speter                                             apr_pool_t *pool);
75251881Speter
76251881Speter/* Reserve a unique reuse ID in the `checksum-reps' table in FS for a
77251881Speter   new instance of a re-used representation as part of TRAIL.  Return
78251881Speter   the slot's id in *REUSE_ID_P, allocated in POOL.  */
79251881Spetersvn_error_t *svn_fs_bdb__reserve_rep_reuse_id(const char **reuse_id_p,
80251881Speter                                              svn_fs_t *fs,
81251881Speter                                              trail_t *trail,
82251881Speter                                              apr_pool_t *pool);
83251881Speter
84251881Speter
85251881Speter#ifdef __cplusplus
86251881Speter}
87251881Speter#endif /* __cplusplus */
88251881Speter
89251881Speter#endif /* SVN_LIBSVN_FS_CHECKSUM_REPS_TABLE_H */
90