1153761Swollman/* reps-strings.h : interpreting representations with respect to strings 2192886Sedwin * 3192886Sedwin * ==================================================================== 4192886Sedwin * Licensed to the Apache Software Foundation (ASF) under one 564499Swollman * or more contributor license agreements. See the NOTICE file 62742Swollman * distributed with this work for additional information 72742Swollman * regarding copyright ownership. The ASF licenses this file 82742Swollman * to you under the Apache License, Version 2.0 (the 92742Swollman * "License"); you may not use this file except in compliance 10158421Swollman * with the License. You may obtain a copy of the License at 112742Swollman * 12158421Swollman * http://www.apache.org/licenses/LICENSE-2.0 13158421Swollman * 142742Swollman * Unless required by applicable law or agreed to in writing, 1586222Swollman * software distributed under the License is distributed on an 1620094Swollman * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 1720094Swollman * KIND, either express or implied. See the License for the 1820094Swollman * specific language governing permissions and limitations 1920094Swollman * under the License. 2020094Swollman * ==================================================================== 21158421Swollman */ 22158421Swollman 2320094Swollman#ifndef SVN_LIBSVN_FS_REPS_STRINGS_H 2419878Swollman#define SVN_LIBSVN_FS_REPS_STRINGS_H 2519878Swollman 2619878Swollman#define SVN_WANT_BDB 2719878Swollman#include "svn_private_config.h" 2819878Swollman 2919878Swollman#include "svn_io.h" 3019878Swollman#include "svn_fs.h" 3119878Swollman 3258787Sru#include "trail.h" 3358787Sru 3458787Sru 3558787Sru#ifdef __cplusplus 3658787Sruextern "C" { 3758787Sru#endif /* __cplusplus */ 3858787Sru 3958787Sru 4058787Sru 4158787Sru/* Get or create a mutable representation in FS, and set *NEW_REP_KEY to its 4258787Sru key. 4358787Sru 4458787Sru TXN_ID is the id of the Subversion transaction under which this occurs. 4558787Sru 4658787Sru If REP_KEY is not null and is already a mutable representation, set 4758787Sru *NEW_REP_KEY to REP_KEY, else create a brand new rep and set *NEW_REP_KEY 4858787Sru to its key, allocated in POOL. */ 4958787Srusvn_error_t *svn_fs_base__get_mutable_rep(const char **new_rep_key, 502742Swollman const char *rep_key, 512742Swollman svn_fs_t *fs, 522742Swollman const char *txn_id, 532742Swollman trail_t *trail, 542742Swollman apr_pool_t *pool); 552742Swollman 562742Swollman 5719878Swollman/* Delete REP_KEY from FS if REP_KEY is mutable, as part of trail, or 582742Swollman do nothing if REP_KEY is immutable. If a mutable rep is deleted, 592742Swollman the string it refers to is deleted as well. TXN_ID is the id of 602742Swollman the Subversion transaction under which this occurs. 6119878Swollman 622742Swollman If no such rep, return SVN_ERR_FS_NO_SUCH_REPRESENTATION. */ 632742Swollmansvn_error_t *svn_fs_base__delete_rep_if_mutable(svn_fs_t *fs, 64149514Swollman const char *rep_key, 6521217Swollman const char *txn_id, 669908Swollman trail_t *trail, 679908Swollman apr_pool_t *pool); 682742Swollman 6919878Swollman 7019878Swollman 7119878Swollman 7219878Swollman/*** Reading and writing rep contents. ***/ 7319878Swollman 7419878Swollman/* Set *SIZE_P to the size of REP_KEY's contents in FS, as part of TRAIL. 7519878Swollman Note: this is the fulltext size, no matter how the contents are 7619878Swollman represented in storage. */ 7719878Swollmansvn_error_t *svn_fs_base__rep_contents_size(svn_filesize_t *size_p, 7819878Swollman svn_fs_t *fs, 7919878Swollman const char *rep_key, 8019878Swollman trail_t *trail, 8119878Swollman apr_pool_t *pool); 8219878Swollman 8319878Swollman 8419878Swollman/* If MD5_CHECKSUM is non-NULL, set *MD5_CHECKSUM to the MD5 checksum 8593799Swollman for REP_KEY in FS, as part of TRAIL. 8658787Sru 8758787Sru If SHA1_CHECKSUM is non-NULL, set *SHA1_CHECKSUM to the SHA1 8819878Swollman checksum for REP_KEY in FS, as part of TRAIL. 8919878Swollman 9019878Swollman These are the prerecorded checksums for the rep's contents' 919908Swollman fulltext. If one or both of the checksums is not stored, do not 92149514Swollman calculate one dynamically, just put NULL into the respective return 939908Swollman value. (By convention, the NULL checksum is considered to match 949908Swollman any checksum.) */ 959908Swollmansvn_error_t * 9621217Swollmansvn_fs_base__rep_contents_checksums(svn_checksum_t **md5_checksum, 9719878Swollman svn_checksum_t **sha1_checksum, 9819878Swollman svn_fs_t *fs, 999908Swollman const char *rep_key, 100149514Swollman trail_t *trail, 1019908Swollman apr_pool_t *pool); 1029908Swollman 1039908Swollman 1049908Swollman/* Set STR->data to the contents of REP_KEY in FS, and STR->len to the 10558787Sru contents' length, as part of TRAIL. The data is allocated in 10658787Sru POOL. If an error occurs, the effect on STR->data and 10758787Sru STR->len is undefined. 10864499Swollman 10964499Swollman Note: this is the fulltext contents, no matter how the contents are 110175034Sedwin represented in storage. */ 111175034Sedwinsvn_error_t *svn_fs_base__rep_contents(svn_string_t *str, 112175034Sedwin svn_fs_t *fs, 113175034Sedwin const char *rep_key, 114175034Sedwin trail_t *trail, 11558787Sru apr_pool_t *pool); 11658787Sru 11767578Swollman 11858787Sru/* Set *RS_P to a stream to read the contents of REP_KEY in FS. 11958787Sru Allocate the stream in POOL. 12058787Sru 121149514Swollman REP_KEY may be null, in which case reads just return 0 bytes. 12264499Swollman 12364499Swollman If USE_TRAIL_FOR_READS is TRUE, the stream's reads are part 12464499Swollman of TRAIL; otherwise, each read happens in an internal, one-off 12564499Swollman trail (though TRAIL is still required). POOL may be TRAIL->pool. */ 12686222Swollmansvn_error_t * 12786222Swollmansvn_fs_base__rep_contents_read_stream(svn_stream_t **rs_p, 12886222Swollman svn_fs_t *fs, 12986222Swollman const char *rep_key, 13086222Swollman svn_boolean_t use_trail_for_reads, 13186222Swollman trail_t *trail, 13286222Swollman apr_pool_t *pool); 13386222Swollman 13486222Swollman 13586222Swollman/* Set *WS_P to a stream to write the contents of REP_KEY. Allocate 13686222Swollman the stream in POOL. TXN_ID is the id of the Subversion transaction 13786222Swollman under which this occurs. 13886222Swollman 13986222Swollman If USE_TRAIL_FOR_WRITES is TRUE, the stream's writes are part 14086222Swollman of TRAIL; otherwise, each write happens in an internal, one-off 14186222Swollman trail (though TRAIL is still required). POOL may be TRAIL->pool. 14286222Swollman 14386222Swollman If REP_KEY is not mutable, writes to *WS_P will return the 14486222Swollman error SVN_ERR_FS_REP_NOT_MUTABLE. */ 14586222Swollmansvn_error_t * 14686222Swollmansvn_fs_base__rep_contents_write_stream(svn_stream_t **ws_p, 14786222Swollman svn_fs_t *fs, 14886222Swollman const char *rep_key, 149175034Sedwin const char *txn_id, 150175034Sedwin svn_boolean_t use_trail_for_writes, 151175034Sedwin trail_t *trail, 152175034Sedwin apr_pool_t *pool); 153175034Sedwin 154175034Sedwin 155175034Sedwin 156175034Sedwin/*** Deltified storage. ***/ 157175034Sedwin 158175034Sedwin/* Offer TARGET the chance to store its contents as a delta against 159175034Sedwin SOURCE, in FS, as part of TRAIL. TARGET and SOURCE are both 160175034Sedwin representation keys. 161175034Sedwin 162175034Sedwin This usually results in TARGET's data being stored as a diff 163175034Sedwin against SOURCE; but it might not, if it turns out to be more 164175034Sedwin efficient to store the contents some other way. */ 165175034Sedwinsvn_error_t *svn_fs_base__rep_deltify(svn_fs_t *fs, 166175034Sedwin const char *target, 167175034Sedwin const char *source, 168175034Sedwin trail_t *trail, 169183066Sedwin apr_pool_t *pool); 170183066Sedwin 171183066Sedwin 172183066Sedwin#ifdef __cplusplus 173183066Sedwin} 174183066Sedwin#endif /* __cplusplus */ 175183066Sedwin 176183066Sedwin#endif /* SVN_LIBSVN_FS_REPS_STRINGS_H */ 177183066Sedwin