1 /* reps-strings.h : interpreting representations with respect to strings 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_REPS_STRINGS_H 24 #define SVN_LIBSVN_FS_REPS_STRINGS_H 25 26 #define SVN_WANT_BDB 27 #include "svn_private_config.h" 28 29 #include "svn_io.h" 30 #include "svn_fs.h" 31 32 #include "trail.h" 33 34 35 #ifdef __cplusplus 36 extern "C" { 37 #endif /* __cplusplus */ 38 39 40 41 /* Get or create a mutable representation in FS, and set *NEW_REP_KEY to its 42 key. 43 44 TXN_ID is the id of the Subversion transaction under which this occurs. 45 46 If REP_KEY is not null and is already a mutable representation, set 47 *NEW_REP_KEY to REP_KEY, else create a brand new rep and set *NEW_REP_KEY 48 to its key, allocated in POOL. */ 49 svn_error_t *svn_fs_base__get_mutable_rep(const char **new_rep_key, 50 const char *rep_key, 51 svn_fs_t *fs, 52 const char *txn_id, 53 trail_t *trail, 54 apr_pool_t *pool); 55 56 57 /* Delete REP_KEY from FS if REP_KEY is mutable, as part of trail, or 58 do nothing if REP_KEY is immutable. If a mutable rep is deleted, 59 the string it refers to is deleted as well. TXN_ID is the id of 60 the Subversion transaction under which this occurs. 61 62 If no such rep, return SVN_ERR_FS_NO_SUCH_REPRESENTATION. */ 63 svn_error_t *svn_fs_base__delete_rep_if_mutable(svn_fs_t *fs, 64 const char *rep_key, 65 const char *txn_id, 66 trail_t *trail, 67 apr_pool_t *pool); 68 69 70 71 72 /*** Reading and writing rep contents. ***/ 73 74 /* Set *SIZE_P to the size of REP_KEY's contents in FS, as part of TRAIL. 75 Note: this is the fulltext size, no matter how the contents are 76 represented in storage. */ 77 svn_error_t *svn_fs_base__rep_contents_size(svn_filesize_t *size_p, 78 svn_fs_t *fs, 79 const char *rep_key, 80 trail_t *trail, 81 apr_pool_t *pool); 82 83 84 /* If MD5_CHECKSUM is non-NULL, set *MD5_CHECKSUM to the MD5 checksum 85 for REP_KEY in FS, as part of TRAIL. 86 87 If SHA1_CHECKSUM is non-NULL, set *SHA1_CHECKSUM to the SHA1 88 checksum for REP_KEY in FS, as part of TRAIL. 89 90 These are the prerecorded checksums for the rep's contents' 91 fulltext. If one or both of the checksums is not stored, do not 92 calculate one dynamically, just put NULL into the respective return 93 value. (By convention, the NULL checksum is considered to match 94 any checksum.) */ 95 svn_error_t * 96 svn_fs_base__rep_contents_checksums(svn_checksum_t **md5_checksum, 97 svn_checksum_t **sha1_checksum, 98 svn_fs_t *fs, 99 const char *rep_key, 100 trail_t *trail, 101 apr_pool_t *pool); 102 103 104 /* Set STR->data to the contents of REP_KEY in FS, and STR->len to the 105 contents' length, as part of TRAIL. The data is allocated in 106 POOL. If an error occurs, the effect on STR->data and 107 STR->len is undefined. 108 109 Note: this is the fulltext contents, no matter how the contents are 110 represented in storage. */ 111 svn_error_t *svn_fs_base__rep_contents(svn_string_t *str, 112 svn_fs_t *fs, 113 const char *rep_key, 114 trail_t *trail, 115 apr_pool_t *pool); 116 117 118 /* Set *RS_P to a stream to read the contents of REP_KEY in FS. 119 Allocate the stream in POOL. 120 121 REP_KEY may be null, in which case reads just return 0 bytes. 122 123 If USE_TRAIL_FOR_READS is TRUE, the stream's reads are part 124 of TRAIL; otherwise, each read happens in an internal, one-off 125 trail (though TRAIL is still required). POOL may be TRAIL->pool. */ 126 svn_error_t * 127 svn_fs_base__rep_contents_read_stream(svn_stream_t **rs_p, 128 svn_fs_t *fs, 129 const char *rep_key, 130 svn_boolean_t use_trail_for_reads, 131 trail_t *trail, 132 apr_pool_t *pool); 133 134 135 /* Set *WS_P to a stream to write the contents of REP_KEY. Allocate 136 the stream in POOL. TXN_ID is the id of the Subversion transaction 137 under which this occurs. 138 139 If USE_TRAIL_FOR_WRITES is TRUE, the stream's writes are part 140 of TRAIL; otherwise, each write happens in an internal, one-off 141 trail (though TRAIL is still required). POOL may be TRAIL->pool. 142 143 If REP_KEY is not mutable, writes to *WS_P will return the 144 error SVN_ERR_FS_REP_NOT_MUTABLE. */ 145 svn_error_t * 146 svn_fs_base__rep_contents_write_stream(svn_stream_t **ws_p, 147 svn_fs_t *fs, 148 const char *rep_key, 149 const char *txn_id, 150 svn_boolean_t use_trail_for_writes, 151 trail_t *trail, 152 apr_pool_t *pool); 153 154 155 156 /*** Deltified storage. ***/ 157 158 /* Offer TARGET the chance to store its contents as a delta against 159 SOURCE, in FS, as part of TRAIL. TARGET and SOURCE are both 160 representation keys. 161 162 This usually results in TARGET's data being stored as a diff 163 against SOURCE; but it might not, if it turns out to be more 164 efficient to store the contents some other way. */ 165 svn_error_t *svn_fs_base__rep_deltify(svn_fs_t *fs, 166 const char *target, 167 const char *source, 168 trail_t *trail, 169 apr_pool_t *pool); 170 171 172 #ifdef __cplusplus 173 } 174 #endif /* __cplusplus */ 175 176 #endif /* SVN_LIBSVN_FS_REPS_STRINGS_H */ 177