1231200Smm/* lock.h : internal interface to lock functions
2231200Smm *
3231200Smm * ====================================================================
4231200Smm *    Licensed to the Apache Software Foundation (ASF) under one
5231200Smm *    or more contributor license agreements.  See the NOTICE file
6231200Smm *    distributed with this work for additional information
7231200Smm *    regarding copyright ownership.  The ASF licenses this file
8231200Smm *    to you under the Apache License, Version 2.0 (the
9231200Smm *    "License"); you may not use this file except in compliance
10231200Smm *    with the License.  You may obtain a copy of the License at
11231200Smm *
12231200Smm *      http://www.apache.org/licenses/LICENSE-2.0
13231200Smm *
14231200Smm *    Unless required by applicable law or agreed to in writing,
15231200Smm *    software distributed under the License is distributed on an
16231200Smm *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17231200Smm *    KIND, either express or implied.  See the License for the
18231200Smm *    specific language governing permissions and limitations
19231200Smm *    under the License.
20231200Smm * ====================================================================
21231200Smm */
22231200Smm
23231200Smm#ifndef SVN_LIBSVN_FS_LOCK_H
24231200Smm#define SVN_LIBSVN_FS_LOCK_H
25231200Smm
26231200Smm#include "trail.h"
27231200Smm
28231200Smm
29231200Smm#ifdef __cplusplus
30231200Smmextern "C" {
31231200Smm#endif /* __cplusplus */
32231200Smm
33231200Smm
34231200Smm
35231200Smm/* These functions implement part of the FS loader library's fs
36231200Smm   vtables.  See the public svn_fs.h for docstrings.*/
37231200Smm
38231200Smmsvn_error_t *svn_fs_base__lock(svn_lock_t **lock,
39231200Smm                               svn_fs_t *fs,
40232153Smm                               const char *path,
41232153Smm                               const char *token,
42232153Smm                               const char *comment,
43231200Smm                               svn_boolean_t is_dav_comment,
44231200Smm                               apr_time_t expiration_date,
45231200Smm                               svn_revnum_t current_rev,
46231200Smm                               svn_boolean_t steal_lock,
47231200Smm                               apr_pool_t *pool);
48231200Smm
49231200Smmsvn_error_t *svn_fs_base__generate_lock_token(const char **token,
50231200Smm                                              svn_fs_t *fs,
51231200Smm                                              apr_pool_t *pool);
52231200Smm
53231200Smmsvn_error_t *svn_fs_base__unlock(svn_fs_t *fs,
54231200Smm                                 const char *path,
55231200Smm                                 const char *token,
56231200Smm                                 svn_boolean_t break_lock,
57231200Smm                                 apr_pool_t *pool);
58231200Smm
59231200Smmsvn_error_t *svn_fs_base__get_lock(svn_lock_t **lock,
60231200Smm                                   svn_fs_t *fs,
61232153Smm                                   const char *path,
62232153Smm                                   apr_pool_t *pool);
63232153Smm
64231200Smmsvn_error_t *
65231200Smmsvn_fs_base__get_locks(svn_fs_t *fs,
66231200Smm                       const char *path,
67231200Smm                       svn_depth_t depth,
68231200Smm                       svn_fs_get_locks_callback_t get_locks_func,
69231200Smm                       void *get_locks_baton,
70231200Smm                       apr_pool_t *pool);
71231200Smm
72231200Smm
73231200Smm
74231200Smm/* These next functions are 'helpers' for internal fs use:
75231200Smm   if a fs function's txn_body needs to enforce existing locks, it
76231200Smm   should use these routines:
77231200Smm*/
78231200Smm
79231200Smm
80231200Smm/* Implements main logic of 'svn_fs_get_lock' (or in this
81231200Smm   case, svn_fs_base__get_lock() above.)  See svn_fs.h. */
82231200Smmsvn_error_t *
83231200Smmsvn_fs_base__get_lock_helper(svn_lock_t **lock_p,
84231200Smm                             const char *path,
85231200Smm                             trail_t *trail,
86231200Smm                             apr_pool_t *pool);
87231200Smm
88231200Smm
89231200Smm/* Examine PATH for existing locks, and check whether they can be
90231200Smm   used.  Do all work in the context of TRAIL, using POOL for
91231200Smm   temporary allocations.
92231200Smm
93231200Smm   If no locks are present, return SVN_NO_ERROR.
94231200Smm
95231200Smm   If PATH is locked (or contains locks "below" it, when RECURSE is
96231200Smm   set), then verify that:
97231200Smm
98231200Smm      1. a username has been supplied to TRAIL->fs's access-context,
99231200Smm         else return SVN_ERR_FS_NO_USER.
100231200Smm
101231200Smm      2. for every lock discovered, the current username in the access
102231200Smm         context of TRAIL->fs matches the "owner" of the lock, else
103231200Smm         return SVN_ERR_FS_LOCK_OWNER_MISMATCH.
104231200Smm
105231200Smm      3. for every lock discovered, a matching lock token has been
106231200Smm         passed into TRAIL->fs's access-context, else return
107231200Smm         SVN_ERR_FS_BAD_LOCK_TOKEN.
108231200Smm
109231200Smm   If all three conditions are met, return SVN_NO_ERROR.
110231200Smm*/
111231200Smmsvn_error_t *svn_fs_base__allow_locked_operation(const char *path,
112231200Smm                                                 svn_boolean_t recurse,
113231200Smm                                                 trail_t *trail,
114231200Smm                                                 apr_pool_t *pool);
115231200Smm
116231200Smm#ifdef __cplusplus
117231200Smm}
118231200Smm#endif /* __cplusplus */
119231200Smm
120231200Smm#endif /* SVN_LIBSVN_FS_LOCK_H */
121231200Smm