config_impl.h revision 362181
1/*
2 * config_impl.h :  private header for the config file implementation.
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
25
26#ifndef SVN_LIBSVN_SUBR_CONFIG_IMPL_H
27#define SVN_LIBSVN_SUBR_CONFIG_IMPL_H
28
29#define APR_WANT_STDIO
30#include <apr_want.h>
31
32#include <apr_hash.h>
33#include "svn_types.h"
34#include "svn_string.h"
35#include "svn_io.h"
36#include "svn_config.h"
37
38#ifdef __cplusplus
39extern "C" {
40#endif /* __cplusplus */
41
42
43/* The configuration data. This is a superhash of sections and options. */
44struct svn_config_t
45{
46  /* Table of cfg_section_t's. */
47  apr_hash_t *sections;
48
49  /* Pool for hash tables, table entries and unexpanded values.
50     Also, parent pool for temporary pools. */
51  apr_pool_t *pool;
52
53  /* Pool for expanded values -- this is separate, so that we can
54     clear it when modifying the config data. */
55  apr_pool_t *x_pool;
56
57  /* Indicates that some values in the configuration have been expanded. */
58  svn_boolean_t x_values;
59
60  /* Temporary string used for lookups.  (Using a stringbuf so that
61     frequent resetting is efficient.) */
62  svn_stringbuf_t *tmp_key;
63
64  /* Temporary value used for expanded default values in svn_config_get.
65     (Using a stringbuf so that frequent resetting is efficient.) */
66  svn_stringbuf_t *tmp_value;
67
68  /* Specifies whether section names are populated case sensitively. */
69  svn_boolean_t section_names_case_sensitive;
70
71  /* Specifies whether option names are populated case sensitively. */
72  svn_boolean_t option_names_case_sensitive;
73
74  /* When set, all modification attempts will be ignored.
75   * In debug mode, we will trigger an assertion. */
76  svn_boolean_t read_only;
77};
78
79/* The default add-value constructor callback, used by the default
80   config parser that populates an svn_config_t. */
81svn_error_t *svn_config__default_add_value_fn(
82    void *baton, svn_stringbuf_t *section,
83    svn_stringbuf_t *option, svn_stringbuf_t *value);
84
85/* Read sections and options from a file. */
86svn_error_t *svn_config__parse_file(svn_config_t *cfg,
87                                    const char *file,
88                                    svn_boolean_t must_exist,
89                                    apr_pool_t *pool);
90
91/* The name of the magic [DEFAULT] section. */
92#define SVN_CONFIG__DEFAULT_SECTION "DEFAULT"
93
94
95#ifdef WIN32
96/* Get the common or user-specific AppData folder */
97svn_error_t *svn_config__win_config_path(const char **folder,
98                                         svn_boolean_t system_path,
99                                         apr_pool_t *result_pool,
100                                         apr_pool_t *scratch_pool);
101
102/* Read sections and options from the Windows Registry. */
103svn_error_t *svn_config__parse_registry(svn_config_t *cfg,
104                                        const char *file,
105                                        svn_boolean_t must_exist,
106                                        apr_pool_t *pool);
107
108/* ### It's unclear to me whether this registry stuff should get the
109   double underscore or not, and if so, where the extra underscore
110   would go.  Thoughts?  -kff */
111#  define SVN_REGISTRY_PREFIX "REGISTRY:"
112#  define SVN_REGISTRY_PREFIX_LEN ((sizeof(SVN_REGISTRY_PREFIX)) - 1)
113#  define SVN_REGISTRY_HKLM "HKLM\\"
114#  define SVN_REGISTRY_HKLM_LEN ((sizeof(SVN_REGISTRY_HKLM)) - 1)
115#  define SVN_REGISTRY_HKCU "HKCU\\"
116#  define SVN_REGISTRY_HKCU_LEN ((sizeof(SVN_REGISTRY_HKCU)) - 1)
117#  define SVN_REGISTRY_PATH "Software\\Tigris.org\\Subversion\\"
118#  define SVN_REGISTRY_PATH_LEN ((sizeof(SVN_REGISTRY_PATH)) - 1)
119#  define SVN_REGISTRY_SYS_CONFIG_PATH \
120                               SVN_REGISTRY_PREFIX     \
121                               SVN_REGISTRY_HKLM       \
122                               SVN_REGISTRY_PATH
123#  define SVN_REGISTRY_USR_CONFIG_PATH \
124                               SVN_REGISTRY_PREFIX     \
125                               SVN_REGISTRY_HKCU       \
126                               SVN_REGISTRY_PATH
127#endif /* WIN32 */
128
129/* System-wide and configuration subdirectory names.
130   NOTE: Don't use these directly; call svn_config__sys_config_path()
131   or svn_config_get_user_config_path() instead. */
132#ifdef WIN32
133#  define SVN_CONFIG__SUBDIRECTORY    "Subversion"
134#elif defined __HAIKU__ /* HAIKU */
135#  define SVN_CONFIG__SYS_DIRECTORY   "subversion"
136#  define SVN_CONFIG__USR_DIRECTORY   "subversion"
137#else  /* ! WIN32 && ! __HAIKU__ */
138#  define SVN_CONFIG__SYS_DIRECTORY   "/etc/subversion"
139#  define SVN_CONFIG__USR_DIRECTORY   ".subversion"
140#endif /* WIN32 */
141
142/* The description/instructions file in the config directory. */
143#define SVN_CONFIG__USR_README_FILE    "README.txt"
144
145/* The name of the main authentication subdir in the config directory */
146#define SVN_CONFIG__AUTH_SUBDIR        "auth"
147
148/* Set *PATH_P to the path to config file FNAME in the system
149   configuration area, allocated in POOL.  If FNAME is NULL, set
150   *PATH_P to the directory name of the system config area, either
151   allocated in POOL or a static constant string.
152
153   If the system configuration area cannot be located (possible under
154   Win32), set *PATH_P to NULL regardless of FNAME.  */
155svn_error_t *
156svn_config__sys_config_path(const char **path_p,
157                            const char *fname,
158                            apr_pool_t *pool);
159
160
161#ifdef __cplusplus
162}
163#endif /* __cplusplus */
164
165#endif /* SVN_LIBSVN_SUBR_CONFIG_IMPL_H */
166