]> CyberLeo.Net >> Repos - FreeBSD/releng/10.2.git/blob - contrib/subversion/subversion/libsvn_fs/access.c
- Copy stable/10@285827 to releng/10.2 in preparation for 10.2-RC1
[FreeBSD/releng/10.2.git] / contrib / subversion / subversion / libsvn_fs / access.c
1 /*
2  * access.c:  shared code to manipulate svn_fs_access_t objects
3  *
4  * ====================================================================
5  *    Licensed to the Apache Software Foundation (ASF) under one
6  *    or more contributor license agreements.  See the NOTICE file
7  *    distributed with this work for additional information
8  *    regarding copyright ownership.  The ASF licenses this file
9  *    to you under the Apache License, Version 2.0 (the
10  *    "License"); you may not use this file except in compliance
11  *    with the License.  You may obtain a copy of the License at
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
15  *    Unless required by applicable law or agreed to in writing,
16  *    software distributed under the License is distributed on an
17  *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18  *    KIND, either express or implied.  See the License for the
19  *    specific language governing permissions and limitations
20  *    under the License.
21  * ====================================================================
22  */
23
24 \f
25 #include <apr_hash.h>
26
27 #include "svn_hash.h"
28 #include "svn_types.h"
29 #include "svn_pools.h"
30 #include "svn_fs.h"
31 #include "private/svn_fs_private.h"
32
33 #include "fs-loader.h"
34
35
36
37 svn_error_t *
38 svn_fs_create_access(svn_fs_access_t **access_ctx,
39                      const char *username,
40                      apr_pool_t *pool)
41 {
42   svn_fs_access_t *ac;
43
44   SVN_ERR_ASSERT(username != NULL);
45
46   ac = apr_pcalloc(pool, sizeof(*ac));
47   ac->username = apr_pstrdup(pool, username);
48   ac->lock_tokens = apr_hash_make(pool);
49   *access_ctx = ac;
50
51   return SVN_NO_ERROR;
52 }
53
54
55 svn_error_t *
56 svn_fs_set_access(svn_fs_t *fs,
57                   svn_fs_access_t *access_ctx)
58 {
59   fs->access_ctx = access_ctx;
60
61   return SVN_NO_ERROR;
62 }
63
64
65 svn_error_t *
66 svn_fs_get_access(svn_fs_access_t **access_ctx,
67                   svn_fs_t *fs)
68 {
69   *access_ctx = fs->access_ctx;
70
71   return SVN_NO_ERROR;
72 }
73
74
75 svn_error_t *
76 svn_fs_access_get_username(const char **username,
77                            svn_fs_access_t *access_ctx)
78 {
79   *username = access_ctx->username;
80
81   return SVN_NO_ERROR;
82 }
83
84
85 svn_error_t *
86 svn_fs_access_add_lock_token2(svn_fs_access_t *access_ctx,
87                               const char *path,
88                               const char *token)
89 {
90   svn_hash_sets(access_ctx->lock_tokens, token, path);
91   return SVN_NO_ERROR;
92 }
93
94 svn_error_t *
95 svn_fs_access_add_lock_token(svn_fs_access_t *access_ctx,
96                              const char *token)
97 {
98   return svn_fs_access_add_lock_token2(access_ctx, (const char *) 1, token);
99 }
100
101 apr_hash_t *
102 svn_fs__access_get_lock_tokens(svn_fs_access_t *access_ctx)
103 {
104   return access_ctx->lock_tokens;
105 }