Merge commit 'origin/master' into msys
[msysgit.git] / include / subversion-1 / svn_config.h
blob46f09c5483f36fdb9c135758910b094429b807a1
1 /**
2 * @copyright
3 * ====================================================================
4 * Copyright (c) 2000-2004 CollabNet. All rights reserved.
6 * This software is licensed as described in the file COPYING, which
7 * you should have received as part of this distribution. The terms
8 * are also available at http://subversion.tigris.org/license-1.html.
9 * If newer versions of this license are posted there, you may use a
10 * newer version instead, at your option.
12 * This software consists of voluntary contributions made by many
13 * individuals. For exact contribution history, see the revision
14 * history and logs, available at http://subversion.tigris.org/.
15 * ====================================================================
16 * @endcopyright
18 * @file svn_config.h
19 * @brief Accessing SVN configuration files.
24 #ifndef SVN_CONFIG_H
25 #define SVN_CONFIG_H
27 #include <apr_pools.h>
29 #include "svn_types.h"
30 #include "svn_error.h"
33 #ifdef __cplusplus
34 extern "C" {
35 #endif /* __cplusplus */
38 /**************************************************************************
39 *** ***
40 *** For a description of the SVN configuration file syntax, see ***
41 *** your ~/.subversion/README, which is written out automatically by ***
42 *** svn_config_ensure(). ***
43 *** ***
44 **************************************************************************/
47 /** Opaque structure describing a set of configuration options. */
48 typedef struct svn_config_t svn_config_t;
51 /*** Configuration Defines ***/
53 /**
54 * @name Client configuration files strings
55 * Strings for the names of files, sections, and options in the
56 * client configuration files.
57 * @{
59 #define SVN_CONFIG_CATEGORY_SERVERS "servers"
60 #define SVN_CONFIG_SECTION_GROUPS "groups"
61 #define SVN_CONFIG_SECTION_GLOBAL "global"
62 #define SVN_CONFIG_OPTION_HTTP_PROXY_HOST "http-proxy-host"
63 #define SVN_CONFIG_OPTION_HTTP_PROXY_PORT "http-proxy-port"
64 #define SVN_CONFIG_OPTION_HTTP_PROXY_USERNAME "http-proxy-username"
65 #define SVN_CONFIG_OPTION_HTTP_PROXY_PASSWORD "http-proxy-password"
66 #define SVN_CONFIG_OPTION_HTTP_PROXY_EXCEPTIONS "http-proxy-exceptions"
67 #define SVN_CONFIG_OPTION_HTTP_TIMEOUT "http-timeout"
68 #define SVN_CONFIG_OPTION_HTTP_COMPRESSION "http-compression"
69 #define SVN_CONFIG_OPTION_NEON_DEBUG_MASK "neon-debug-mask"
70 #define SVN_CONFIG_OPTION_SSL_AUTHORITY_FILES "ssl-authority-files"
71 #define SVN_CONFIG_OPTION_SSL_TRUST_DEFAULT_CA "ssl-trust-default-ca"
72 #define SVN_CONFIG_OPTION_SSL_CLIENT_CERT_FILE "ssl-client-cert-file"
73 #define SVN_CONFIG_OPTION_SSL_CLIENT_CERT_PASSWORD "ssl-client-cert-password"
75 #define SVN_CONFIG_CATEGORY_CONFIG "config"
76 #define SVN_CONFIG_SECTION_AUTH "auth"
77 #define SVN_CONFIG_OPTION_STORE_PASSWORDS "store-passwords"
78 #define SVN_CONFIG_OPTION_STORE_AUTH_CREDS "store-auth-creds"
79 #define SVN_CONFIG_SECTION_HELPERS "helpers"
80 #define SVN_CONFIG_OPTION_EDITOR_CMD "editor-cmd"
81 #define SVN_CONFIG_OPTION_DIFF_CMD "diff-cmd"
82 #define SVN_CONFIG_OPTION_DIFF3_CMD "diff3-cmd"
83 #define SVN_CONFIG_OPTION_DIFF3_HAS_PROGRAM_ARG "diff3-has-program-arg"
84 #define SVN_CONFIG_SECTION_MISCELLANY "miscellany"
85 #define SVN_CONFIG_OPTION_GLOBAL_IGNORES "global-ignores"
86 #define SVN_CONFIG_OPTION_LOG_ENCODING "log-encoding"
87 #define SVN_CONFIG_OPTION_USE_COMMIT_TIMES "use-commit-times"
88 #define SVN_CONFIG_OPTION_TEMPLATE_ROOT "template-root"
89 #define SVN_CONFIG_OPTION_ENABLE_AUTO_PROPS "enable-auto-props"
90 #define SVN_CONFIG_OPTION_NO_UNLOCK "no-unlock"
91 #define SVN_CONFIG_SECTION_TUNNELS "tunnels"
92 #define SVN_CONFIG_SECTION_AUTO_PROPS "auto-props"
93 /** @} */
95 /** @name Repository conf directory configuration files strings
96 * Strings for the names of sections and options in the
97 * repository conf directory configuration files.
98 * @{
100 /* For repository svnserve.conf files */
101 #define SVN_CONFIG_SECTION_GENERAL "general"
102 #define SVN_CONFIG_OPTION_ANON_ACCESS "anon-access"
103 #define SVN_CONFIG_OPTION_AUTH_ACCESS "auth-access"
104 #define SVN_CONFIG_OPTION_PASSWORD_DB "password-db"
105 #define SVN_CONFIG_OPTION_REALM "realm"
106 #define SVN_CONFIG_OPTION_AUTHZ_DB "authz-db"
108 /* For repository password database */
109 #define SVN_CONFIG_SECTION_USERS "users"
110 /** @} */
112 /*** Configuration Default Values ***/
114 #define SVN_CONFIG_DEFAULT_GLOBAL_IGNORES \
115 "*.o *.lo *.la #*# .*.rej *.rej .*~ *~ .#* .DS_Store"
117 #define SVN_CONFIG_TRUE "true"
118 #define SVN_CONFIG_FALSE "false"
121 /** Read configuration information from the standard sources and merge it
122 * into the hash @a *cfg_hash. If @a config_dir is not NULL it specifies a
123 * directory from which to read the configuration files, overriding all
124 * other sources. Otherwise, first read any system-wide configurations
125 * (from a file or from the registry), then merge in personal
126 * configurations (again from file or registry). The hash and all its data
127 * are allocated in @a pool.
129 * @a *cfg_hash is a hash whose keys are @c const char * configuration
130 * categories (@c SVN_CONFIG_CATEGORY_SERVERS,
131 * @c SVN_CONFIG_CATEGORY_CONFIG, etc.) and whose values are the @c
132 * svn_config_t * items representing the configuration values for that
133 * category.
135 svn_error_t *svn_config_get_config(apr_hash_t **cfg_hash,
136 const char *config_dir,
137 apr_pool_t *pool);
140 /** Read configuration data from @a file (a file or registry path) into
141 * @a *cfgp, allocated in @a pool.
143 * If @a file does not exist, then if @a must_exist, return an error,
144 * otherwise return an empty @c svn_config_t.
146 svn_error_t *svn_config_read(svn_config_t **cfgp,
147 const char *file,
148 svn_boolean_t must_exist,
149 apr_pool_t *pool);
151 /** Like svn_config_read(), but merges the configuration data from @a file
152 * (a file or registry path) into @a *cfg, which was previously returned
153 * from svn_config_read(). This function invalidates all value
154 * expansions in @a cfg, so that the next svn_config_get() takes the
155 * modifications into account.
157 svn_error_t *svn_config_merge(svn_config_t *cfg,
158 const char *file,
159 svn_boolean_t must_exist);
162 /** Find the value of a (@a section, @a option) pair in @a cfg, set @a
163 * *valuep to the value.
165 * If @a cfg is @c NULL, just sets @a *valuep to @a default_value. If
166 * the value does not exist, expand and return @a default_value. @a
167 * default_value can be NULL.
169 * The returned value will be valid at least until the next call to
170 * svn_config_get(), or for the lifetime of @a default_value. It is
171 * safest to consume the returned value immediately.
173 * This function may change @a cfg by expanding option values.
175 void svn_config_get(svn_config_t *cfg, const char **valuep,
176 const char *section, const char *option,
177 const char *default_value);
179 /** Add or replace the value of a (@a section, @a option) pair in @a cfg with
180 * @a value.
182 * This function invalidates all value expansions in @a cfg.
184 void svn_config_set(svn_config_t *cfg,
185 const char *section, const char *option,
186 const char *value);
188 /** Like svn_config_get(), but for boolean values.
190 * Parses the option as a boolean value. The recognized representations
191 * are 'true'/'false', 'yes'/'no', 'on'/'off', '1'/'0'; case does not
192 * matter. Returns an error if the option doesn't contain a known string.
194 svn_error_t *svn_config_get_bool(svn_config_t *cfg, svn_boolean_t *valuep,
195 const char *section, const char *option,
196 svn_boolean_t default_value);
198 /** Like svn_config_set(), but for boolean values.
200 * Sets the option to 'true'/'false', depending on @a value.
202 void svn_config_set_bool(svn_config_t *cfg,
203 const char *section, const char *option,
204 svn_boolean_t value);
206 /** Similar to @c svn_config_section_enumerator2_t, but is not
207 * provided with a memory pool argument.
209 * See svn_config_enumerate_sections() for the details of this type.
211 * @deprecated Provided for backwards compatibility with the 1.2 API.
213 typedef svn_boolean_t (*svn_config_section_enumerator_t)(const char *name,
214 void *baton);
216 /** Similar to svn_config_enumerate_sections2(), but uses a memory pool of
217 * @a cfg instead of one that is explicitely provided.
219 * @deprecated Provided for backwards compatibility with the 1.2 API.
221 int svn_config_enumerate_sections(svn_config_t *cfg,
222 svn_config_section_enumerator_t callback,
223 void *baton);
225 /** A callback function used in enumerating config sections.
227 * See svn_config_enumerate_sections2() for the details of this type.
229 * @since New in 1.3.
231 typedef svn_boolean_t (*svn_config_section_enumerator2_t)(const char *name,
232 void *baton,
233 apr_pool_t *pool);
235 /** Enumerate the sections, passing @a baton and the current section's name
236 * to @a callback. Continue the enumeration if @a callback returns @c TRUE.
237 * Return the number of times @a callback was called.
239 * ### See kff's comment to svn_config_enumerate2(). It applies to this
240 * function, too. ###
242 * @a callback's @a name and @a name parameters are only valid for the
243 * duration of the call.
245 * @since New in 1.3.
247 int svn_config_enumerate_sections2(svn_config_t *cfg,
248 svn_config_section_enumerator2_t callback,
249 void *baton, apr_pool_t *pool);
251 /** Similar to @c svn_config_enumerator2_t, but is not
252 * provided with a memory pool argument.
253 * See svn_config_enumerate() for the details of this type.
255 * @deprecated Provided for backwards compatibility with the 1.2 API.
257 typedef svn_boolean_t (*svn_config_enumerator_t)(const char *name,
258 const char *value,
259 void *baton);
261 /** Similar to svn_config_enumerate2(), but uses a memory pool of
262 * @a cfg instead of one that is explicitely provided.
264 * @deprecated Provided for backwards compatibility with the 1.2 API.
266 int svn_config_enumerate(svn_config_t *cfg, const char *section,
267 svn_config_enumerator_t callback, void *baton);
270 /** A callback function used in enumerating config options.
272 * See svn_config_enumerate2() for the details of this type.
274 * @since New in 1.3.
276 typedef svn_boolean_t (*svn_config_enumerator2_t)(const char *name,
277 const char *value,
278 void *baton,
279 apr_pool_t *pool);
281 /** Enumerate the options in @a section, passing @a baton and the current
282 * option's name and value to @a callback. Continue the enumeration if
283 * @a callback returns @c TRUE. Return the number of times @a callback
284 * was called.
286 * ### kff asks: A more usual interface is to continue enumerating
287 * while @a callback does not return error, and if @a callback does
288 * return error, to return the same error (or a wrapping of it)
289 * from svn_config_enumerate(). What's the use case for
290 * svn_config_enumerate()? Is it more likely to need to break out
291 * of an enumeration early, with no error, than an invocation of
292 * @a callback is likely to need to return an error? ###
294 * @a callback's @a name and @a value parameters are only valid for the
295 * duration of the call.
297 * @since New in 1.3.
299 int svn_config_enumerate2(svn_config_t *cfg, const char *section,
300 svn_config_enumerator2_t callback, void *baton,
301 apr_pool_t *pool);
304 * Return @c TRUE if @a section exists in @a config, @c FALSE otherwise.
306 * @since New in 1.4.
308 svn_boolean_t svn_config_has_section(svn_config_t *cfg, const char *section);
310 /** Enumerate the group @a master_section in @a cfg. Each variable
311 * value is interpreted as a list of glob patterns (separated by comma
312 * and optional whitespace). Return the name of the first variable
313 * whose value matches @a key, or @c NULL if no variable matches.
315 const char *svn_config_find_group(svn_config_t *cfg, const char *key,
316 const char *master_section,
317 apr_pool_t *pool);
319 /** Retrieve value corresponding to @a option_name for a given
320 * @a server_group in @a cfg , or return @a default_value if none is found.
322 * The config will first be checked for a default, then will be checked for
323 * an override in a server group.
325 const char *svn_config_get_server_setting(svn_config_t *cfg,
326 const char* server_group,
327 const char* option_name,
328 const char* default_value);
330 /** Retrieve value into @a result_value corresponding to @a option_name for a
331 * given @a server_group in @a cfg, or return @a default_value if none is
332 * found.
334 * The config will first be checked for a default, then will be checked for
335 * an override in a server group. If the value found is not a valid integer,
336 * a @c svn_error_t* will be returned.
338 svn_error_t *svn_config_get_server_setting_int(svn_config_t *cfg,
339 const char *server_group,
340 const char *option_name,
341 apr_int64_t default_value,
342 apr_int64_t *result_value,
343 apr_pool_t *pool);
346 /** Try to ensure that the user's ~/.subversion/ area exists, and create
347 * no-op template files for any absent config files. Use @a pool for any
348 * temporary allocation. If @a config_dir is not @c NULL it specifies a
349 * directory from which to read the config overriding all other sources.
351 * Don't error if something exists but is the wrong kind (for example,
352 * ~/.subversion exists but is a file, or ~/.subversion/servers exists
353 * but is a directory).
355 * Also don't error if trying to create something and failing -- it's
356 * okay for the config area or its contents not to be created.
357 * However, if creating a config template file succeeds, return an
358 * error if unable to initialize its contents.
360 svn_error_t *svn_config_ensure(const char *config_dir, apr_pool_t *pool);
365 /** Accessing cached authentication data in the user config area.
367 * @defgroup cached_authentication_data cached authentication data.
368 * @{
372 /** A hash-key pointing to a realmstring. Every file containing
373 * authentication data should have this key.
375 #define SVN_CONFIG_REALMSTRING_KEY "svn:realmstring"
377 /** Use @a cred_kind and @a realmstring to locate a file within the
378 * ~/.subversion/auth/ area. If the file exists, initialize @a *hash
379 * and load the file contents into the hash, using @a pool. If the
380 * file doesn't exist, set @a *hash to NULL.
382 * If @a config_dir is not NULL it specifies a directory from which to
383 * read the config overriding all other sources.
385 * Besides containing the original credential fields, the hash will
386 * also contain @c SVN_CONFIG_REALMSTRING_KEY. The caller can examine
387 * this value as a sanity-check that the correct file was loaded.
389 * The hashtable will contain <tt>const char *</tt> keys and
390 * <tt>svn_string_t *</tt> values.
392 svn_error_t * svn_config_read_auth_data(apr_hash_t **hash,
393 const char *cred_kind,
394 const char *realmstring,
395 const char *config_dir,
396 apr_pool_t *pool);
398 /** Use @a cred_kind and @a realmstring to create or overwrite a file
399 * within the ~/.subversion/auth/ area. Write the contents of @a hash into
400 * the file. If @a config_dir is not NULL it specifies a directory to read
401 * the config overriding all other sources.
403 * Also, add @a realmstring to the file, with key @c
404 * SVN_CONFIG_REALMSTRING_KEY. This allows programs (or users) to
405 * verify exactly which set credentials live within the file.
407 * The hashtable must contain <tt>const char *</tt> keys and
408 * <tt>svn_string_t *</tt> values.
410 svn_error_t * svn_config_write_auth_data(apr_hash_t *hash,
411 const char *cred_kind,
412 const char *realmstring,
413 const char *config_dir,
414 apr_pool_t *pool);
416 /** @} */
418 #ifdef __cplusplus
420 #endif /* __cplusplus */
422 #endif /* SVN_CONFIG_H */