In the command-line client, forbid
[svn.git] / subversion / include / private / svn_fs_util.h
blob09407525635596422ad08ac6da0533bf489017ab
1 /*
2 * svn_fs_util.h: Declarations for the APIs of libsvn_fs_util to be
3 * consumed by only fs_* libs.
5 * ====================================================================
6 * Copyright (c) 2007 CollabNet. All rights reserved.
8 * This software is licensed as described in the file COPYING, which
9 * you should have received as part of this distribution. The terms
10 * are also available at http://subversion.tigris.org/license-1.html.
11 * If newer versions of this license are posted there, you may use a
12 * newer version instead, at your option.
14 * This software consists of voluntary contributions made by many
15 * individuals. For exact contribution history, see the revision
16 * history and logs, available at http://subversion.tigris.org/.
17 * ====================================================================
20 #ifndef SVN_FS_UTIL_H
21 #define SVN_FS_UTIL_H
23 #include "svn_private_config.h"
24 #ifdef __cplusplus
25 extern "C" {
26 #endif /* __cplusplus */
28 /* Return a canonicalized version of a filesystem PATH, allocated in
29 POOL. While the filesystem API is pretty flexible about the
30 incoming paths (they must be UTF-8 with '/' as separators, but they
31 don't have to begin with '/', and multiple contiguous '/'s are
32 ignored) we want any paths that are physically stored in the
33 underlying database to look consistent. Specifically, absolute
34 filesystem paths should begin with '/', and all redundant and trailing '/'
35 characters be removed. */
36 const char *
37 svn_fs__canonicalize_abspath(const char *path, apr_pool_t *pool);
39 /* Verify that FS refers to an open database; return an appropriate
40 error if this is not the case. */
41 svn_error_t *svn_fs__check_fs(svn_fs_t *fs);
43 /* Constructing nice error messages for roots. */
45 /* Build an SVN_ERR_FS_NOT_FOUND error, with a detailed error text,
46 for PATH in ROOT. ROOT is of type svn_fs_root_t *. */
47 #define SVN_FS__NOT_FOUND(root, path) ( \
48 root->is_txn_root ? \
49 svn_error_createf \
50 (SVN_ERR_FS_NOT_FOUND, 0, \
51 _("File not found: transaction '%s', path '%s'"), \
52 root->txn, path) \
53 : \
54 svn_error_createf \
55 (SVN_ERR_FS_NOT_FOUND, 0, \
56 _("File not found: revision %ld, path '%s'"), \
57 root->rev, path) \
61 /* Build a detailed `file already exists' message for PATH in ROOT.
62 ROOT is of type svn_fs_root_t *. */
63 #define SVN_FS__ALREADY_EXISTS(root, path_str) ( \
64 root->is_txn_root ? \
65 svn_error_createf \
66 (SVN_ERR_FS_ALREADY_EXISTS, 0, \
67 _("File already exists: filesystem '%s', transaction '%s', path '%s'"), \
68 root->fs->path, root->txn, path_str) \
69 : \
70 svn_error_createf \
71 (SVN_ERR_FS_ALREADY_EXISTS, 0, \
72 _("File already exists: filesystem '%s', revision %ld, path '%s'"), \
73 root->fs->path, root->rev, path_str) \
76 /* ROOT is of type svn_fs_root_t *. */
77 #define SVN_FS__NOT_TXN(root) \
78 svn_error_create \
79 (SVN_ERR_FS_NOT_TXN_ROOT, NULL, \
80 _("Root object must be a transaction root"))
82 /* SVN_FS__ERR_NOT_MUTABLE: the caller attempted to change a node
83 outside of a transaction. FS is of type "svn_fs_t *". */
84 #define SVN_FS__ERR_NOT_MUTABLE(fs, rev, path_in_repo) \
85 svn_error_createf \
86 (SVN_ERR_FS_NOT_MUTABLE, 0, \
87 _("File is not mutable: filesystem '%s', revision %ld, path '%s'"), \
88 fs->path, rev, path_in_repo)
90 /* FS is of type "svn fs_t *".*/
91 #define SVN_FS__ERR_NOT_DIRECTORY(fs, path_in_repo) \
92 svn_error_createf \
93 (SVN_ERR_FS_NOT_DIRECTORY, 0, \
94 _("'%s' is not a directory in filesystem '%s'"), \
95 path_in_repo, fs->path)
97 /* FS is of type "svn fs_t *". */
98 #define SVN_FS__ERR_NOT_FILE(fs, path_in_repo) \
99 svn_error_createf \
100 (SVN_ERR_FS_NOT_FILE, 0, \
101 _("'%s' is not a file in filesystem '%s'"), \
102 path_in_repo, fs->path)
104 /* FS is of type "svn fs_t *", LOCK is of type "svn_lock_t *". */
105 #define SVN_FS__ERR_PATH_ALREADY_LOCKED(fs, lock) \
106 svn_error_createf \
107 (SVN_ERR_FS_PATH_ALREADY_LOCKED, 0, \
108 _("Path '%s' is already locked by user '%s' in filesystem '%s'"), \
109 lock->path, lock->owner, fs->path)
111 /* FS is of type "svn fs_t *". */
112 #define SVN_FS__ERR_NO_SUCH_LOCK(fs, path_in_repo) \
113 svn_error_createf \
114 (SVN_ERR_FS_NO_SUCH_LOCK, 0, \
115 _("No lock on path '%s' in filesystem '%s'"), \
116 path_in_repo, fs->path)
118 /* FS is of type "svn fs_t *". */
119 #define SVN_FS__ERR_LOCK_EXPIRED(fs, token) \
120 svn_error_createf \
121 (SVN_ERR_FS_LOCK_EXPIRED, 0, \
122 _("Lock has expired: lock-token '%s' in filesystem '%s'"), \
123 token, fs->path)
125 /* FS is of type "svn fs_t *". */
126 #define SVN_FS__ERR_NO_USER(fs) \
127 svn_error_createf \
128 (SVN_ERR_FS_NO_USER, 0, \
129 _("No username is currently associated with filesystem '%s'"), \
130 fs->path)
132 /* SVN_FS__ERR_LOCK_OWNER_MISMATCH: trying to use a lock whose
133 LOCK_OWNER doesn't match the USERNAME associated with FS.
134 FS is of type "svn fs_t *". */
135 #define SVN_FS__ERR_LOCK_OWNER_MISMATCH(fs, username, lock_owner) \
136 svn_error_createf \
137 (SVN_ERR_FS_LOCK_OWNER_MISMATCH, 0, \
138 _("User '%s' is trying to use a lock owned by '%s' in " \
139 "filesystem '%s'"), \
140 username, lock_owner, fs->path)
142 /* Return a NULL-terminated copy of the first component of PATH,
143 allocated in POOL. If path is empty, or consists entirely of
144 slashes, return the empty string.
146 If the component is followed by one or more slashes, we set *NEXT_P
147 to point after the slashes. If the component ends PATH, we set
148 *NEXT_P to zero. This means:
149 - If *NEXT_P is zero, then the component ends the PATH, and there
150 are no trailing slashes in the path.
151 - If *NEXT_P points at PATH's terminating NULL character, then
152 the component returned was the last, and PATH ends with one or more
153 slash characters.
154 - Otherwise, *NEXT_P points to the beginning of the next component
155 of PATH. You can pass this value to next_entry_name to extract
156 the next component. */
157 char *
158 svn_fs__next_entry_name(const char **next_p,
159 const char *path,
160 apr_pool_t *pool);
162 #ifdef __cplusplus
164 #endif /* __cplusplus */
166 #endif /* SVN_FS_UTIL_H */