1251881Speter/* strings-table.h : internal interface to `strings' table 2251881Speter * 3251881Speter * ==================================================================== 4251881Speter * Licensed to the Apache Software Foundation (ASF) under one 5251881Speter * or more contributor license agreements. See the NOTICE file 6251881Speter * distributed with this work for additional information 7251881Speter * regarding copyright ownership. The ASF licenses this file 8251881Speter * to you under the Apache License, Version 2.0 (the 9251881Speter * "License"); you may not use this file except in compliance 10251881Speter * with the License. You may obtain a copy of the License at 11251881Speter * 12251881Speter * http://www.apache.org/licenses/LICENSE-2.0 13251881Speter * 14251881Speter * Unless required by applicable law or agreed to in writing, 15251881Speter * software distributed under the License is distributed on an 16251881Speter * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17251881Speter * KIND, either express or implied. See the License for the 18251881Speter * specific language governing permissions and limitations 19251881Speter * under the License. 20251881Speter * ==================================================================== 21251881Speter */ 22251881Speter 23251881Speter#ifndef SVN_LIBSVN_FS_STRINGS_TABLE_H 24251881Speter#define SVN_LIBSVN_FS_STRINGS_TABLE_H 25251881Speter 26251881Speter#define SVN_WANT_BDB 27251881Speter#include "svn_private_config.h" 28251881Speter 29251881Speter#include "svn_io.h" 30251881Speter#include "svn_fs.h" 31251881Speter#include "../trail.h" 32251881Speter 33251881Speter#ifdef __cplusplus 34251881Speterextern "C" { 35251881Speter#endif /* __cplusplus */ 36251881Speter 37251881Speter 38251881Speter/* This interface provides raw access to the `strings' table. It does 39251881Speter not deal with deltification, undeltification, or skels. It just 40251881Speter reads and writes strings of bytes. */ 41251881Speter 42251881Speter 43251881Speter/* Open a `strings' table in ENV. If CREATE is non-zero, create 44251881Speter * one if it doesn't exist. Set *STRINGS_P to the new table. 45251881Speter * Return a Berkeley DB error code. 46251881Speter */ 47251881Speterint svn_fs_bdb__open_strings_table(DB **strings_p, 48251881Speter DB_ENV *env, 49251881Speter svn_boolean_t create); 50251881Speter 51251881Speter 52251881Speter/* Read *LEN bytes into BUF from OFFSET in string KEY in FS, as part 53251881Speter * of TRAIL. 54251881Speter * 55251881Speter * On return, *LEN is set to the number of bytes read. If this value 56251881Speter * is less than the number requested, the end of the string has been 57251881Speter * reached (no error is returned on end-of-string). 58251881Speter * 59251881Speter * If OFFSET is past the end of the string, then *LEN will be set to 60251881Speter * zero. Callers which are advancing OFFSET as they read portions of 61251881Speter * the string can terminate their loop when *LEN is returned as zero 62251881Speter * (which will occur when OFFSET == length(the string)). 63251881Speter * 64251881Speter * If string KEY does not exist, the error SVN_ERR_FS_NO_SUCH_STRING 65251881Speter * is returned. 66251881Speter */ 67251881Spetersvn_error_t *svn_fs_bdb__string_read(svn_fs_t *fs, 68251881Speter const char *key, 69251881Speter char *buf, 70251881Speter svn_filesize_t offset, 71251881Speter apr_size_t *len, 72251881Speter trail_t *trail, 73251881Speter apr_pool_t *pool); 74251881Speter 75251881Speter 76251881Speter/* Set *SIZE to the size in bytes of string KEY in FS, as part of 77251881Speter * TRAIL. 78251881Speter * 79251881Speter * If string KEY does not exist, return SVN_ERR_FS_NO_SUCH_STRING. 80251881Speter */ 81251881Spetersvn_error_t *svn_fs_bdb__string_size(svn_filesize_t *size, 82251881Speter svn_fs_t *fs, 83251881Speter const char *key, 84251881Speter trail_t *trail, 85251881Speter apr_pool_t *pool); 86251881Speter 87251881Speter 88251881Speter/* Append LEN bytes from BUF to string *KEY in FS, as part of TRAIL. 89251881Speter * 90251881Speter * If *KEY is null, then create a new string and store the new key in 91251881Speter * *KEY (allocating it in POOL), and write LEN bytes from BUF 92251881Speter * as the initial contents of the string. 93251881Speter * 94251881Speter * If *KEY is not null but there is no string named *KEY, return 95251881Speter * SVN_ERR_FS_NO_SUCH_STRING. 96251881Speter * 97251881Speter * Note: to overwrite the old contents of a string, call 98251881Speter * svn_fs_bdb__string_clear() and then svn_fs_bdb__string_append(). */ 99251881Spetersvn_error_t *svn_fs_bdb__string_append(svn_fs_t *fs, 100251881Speter const char **key, 101251881Speter apr_size_t len, 102251881Speter const char *buf, 103251881Speter trail_t *trail, 104251881Speter apr_pool_t *pool); 105251881Speter 106251881Speter 107251881Speter/* Make string KEY in FS zero length, as part of TRAIL. 108251881Speter * If the string does not exist, return SVN_ERR_FS_NO_SUCH_STRING. 109251881Speter */ 110251881Spetersvn_error_t *svn_fs_bdb__string_clear(svn_fs_t *fs, 111251881Speter const char *key, 112251881Speter trail_t *trail, 113251881Speter apr_pool_t *pool); 114251881Speter 115251881Speter 116251881Speter/* Delete string KEY from FS, as part of TRAIL. 117251881Speter * 118251881Speter * If string KEY does not exist, return SVN_ERR_FS_NO_SUCH_STRING. 119251881Speter * 120251881Speter * WARNING: Deleting a string renders unusable any representations 121251881Speter * that refer to it. Be careful. 122251881Speter */ 123251881Spetersvn_error_t *svn_fs_bdb__string_delete(svn_fs_t *fs, 124251881Speter const char *key, 125251881Speter trail_t *trail, 126251881Speter apr_pool_t *pool); 127251881Speter 128251881Speter 129251881Speter/* Copy the contents of the string referred to by KEY in FS into a new 130251881Speter * record, returning the new record's key in *NEW_KEY. All 131251881Speter * allocations (including *NEW_KEY) occur in POOL. */ 132251881Spetersvn_error_t *svn_fs_bdb__string_copy(svn_fs_t *fs, 133251881Speter const char **new_key, 134251881Speter const char *key, 135251881Speter trail_t *trail, 136251881Speter apr_pool_t *pool); 137251881Speter 138251881Speter 139251881Speter#ifdef __cplusplus 140251881Speter} 141251881Speter#endif /* __cplusplus */ 142251881Speter 143251881Speter#endif /* SVN_LIBSVN_FS_STRINGS_TABLE_H */ 144