summaryrefslogtreecommitdiff
path: root/subversion/libsvn_subr/config_impl.h
blob: a3ab8fa1a6143838d5f56f3d5a2c99fae48612b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
/*
 * config_impl.h :  private header for the config file implementation.
 *
 * ====================================================================
 *    Licensed to the Apache Software Foundation (ASF) under one
 *    or more contributor license agreements.  See the NOTICE file
 *    distributed with this work for additional information
 *    regarding copyright ownership.  The ASF licenses this file
 *    to you under the Apache License, Version 2.0 (the
 *    "License"); you may not use this file except in compliance
 *    with the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing,
 *    software distributed under the License is distributed on an
 *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 *    KIND, either express or implied.  See the License for the
 *    specific language governing permissions and limitations
 *    under the License.
 * ====================================================================
 */



#ifndef SVN_LIBSVN_SUBR_CONFIG_IMPL_H
#define SVN_LIBSVN_SUBR_CONFIG_IMPL_H

#define APR_WANT_STDIO
#include <apr_want.h>

#include <apr_hash.h>
#include "svn_types.h"
#include "svn_string.h"
#include "svn_io.h"
#include "svn_config.h"
#include "svn_private_config.h"

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */


/* The configuration data. This is a superhash of sections and options. */
struct svn_config_t
{
  /* Table of cfg_section_t's. */
  apr_hash_t *sections;

  /* Pool for hash tables, table entries and unexpanded values */
  apr_pool_t *pool;

  /* Pool for expanded values -- this is separate, so that we can
     clear it when modifying the config data. */
  apr_pool_t *x_pool;

  /* Indicates that some values in the configuration have been expanded. */
  svn_boolean_t x_values;

  /* Temporary string used for lookups.  (Using a stringbuf so that
     frequent resetting is efficient.) */
  svn_stringbuf_t *tmp_key;

  /* Temporary value used for expanded default values in svn_config_get.
     (Using a stringbuf so that frequent resetting is efficient.) */
  svn_stringbuf_t *tmp_value;

  /* Specifies whether section names are populated case sensitively. */
  svn_boolean_t section_names_case_sensitive;

  /* Specifies whether option names are populated case sensitively. */
  svn_boolean_t option_names_case_sensitive;
};


/* Read sections and options from a file. */
svn_error_t *svn_config__parse_file(svn_config_t *cfg,
                                    const char *file,
                                    svn_boolean_t must_exist,
                                    apr_pool_t *pool);

/* Read sections and options from a stream. */
svn_error_t *svn_config__parse_stream(svn_config_t *cfg,
                                      svn_stream_t *stream,
                                      apr_pool_t *result_pool,
                                      apr_pool_t *scratch_pool);

/* The name of the magic [DEFAULT] section. */
#define SVN_CONFIG__DEFAULT_SECTION "DEFAULT"


#ifdef WIN32
/* Get the common or user-specific AppData folder */
svn_error_t *svn_config__win_config_path(const char **folder,
                                         int system_path,
                                         apr_pool_t *pool);

/* Read sections and options from the Windows Registry. */
svn_error_t *svn_config__parse_registry(svn_config_t *cfg,
                                        const char *file,
                                        svn_boolean_t must_exist,
                                        apr_pool_t *pool);

/* ### It's unclear to me whether this registry stuff should get the
   double underscore or not, and if so, where the extra underscore
   would go.  Thoughts?  -kff */
#  define SVN_REGISTRY_PREFIX "REGISTRY:"
#  define SVN_REGISTRY_PREFIX_LEN ((sizeof(SVN_REGISTRY_PREFIX)) - 1)
#  define SVN_REGISTRY_HKLM "HKLM\\"
#  define SVN_REGISTRY_HKLM_LEN ((sizeof(SVN_REGISTRY_HKLM)) - 1)
#  define SVN_REGISTRY_HKCU "HKCU\\"
#  define SVN_REGISTRY_HKCU_LEN ((sizeof(SVN_REGISTRY_HKCU)) - 1)
#  define SVN_REGISTRY_PATH "Software\\Tigris.org\\Subversion\\"
#  define SVN_REGISTRY_PATH_LEN ((sizeof(SVN_REGISTRY_PATH)) - 1)
#  define SVN_REGISTRY_SYS_CONFIG_PATH \
                               SVN_REGISTRY_PREFIX     \
                               SVN_REGISTRY_HKLM       \
                               SVN_REGISTRY_PATH
#  define SVN_REGISTRY_USR_CONFIG_PATH \
                               SVN_REGISTRY_PREFIX     \
                               SVN_REGISTRY_HKCU       \
                               SVN_REGISTRY_PATH
#endif /* WIN32 */

/* System-wide and configuration subdirectory names.
   NOTE: Don't use these directly; call svn_config__sys_config_path()
   or svn_config_get_user_config_path() instead. */
#ifdef WIN32
#  define SVN_CONFIG__SUBDIRECTORY    "Subversion"
#elif defined __HAIKU__ /* HAIKU */
#  define SVN_CONFIG__SYS_DIRECTORY   "subversion"
#  define SVN_CONFIG__USR_DIRECTORY   "subversion"
#else  /* ! WIN32 && ! __HAIKU__ */
#  define SVN_CONFIG__SYS_DIRECTORY   "/etc/subversion"
#  define SVN_CONFIG__USR_DIRECTORY   ".subversion"
#endif /* WIN32 */

/* The description/instructions file in the config directory. */
#define SVN_CONFIG__USR_README_FILE    "README.txt"

/* The name of the main authentication subdir in the config directory */
#define SVN_CONFIG__AUTH_SUBDIR        "auth"

/* Set *PATH_P to the path to config file FNAME in the system
   configuration area, allocated in POOL.  If FNAME is NULL, set
   *PATH_P to the directory name of the system config area, either
   allocated in POOL or a static constant string.

   If the system configuration area cannot be located (possible under
   Win32), set *PATH_P to NULL regardless of FNAME.  */
svn_error_t *
svn_config__sys_config_path(const char **path_p,
                            const char *fname,
                            apr_pool_t *pool);


#ifdef __cplusplus
}
#endif /* __cplusplus */

#endif /* SVN_LIBSVN_SUBR_CONFIG_IMPL_H */