Subversion
svn_config.h
Go to the documentation of this file.
1 /**
2  * @copyright
3  * ====================================================================
4  * Licensed to the Apache Software Foundation (ASF) under one
5  * or more contributor license agreements. See the NOTICE file
6  * distributed with this work for additional information
7  * regarding copyright ownership. The ASF licenses this file
8  * to you under the Apache License, Version 2.0 (the
9  * "License"); you may not use this file except in compliance
10  * with the License. You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing,
15  * software distributed under the License is distributed on an
16  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17  * KIND, either express or implied. See the License for the
18  * specific language governing permissions and limitations
19  * under the License.
20  * ====================================================================
21  * @endcopyright
22  *
23  * @file svn_config.h
24  * @brief Accessing SVN configuration files.
25  */
26 
27 
28 ␌
29 #ifndef SVN_CONFIG_H
30 #define SVN_CONFIG_H
31 
32 #include <apr.h> /* for apr_int64_t */
33 #include <apr_pools.h> /* for apr_pool_t */
34 #include <apr_hash.h> /* for apr_hash_t */
35 
36 #include "svn_types.h"
37 #include "svn_io.h"
38 
39 #ifdef __cplusplus
40 extern "C" {
41 #endif /* __cplusplus */
42 
43 
44 /**************************************************************************
45  *** ***
46  *** For a description of the SVN configuration file syntax, see ***
47  *** your ~/.subversion/README.txt, which is written out automatically ***
48  *** by svn_config_ensure(). ***
49  *** ***
50  **************************************************************************/
51 
52 
53 /** Opaque structure describing a set of configuration options. */
54 typedef struct svn_config_t svn_config_t;
55 
56 ␌
57 /*** Configuration Defines ***/
58 
59 /**
60  * @name Client configuration files strings
61  * Strings for the names of files, sections, and options in the
62  * client configuration files.
63  * @{
64  */
65 
66 /* If you add a new SVN_CONFIG_* category/section/option macro to this group,
67  * you have to re-run gen-make.py manually.
68  *
69  * ### This should be fixed in the build system; see issue #4581.
70  */
71 
72  /* This list of #defines is intentionally presented as a nested list
73  that matches the in-config hierarchy. */
74 
75 #define SVN_CONFIG_CATEGORY_SERVERS "servers"
76 #define SVN_CONFIG_SECTION_GROUPS "groups"
77 #define SVN_CONFIG_SECTION_GLOBAL "global"
78 #define SVN_CONFIG_OPTION_HTTP_PROXY_HOST "http-proxy-host"
79 #define SVN_CONFIG_OPTION_HTTP_PROXY_PORT "http-proxy-port"
80 #define SVN_CONFIG_OPTION_HTTP_PROXY_USERNAME "http-proxy-username"
81 #define SVN_CONFIG_OPTION_HTTP_PROXY_PASSWORD "http-proxy-password"
82 #define SVN_CONFIG_OPTION_HTTP_PROXY_EXCEPTIONS "http-proxy-exceptions"
83 #define SVN_CONFIG_OPTION_HTTP_TIMEOUT "http-timeout"
84 #define SVN_CONFIG_OPTION_HTTP_COMPRESSION "http-compression"
85 /** @deprecated Not used since 1.8. */
86 #define SVN_CONFIG_OPTION_NEON_DEBUG_MASK "neon-debug-mask"
87 /** @since New in 1.5. */
88 #define SVN_CONFIG_OPTION_HTTP_AUTH_TYPES "http-auth-types"
89 #define SVN_CONFIG_OPTION_SSL_AUTHORITY_FILES "ssl-authority-files"
90 #define SVN_CONFIG_OPTION_SSL_TRUST_DEFAULT_CA "ssl-trust-default-ca"
91 #define SVN_CONFIG_OPTION_SSL_CLIENT_CERT_FILE "ssl-client-cert-file"
92 #define SVN_CONFIG_OPTION_SSL_CLIENT_CERT_PASSWORD "ssl-client-cert-password"
93 /** @deprecated Not used since 1.8.
94  * @since New in 1.5. */
95 #define SVN_CONFIG_OPTION_SSL_PKCS11_PROVIDER "ssl-pkcs11-provider"
96 /** @since New in 1.5. */
97 #define SVN_CONFIG_OPTION_HTTP_LIBRARY "http-library"
98 /** @since New in 1.1. */
99 #define SVN_CONFIG_OPTION_STORE_PASSWORDS "store-passwords"
100 /** @since New in 1.6. */
101 #define SVN_CONFIG_OPTION_STORE_PLAINTEXT_PASSWORDS "store-plaintext-passwords"
102 #define SVN_CONFIG_OPTION_STORE_AUTH_CREDS "store-auth-creds"
103 /** @since New in 1.6. */
104 #define SVN_CONFIG_OPTION_STORE_SSL_CLIENT_CERT_PP "store-ssl-client-cert-pp"
105 /** @since New in 1.6. */
106 #define SVN_CONFIG_OPTION_STORE_SSL_CLIENT_CERT_PP_PLAINTEXT \
107  "store-ssl-client-cert-pp-plaintext"
108 #define SVN_CONFIG_OPTION_USERNAME "username"
109 /** @since New in 1.8. */
110 #define SVN_CONFIG_OPTION_HTTP_BULK_UPDATES "http-bulk-updates"
111 /** @since New in 1.8. */
112 #define SVN_CONFIG_OPTION_HTTP_MAX_CONNECTIONS "http-max-connections"
113 /** @since New in 1.9. */
114 #define SVN_CONFIG_OPTION_HTTP_CHUNKED_REQUESTS "http-chunked-requests"
115 
116 /** @since New in 1.9. */
117 #define SVN_CONFIG_OPTION_SERF_LOG_COMPONENTS "serf-log-components"
118 /** @since New in 1.9. */
119 #define SVN_CONFIG_OPTION_SERF_LOG_LEVEL "serf-log-level"
120 
121 
122 #define SVN_CONFIG_CATEGORY_CONFIG "config"
123 #define SVN_CONFIG_SECTION_AUTH "auth"
124 /** @since New in 1.6. */
125 #define SVN_CONFIG_OPTION_PASSWORD_STORES "password-stores"
126 /** @since New in 1.6. */
127 #define SVN_CONFIG_OPTION_KWALLET_WALLET "kwallet-wallet"
128 /** @since New in 1.6. */
129 #define SVN_CONFIG_OPTION_KWALLET_SVN_APPLICATION_NAME_WITH_PID "kwallet-svn-application-name-with-pid"
130 /** @since New in 1.8. */
131 #define SVN_CONFIG_OPTION_SSL_CLIENT_CERT_FILE_PROMPT "ssl-client-cert-file-prompt"
132 /* The majority of options of the "auth" section
133  * has been moved to SVN_CONFIG_CATEGORY_SERVERS. */
134 #define SVN_CONFIG_SECTION_HELPERS "helpers"
135 #define SVN_CONFIG_OPTION_EDITOR_CMD "editor-cmd"
136 #define SVN_CONFIG_OPTION_DIFF_CMD "diff-cmd"
137 /** @since New in 1.7. */
138 #define SVN_CONFIG_OPTION_DIFF_EXTENSIONS "diff-extensions"
139 #define SVN_CONFIG_OPTION_DIFF3_CMD "diff3-cmd"
140 #define SVN_CONFIG_OPTION_DIFF3_HAS_PROGRAM_ARG "diff3-has-program-arg"
141 /** @since New in 1.5. */
142 #define SVN_CONFIG_OPTION_MERGE_TOOL_CMD "merge-tool-cmd"
143 #define SVN_CONFIG_SECTION_MISCELLANY "miscellany"
144 #define SVN_CONFIG_OPTION_GLOBAL_IGNORES "global-ignores"
145 #define SVN_CONFIG_OPTION_LOG_ENCODING "log-encoding"
146 #define SVN_CONFIG_OPTION_USE_COMMIT_TIMES "use-commit-times"
147 /** @deprecated Not used by Subversion since 2003/r847039 (well before 1.0) */
148 #define SVN_CONFIG_OPTION_TEMPLATE_ROOT "template-root"
149 #define SVN_CONFIG_OPTION_ENABLE_AUTO_PROPS "enable-auto-props"
150 /** @since New in 1.9. */
151 #define SVN_CONFIG_OPTION_ENABLE_MAGIC_FILE "enable-magic-file"
152 /** @since New in 1.2. */
153 #define SVN_CONFIG_OPTION_NO_UNLOCK "no-unlock"
154 /** @since New in 1.5. */
155 #define SVN_CONFIG_OPTION_MIMETYPES_FILE "mime-types-file"
156 /** @since New in 1.5. */
157 #define SVN_CONFIG_OPTION_PRESERVED_CF_EXTS "preserved-conflict-file-exts"
158 /** @since New in 1.7. */
159 #define SVN_CONFIG_OPTION_INTERACTIVE_CONFLICTS "interactive-conflicts"
160 /** @since New in 1.7. */
161 #define SVN_CONFIG_OPTION_MEMORY_CACHE_SIZE "memory-cache-size"
162 /** @since New in 1.9. */
163 #define SVN_CONFIG_OPTION_DIFF_IGNORE_CONTENT_TYPE "diff-ignore-content-type"
164 #define SVN_CONFIG_SECTION_TUNNELS "tunnels"
165 #define SVN_CONFIG_SECTION_AUTO_PROPS "auto-props"
166 /** @since New in 1.8. */
167 #define SVN_CONFIG_SECTION_WORKING_COPY "working-copy"
168 /** @since New in 1.8. */
169 #define SVN_CONFIG_OPTION_SQLITE_EXCLUSIVE "exclusive-locking"
170 /** @since New in 1.8. */
171 #define SVN_CONFIG_OPTION_SQLITE_EXCLUSIVE_CLIENTS "exclusive-locking-clients"
172 /** @since New in 1.9. */
173 #define SVN_CONFIG_OPTION_SQLITE_BUSY_TIMEOUT "busy-timeout"
174 /** @since New in 1.15. */
175 #define SVN_CONFIG_OPTION_COMPATIBLE_VERSION "compatible-version"
176 /** @} */
177 
178 /** @name Repository conf directory configuration files strings
179  * Strings for the names of sections and options in the
180  * repository conf directory configuration files.
181  * @{
182  */
183 /* For repository svnserve.conf files */
184 #define SVN_CONFIG_SECTION_GENERAL "general"
185 #define SVN_CONFIG_OPTION_ANON_ACCESS "anon-access"
186 #define SVN_CONFIG_OPTION_AUTH_ACCESS "auth-access"
187 #define SVN_CONFIG_OPTION_PASSWORD_DB "password-db"
188 #define SVN_CONFIG_OPTION_REALM "realm"
189 #define SVN_CONFIG_OPTION_AUTHZ_DB "authz-db"
190 /** @since New in 1.8. */
191 #define SVN_CONFIG_OPTION_GROUPS_DB "groups-db"
192 /** @since New in 1.7. */
193 #define SVN_CONFIG_OPTION_FORCE_USERNAME_CASE "force-username-case"
194 /** @since New in 1.8. */
195 #define SVN_CONFIG_OPTION_HOOKS_ENV "hooks-env"
196 /** @since New in 1.5. */
197 #define SVN_CONFIG_SECTION_SASL "sasl"
198 /** @since New in 1.5. */
199 #define SVN_CONFIG_OPTION_USE_SASL "use-sasl"
200 /** @since New in 1.5. */
201 #define SVN_CONFIG_OPTION_MIN_SSF "min-encryption"
202 /** @since New in 1.5. */
203 #define SVN_CONFIG_OPTION_MAX_SSF "max-encryption"
204 
205 /* For repository password database */
206 #define SVN_CONFIG_SECTION_USERS "users"
207 /** @} */
208 
209 /*** Configuration Default Values ***/
210 
211 /* '*' matches leading dots, e.g. '*.rej' matches '.foo.rej'. */
212 /* We want this to be printed on two lines in the generated config file,
213  * but we don't want the # character to end up in the variable.
214  */
215 #ifndef DOXYGEN_SHOULD_SKIP_THIS
216 #define SVN_CONFIG__DEFAULT_GLOBAL_IGNORES_LINE_1 \
217  "*.o *.lo *.la *.al .libs *.so *.so.[0-9]* *.a *.pyc *.pyo __pycache__"
218 #define SVN_CONFIG__DEFAULT_GLOBAL_IGNORES_LINE_2 \
219  "*.rej *~ #*# .#* .*.swp .DS_Store [Tt]humbs.db"
220 #endif
221 
222 #define SVN_CONFIG_DEFAULT_GLOBAL_IGNORES \
223  SVN_CONFIG__DEFAULT_GLOBAL_IGNORES_LINE_1 " " \
224  SVN_CONFIG__DEFAULT_GLOBAL_IGNORES_LINE_2
225 
226 #define SVN_CONFIG_TRUE "TRUE"
227 #define SVN_CONFIG_FALSE "FALSE"
228 #define SVN_CONFIG_ASK "ASK"
229 
230 /* Default values for some options. Should be passed as default values
231  * to svn_config_get and friends, instead of hard-coding the defaults in
232  * multiple places. */
233 #define SVN_CONFIG_DEFAULT_OPTION_STORE_PASSWORDS TRUE
234 #define SVN_CONFIG_DEFAULT_OPTION_STORE_PLAINTEXT_PASSWORDS SVN_CONFIG_ASK
235 #define SVN_CONFIG_DEFAULT_OPTION_STORE_AUTH_CREDS TRUE
236 #define SVN_CONFIG_DEFAULT_OPTION_STORE_SSL_CLIENT_CERT_PP TRUE
237 #define SVN_CONFIG_DEFAULT_OPTION_STORE_SSL_CLIENT_CERT_PP_PLAINTEXT \
238  SVN_CONFIG_ASK
239 #define SVN_CONFIG_DEFAULT_OPTION_HTTP_MAX_CONNECTIONS 4
240 
241 /** Read configuration information from the standard sources and merge it
242  * into the hash @a *cfg_hash. If @a config_dir is not NULL it specifies a
243  * directory from which to read the configuration files, overriding all
244  * other sources. Otherwise, first read any system-wide configurations
245  * (from a file or from the registry), then merge in personal
246  * configurations (again from file or registry). The hash and all its data
247  * are allocated in @a pool.
248  *
249  * @a *cfg_hash is a hash whose keys are @c const char * configuration
250  * categories (@c SVN_CONFIG_CATEGORY_SERVERS,
251  * @c SVN_CONFIG_CATEGORY_CONFIG, etc.) and whose values are the @c
252  * svn_config_t * items representing the configuration values for that
253  * category.
254  */
255 svn_error_t *
256 svn_config_get_config(apr_hash_t **cfg_hash,
257  const char *config_dir,
258  apr_pool_t *pool);
259 
260 /** Set @a *cfgp to an empty @c svn_config_t structure,
261  * allocated in @a result_pool.
262  *
263  * Pass TRUE to @a section_names_case_sensitive if
264  * section names are to be populated case sensitively.
265  *
266  * Pass TRUE to @a option_names_case_sensitive if
267  * option names are to be populated case sensitively.
268  *
269  * @since New in 1.8.
270  */
271 svn_error_t *
273  svn_boolean_t section_names_case_sensitive,
274  svn_boolean_t option_names_case_sensitive,
275  apr_pool_t *result_pool);
276 
277 /** Similar to svn_config_create2, but always passes @c FALSE to
278  * @a option_names_case_sensitive.
279  *
280  * @since New in 1.7.
281  * @deprecated Provided for backward compatibility with 1.7 API.
282  */
284 svn_error_t *
286  svn_boolean_t section_names_case_sensitive,
287  apr_pool_t *result_pool);
288 
289 /** Read configuration data from @a file (a file or registry path) into
290  * @a *cfgp, allocated in @a pool.
291  *
292  * If @a file does not exist, then if @a must_exist, return an error,
293  * otherwise return an empty @c svn_config_t.
294  *
295  * If @a section_names_case_sensitive is @c TRUE, populate section name hashes
296  * case sensitively, except for the @c "DEFAULT" section.
297  *
298  * If @a option_names_case_sensitive is @c TRUE, populate option name hashes
299  * case sensitively.
300  *
301  * @since New in 1.8.
302  */
303 svn_error_t *
305  const char *file,
306  svn_boolean_t must_exist,
307  svn_boolean_t section_names_case_sensitive,
308  svn_boolean_t option_names_case_sensitive,
309  apr_pool_t *result_pool);
310 
311 /** Similar to svn_config_read3, but always passes @c FALSE to
312  * @a option_names_case_sensitive.
313  *
314  * @since New in 1.7.
315  * @deprecated Provided for backward compatibility with 1.7 API.
316  */
318 svn_error_t *
320  const char *file,
321  svn_boolean_t must_exist,
322  svn_boolean_t section_names_case_sensitive,
323  apr_pool_t *result_pool);
324 
325 /** Similar to svn_config_read2, but always passes @c FALSE to
326  * @a section_names_case_sensitive.
327  *
328  * @deprecated Provided for backward compatibility with 1.6 API.
329  */
331 svn_error_t *
333  const char *file,
334  svn_boolean_t must_exist,
335  apr_pool_t *result_pool);
336 
337 /** Read configuration data from @a stream into @a *cfgp, allocated in
338  * @a result_pool.
339  *
340  * If @a section_names_case_sensitive is @c TRUE, populate section name hashes
341  * case sensitively, except for the @c "DEFAULT" section.
342  *
343  * If @a option_names_case_sensitive is @c TRUE, populate option name hashes
344  * case sensitively.
345  *
346  * @since New in 1.8.
347  */
348 
349 svn_error_t *
351  svn_stream_t *stream,
352  svn_boolean_t section_names_case_sensitive,
353  svn_boolean_t option_names_case_sensitive,
354  apr_pool_t *result_pool);
355 
356 /** Like svn_config_read(), but merges the configuration data from @a file
357  * (a file or registry path) into @a *cfg, which was previously returned
358  * from svn_config_read(). This function invalidates all value
359  * expansions in @a cfg, so that the next svn_config_get() takes the
360  * modifications into account.
361  */
362 svn_error_t *
364  const char *file,
365  svn_boolean_t must_exist);
366 
367 
368 /** Find the value of a (@a section, @a option) pair in @a cfg, set @a
369  * *valuep to the value.
370  *
371  * If @a cfg is @c NULL, just sets @a *valuep to @a default_value. If
372  * the value does not exist, expand and return @a default_value. @a
373  * default_value can be NULL.
374  *
375  * The returned value will be valid at least until the next call to
376  * svn_config_get(), or for the lifetime of @a default_value. It is
377  * safest to consume the returned value immediately.
378  *
379  * This function may change @a cfg by expanding option values.
380  */
381 void
383  const char **valuep,
384  const char *section,
385  const char *option,
386  const char *default_value);
387 
388 /** Add or replace the value of a (@a section, @a option) pair in @a cfg with
389  * @a value.
390  *
391  * This function invalidates all value expansions in @a cfg.
392  *
393  * To remove an option, pass NULL for the @a value.
394  */
395 void
397  const char *section,
398  const char *option,
399  const char *value);
400 
401 /** Like svn_config_get(), but for boolean values.
402  *
403  * Parses the option as a boolean value. The recognized representations
404  * are 'TRUE'/'FALSE', 'yes'/'no', 'on'/'off', '1'/'0'; case does not
405  * matter. Returns an error if the option doesn't contain a known string.
406  */
407 svn_error_t *
409  svn_boolean_t *valuep,
410  const char *section,
411  const char *option,
412  svn_boolean_t default_value);
413 
414 /** Like svn_config_set(), but for boolean values.
415  *
416  * Sets the option to 'TRUE'/'FALSE', depending on @a value.
417  */
418 void
420  const char *section,
421  const char *option,
422  svn_boolean_t value);
423 
424 /** Like svn_config_get(), but for 64-bit signed integers.
425  *
426  * Parses the @a option in @a section of @a cfg as an integer value,
427  * setting @a *valuep to the result. If the option is not found, sets
428  * @a *valuep to @a default_value. If the option is found but cannot
429  * be converted to an integer, returns an error.
430  *
431  * @since New in 1.8.
432  */
433 svn_error_t *
435  apr_int64_t *valuep,
436  const char *section,
437  const char *option,
438  apr_int64_t default_value);
439 
440 /** Like svn_config_set(), but for 64-bit signed integers.
441  *
442  * Sets the value of @a option in @a section of @a cfg to the signed
443  * decimal @a value.
444  *
445  * @since New in 1.8.
446  */
447 void
449  const char *section,
450  const char *option,
451  apr_int64_t value);
452 
453 /** Like svn_config_get(), but only for yes/no/ask values.
454  *
455  * Parse @a option in @a section and set @a *valuep to one of
456  * SVN_CONFIG_TRUE, SVN_CONFIG_FALSE, or SVN_CONFIG_ASK. If there is
457  * no setting for @a option, then parse @a default_value and set
458  * @a *valuep accordingly. If @a default_value is NULL, the result is
459  * undefined, and may be an error; we recommend that you pass one of
460  * SVN_CONFIG_TRUE, SVN_CONFIG_FALSE, or SVN_CONFIG_ASK for @a default value.
461  *
462  * Valid representations are (at least) "true"/"false", "yes"/"no",
463  * "on"/"off", "1"/"0", and "ask"; they are case-insensitive. Return
464  * an SVN_ERR_BAD_CONFIG_VALUE error if either @a default_value or
465  * @a option's value is not a valid representation.
466  *
467  * @since New in 1.6.
468  */
469 svn_error_t *
471  const char **valuep,
472  const char *section,
473  const char *option,
474  const char* default_value);
475 
476 /** Like svn_config_get_bool(), but for tristate values.
477  *
478  * Set @a *valuep to #svn_tristate_true, #svn_tristate_false, or
479  * #svn_tristate_unknown, depending on the value of @a option in @a
480  * section of @a cfg. True and false values are the same as for
481  * svn_config_get_bool(); @a unknown_value specifies the option value
482  * allowed for third state (#svn_tristate_unknown).
483  *
484  * Use @a default_value as the default value if @a option cannot be
485  * found.
486  *
487  * @since New in 1.8.
488  */
489 svn_error_t *
491  svn_tristate_t *valuep,
492  const char *section,
493  const char *option,
494  const char *unknown_value,
495  svn_tristate_t default_value);
496 
497 /** Similar to @c svn_config_section_enumerator2_t, but is not
498  * provided with a memory pool argument.
499  *
500  * See svn_config_enumerate_sections() for the details of this type.
501  *
502  * @deprecated Provided for backwards compatibility with the 1.2 API.
503  */
504 typedef svn_boolean_t (*svn_config_section_enumerator_t)(const char *name,
505  void *baton);
506 
507 /** Similar to svn_config_enumerate_sections2(), but uses a memory pool of
508  * @a cfg instead of one that is explicitly provided.
509  *
510  * @deprecated Provided for backwards compatibility with the 1.2 API.
511  */
513 int
516  void *baton);
517 
518 /** A callback function used in enumerating config sections.
519  *
520  * See svn_config_enumerate_sections2() for the details of this type.
521  *
522  * @since New in 1.3.
523  */
525  void *baton,
526  apr_pool_t *pool);
527 
528 /** Enumerate the sections, passing @a baton and the current section's name
529  * to @a callback. Continue the enumeration if @a callback returns @c TRUE.
530  * Return the number of times @a callback was called.
531  *
532  * ### See kff's comment to svn_config_enumerate2(). It applies to this
533  * function, too. ###
534  *
535  * @a callback's @a name parameter is only valid for the duration of the call.
536  *
537  * @since New in 1.3.
538  */
539 int
542  void *baton, apr_pool_t *pool);
543 
544 /** Similar to @c svn_config_enumerator2_t, but is not
545  * provided with a memory pool argument.
546  * See svn_config_enumerate() for the details of this type.
547  *
548  * @deprecated Provided for backwards compatibility with the 1.2 API.
549  */
550 typedef svn_boolean_t (*svn_config_enumerator_t)(const char *name,
551  const char *value,
552  void *baton);
553 
554 /** Similar to svn_config_enumerate2(), but uses a memory pool of
555  * @a cfg instead of one that is explicitly provided.
556  *
557  * @deprecated Provided for backwards compatibility with the 1.2 API.
558  */
560 int
562  const char *section,
563  svn_config_enumerator_t callback,
564  void *baton);
565 
566 
567 /** A callback function used in enumerating config options.
568  *
569  * See svn_config_enumerate2() for the details of this type.
570  *
571  * @since New in 1.3.
572  */
573 typedef svn_boolean_t (*svn_config_enumerator2_t)(const char *name,
574  const char *value,
575  void *baton,
576  apr_pool_t *pool);
577 
578 /** Enumerate the options in @a section, passing @a baton and the current
579  * option's name and value to @a callback. Continue the enumeration if
580  * @a callback returns @c TRUE. Return the number of times @a callback
581  * was called.
582  *
583  * ### kff asks: A more usual interface is to continue enumerating
584  * while @a callback does not return error, and if @a callback does
585  * return error, to return the same error (or a wrapping of it)
586  * from svn_config_enumerate(). What's the use case for
587  * svn_config_enumerate()? Is it more likely to need to break out
588  * of an enumeration early, with no error, than an invocation of
589  * @a callback is likely to need to return an error? ###
590  *
591  * @a callback's @a name and @a value parameters are only valid for the
592  * duration of the call.
593  *
594  * @since New in 1.3.
595  */
596 int
598  const char *section,
599  svn_config_enumerator2_t callback,
600  void *baton,
601  apr_pool_t *pool);
602 
603 /**
604  * Return @c TRUE if @a section exists in @a cfg, @c FALSE otherwise.
605  *
606  * @since New in 1.4.
607  */
610  const char *section);
611 
612 /** Enumerate the group @a master_section in @a cfg. Each variable
613  * value is interpreted as a list of glob patterns (separated by comma
614  * and optional whitespace). Return the name of the first variable
615  * whose value matches @a key, or @c NULL if no variable matches.
616  */
617 const char *
619  const char *key,
620  const char *master_section,
621  apr_pool_t *pool);
622 
623 /** Retrieve value corresponding to @a option_name in @a cfg, or
624  * return @a default_value if none is found.
625  *
626  * The config will first be checked for a default.
627  * If @a server_group is not @c NULL, the config will also be checked
628  * for an override in a server group,
629  *
630  */
631 const char *
633  const char* server_group,
634  const char* option_name,
635  const char* default_value);
636 
637 /** Retrieve value into @a result_value corresponding to @a option_name for a
638  * given @a server_group in @a cfg, or return @a default_value if none is
639  * found.
640  *
641  * The config will first be checked for a default, then will be checked for
642  * an override in a server group. If the value found is not a valid integer,
643  * a @c svn_error_t* will be returned.
644  */
645 svn_error_t *
647  const char *server_group,
648  const char *option_name,
649  apr_int64_t default_value,
650  apr_int64_t *result_value,
651  apr_pool_t *pool);
652 
653 
654 /** Set @a *valuep according to @a option_name for a given
655  * @a server_group in @a cfg, or set to @a default_value if no value is
656  * specified.
657  *
658  * Check first a default, then for an override in a server group. If
659  * a value is found but is not a valid boolean, return an
660  * SVN_ERR_BAD_CONFIG_VALUE error.
661  *
662  * @since New in 1.6.
663  */
664 svn_error_t *
666  svn_boolean_t *valuep,
667  const char *server_group,
668  const char *option_name,
669  svn_boolean_t default_value);
670 
671 
672 ␌
673 /** Try to ensure that the user's ~/.subversion/ area exists, and create
674  * no-op template files for any absent config files. Use @a pool for any
675  * temporary allocation. If @a config_dir is not @c NULL it specifies a
676  * directory from which to read the config overriding all other sources.
677  *
678  * Don't error if something exists but is the wrong kind (for example,
679  * ~/.subversion exists but is a file, or ~/.subversion/servers exists
680  * but is a directory).
681  *
682  * Also don't error if trying to create something and failing -- it's
683  * okay for the config area or its contents not to be created.
684  * However, if creating a config template file succeeds, return an
685  * error if unable to initialize its contents.
686  */
687 svn_error_t *
688 svn_config_ensure(const char *config_dir,
689  apr_pool_t *pool);
690 
691 
692 
693 ␌
694 /** Accessing cached authentication data in the user config area.
695  *
696  * @defgroup cached_authentication_data Cached authentication data
697  * @{
698  */
699 
700 
701 /**
702  * Attributes of authentication credentials.
703  *
704  * The values of these keys are C strings.
705  *
706  * @note Some of these hash keys were also used in versions < 1.9 but were
707  * not part of the public API (except #SVN_CONFIG_REALMSTRING_KEY which
708  * has been present since 1.0).
709  *
710  * @defgroup cached_authentication_data_attributes Cached authentication data attributes
711  * @{
712  */
713 
714 /** A hash-key pointing to a realmstring. This attribute is mandatory.
715  *
716  * @since New in 1.0.
717  */
718 #define SVN_CONFIG_REALMSTRING_KEY "svn:realmstring"
719 
720 /** A hash-key for usernames.
721  * @since New in 1.9.
722  */
723 #define SVN_CONFIG_AUTHN_USERNAME_KEY "username"
724 
725 /** A hash-key for passwords.
726  * The password may be in plaintext or encrypted form, depending on
727  * the authentication provider.
728  * @since New in 1.9.
729  */
730 #define SVN_CONFIG_AUTHN_PASSWORD_KEY "password"
731 
732 /** A hash-key for passphrases,
733  * such as SSL client ceritifcate passphrases. The passphrase may be in
734  * plaintext or encrypted form, depending on the authentication provider.
735  * @since New in 1.9.
736  */
737 #define SVN_CONFIG_AUTHN_PASSPHRASE_KEY "passphrase"
738 
739 /** A hash-key for the type of a password or passphrase. The type
740  * indicates which provider owns the credential.
741  * @since New in 1.9.
742  */
743 #define SVN_CONFIG_AUTHN_PASSTYPE_KEY "passtype"
744 
745 /** A hash-key for SSL certificates. The value is the base64-encoded DER form
746  * certificate.
747  * @since New in 1.9.
748  * @note The value is not human readable.
749  */
750 #define SVN_CONFIG_AUTHN_ASCII_CERT_KEY "ascii_cert"
751 
752 /** A hash-key for recorded SSL certificate verification
753  * failures. Failures encoded as an ASCII integer containing any of the
754  * SVN_AUTH_SSL_* SSL server certificate failure bits defined in svn_auth.h.
755  * @since New in 1.9.
756  */
757 #define SVN_CONFIG_AUTHN_FAILURES_KEY "failures"
758 
759 
760 /** @} */
761 
762 /** Use @a cred_kind and @a realmstring to locate a file within the
763  * ~/.subversion/auth/ area. If the file exists, initialize @a *hash
764  * and load the file contents into the hash, using @a pool. If the
765  * file doesn't exist, set @a *hash to NULL.
766  *
767  * If @a config_dir is not NULL it specifies a directory from which to
768  * read the config overriding all other sources.
769  *
770  * Besides containing the original credential fields, the hash will
771  * also contain @c SVN_CONFIG_REALMSTRING_KEY. The caller can examine
772  * this value as a sanity-check that the correct file was loaded.
773  *
774  * The hashtable will contain <tt>const char *</tt> keys and
775  * <tt>svn_string_t *</tt> values.
776  */
777 svn_error_t *
778 svn_config_read_auth_data(apr_hash_t **hash,
779  const char *cred_kind,
780  const char *realmstring,
781  const char *config_dir,
782  apr_pool_t *pool);
783 
784 /** Use @a cred_kind and @a realmstring to create or overwrite a file
785  * within the ~/.subversion/auth/ area. Write the contents of @a hash into
786  * the file. If @a config_dir is not NULL it specifies a directory to read
787  * the config overriding all other sources.
788  *
789  * Also, add @a realmstring to the file, with key @c
790  * SVN_CONFIG_REALMSTRING_KEY. This allows programs (or users) to
791  * verify exactly which set credentials live within the file.
792  *
793  * The hashtable must contain <tt>const char *</tt> keys and
794  * <tt>svn_string_t *</tt> values.
795  */
796 svn_error_t *
797 svn_config_write_auth_data(apr_hash_t *hash,
798  const char *cred_kind,
799  const char *realmstring,
800  const char *config_dir,
801  apr_pool_t *pool);
802 
803 
804 /** Callback for svn_config_walk_auth_data().
805  *
806  * Called for each credential walked by that function (and able to be
807  * fully purged) to allow perusal and selective removal of credentials.
808  *
809  * @a cred_kind and @a realmstring specify the key of the credential.
810  * @a hash contains the hash data associated with the record. @a walk_baton
811  * is the baton passed to svn_config_walk_auth_data().
812  *
813  * Before returning set @a *delete_cred to TRUE to remove the credential from
814  * the cache; leave @a *delete_cred unchanged or set it to FALSE to keep the
815  * credential.
816  *
817  * Implementations may return #SVN_ERR_CEASE_INVOCATION to indicate
818  * that the callback should not be called again. Note that when that
819  * error is returned, the value of @a delete_cred will still be
820  * honored and action taken if necessary. (For other returned errors,
821  * @a delete_cred is ignored by svn_config_walk_auth_data().)
822  *
823  * @since New in 1.8.
824  */
825 typedef svn_error_t *
826 (*svn_config_auth_walk_func_t)(svn_boolean_t *delete_cred,
827  void *walk_baton,
828  const char *cred_kind,
829  const char *realmstring,
830  apr_hash_t *hash,
831  apr_pool_t *scratch_pool);
832 
833 /** Call @a walk_func with @a walk_baton and information describing
834  * each credential cached within the Subversion auth store located
835  * under @a config_dir. If the callback sets its delete_cred return
836  * flag, delete the associated credential.
837  *
838  * If @a config_dir is not NULL, it must point to an alternative
839  * config directory location. If it is NULL, the default location
840  * is used.
841  *
842  * @note @a config_dir may only be NULL in 1.8.2 and later.
843  *
844  * @note Removing credentials from the config-based disk store will
845  * not purge them from any open svn_auth_baton_t instance. Consider
846  * using svn_auth_forget_credentials() -- from the @a walk_func,
847  * even -- for this purpose.
848  *
849  * @note Removing credentials from the config-based disk store will
850  * not also remove any related credentials from third-party password
851  * stores. (Implementations of @a walk_func which delete credentials
852  * may wish to consult the "passtype" element of @a hash, if any, to
853  * see if a third-party store -- such as "gnome-keyring" or "kwallet"
854  * is being used to hold the most sensitive portion of the credentials
855  * for this @a cred_kind and @a realmstring.)
856  *
857  * @see svn_auth_forget_credentials()
858  *
859  * @since New in 1.8.
860  */
861 svn_error_t *
862 svn_config_walk_auth_data(const char *config_dir,
863  svn_config_auth_walk_func_t walk_func,
864  void *walk_baton,
865  apr_pool_t *scratch_pool);
866 
867 /** Put the absolute path to the user's configuration directory,
868  * or to a file within that directory, into @a *path.
869  *
870  * If @a config_dir is not NULL, it must point to an alternative
871  * config directory location. If it is NULL, the default location
872  * is used. If @a fname is not NULL, it must specify the last
873  * component of the path to be returned. This can be used to create
874  * a path to any file in the configuration directory.
875  *
876  * Do all allocations in @a pool.
877  *
878  * Hint:
879  * To get the user configuration file, pass @c SVN_CONFIG_CATEGORY_CONFIG
880  * for @a fname. To get the servers configuration file, pass
881  * @c SVN_CONFIG_CATEGORY_SERVERS for @a fname.
882  *
883  * @since New in 1.6.
884  */
885 svn_error_t *
887  const char *config_dir,
888  const char *fname,
889  apr_pool_t *pool);
890 
891 /** Create a deep copy of the config object @a src and return
892  * it in @a cfgp, allocating the memory in @a pool.
893  *
894  * @since New in 1.8.
895  */
896 svn_error_t *
898  const svn_config_t *src,
899  apr_pool_t *pool);
900 
901 /** Create a deep copy of the config hash @a src_hash and return
902  * it in @a cfg_hash, allocating the memory in @a pool.
903  *
904  * @since New in 1.8.
905  */
906 svn_error_t *
907 svn_config_copy_config(apr_hash_t **cfg_hash,
908  apr_hash_t *src_hash,
909  apr_pool_t *pool);
910 
911 /** @} */
912 
913 #ifdef __cplusplus
914 }
915 #endif /* __cplusplus */
916 
917 #endif /* SVN_CONFIG_H */
svn_error_t * svn_config_copy_config(apr_hash_t **cfg_hash, apr_hash_t *src_hash, apr_pool_t *pool)
Create a deep copy of the config hash src_hash and return it in cfg_hash, allocating the memory in po...
svn_error_t * svn_config_walk_auth_data(const char *config_dir, svn_config_auth_walk_func_t walk_func, void *walk_baton, apr_pool_t *scratch_pool)
Call walk_func with walk_baton and information describing each credential cached within the Subversio...
svn_error_t * svn_config_write_auth_data(apr_hash_t *hash, const char *cred_kind, const char *realmstring, const char *config_dir, apr_pool_t *pool)
Use cred_kind and realmstring to create or overwrite a file within the ~/.subversion/auth/ area.
svn_error_t * svn_config_get_user_config_path(const char **path, const char *config_dir, const char *fname, apr_pool_t *pool)
Put the absolute path to the user's configuration directory, or to a file within that directory,...
svn_error_t * svn_config_read_auth_data(apr_hash_t **hash, const char *cred_kind, const char *realmstring, const char *config_dir, apr_pool_t *pool)
Use cred_kind and realmstring to locate a file within the ~/.subversion/auth/ area.
svn_error_t *(* svn_config_auth_walk_func_t)(svn_boolean_t *delete_cred, void *walk_baton, const char *cred_kind, const char *realmstring, apr_hash_t *hash, apr_pool_t *scratch_pool)
Callback for svn_config_walk_auth_data().
Definition: svn_config.h:826
svn_error_t * svn_config_dup(svn_config_t **cfgp, const svn_config_t *src, apr_pool_t *pool)
Create a deep copy of the config object src and return it in cfgp, allocating the memory in pool.
struct svn_stream_t svn_stream_t
An abstract stream of bytes–either incoming or outgoing or both.
Definition: svn_io.h:863
Subversion error object.
Definition: svn_types.h:177
svn_boolean_t svn_config_has_section(svn_config_t *cfg, const char *section)
Return TRUE if section exists in cfg, FALSE otherwise.
void svn_config_set_bool(svn_config_t *cfg, const char *section, const char *option, svn_boolean_t value)
Like svn_config_set(), but for boolean values.
const char * svn_config_get_server_setting(svn_config_t *cfg, const char *server_group, const char *option_name, const char *default_value)
Retrieve value corresponding to option_name in cfg, or return default_value if none is found.
svn_error_t * svn_config_read2(svn_config_t **cfgp, const char *file, svn_boolean_t must_exist, svn_boolean_t section_names_case_sensitive, apr_pool_t *result_pool)
Similar to svn_config_read3, but always passes FALSE to option_names_case_sensitive.
int svn_config_enumerate_sections(svn_config_t *cfg, svn_config_section_enumerator_t callback, void *baton)
Similar to svn_config_enumerate_sections2(), but uses a memory pool of cfg instead of one that is exp...
svn_boolean_t(* svn_config_section_enumerator2_t)(const char *name, void *baton, apr_pool_t *pool)
A callback function used in enumerating config sections.
Definition: svn_config.h:524
void svn_config_set(svn_config_t *cfg, const char *section, const char *option, const char *value)
Add or replace the value of a (section, option) pair in cfg with value.
svn_error_t * svn_config_read(svn_config_t **cfgp, const char *file, svn_boolean_t must_exist, apr_pool_t *result_pool)
Similar to svn_config_read2, but always passes FALSE to section_names_case_sensitive.
int svn_config_enumerate_sections2(svn_config_t *cfg, svn_config_section_enumerator2_t callback, void *baton, apr_pool_t *pool)
Enumerate the sections, passing baton and the current section's name to callback.
svn_boolean_t(* svn_config_section_enumerator_t)(const char *name, void *baton)
Similar to svn_config_section_enumerator2_t, but is not provided with a memory pool argument.
Definition: svn_config.h:504
svn_error_t * svn_config_get_tristate(svn_config_t *cfg, svn_tristate_t *valuep, const char *section, const char *option, const char *unknown_value, svn_tristate_t default_value)
Like svn_config_get_bool(), but for tristate values.
svn_error_t * svn_config_read3(svn_config_t **cfgp, const char *file, svn_boolean_t must_exist, svn_boolean_t section_names_case_sensitive, svn_boolean_t option_names_case_sensitive, apr_pool_t *result_pool)
Read configuration data from file (a file or registry path) into *cfgp, allocated in pool.
svn_error_t * svn_config_get_int64(svn_config_t *cfg, apr_int64_t *valuep, const char *section, const char *option, apr_int64_t default_value)
Like svn_config_get(), but for 64-bit signed integers.
svn_error_t * svn_config_get_server_setting_bool(svn_config_t *cfg, svn_boolean_t *valuep, const char *server_group, const char *option_name, svn_boolean_t default_value)
Set *valuep according to option_name for a given server_group in cfg, or set to default_value if no v...
int svn_config_enumerate(svn_config_t *cfg, const char *section, svn_config_enumerator_t callback, void *baton)
Similar to svn_config_enumerate2(), but uses a memory pool of cfg instead of one that is explicitly p...
svn_error_t * svn_config_get_yes_no_ask(svn_config_t *cfg, const char **valuep, const char *section, const char *option, const char *default_value)
Like svn_config_get(), but only for yes/no/ask values.
int svn_config_enumerate2(svn_config_t *cfg, const char *section, svn_config_enumerator2_t callback, void *baton, apr_pool_t *pool)
Enumerate the options in section, passing baton and the current option's name and value to callback.
svn_error_t * svn_config_get_server_setting_int(svn_config_t *cfg, const char *server_group, const char *option_name, apr_int64_t default_value, apr_int64_t *result_value, apr_pool_t *pool)
Retrieve value into result_value corresponding to option_name for a given server_group in cfg,...
svn_error_t * svn_config_create(svn_config_t **cfgp, svn_boolean_t section_names_case_sensitive, apr_pool_t *result_pool)
Similar to svn_config_create2, but always passes FALSE to option_names_case_sensitive.
const char * svn_config_find_group(svn_config_t *cfg, const char *key, const char *master_section, apr_pool_t *pool)
Enumerate the group master_section in cfg.
void svn_config_get(svn_config_t *cfg, const char **valuep, const char *section, const char *option, const char *default_value)
Find the value of a (section, option) pair in cfg, set *valuep to the value.
svn_boolean_t(* svn_config_enumerator_t)(const char *name, const char *value, void *baton)
Similar to svn_config_enumerator2_t, but is not provided with a memory pool argument.
Definition: svn_config.h:550
void svn_config_set_int64(svn_config_t *cfg, const char *section, const char *option, apr_int64_t value)
Like svn_config_set(), but for 64-bit signed integers.
struct svn_config_t svn_config_t
Opaque structure describing a set of configuration options.
Definition: svn_config.h:54
svn_error_t * svn_config_get_config(apr_hash_t **cfg_hash, const char *config_dir, apr_pool_t *pool)
Read configuration information from the standard sources and merge it into the hash *cfg_hash.
svn_boolean_t(* svn_config_enumerator2_t)(const char *name, const char *value, void *baton, apr_pool_t *pool)
A callback function used in enumerating config options.
Definition: svn_config.h:573
svn_error_t * svn_config_create2(svn_config_t **cfgp, svn_boolean_t section_names_case_sensitive, svn_boolean_t option_names_case_sensitive, apr_pool_t *result_pool)
Set *cfgp to an empty svn_config_t structure, allocated in result_pool.
svn_error_t * svn_config_merge(svn_config_t *cfg, const char *file, svn_boolean_t must_exist)
Like svn_config_read(), but merges the configuration data from file (a file or registry path) into *c...
svn_error_t * svn_config_get_bool(svn_config_t *cfg, svn_boolean_t *valuep, const char *section, const char *option, svn_boolean_t default_value)
Like svn_config_get(), but for boolean values.
svn_error_t * svn_config_ensure(const char *config_dir, apr_pool_t *pool)
Try to ensure that the user's ~/.subversion/ area exists, and create no-op template files for any abs...
svn_error_t * svn_config_parse(svn_config_t **cfgp, svn_stream_t *stream, svn_boolean_t section_names_case_sensitive, svn_boolean_t option_names_case_sensitive, apr_pool_t *result_pool)
Read configuration data from stream into *cfgp, allocated in result_pool.
General file I/O for Subversion.
Subversion's data types.
int svn_boolean_t
YABT: Yet Another Boolean Type.
Definition: svn_types.h:137
#define SVN_DEPRECATED
Macro used to mark deprecated functions.
Definition: svn_types.h:62
svn_tristate_t
Generic three-state property to represent an unknown value for values that are just like booleans.