1 /* strings-table.h : internal interface to `strings' table 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_STRINGS_TABLE_H 24 #define SVN_LIBSVN_FS_STRINGS_TABLE_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 #include "../trail.h" 32 33 #ifdef __cplusplus 34 extern "C" { 35 #endif /* __cplusplus */ 36 37 38 /* This interface provides raw access to the `strings' table. It does 39 not deal with deltification, undeltification, or skels. It just 40 reads and writes strings of bytes. */ 41 42 43 /* Open a `strings' table in ENV. If CREATE is non-zero, create 44 * one if it doesn't exist. Set *STRINGS_P to the new table. 45 * Return a Berkeley DB error code. 46 */ 47 int svn_fs_bdb__open_strings_table(DB **strings_p, 48 DB_ENV *env, 49 svn_boolean_t create); 50 51 52 /* Read *LEN bytes into BUF from OFFSET in string KEY in FS, as part 53 * of TRAIL. 54 * 55 * On return, *LEN is set to the number of bytes read. If this value 56 * is less than the number requested, the end of the string has been 57 * reached (no error is returned on end-of-string). 58 * 59 * If OFFSET is past the end of the string, then *LEN will be set to 60 * zero. Callers which are advancing OFFSET as they read portions of 61 * the string can terminate their loop when *LEN is returned as zero 62 * (which will occur when OFFSET == length(the string)). 63 * 64 * If string KEY does not exist, the error SVN_ERR_FS_NO_SUCH_STRING 65 * is returned. 66 */ 67 svn_error_t *svn_fs_bdb__string_read(svn_fs_t *fs, 68 const char *key, 69 char *buf, 70 svn_filesize_t offset, 71 apr_size_t *len, 72 trail_t *trail, 73 apr_pool_t *pool); 74 75 76 /* Set *SIZE to the size in bytes of string KEY in FS, as part of 77 * TRAIL. 78 * 79 * If string KEY does not exist, return SVN_ERR_FS_NO_SUCH_STRING. 80 */ 81 svn_error_t *svn_fs_bdb__string_size(svn_filesize_t *size, 82 svn_fs_t *fs, 83 const char *key, 84 trail_t *trail, 85 apr_pool_t *pool); 86 87 88 /* Append LEN bytes from BUF to string *KEY in FS, as part of TRAIL. 89 * 90 * If *KEY is null, then create a new string and store the new key in 91 * *KEY (allocating it in POOL), and write LEN bytes from BUF 92 * as the initial contents of the string. 93 * 94 * If *KEY is not null but there is no string named *KEY, return 95 * SVN_ERR_FS_NO_SUCH_STRING. 96 * 97 * Note: to overwrite the old contents of a string, call 98 * svn_fs_bdb__string_clear() and then svn_fs_bdb__string_append(). */ 99 svn_error_t *svn_fs_bdb__string_append(svn_fs_t *fs, 100 const char **key, 101 apr_size_t len, 102 const char *buf, 103 trail_t *trail, 104 apr_pool_t *pool); 105 106 107 /* Make string KEY in FS zero length, as part of TRAIL. 108 * If the string does not exist, return SVN_ERR_FS_NO_SUCH_STRING. 109 */ 110 svn_error_t *svn_fs_bdb__string_clear(svn_fs_t *fs, 111 const char *key, 112 trail_t *trail, 113 apr_pool_t *pool); 114 115 116 /* Delete string KEY from FS, as part of TRAIL. 117 * 118 * If string KEY does not exist, return SVN_ERR_FS_NO_SUCH_STRING. 119 * 120 * WARNING: Deleting a string renders unusable any representations 121 * that refer to it. Be careful. 122 */ 123 svn_error_t *svn_fs_bdb__string_delete(svn_fs_t *fs, 124 const char *key, 125 trail_t *trail, 126 apr_pool_t *pool); 127 128 129 /* Copy the contents of the string referred to by KEY in FS into a new 130 * record, returning the new record's key in *NEW_KEY. All 131 * allocations (including *NEW_KEY) occur in POOL. */ 132 svn_error_t *svn_fs_bdb__string_copy(svn_fs_t *fs, 133 const char **new_key, 134 const char *key, 135 trail_t *trail, 136 apr_pool_t *pool); 137 138 139 #ifdef __cplusplus 140 } 141 #endif /* __cplusplus */ 142 143 #endif /* SVN_LIBSVN_FS_STRINGS_TABLE_H */ 144