1 /* low_level.c --- low level r/w access to fs_x file structures
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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
20 * ====================================================================
23 #ifndef SVN_LIBSVN_FS__LOW_LEVEL_H
24 #define SVN_LIBSVN_FS__LOW_LEVEL_H
33 #endif /* __cplusplus */
35 /* Kinds that a node-rev can be. */
36 #define SVN_FS_X__KIND_FILE "file"
37 #define SVN_FS_X__KIND_DIR "dir"
39 /* The functions are grouped as follows:
42 * - representation (as in "text:" and "props:" lines)
44 * - representation header ("DELTA" lines)
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.
53 * Note that REV is only used to construct nicer error objects that
54 * mention this revision. Allocate the checksums in RESULT_POOL.
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,
63 apr_pool_t *result_pool);
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.
69 * Return the corresponding format 7+ revision / pack file footer.
70 * Allocate it in RESULT_POOL and use SCRATCH_POOL for temporary.
73 svn_fs_x__unparse_footer(apr_off_t l2p_offset,
74 svn_checksum_t *l2p_checksum,
76 svn_checksum_t *p2l_checksum,
77 apr_pool_t *result_pool,
78 apr_pool_t *scratch_pool);
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. */
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);
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. */
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);
100 /* Read a node-revision from STREAM. Set *NODEREV to the new structure,
101 allocated in RESULT_POOL. */
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);
108 /* Write the node-revision NODEREV into the stream OUTFILE.
109 Temporary allocations are from SCRATCH_POOL. */
111 svn_fs_x__write_noderev(svn_stream_t *outfile,
112 svn_fs_x__noderev_t *noderev,
113 apr_pool_t *scratch_pool);
115 /* This type enumerates all forms of representations that we support. */
116 typedef enum svn_fs_x__rep_type_t
118 /* this is a DELTA representation with no base representation */
119 svn_fs_x__rep_self_delta,
121 /* this is a DELTA representation against some base representation */
124 /* this is a representation in a star-delta container */
125 svn_fs_x__rep_container
126 } svn_fs_x__rep_type_t;
128 /* This structure is used to hold the information stored in a representation
130 typedef struct svn_fs_x__rep_header_t
132 /* type of the representation, i.e. whether self-DELTA etc. */
133 svn_fs_x__rep_type_t type;
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;
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;
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;
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;
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. */
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);
163 /* Write the representation HEADER to STREAM.
164 * Use SCRATCH_POOL for allocations. */
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);
170 /* Read all the changes from STREAM and store them in *CHANGES,
171 allocated in RESULT_POOL. Do temporary allocations in SCRATCH_POOL. */
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);
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.
182 typedef svn_error_t *(*svn_fs_x__change_receiver_t)(
184 svn_fs_x__change_t *change,
185 apr_pool_t *scratch_pool);
187 /* Read all the changes from STREAM and invoke CHANGE_RECEIVER on each change.
188 Do all allocations in SCRATCH_POOL. */
190 svn_fs_x__read_changes_incrementally(svn_stream_t *stream,
191 svn_fs_x__change_receiver_t
193 void *change_receiver_baton,
194 apr_pool_t *scratch_pool);
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.
204 svn_fs_x__write_changes(svn_stream_t *stream,
207 svn_boolean_t terminate_list,
208 apr_pool_t *scratch_pool);
212 #endif /* __cplusplus */
214 #endif /* SVN_LIBSVN_FS__LOW_LEVEL_H */