📄 svn_repos.h
字号:
/** * @copyright * ==================================================================== * Copyright (c) 2000-2006 CollabNet. All rights reserved. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms * are also available at http://subversion.tigris.org/license-1.html. * If newer versions of this license are posted there, you may use a * newer version instead, at your option. * * This software consists of voluntary contributions made by many * individuals. For exact contribution history, see the revision * history and logs, available at http://subversion.tigris.org/. * ==================================================================== * @endcopyright * * @file svn_repos.h * @brief tools built on top of the filesystem. */#ifndef SVN_REPOS_H#define SVN_REPOS_H#include <apr_pools.h>#include <apr_hash.h>#include "svn_fs.h"#include "svn_delta.h"#include "svn_types.h"#include "svn_error.h"#include "svn_version.h"#ifdef __cplusplusextern "C" {#endif /* __cplusplus *//* ---------------------------------------------------------------*//** * Get libsvn_repos version information. * * @since New in 1.1. */const svn_version_t *svn_repos_version(void);/** Callback type for checking authorization on paths produced by (at * least) svn_repos_dir_delta(). * * Set @a *allowed to TRUE to indicate that some operation is * authorized for @a path in @a root, or set it to FALSE to indicate * unauthorized (presumably according to state stored in @a baton). * * Do not assume @a pool has any lifetime beyond this call. * * The exact operation being authorized depends on the callback * implementation. For read authorization, for example, the caller * would implement an instance that does read checking, and pass it as * a parameter named [perhaps] 'authz_read_func'. The receiver of * that parameter might also take another parameter named * 'authz_write_func', which although sharing this type, would be a * different implementation. * * @note If someday we want more sophisticated authorization states * than just yes/no, @a allowed can become an enum type. */typedef svn_error_t *(*svn_repos_authz_func_t)(svn_boolean_t *allowed, svn_fs_root_t *root, const char *path, void *baton, apr_pool_t *pool);/** An enum defining the kinds of access authz looks up. * * @since New in 1.3. */typedef enum{ /** No access. */ svn_authz_none = 0, /** Path can be read. */ svn_authz_read = 1, /** Path can be altered. */ svn_authz_write = 2, /** The other access credentials are recursive. */ svn_authz_recursive = 4} svn_repos_authz_access_t;/** Callback type for checking authorization on paths produced by * the repository commit editor. * * Set @a *allowed to TRUE to indicate that the @a required access on * @a path in @a root is authorized, or set it to FALSE to indicate * unauthorized (presumable according to state stored in @a baton). * * If @a path is NULL, the callback should perform a global authz * lookup for the @a required access. That is, the lookup should * check if the @a required access is granted for at least one path of * the repository, and set @a *allowed to TRUE if so. @a root may * also be NULL if @a path is NULL. * * This callback is very similar to svn_repos_authz_func_t, with the * exception of the addition of the @a required parameter. * This is due to historical reasons: when authz was first implemented * for svn_repos_dir_delta(), it seemed there would need only checks * for read and write operations, hence the svn_repos_authz_func_t * callback prototype and usage scenario. But it was then realized * that lookups due to copying needed to be recursive, and that * brute-force recursive lookups didn't square with the O(1) * performances a copy operation should have. * * So a special way to ask for a recursive lookup was introduced. The * commit editor needs this capability to retain acceptable * performance. Instead of revving the existing callback, causing * unnecessary revving of functions that don't actually need the * extended functionality, this second, more complete callback was * introduced, for use by the commit editor. * * Some day, it would be nice to reunite these two callbacks and do * the necessary revving anyway, but for the time being, this dual * callback mechanism will do. */typedef svn_error_t *(*svn_repos_authz_callback_t) (svn_repos_authz_access_t required, svn_boolean_t *allowed, svn_fs_root_t *root, const char *path, void *baton, apr_pool_t *pool);/** * A callback function type for use in svn_repos_get_file_revs(). * @a baton is provided by the caller, @a path is the pathname of the file * in revision @a rev and @a rev_props are the revision properties. * If @a delta_handler and @a delta_baton are non-NULL, they may be set to a * handler/baton which will be called with the delta between the previous * revision and this one after the return of this callback. They may be * left as NULL/NULL. * @a prop_diffs is an array of svn_prop_t elements indicating the property * delta for this and the previous revision. * @a pool may be used for temporary allocations, but you can't rely * on objects allocated to live outside of this particular call and the * immediately following calls to @a *delta_handler if any. * * @since New in 1.1. */typedef svn_error_t *(*svn_repos_file_rev_handler_t) (void *baton, const char *path, svn_revnum_t rev, apr_hash_t *rev_props, svn_txdelta_window_handler_t *delta_handler, void **delta_baton, apr_array_header_t *prop_diffs, apr_pool_t *pool);/** The repository object. */typedef struct svn_repos_t svn_repos_t;/* Opening and creating repositories. *//** Find the root path of the repository that contains @a path. * * If a repository was found, the path to the root of the repository * is returned, else @c NULL. The pointer to the returned path may be * equal to @a path. */const char *svn_repos_find_root_path(const char *path, apr_pool_t *pool);/** Set @a *repos_p to a repository object for the repository at @a path. * * Allocate @a *repos_p in @a pool. * * Acquires a shared lock on the repository, and attaches a cleanup * function to @a pool to remove the lock. If no lock can be acquired, * returns error, with undefined effect on @a *repos_p. If an exclusive * lock is present, this blocks until it's gone. */svn_error_t *svn_repos_open(svn_repos_t **repos_p, const char *path, apr_pool_t *pool);/** Create a new Subversion repository at @a path, building the necessary * directory structure, creating the filesystem, and so on. * Return the repository object in @a *repos_p, allocated in @a pool. * * @a config is a client configuration hash of @c svn_config_t * items * keyed on config category names, and may be NULL. * * @a fs_config is passed to the filesystem, and may be NULL. * * @a unused_1 and @a unused_2 are not used and should be NULL. */svn_error_t *svn_repos_create(svn_repos_t **repos_p, const char *path, const char *unused_1, const char *unused_2, apr_hash_t *config, apr_hash_t *fs_config, apr_pool_t *pool);/** Destroy the Subversion repository found at @a path, using @a pool for any * necessary allocations. */svn_error_t *svn_repos_delete(const char *path, apr_pool_t *pool);/** Return the filesystem associated with repository object @a repos. */svn_fs_t *svn_repos_fs(svn_repos_t *repos);/** Make a hot copy of the Subversion repository found at @a src_path * to @a dst_path. * * Copy a possibly live Subversion repository from @a src_path to * @a dst_path. If @a clean_logs is @c TRUE, perform cleanup on the * source filesystem as part of the copy operation; currently, this * means deleting copied, unused logfiles for a Berkeley DB source * repository. */svn_error_t * svn_repos_hotcopy(const char *src_path, const char *dst_path, svn_boolean_t clean_logs, apr_pool_t *pool);/** * Run database recovery procedures on the repository at @a path, * returning the database to a consistent state. Use @a pool for all * allocation. * * Acquires an exclusive lock on the repository, recovers the * database, and releases the lock. If an exclusive lock can't be * acquired, returns error. * * @deprecated Provided for backward compatibility with the 1.0 API. */svn_error_t *svn_repos_recover(const char *path, apr_pool_t *pool);/** * Run database recovery procedures on the repository at @a path, * returning the database to a consistent state. Use @a pool for all * allocation. * * Acquires an exclusive lock on the repository, recovers the * database, and releases the lock. If an exclusive lock can't be * acquired, returns error. * * If @a nonblocking is TRUE, an error of type EWOULDBLOCK is * returned if the lock is not immediately available. * * If @a start_callback is not NULL, it will be called with @a * start_callback_baton as argument before the recovery starts, but * after the exclusive lock has been acquired. * * @since New in 1.1. */svn_error_t *svn_repos_recover2(const char *path, svn_boolean_t nonblocking, svn_error_t *(*start_callback)(void *baton), void *start_callback_baton, apr_pool_t *pool);/** This function is a wrapper around svn_fs_berkeley_logfiles(), * returning log file paths relative to the root of the repository. * * @copydoc svn_fs_berkeley_logfiles() */svn_error_t *svn_repos_db_logfiles(apr_array_header_t **logfiles, const char *path, svn_boolean_t only_unused, apr_pool_t *pool);/* Repository Paths *//** Return the top-level repository path allocated in @a pool. */const char *svn_repos_path(svn_repos_t *repos, apr_pool_t *pool);/** Return the path to @a repos's filesystem directory, allocated in * @a pool. */const char *svn_repos_db_env(svn_repos_t *repos, apr_pool_t *pool);/** Return path to @a repos's config directory, allocated in @a pool. */const char *svn_repos_conf_dir(svn_repos_t *repos, apr_pool_t *pool);/** Return path to @a repos's svnserve.conf, allocated in @a pool. */const char *svn_repos_svnserve_conf(svn_repos_t *repos, apr_pool_t *pool);/** Return path to @a repos's lock directory, allocated in @a pool. */const char *svn_repos_lock_dir(svn_repos_t *repos, apr_pool_t *pool);/** Return path to @a repos's db lockfile, allocated in @a pool. */const char *svn_repos_db_lockfile(svn_repos_t *repos, apr_pool_t *pool);/** Return path to @a repos's db logs lockfile, allocated in @a pool. */const char *svn_repos_db_logs_lockfile(svn_repos_t *repos, apr_pool_t *pool);/** Return the path to @a repos's hook directory, allocated in @a pool. */const char *svn_repos_hook_dir(svn_repos_t *repos, apr_pool_t *pool);/** Return the path to @a repos's start-commit hook, allocated in @a pool. */const char *svn_repos_start_commit_hook(svn_repos_t *repos, apr_pool_t *pool);/** Return the path to @a repos's pre-commit hook, allocated in @a pool. */const char *svn_repos_pre_commit_hook(svn_repos_t *repos, apr_pool_t *pool);/** Return the path to @a repos's post-commit hook, allocated in @a pool. */const char *svn_repos_post_commit_hook(svn_repos_t *repos, apr_pool_t *pool);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -