* www/release-process.html
[svn.git] / subversion / include / svn_config.h
blob0a0603d2e168360fa76fb782c0429eb207431672
1 /**
2 * @copyright
3 * ====================================================================
4 * Copyright (c) 2000-2007 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_HTTP_AUTH_TYPES "http-auth-types"
71 #define SVN_CONFIG_OPTION_SSL_AUTHORITY_FILES "ssl-authority-files"
72 #define SVN_CONFIG_OPTION_SSL_TRUST_DEFAULT_CA "ssl-trust-default-ca"
73 #define SVN_CONFIG_OPTION_SSL_CLIENT_CERT_FILE "ssl-client-cert-file"
74 #define SVN_CONFIG_OPTION_SSL_CLIENT_CERT_PASSWORD "ssl-client-cert-password"
75 #define SVN_CONFIG_OPTION_SSL_PKCS11_PROVIDER "ssl-pkcs11-provider"
76 #define SVN_CONFIG_OPTION_HTTP_LIBRARY "http-library"
78 #define SVN_CONFIG_CATEGORY_CONFIG "config"
79 #define SVN_CONFIG_SECTION_AUTH "auth"
80 #define SVN_CONFIG_OPTION_STORE_PASSWORDS "store-passwords"
81 #define SVN_CONFIG_OPTION_STORE_AUTH_CREDS "store-auth-creds"
82 #define SVN_CONFIG_SECTION_HELPERS "helpers"
83 #define SVN_CONFIG_OPTION_EDITOR_CMD "editor-cmd"
84 #define SVN_CONFIG_OPTION_DIFF_CMD "diff-cmd"
85 #define SVN_CONFIG_OPTION_DIFF3_CMD "diff3-cmd"
86 #define SVN_CONFIG_OPTION_DIFF3_HAS_PROGRAM_ARG "diff3-has-program-arg"
87 #define SVN_CONFIG_OPTION_MERGE_TOOL_CMD "merge-tool-cmd"
88 #define SVN_CONFIG_SECTION_MISCELLANY "miscellany"
89 #define SVN_CONFIG_OPTION_GLOBAL_IGNORES "global-ignores"
90 #define SVN_CONFIG_OPTION_LOG_ENCODING "log-encoding"
91 #define SVN_CONFIG_OPTION_USE_COMMIT_TIMES "use-commit-times"
92 #define SVN_CONFIG_OPTION_TEMPLATE_ROOT "template-root"
93 #define SVN_CONFIG_OPTION_ENABLE_AUTO_PROPS "enable-auto-props"
94 #define SVN_CONFIG_OPTION_NO_UNLOCK "no-unlock"
95 #define SVN_CONFIG_OPTION_MIMETYPES_FILE "mime-types-file"
96 #define SVN_CONFIG_OPTION_PRESERVED_CF_EXTS "preserved-conflict-file-exts"
97 #define SVN_CONFIG_OPTION_INTERACTIVE_CONFLICTS "interactive-conflicts"
98 #define SVN_CONFIG_SECTION_TUNNELS "tunnels"
99 #define SVN_CONFIG_SECTION_AUTO_PROPS "auto-props"
100 /** @} */
102 /** @name Repository conf directory configuration files strings
103 * Strings for the names of sections and options in the
104 * repository conf directory configuration files.
105 * @{
107 /* For repository svnserve.conf files */
108 #define SVN_CONFIG_SECTION_GENERAL "general"
109 #define SVN_CONFIG_OPTION_ANON_ACCESS "anon-access"
110 #define SVN_CONFIG_OPTION_AUTH_ACCESS "auth-access"
111 #define SVN_CONFIG_OPTION_PASSWORD_DB "password-db"
112 #define SVN_CONFIG_OPTION_REALM "realm"
113 #define SVN_CONFIG_OPTION_AUTHZ_DB "authz-db"
114 #define SVN_CONFIG_SECTION_SASL "sasl"
115 #define SVN_CONFIG_OPTION_USE_SASL "use-sasl"
116 #define SVN_CONFIG_OPTION_MIN_SSF "min-encryption"
117 #define SVN_CONFIG_OPTION_MAX_SSF "max-encryption"
119 /* For repository password database */
120 #define SVN_CONFIG_SECTION_USERS "users"
121 /** @} */
123 /*** Configuration Default Values ***/
125 /* '*' matches leading dots, e.g. '*.rej' matches '.foo.rej'. */
126 /* We want this to be printed on two lines in the generated config file,
127 * but we don't want the # character to end up in the variable.
129 #define SVN_CONFIG__DEFAULT_GLOBAL_IGNORES_LINE_1 \
130 "*.o *.lo *.la *.al .libs *.so *.so.[0-9]* *.a *.pyc *.pyo"
131 #define SVN_CONFIG__DEFAULT_GLOBAL_IGNORES_LINE_2 \
132 "*.rej *~ #*# .#* .*.swp .DS_Store"
134 #define SVN_CONFIG_DEFAULT_GLOBAL_IGNORES \
135 SVN_CONFIG__DEFAULT_GLOBAL_IGNORES_LINE_1 " " \
136 SVN_CONFIG__DEFAULT_GLOBAL_IGNORES_LINE_2
138 #define SVN_CONFIG_TRUE "TRUE"
139 #define SVN_CONFIG_FALSE "FALSE"
142 /** Read configuration information from the standard sources and merge it
143 * into the hash @a *cfg_hash. If @a config_dir is not NULL it specifies a
144 * directory from which to read the configuration files, overriding all
145 * other sources. Otherwise, first read any system-wide configurations
146 * (from a file or from the registry), then merge in personal
147 * configurations (again from file or registry). The hash and all its data
148 * are allocated in @a pool.
150 * @a *cfg_hash is a hash whose keys are @c const char * configuration
151 * categories (@c SVN_CONFIG_CATEGORY_SERVERS,
152 * @c SVN_CONFIG_CATEGORY_CONFIG, etc.) and whose values are the @c
153 * svn_config_t * items representing the configuration values for that
154 * category.
156 svn_error_t *svn_config_get_config(apr_hash_t **cfg_hash,
157 const char *config_dir,
158 apr_pool_t *pool);
161 /** Read configuration data from @a file (a file or registry path) into
162 * @a *cfgp, allocated in @a pool.
164 * If @a file does not exist, then if @a must_exist, return an error,
165 * otherwise return an empty @c svn_config_t.
167 svn_error_t *svn_config_read(svn_config_t **cfgp,
168 const char *file,
169 svn_boolean_t must_exist,
170 apr_pool_t *pool);
172 /** Like svn_config_read(), but merges the configuration data from @a file
173 * (a file or registry path) into @a *cfg, which was previously returned
174 * from svn_config_read(). This function invalidates all value
175 * expansions in @a cfg, so that the next svn_config_get() takes the
176 * modifications into account.
178 svn_error_t *svn_config_merge(svn_config_t *cfg,
179 const char *file,
180 svn_boolean_t must_exist);
183 /** Find the value of a (@a section, @a option) pair in @a cfg, set @a
184 * *valuep to the value.
186 * If @a cfg is @c NULL, just sets @a *valuep to @a default_value. If
187 * the value does not exist, expand and return @a default_value. @a
188 * default_value can be NULL.
190 * The returned value will be valid at least until the next call to
191 * svn_config_get(), or for the lifetime of @a default_value. It is
192 * safest to consume the returned value immediately.
194 * This function may change @a cfg by expanding option values.
196 void svn_config_get(svn_config_t *cfg, const char **valuep,
197 const char *section, const char *option,
198 const char *default_value);
200 /** Add or replace the value of a (@a section, @a option) pair in @a cfg with
201 * @a value.
203 * This function invalidates all value expansions in @a cfg.
205 * To remove an option, pass NULL for the @c value.
207 void svn_config_set(svn_config_t *cfg,
208 const char *section, const char *option,
209 const char *value);
211 /** Like svn_config_get(), but for boolean values.
213 * Parses the option as a boolean value. The recognized representations
214 * are 'TRUE'/'FALSE', 'yes'/'no', 'on'/'off', '1'/'0'; case does not
215 * matter. Returns an error if the option doesn't contain a known string.
217 svn_error_t *svn_config_get_bool(svn_config_t *cfg, svn_boolean_t *valuep,
218 const char *section, const char *option,
219 svn_boolean_t default_value);
221 /** Like svn_config_set(), but for boolean values.
223 * Sets the option to 'TRUE'/'FALSE', depending on @a value.
225 void svn_config_set_bool(svn_config_t *cfg,
226 const char *section, const char *option,
227 svn_boolean_t value);
229 /** Similar to @c svn_config_section_enumerator2_t, but is not
230 * provided with a memory pool argument.
232 * See svn_config_enumerate_sections() for the details of this type.
234 * @deprecated Provided for backwards compatibility with the 1.2 API.
236 typedef svn_boolean_t (*svn_config_section_enumerator_t)(const char *name,
237 void *baton);
239 /** Similar to svn_config_enumerate_sections2(), but uses a memory pool of
240 * @a cfg instead of one that is explicitely provided.
242 * @deprecated Provided for backwards compatibility with the 1.2 API.
244 int svn_config_enumerate_sections(svn_config_t *cfg,
245 svn_config_section_enumerator_t callback,
246 void *baton);
248 /** A callback function used in enumerating config sections.
250 * See svn_config_enumerate_sections2() for the details of this type.
252 * @since New in 1.3.
254 typedef svn_boolean_t (*svn_config_section_enumerator2_t)(const char *name,
255 void *baton,
256 apr_pool_t *pool);
258 /** Enumerate the sections, passing @a baton and the current section's name
259 * to @a callback. Continue the enumeration if @a callback returns @c TRUE.
260 * Return the number of times @a callback was called.
262 * ### See kff's comment to svn_config_enumerate2(). It applies to this
263 * function, too. ###
265 * @a callback's @a name parameter is only valid for the duration of the call.
267 * @since New in 1.3.
269 int svn_config_enumerate_sections2(svn_config_t *cfg,
270 svn_config_section_enumerator2_t callback,
271 void *baton, apr_pool_t *pool);
273 /** Similar to @c svn_config_enumerator2_t, but is not
274 * provided with a memory pool argument.
275 * See svn_config_enumerate() for the details of this type.
277 * @deprecated Provided for backwards compatibility with the 1.2 API.
279 typedef svn_boolean_t (*svn_config_enumerator_t)(const char *name,
280 const char *value,
281 void *baton);
283 /** Similar to svn_config_enumerate2(), but uses a memory pool of
284 * @a cfg instead of one that is explicitely provided.
286 * @deprecated Provided for backwards compatibility with the 1.2 API.
288 int svn_config_enumerate(svn_config_t *cfg, const char *section,
289 svn_config_enumerator_t callback, void *baton);
292 /** A callback function used in enumerating config options.
294 * See svn_config_enumerate2() for the details of this type.
296 * @since New in 1.3.
298 typedef svn_boolean_t (*svn_config_enumerator2_t)(const char *name,
299 const char *value,
300 void *baton,
301 apr_pool_t *pool);
303 /** Enumerate the options in @a section, passing @a baton and the current
304 * option's name and value to @a callback. Continue the enumeration if
305 * @a callback returns @c TRUE. Return the number of times @a callback
306 * was called.
308 * ### kff asks: A more usual interface is to continue enumerating
309 * while @a callback does not return error, and if @a callback does
310 * return error, to return the same error (or a wrapping of it)
311 * from svn_config_enumerate(). What's the use case for
312 * svn_config_enumerate()? Is it more likely to need to break out
313 * of an enumeration early, with no error, than an invocation of
314 * @a callback is likely to need to return an error? ###
316 * @a callback's @a name and @a value parameters are only valid for the
317 * duration of the call.
319 * @since New in 1.3.
321 int svn_config_enumerate2(svn_config_t *cfg, const char *section,
322 svn_config_enumerator2_t callback, void *baton,
323 apr_pool_t *pool);
326 * Return @c TRUE if @a section exists in @a cfg, @c FALSE otherwise.
328 * @since New in 1.4.
330 svn_boolean_t svn_config_has_section(svn_config_t *cfg, const char *section);
332 /** Enumerate the group @a master_section in @a cfg. Each variable
333 * value is interpreted as a list of glob patterns (separated by comma
334 * and optional whitespace). Return the name of the first variable
335 * whose value matches @a key, or @c NULL if no variable matches.
337 const char *svn_config_find_group(svn_config_t *cfg, const char *key,
338 const char *master_section,
339 apr_pool_t *pool);
341 /** Retrieve value corresponding to @a option_name in @a cfg ,
342 * or return @a default_value if none is found.
344 * The config will first be checked for a default.
345 * If @a server_group is not @c NULL, the config will also be checked
346 * for an override in a server group,
349 const char *svn_config_get_server_setting(svn_config_t *cfg,
350 const char* server_group,
351 const char* option_name,
352 const char* default_value);
354 /** Retrieve value into @a result_value corresponding to @a option_name for a
355 * given @a server_group in @a cfg, or return @a default_value if none is
356 * found.
358 * The config will first be checked for a default, then will be checked for
359 * an override in a server group. If the value found is not a valid integer,
360 * a @c svn_error_t* will be returned.
362 svn_error_t *svn_config_get_server_setting_int(svn_config_t *cfg,
363 const char *server_group,
364 const char *option_name,
365 apr_int64_t default_value,
366 apr_int64_t *result_value,
367 apr_pool_t *pool);
370 /** Try to ensure that the user's ~/.subversion/ area exists, and create
371 * no-op template files for any absent config files. Use @a pool for any
372 * temporary allocation. If @a config_dir is not @c NULL it specifies a
373 * directory from which to read the config overriding all other sources.
375 * Don't error if something exists but is the wrong kind (for example,
376 * ~/.subversion exists but is a file, or ~/.subversion/servers exists
377 * but is a directory).
379 * Also don't error if trying to create something and failing -- it's
380 * okay for the config area or its contents not to be created.
381 * However, if creating a config template file succeeds, return an
382 * error if unable to initialize its contents.
384 svn_error_t *svn_config_ensure(const char *config_dir, apr_pool_t *pool);
389 /** Accessing cached authentication data in the user config area.
391 * @defgroup cached_authentication_data Cached authentication data
392 * @{
396 /** A hash-key pointing to a realmstring. Every file containing
397 * authentication data should have this key.
399 #define SVN_CONFIG_REALMSTRING_KEY "svn:realmstring"
401 /** Use @a cred_kind and @a realmstring to locate a file within the
402 * ~/.subversion/auth/ area. If the file exists, initialize @a *hash
403 * and load the file contents into the hash, using @a pool. If the
404 * file doesn't exist, set @a *hash to NULL.
406 * If @a config_dir is not NULL it specifies a directory from which to
407 * read the config overriding all other sources.
409 * Besides containing the original credential fields, the hash will
410 * also contain @c SVN_CONFIG_REALMSTRING_KEY. The caller can examine
411 * this value as a sanity-check that the correct file was loaded.
413 * The hashtable will contain <tt>const char *</tt> keys and
414 * <tt>svn_string_t *</tt> values.
416 svn_error_t * svn_config_read_auth_data(apr_hash_t **hash,
417 const char *cred_kind,
418 const char *realmstring,
419 const char *config_dir,
420 apr_pool_t *pool);
422 /** Use @a cred_kind and @a realmstring to create or overwrite a file
423 * within the ~/.subversion/auth/ area. Write the contents of @a hash into
424 * the file. If @a config_dir is not NULL it specifies a directory to read
425 * the config overriding all other sources.
427 * Also, add @a realmstring to the file, with key @c
428 * SVN_CONFIG_REALMSTRING_KEY. This allows programs (or users) to
429 * verify exactly which set credentials live within the file.
431 * The hashtable must contain <tt>const char *</tt> keys and
432 * <tt>svn_string_t *</tt> values.
434 svn_error_t * svn_config_write_auth_data(apr_hash_t *hash,
435 const char *cred_kind,
436 const char *realmstring,
437 const char *config_dir,
438 apr_pool_t *pool);
440 /** @} */
442 #ifdef __cplusplus
444 #endif /* __cplusplus */
446 #endif /* SVN_CONFIG_H */