]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/blob - contrib/subversion/subversion/libsvn_fs_x/low_level.h
MFC r275385 (by bapt):
[FreeBSD/stable/10.git] / contrib / subversion / subversion / libsvn_fs_x / low_level.h
1 /* low_level.c --- low level r/w access to fs_x file structures
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__LOW_LEVEL_H
24 #define SVN_LIBSVN_FS__LOW_LEVEL_H
25
26 #include "svn_fs.h"
27
28 #include "fs_x.h"
29 #include "id.h"
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif /* __cplusplus */
34
35 /* Kinds that a node-rev can be. */
36 #define SVN_FS_X__KIND_FILE          "file"
37 #define SVN_FS_X__KIND_DIR           "dir"
38
39 /* The functions are grouped as follows:
40  *
41  * - revision footer
42  * - representation (as in "text:" and "props:" lines)
43  * - node revision
44  * - representation header ("DELTA" lines)
45  * - changed path list
46  */
47
48 /* Given the FSX revision / pack FOOTER, parse it destructively
49  * and return the start offsets of the index data in *L2P_OFFSET and
50  * *P2L_OFFSET, respectively.  Also, return the expected checksums in
51  * in *L2P_CHECKSUM and *P2L_CHECKSUM.
52  *
53  * Note that REV is only used to construct nicer error objects that
54  * mention this revision.  Allocate the checksums in RESULT_POOL.
55  */
56 svn_error_t *
57 svn_fs_x__parse_footer(apr_off_t *l2p_offset,
58                        svn_checksum_t **l2p_checksum,
59                        apr_off_t *p2l_offset,
60                        svn_checksum_t **p2l_checksum,
61                        svn_stringbuf_t *footer,
62                        svn_revnum_t rev,
63                        apr_pool_t *result_pool);
64
65 /* Given the offset of the L2P index data in L2P_OFFSET, the content
66  * checksum in L2P_CHECKSUM and the offset plus checksum of the P2L
67  * index data in P2L_OFFSET and P2L_CHECKSUM.
68  *
69  * Return the corresponding format 7+ revision / pack file footer.
70  * Allocate it in RESULT_POOL and use SCRATCH_POOL for temporary.
71  */
72 svn_stringbuf_t *
73 svn_fs_x__unparse_footer(apr_off_t l2p_offset,
74                          svn_checksum_t *l2p_checksum,
75                          apr_off_t p2l_offset,
76                          svn_checksum_t *p2l_checksum,
77                          apr_pool_t *result_pool,
78                          apr_pool_t *scratch_pool);
79
80 /* Parse the description of a representation from TEXT and store it
81    into *REP_P.  TEXT will be invalidated by this call.  Allocate *REP_P in
82    RESULT_POOL and use SCRATCH_POOL for temporaries. */
83 svn_error_t *
84 svn_fs_x__parse_representation(svn_fs_x__representation_t **rep_p,
85                                svn_stringbuf_t *text,
86                                apr_pool_t *result_pool,
87                                apr_pool_t *scratch_pool);
88
89 /* Return a formatted string that represents the location of representation
90  * REP.  If MUTABLE_REP_TRUNCATED is given, the rep is for props or dir
91  * contents, and only a "-1" revision number will be given for a mutable rep.
92  * If MAY_BE_CORRUPT is true, guard for NULL when constructing the string.
93  * Allocate the result in RESULT_POOL and temporaries in SCRATCH_POOL. */
94 svn_stringbuf_t *
95 svn_fs_x__unparse_representation(svn_fs_x__representation_t *rep,
96                                  svn_boolean_t mutable_rep_truncated,
97                                  apr_pool_t *result_pool,
98                                  apr_pool_t *scratch_pool);
99
100 /* Read a node-revision from STREAM. Set *NODEREV to the new structure,
101    allocated in RESULT_POOL. */
102 svn_error_t *
103 svn_fs_x__read_noderev(svn_fs_x__noderev_t **noderev,
104                        svn_stream_t *stream,
105                        apr_pool_t *result_pool,
106                        apr_pool_t *scratch_pool);
107
108 /* Write the node-revision NODEREV into the stream OUTFILE.
109    Temporary allocations are from SCRATCH_POOL. */
110 svn_error_t *
111 svn_fs_x__write_noderev(svn_stream_t *outfile,
112                         svn_fs_x__noderev_t *noderev,
113                         apr_pool_t *scratch_pool);
114
115 /* This type enumerates all forms of representations that we support. */
116 typedef enum svn_fs_x__rep_type_t
117 {
118   /* this is a DELTA representation with no base representation */
119   svn_fs_x__rep_self_delta,
120
121   /* this is a DELTA representation against some base representation */
122   svn_fs_x__rep_delta,
123
124   /* this is a representation in a star-delta container */
125   svn_fs_x__rep_container
126 } svn_fs_x__rep_type_t;
127
128 /* This structure is used to hold the information stored in a representation
129  * header. */
130 typedef struct svn_fs_x__rep_header_t
131 {
132   /* type of the representation, i.e. whether self-DELTA etc. */
133   svn_fs_x__rep_type_t type;
134
135   /* if this rep is a delta against some other rep, that base rep can
136    * be found in this revision.  Should be 0 if there is no base rep. */
137   svn_revnum_t base_revision;
138
139   /* if this rep is a delta against some other rep, that base rep can
140    * be found at this item index within the base rep's revision.  Should
141    * be 0 if there is no base rep. */
142   apr_off_t base_item_index;
143
144   /* if this rep is a delta against some other rep, this is the (deltified)
145    * size of that base rep.  Should be 0 if there is no base rep. */
146   svn_filesize_t base_length;
147
148   /* length of the textual representation of the header in the rep or pack
149    * file, including EOL.  Only valid after reading it from disk.
150    * Should be 0 otherwise. */
151   apr_size_t header_size;
152 } svn_fs_x__rep_header_t;
153
154 /* Read the next line from STREAM and parse it as a text
155    representation header.  Return the parsed entry in *HEADER, allocated
156    in RESULT_POOL. Perform temporary allocations in SCRATCH_POOL. */
157 svn_error_t *
158 svn_fs_x__read_rep_header(svn_fs_x__rep_header_t **header,
159                           svn_stream_t *stream,
160                           apr_pool_t *result_pool,
161                           apr_pool_t *scratch_pool);
162
163 /* Write the representation HEADER to STREAM.
164  * Use SCRATCH_POOL for allocations. */
165 svn_error_t *
166 svn_fs_x__write_rep_header(svn_fs_x__rep_header_t *header,
167                            svn_stream_t *stream,
168                            apr_pool_t *scratch_pool);
169
170 /* Read all the changes from STREAM and store them in *CHANGES,
171    allocated in RESULT_POOL. Do temporary allocations in SCRATCH_POOL. */
172 svn_error_t *
173 svn_fs_x__read_changes(apr_array_header_t **changes,
174                        svn_stream_t *stream,
175                        apr_pool_t *result_pool,
176                        apr_pool_t *scratch_pool);
177
178 /* Callback function used by svn_fs_fs__read_changes_incrementally(),
179  * asking the receiver to process to process CHANGE using BATON.  CHANGE
180  * and SCRATCH_POOL will not be valid beyond the current callback invocation.
181  */
182 typedef svn_error_t *(*svn_fs_x__change_receiver_t)(
183   void *baton,
184   svn_fs_x__change_t *change,
185   apr_pool_t *scratch_pool);
186
187 /* Read all the changes from STREAM and invoke CHANGE_RECEIVER on each change.
188    Do all allocations in SCRATCH_POOL. */
189 svn_error_t *
190 svn_fs_x__read_changes_incrementally(svn_stream_t *stream,
191                                      svn_fs_x__change_receiver_t
192                                        change_receiver,
193                                      void *change_receiver_baton,
194                                      apr_pool_t *scratch_pool);
195
196 /* Write the changed path info from CHANGES in filesystem FS to the
197    output stream STREAM.  You may call this function multiple time on
198    the same stream.  If you are writing to a (proto-)revision file,
199    the last call must set TERMINATE_LIST to write an extra empty line
200    that marks the end of the changed paths list.
201    Perform temporary allocations in SCRATCH_POOL.
202  */
203 svn_error_t *
204 svn_fs_x__write_changes(svn_stream_t *stream,
205                         svn_fs_t *fs,
206                         apr_hash_t *changes,
207                         svn_boolean_t terminate_list,
208                         apr_pool_t *scratch_pool);
209
210 #ifdef __cplusplus
211 }
212 #endif /* __cplusplus */
213
214 #endif /* SVN_LIBSVN_FS__LOW_LEVEL_H */