00001 /** 00002 * @copyright 00003 * ==================================================================== 00004 * Licensed to the Apache Software Foundation (ASF) under one 00005 * or more contributor license agreements. See the NOTICE file 00006 * distributed with this work for additional information 00007 * regarding copyright ownership. The ASF licenses this file 00008 * to you under the Apache License, Version 2.0 (the 00009 * "License"); you may not use this file except in compliance 00010 * with the License. You may obtain a copy of the License at 00011 * 00012 * http://www.apache.org/licenses/LICENSE-2.0 00013 * 00014 * Unless required by applicable law or agreed to in writing, 00015 * software distributed under the License is distributed on an 00016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 00017 * KIND, either express or implied. See the License for the 00018 * specific language governing permissions and limitations 00019 * under the License. 00020 * ==================================================================== 00021 * @endcopyright 00022 * 00023 * @file svn_config.h 00024 * @brief Accessing SVN configuration files. 00025 */ 00026 00027 00028 00029 #ifndef SVN_CONFIG_H 00030 #define SVN_CONFIG_H 00031 00032 #include <apr.h> /* for apr_int64_t */ 00033 #include <apr_pools.h> /* for apr_pool_t */ 00034 #include <apr_hash.h> /* for apr_hash_t */ 00035 00036 #include "svn_types.h" 00037 #include "svn_io.h" 00038 00039 #ifdef __cplusplus 00040 extern "C" { 00041 #endif /* __cplusplus */ 00042 00043 00044 /************************************************************************** 00045 *** *** 00046 *** For a description of the SVN configuration file syntax, see *** 00047 *** your ~/.subversion/README, which is written out automatically by *** 00048 *** svn_config_ensure(). *** 00049 *** *** 00050 **************************************************************************/ 00051 00052 00053 /** Opaque structure describing a set of configuration options. */ 00054 typedef struct svn_config_t svn_config_t; 00055 00056 00057 /*** Configuration Defines ***/ 00058 00059 /** 00060 * @name Client configuration files strings 00061 * Strings for the names of files, sections, and options in the 00062 * client configuration files. 00063 * @{ 00064 */ 00065 00066 /* If you add a new SVN_CONFIG_* category/section/option macro to this group, 00067 * you have to re-run gen-make.py manually. 00068 * 00069 * ### This should be fixed in the build system; see issue #4581. 00070 */ 00071 00072 /* This list of #defines is intentionally presented as a nested list 00073 that matches the in-config hierarchy. */ 00074 00075 #define SVN_CONFIG_CATEGORY_SERVERS "servers" 00076 #define SVN_CONFIG_SECTION_GROUPS "groups" 00077 #define SVN_CONFIG_SECTION_GLOBAL "global" 00078 #define SVN_CONFIG_OPTION_HTTP_PROXY_HOST "http-proxy-host" 00079 #define SVN_CONFIG_OPTION_HTTP_PROXY_PORT "http-proxy-port" 00080 #define SVN_CONFIG_OPTION_HTTP_PROXY_USERNAME "http-proxy-username" 00081 #define SVN_CONFIG_OPTION_HTTP_PROXY_PASSWORD "http-proxy-password" 00082 #define SVN_CONFIG_OPTION_HTTP_PROXY_EXCEPTIONS "http-proxy-exceptions" 00083 #define SVN_CONFIG_OPTION_HTTP_TIMEOUT "http-timeout" 00084 #define SVN_CONFIG_OPTION_HTTP_COMPRESSION "http-compression" 00085 /** @deprecated Not used since 1.8. */ 00086 #define SVN_CONFIG_OPTION_NEON_DEBUG_MASK "neon-debug-mask" 00087 /** @since New in 1.5. */ 00088 #define SVN_CONFIG_OPTION_HTTP_AUTH_TYPES "http-auth-types" 00089 #define SVN_CONFIG_OPTION_SSL_AUTHORITY_FILES "ssl-authority-files" 00090 #define SVN_CONFIG_OPTION_SSL_TRUST_DEFAULT_CA "ssl-trust-default-ca" 00091 #define SVN_CONFIG_OPTION_SSL_CLIENT_CERT_FILE "ssl-client-cert-file" 00092 #define SVN_CONFIG_OPTION_SSL_CLIENT_CERT_PASSWORD "ssl-client-cert-password" 00093 /** @deprecated Not used since 1.8. 00094 * @since New in 1.5. */ 00095 #define SVN_CONFIG_OPTION_SSL_PKCS11_PROVIDER "ssl-pkcs11-provider" 00096 /** @since New in 1.5. */ 00097 #define SVN_CONFIG_OPTION_HTTP_LIBRARY "http-library" 00098 /** @since New in 1.1. */ 00099 #define SVN_CONFIG_OPTION_STORE_PASSWORDS "store-passwords" 00100 /** @since New in 1.6. */ 00101 #define SVN_CONFIG_OPTION_STORE_PLAINTEXT_PASSWORDS "store-plaintext-passwords" 00102 #define SVN_CONFIG_OPTION_STORE_AUTH_CREDS "store-auth-creds" 00103 /** @since New in 1.6. */ 00104 #define SVN_CONFIG_OPTION_STORE_SSL_CLIENT_CERT_PP "store-ssl-client-cert-pp" 00105 /** @since New in 1.6. */ 00106 #define SVN_CONFIG_OPTION_STORE_SSL_CLIENT_CERT_PP_PLAINTEXT \ 00107 "store-ssl-client-cert-pp-plaintext" 00108 #define SVN_CONFIG_OPTION_USERNAME "username" 00109 /** @since New in 1.8. */ 00110 #define SVN_CONFIG_OPTION_HTTP_BULK_UPDATES "http-bulk-updates" 00111 /** @since New in 1.8. */ 00112 #define SVN_CONFIG_OPTION_HTTP_MAX_CONNECTIONS "http-max-connections" 00113 /** @since New in 1.9. */ 00114 #define SVN_CONFIG_OPTION_HTTP_CHUNKED_REQUESTS "http-chunked-requests" 00115 00116 /** @since New in 1.9. */ 00117 #define SVN_CONFIG_OPTION_SERF_LOG_COMPONENTS "serf-log-components" 00118 /** @since New in 1.9. */ 00119 #define SVN_CONFIG_OPTION_SERF_LOG_LEVEL "serf-log-level" 00120 00121 00122 #define SVN_CONFIG_CATEGORY_CONFIG "config" 00123 #define SVN_CONFIG_SECTION_AUTH "auth" 00124 /** @since New in 1.6. */ 00125 #define SVN_CONFIG_OPTION_PASSWORD_STORES "password-stores" 00126 /** @since New in 1.6. */ 00127 #define SVN_CONFIG_OPTION_KWALLET_WALLET "kwallet-wallet" 00128 /** @since New in 1.6. */ 00129 #define SVN_CONFIG_OPTION_KWALLET_SVN_APPLICATION_NAME_WITH_PID "kwallet-svn-application-name-with-pid" 00130 /** @since New in 1.8. */ 00131 #define SVN_CONFIG_OPTION_SSL_CLIENT_CERT_FILE_PROMPT "ssl-client-cert-file-prompt" 00132 /* The majority of options of the "auth" section 00133 * has been moved to SVN_CONFIG_CATEGORY_SERVERS. */ 00134 #define SVN_CONFIG_SECTION_HELPERS "helpers" 00135 #define SVN_CONFIG_OPTION_EDITOR_CMD "editor-cmd" 00136 #define SVN_CONFIG_OPTION_DIFF_CMD "diff-cmd" 00137 /** @since New in 1.7. */ 00138 #define SVN_CONFIG_OPTION_DIFF_EXTENSIONS "diff-extensions" 00139 #define SVN_CONFIG_OPTION_DIFF3_CMD "diff3-cmd" 00140 #define SVN_CONFIG_OPTION_DIFF3_HAS_PROGRAM_ARG "diff3-has-program-arg" 00141 /** @since New in 1.5. */ 00142 #define SVN_CONFIG_OPTION_MERGE_TOOL_CMD "merge-tool-cmd" 00143 #define SVN_CONFIG_SECTION_MISCELLANY "miscellany" 00144 #define SVN_CONFIG_OPTION_GLOBAL_IGNORES "global-ignores" 00145 #define SVN_CONFIG_OPTION_LOG_ENCODING "log-encoding" 00146 #define SVN_CONFIG_OPTION_USE_COMMIT_TIMES "use-commit-times" 00147 /** @deprecated Not used by Subversion since 2003/r847039 (well before 1.0) */ 00148 #define SVN_CONFIG_OPTION_TEMPLATE_ROOT "template-root" 00149 #define SVN_CONFIG_OPTION_ENABLE_AUTO_PROPS "enable-auto-props" 00150 /** @since New in 1.9. */ 00151 #define SVN_CONFIG_OPTION_ENABLE_MAGIC_FILE "enable-magic-file" 00152 /** @since New in 1.2. */ 00153 #define SVN_CONFIG_OPTION_NO_UNLOCK "no-unlock" 00154 /** @since New in 1.5. */ 00155 #define SVN_CONFIG_OPTION_MIMETYPES_FILE "mime-types-file" 00156 /** @since New in 1.5. */ 00157 #define SVN_CONFIG_OPTION_PRESERVED_CF_EXTS "preserved-conflict-file-exts" 00158 /** @since New in 1.7. */ 00159 #define SVN_CONFIG_OPTION_INTERACTIVE_CONFLICTS "interactive-conflicts" 00160 /** @since New in 1.7. */ 00161 #define SVN_CONFIG_OPTION_MEMORY_CACHE_SIZE "memory-cache-size" 00162 /** @since New in 1.9. */ 00163 #define SVN_CONFIG_OPTION_DIFF_IGNORE_CONTENT_TYPE "diff-ignore-content-type" 00164 #define SVN_CONFIG_SECTION_TUNNELS "tunnels" 00165 #define SVN_CONFIG_SECTION_AUTO_PROPS "auto-props" 00166 /** @since New in 1.8. */ 00167 #define SVN_CONFIG_SECTION_WORKING_COPY "working-copy" 00168 /** @since New in 1.8. */ 00169 #define SVN_CONFIG_OPTION_SQLITE_EXCLUSIVE "exclusive-locking" 00170 /** @since New in 1.8. */ 00171 #define SVN_CONFIG_OPTION_SQLITE_EXCLUSIVE_CLIENTS "exclusive-locking-clients" 00172 /** @since New in 1.9. */ 00173 #define SVN_CONFIG_OPTION_SQLITE_BUSY_TIMEOUT "busy-timeout" 00174 /** @} */ 00175 00176 /** @name Repository conf directory configuration files strings 00177 * Strings for the names of sections and options in the 00178 * repository conf directory configuration files. 00179 * @{ 00180 */ 00181 /* For repository svnserve.conf files */ 00182 #define SVN_CONFIG_SECTION_GENERAL "general" 00183 #define SVN_CONFIG_OPTION_ANON_ACCESS "anon-access" 00184 #define SVN_CONFIG_OPTION_AUTH_ACCESS "auth-access" 00185 #define SVN_CONFIG_OPTION_PASSWORD_DB "password-db" 00186 #define SVN_CONFIG_OPTION_REALM "realm" 00187 #define SVN_CONFIG_OPTION_AUTHZ_DB "authz-db" 00188 /** @since New in 1.8. */ 00189 #define SVN_CONFIG_OPTION_GROUPS_DB "groups-db" 00190 /** @since New in 1.7. */ 00191 #define SVN_CONFIG_OPTION_FORCE_USERNAME_CASE "force-username-case" 00192 /** @since New in 1.8. */ 00193 #define SVN_CONFIG_OPTION_HOOKS_ENV "hooks-env" 00194 /** @since New in 1.5. */ 00195 #define SVN_CONFIG_SECTION_SASL "sasl" 00196 /** @since New in 1.5. */ 00197 #define SVN_CONFIG_OPTION_USE_SASL "use-sasl" 00198 /** @since New in 1.5. */ 00199 #define SVN_CONFIG_OPTION_MIN_SSF "min-encryption" 00200 /** @since New in 1.5. */ 00201 #define SVN_CONFIG_OPTION_MAX_SSF "max-encryption" 00202 00203 /* For repository password database */ 00204 #define SVN_CONFIG_SECTION_USERS "users" 00205 /** @} */ 00206 00207 /*** Configuration Default Values ***/ 00208 00209 /* '*' matches leading dots, e.g. '*.rej' matches '.foo.rej'. */ 00210 /* We want this to be printed on two lines in the generated config file, 00211 * but we don't want the # character to end up in the variable. 00212 */ 00213 #ifndef DOXYGEN_SHOULD_SKIP_THIS 00214 #define SVN_CONFIG__DEFAULT_GLOBAL_IGNORES_LINE_1 \ 00215 "*.o *.lo *.la *.al .libs *.so *.so.[0-9]* *.a *.pyc *.pyo __pycache__" 00216 #define SVN_CONFIG__DEFAULT_GLOBAL_IGNORES_LINE_2 \ 00217 "*.rej *~ #*# .#* .*.swp .DS_Store [Tt]humbs.db" 00218 #endif 00219 00220 #define SVN_CONFIG_DEFAULT_GLOBAL_IGNORES \ 00221 SVN_CONFIG__DEFAULT_GLOBAL_IGNORES_LINE_1 " " \ 00222 SVN_CONFIG__DEFAULT_GLOBAL_IGNORES_LINE_2 00223 00224 #define SVN_CONFIG_TRUE "TRUE" 00225 #define SVN_CONFIG_FALSE "FALSE" 00226 #define SVN_CONFIG_ASK "ASK" 00227 00228 /* Default values for some options. Should be passed as default values 00229 * to svn_config_get and friends, instead of hard-coding the defaults in 00230 * multiple places. */ 00231 #define SVN_CONFIG_DEFAULT_OPTION_STORE_PASSWORDS TRUE 00232 #define SVN_CONFIG_DEFAULT_OPTION_STORE_PLAINTEXT_PASSWORDS SVN_CONFIG_ASK 00233 #define SVN_CONFIG_DEFAULT_OPTION_STORE_AUTH_CREDS TRUE 00234 #define SVN_CONFIG_DEFAULT_OPTION_STORE_SSL_CLIENT_CERT_PP TRUE 00235 #define SVN_CONFIG_DEFAULT_OPTION_STORE_SSL_CLIENT_CERT_PP_PLAINTEXT \ 00236 SVN_CONFIG_ASK 00237 #define SVN_CONFIG_DEFAULT_OPTION_HTTP_MAX_CONNECTIONS 4 00238 00239 /** Read configuration information from the standard sources and merge it 00240 * into the hash @a *cfg_hash. If @a config_dir is not NULL it specifies a 00241 * directory from which to read the configuration files, overriding all 00242 * other sources. Otherwise, first read any system-wide configurations 00243 * (from a file or from the registry), then merge in personal 00244 * configurations (again from file or registry). The hash and all its data 00245 * are allocated in @a pool. 00246 * 00247 * @a *cfg_hash is a hash whose keys are @c const char * configuration 00248 * categories (@c SVN_CONFIG_CATEGORY_SERVERS, 00249 * @c SVN_CONFIG_CATEGORY_CONFIG, etc.) and whose values are the @c 00250 * svn_config_t * items representing the configuration values for that 00251 * category. 00252 */ 00253 svn_error_t * 00254 svn_config_get_config(apr_hash_t **cfg_hash, 00255 const char *config_dir, 00256 apr_pool_t *pool); 00257 00258 /** Set @a *cfgp to an empty @c svn_config_t structure, 00259 * allocated in @a result_pool. 00260 * 00261 * Pass TRUE to @a section_names_case_sensitive if 00262 * section names are to be populated case sensitively. 00263 * 00264 * Pass TRUE to @a option_names_case_sensitive if 00265 * option names are to be populated case sensitively. 00266 * 00267 * @since New in 1.8. 00268 */ 00269 svn_error_t * 00270 svn_config_create2(svn_config_t **cfgp, 00271 svn_boolean_t section_names_case_sensitive, 00272 svn_boolean_t option_names_case_sensitive, 00273 apr_pool_t *result_pool); 00274 00275 /** Similar to svn_config_create2, but always passes @c FALSE to 00276 * @a option_names_case_sensitive. 00277 * 00278 * @since New in 1.7. 00279 * @deprecated Provided for backward compatibility with 1.7 API. 00280 */ 00281 SVN_DEPRECATED 00282 svn_error_t * 00283 svn_config_create(svn_config_t **cfgp, 00284 svn_boolean_t section_names_case_sensitive, 00285 apr_pool_t *result_pool); 00286 00287 /** Read configuration data from @a file (a file or registry path) into 00288 * @a *cfgp, allocated in @a pool. 00289 * 00290 * If @a file does not exist, then if @a must_exist, return an error, 00291 * otherwise return an empty @c svn_config_t. 00292 * 00293 * If @a section_names_case_sensitive is @c TRUE, populate section name hashes 00294 * case sensitively, except for the @c "DEFAULT" section. 00295 * 00296 * If @a option_names_case_sensitive is @c TRUE, populate option name hashes 00297 * case sensitively. 00298 * 00299 * @since New in 1.8. 00300 */ 00301 svn_error_t * 00302 svn_config_read3(svn_config_t **cfgp, 00303 const char *file, 00304 svn_boolean_t must_exist, 00305 svn_boolean_t section_names_case_sensitive, 00306 svn_boolean_t option_names_case_sensitive, 00307 apr_pool_t *result_pool); 00308 00309 /** Similar to svn_config_read3, but always passes @c FALSE to 00310 * @a option_names_case_sensitive. 00311 * 00312 * @since New in 1.7. 00313 * @deprecated Provided for backward compatibility with 1.7 API. 00314 */ 00315 SVN_DEPRECATED 00316 svn_error_t * 00317 svn_config_read2(svn_config_t **cfgp, 00318 const char *file, 00319 svn_boolean_t must_exist, 00320 svn_boolean_t section_names_case_sensitive, 00321 apr_pool_t *result_pool); 00322 00323 /** Similar to svn_config_read2, but always passes @c FALSE to 00324 * @a section_names_case_sensitive. 00325 * 00326 * @deprecated Provided for backward compatibility with 1.6 API. 00327 */ 00328 SVN_DEPRECATED 00329 svn_error_t * 00330 svn_config_read(svn_config_t **cfgp, 00331 const char *file, 00332 svn_boolean_t must_exist, 00333 apr_pool_t *result_pool); 00334 00335 /** Read configuration data from @a stream into @a *cfgp, allocated in 00336 * @a result_pool. 00337 * 00338 * If @a section_names_case_sensitive is @c TRUE, populate section name hashes 00339 * case sensitively, except for the @c "DEFAULT" section. 00340 * 00341 * If @a option_names_case_sensitive is @c TRUE, populate option name hashes 00342 * case sensitively. 00343 * 00344 * @since New in 1.8. 00345 */ 00346 00347 svn_error_t * 00348 svn_config_parse(svn_config_t **cfgp, 00349 svn_stream_t *stream, 00350 svn_boolean_t section_names_case_sensitive, 00351 svn_boolean_t option_names_case_sensitive, 00352 apr_pool_t *result_pool); 00353 00354 /** Like svn_config_read(), but merges the configuration data from @a file 00355 * (a file or registry path) into @a *cfg, which was previously returned 00356 * from svn_config_read(). This function invalidates all value 00357 * expansions in @a cfg, so that the next svn_config_get() takes the 00358 * modifications into account. 00359 */ 00360 svn_error_t * 00361 svn_config_merge(svn_config_t *cfg, 00362 const char *file, 00363 svn_boolean_t must_exist); 00364 00365 00366 /** Find the value of a (@a section, @a option) pair in @a cfg, set @a 00367 * *valuep to the value. 00368 * 00369 * If @a cfg is @c NULL, just sets @a *valuep to @a default_value. If 00370 * the value does not exist, expand and return @a default_value. @a 00371 * default_value can be NULL. 00372 * 00373 * The returned value will be valid at least until the next call to 00374 * svn_config_get(), or for the lifetime of @a default_value. It is 00375 * safest to consume the returned value immediately. 00376 * 00377 * This function may change @a cfg by expanding option values. 00378 */ 00379 void 00380 svn_config_get(svn_config_t *cfg, 00381 const char **valuep, 00382 const char *section, 00383 const char *option, 00384 const char *default_value); 00385 00386 /** Add or replace the value of a (@a section, @a option) pair in @a cfg with 00387 * @a value. 00388 * 00389 * This function invalidates all value expansions in @a cfg. 00390 * 00391 * To remove an option, pass NULL for the @a value. 00392 */ 00393 void 00394 svn_config_set(svn_config_t *cfg, 00395 const char *section, 00396 const char *option, 00397 const char *value); 00398 00399 /** Like svn_config_get(), but for boolean values. 00400 * 00401 * Parses the option as a boolean value. The recognized representations 00402 * are 'TRUE'/'FALSE', 'yes'/'no', 'on'/'off', '1'/'0'; case does not 00403 * matter. Returns an error if the option doesn't contain a known string. 00404 */ 00405 svn_error_t * 00406 svn_config_get_bool(svn_config_t *cfg, 00407 svn_boolean_t *valuep, 00408 const char *section, 00409 const char *option, 00410 svn_boolean_t default_value); 00411 00412 /** Like svn_config_set(), but for boolean values. 00413 * 00414 * Sets the option to 'TRUE'/'FALSE', depending on @a value. 00415 */ 00416 void 00417 svn_config_set_bool(svn_config_t *cfg, 00418 const char *section, 00419 const char *option, 00420 svn_boolean_t value); 00421 00422 /** Like svn_config_get(), but for 64-bit signed integers. 00423 * 00424 * Parses the @a option in @a section of @a cfg as an integer value, 00425 * setting @a *valuep to the result. If the option is not found, sets 00426 * @a *valuep to @a default_value. If the option is found but cannot 00427 * be converted to an integer, returns an error. 00428 * 00429 * @since New in 1.8. 00430 */ 00431 svn_error_t * 00432 svn_config_get_int64(svn_config_t *cfg, 00433 apr_int64_t *valuep, 00434 const char *section, 00435 const char *option, 00436 apr_int64_t default_value); 00437 00438 /** Like svn_config_set(), but for 64-bit signed integers. 00439 * 00440 * Sets the value of @a option in @a section of @a cfg to the signed 00441 * decimal @a value. 00442 * 00443 * @since New in 1.8. 00444 */ 00445 void 00446 svn_config_set_int64(svn_config_t *cfg, 00447 const char *section, 00448 const char *option, 00449 apr_int64_t value); 00450 00451 /** Like svn_config_get(), but only for yes/no/ask values. 00452 * 00453 * Parse @a option in @a section and set @a *valuep to one of 00454 * SVN_CONFIG_TRUE, SVN_CONFIG_FALSE, or SVN_CONFIG_ASK. If there is 00455 * no setting for @a option, then parse @a default_value and set 00456 * @a *valuep accordingly. If @a default_value is NULL, the result is 00457 * undefined, and may be an error; we recommend that you pass one of 00458 * SVN_CONFIG_TRUE, SVN_CONFIG_FALSE, or SVN_CONFIG_ASK for @a default value. 00459 * 00460 * Valid representations are (at least) "true"/"false", "yes"/"no", 00461 * "on"/"off", "1"/"0", and "ask"; they are case-insensitive. Return 00462 * an SVN_ERR_BAD_CONFIG_VALUE error if either @a default_value or 00463 * @a option's value is not a valid representation. 00464 * 00465 * @since New in 1.6. 00466 */ 00467 svn_error_t * 00468 svn_config_get_yes_no_ask(svn_config_t *cfg, 00469 const char **valuep, 00470 const char *section, 00471 const char *option, 00472 const char* default_value); 00473 00474 /** Like svn_config_get_bool(), but for tristate values. 00475 * 00476 * Set @a *valuep to #svn_tristate_true, #svn_tristate_false, or 00477 * #svn_tristate_unknown, depending on the value of @a option in @a 00478 * section of @a cfg. True and false values are the same as for 00479 * svn_config_get_bool(); @a unknown_value specifies the option value 00480 * allowed for third state (#svn_tristate_unknown). 00481 * 00482 * Use @a default_value as the default value if @a option cannot be 00483 * found. 00484 * 00485 * @since New in 1.8. 00486 */ 00487 svn_error_t * 00488 svn_config_get_tristate(svn_config_t *cfg, 00489 svn_tristate_t *valuep, 00490 const char *section, 00491 const char *option, 00492 const char *unknown_value, 00493 svn_tristate_t default_value); 00494 00495 /** Similar to @c svn_config_section_enumerator2_t, but is not 00496 * provided with a memory pool argument. 00497 * 00498 * See svn_config_enumerate_sections() for the details of this type. 00499 * 00500 * @deprecated Provided for backwards compatibility with the 1.2 API. 00501 */ 00502 typedef svn_boolean_t (*svn_config_section_enumerator_t)(const char *name, 00503 void *baton); 00504 00505 /** Similar to svn_config_enumerate_sections2(), but uses a memory pool of 00506 * @a cfg instead of one that is explicitly provided. 00507 * 00508 * @deprecated Provided for backwards compatibility with the 1.2 API. 00509 */ 00510 SVN_DEPRECATED 00511 int 00512 svn_config_enumerate_sections(svn_config_t *cfg, 00513 svn_config_section_enumerator_t callback, 00514 void *baton); 00515 00516 /** A callback function used in enumerating config sections. 00517 * 00518 * See svn_config_enumerate_sections2() for the details of this type. 00519 * 00520 * @since New in 1.3. 00521 */ 00522 typedef svn_boolean_t (*svn_config_section_enumerator2_t)(const char *name, 00523 void *baton, 00524 apr_pool_t *pool); 00525 00526 /** Enumerate the sections, passing @a baton and the current section's name 00527 * to @a callback. Continue the enumeration if @a callback returns @c TRUE. 00528 * Return the number of times @a callback was called. 00529 * 00530 * ### See kff's comment to svn_config_enumerate2(). It applies to this 00531 * function, too. ### 00532 * 00533 * @a callback's @a name parameter is only valid for the duration of the call. 00534 * 00535 * @since New in 1.3. 00536 */ 00537 int 00538 svn_config_enumerate_sections2(svn_config_t *cfg, 00539 svn_config_section_enumerator2_t callback, 00540 void *baton, apr_pool_t *pool); 00541 00542 /** Similar to @c svn_config_enumerator2_t, but is not 00543 * provided with a memory pool argument. 00544 * See svn_config_enumerate() for the details of this type. 00545 * 00546 * @deprecated Provided for backwards compatibility with the 1.2 API. 00547 */ 00548 typedef svn_boolean_t (*svn_config_enumerator_t)(const char *name, 00549 const char *value, 00550 void *baton); 00551 00552 /** Similar to svn_config_enumerate2(), but uses a memory pool of 00553 * @a cfg instead of one that is explicitly provided. 00554 * 00555 * @deprecated Provided for backwards compatibility with the 1.2 API. 00556 */ 00557 SVN_DEPRECATED 00558 int 00559 svn_config_enumerate(svn_config_t *cfg, 00560 const char *section, 00561 svn_config_enumerator_t callback, 00562 void *baton); 00563 00564 00565 /** A callback function used in enumerating config options. 00566 * 00567 * See svn_config_enumerate2() for the details of this type. 00568 * 00569 * @since New in 1.3. 00570 */ 00571 typedef svn_boolean_t (*svn_config_enumerator2_t)(const char *name, 00572 const char *value, 00573 void *baton, 00574 apr_pool_t *pool); 00575 00576 /** Enumerate the options in @a section, passing @a baton and the current 00577 * option's name and value to @a callback. Continue the enumeration if 00578 * @a callback returns @c TRUE. Return the number of times @a callback 00579 * was called. 00580 * 00581 * ### kff asks: A more usual interface is to continue enumerating 00582 * while @a callback does not return error, and if @a callback does 00583 * return error, to return the same error (or a wrapping of it) 00584 * from svn_config_enumerate(). What's the use case for 00585 * svn_config_enumerate()? Is it more likely to need to break out 00586 * of an enumeration early, with no error, than an invocation of 00587 * @a callback is likely to need to return an error? ### 00588 * 00589 * @a callback's @a name and @a value parameters are only valid for the 00590 * duration of the call. 00591 * 00592 * @since New in 1.3. 00593 */ 00594 int 00595 svn_config_enumerate2(svn_config_t *cfg, 00596 const char *section, 00597 svn_config_enumerator2_t callback, 00598 void *baton, 00599 apr_pool_t *pool); 00600 00601 /** 00602 * Return @c TRUE if @a section exists in @a cfg, @c FALSE otherwise. 00603 * 00604 * @since New in 1.4. 00605 */ 00606 svn_boolean_t 00607 svn_config_has_section(svn_config_t *cfg, 00608 const char *section); 00609 00610 /** Enumerate the group @a master_section in @a cfg. Each variable 00611 * value is interpreted as a list of glob patterns (separated by comma 00612 * and optional whitespace). Return the name of the first variable 00613 * whose value matches @a key, or @c NULL if no variable matches. 00614 */ 00615 const char * 00616 svn_config_find_group(svn_config_t *cfg, 00617 const char *key, 00618 const char *master_section, 00619 apr_pool_t *pool); 00620 00621 /** Retrieve value corresponding to @a option_name in @a cfg, or 00622 * return @a default_value if none is found. 00623 * 00624 * The config will first be checked for a default. 00625 * If @a server_group is not @c NULL, the config will also be checked 00626 * for an override in a server group, 00627 * 00628 */ 00629 const char * 00630 svn_config_get_server_setting(svn_config_t *cfg, 00631 const char* server_group, 00632 const char* option_name, 00633 const char* default_value); 00634 00635 /** Retrieve value into @a result_value corresponding to @a option_name for a 00636 * given @a server_group in @a cfg, or return @a default_value if none is 00637 * found. 00638 * 00639 * The config will first be checked for a default, then will be checked for 00640 * an override in a server group. If the value found is not a valid integer, 00641 * a @c svn_error_t* will be returned. 00642 */ 00643 svn_error_t * 00644 svn_config_get_server_setting_int(svn_config_t *cfg, 00645 const char *server_group, 00646 const char *option_name, 00647 apr_int64_t default_value, 00648 apr_int64_t *result_value, 00649 apr_pool_t *pool); 00650 00651 00652 /** Set @a *valuep according to @a option_name for a given 00653 * @a server_group in @a cfg, or set to @a default_value if no value is 00654 * specified. 00655 * 00656 * Check first a default, then for an override in a server group. If 00657 * a value is found but is not a valid boolean, return an 00658 * SVN_ERR_BAD_CONFIG_VALUE error. 00659 * 00660 * @since New in 1.6. 00661 */ 00662 svn_error_t * 00663 svn_config_get_server_setting_bool(svn_config_t *cfg, 00664 svn_boolean_t *valuep, 00665 const char *server_group, 00666 const char *option_name, 00667 svn_boolean_t default_value); 00668 00669 00670 00671 /** Try to ensure that the user's ~/.subversion/ area exists, and create 00672 * no-op template files for any absent config files. Use @a pool for any 00673 * temporary allocation. If @a config_dir is not @c NULL it specifies a 00674 * directory from which to read the config overriding all other sources. 00675 * 00676 * Don't error if something exists but is the wrong kind (for example, 00677 * ~/.subversion exists but is a file, or ~/.subversion/servers exists 00678 * but is a directory). 00679 * 00680 * Also don't error if trying to create something and failing -- it's 00681 * okay for the config area or its contents not to be created. 00682 * However, if creating a config template file succeeds, return an 00683 * error if unable to initialize its contents. 00684 */ 00685 svn_error_t * 00686 svn_config_ensure(const char *config_dir, 00687 apr_pool_t *pool); 00688 00689 00690 00691 00692 /** Accessing cached authentication data in the user config area. 00693 * 00694 * @defgroup cached_authentication_data Cached authentication data 00695 * @{ 00696 */ 00697 00698 00699 /** 00700 * Attributes of authentication credentials. 00701 * 00702 * The values of these keys are C strings. 00703 * 00704 * @note Some of these hash keys were also used in versions < 1.9 but were 00705 * not part of the public API (except #SVN_CONFIG_REALMSTRING_KEY which 00706 * has been present since 1.0). 00707 * 00708 * @defgroup cached_authentication_data_attributes Cached authentication data attributes 00709 * @{ 00710 */ 00711 00712 /** A hash-key pointing to a realmstring. This attribute is mandatory. 00713 * 00714 * @since New in 1.0. 00715 */ 00716 #define SVN_CONFIG_REALMSTRING_KEY "svn:realmstring" 00717 00718 /** A hash-key for usernames. 00719 * @since New in 1.9. 00720 */ 00721 #define SVN_CONFIG_AUTHN_USERNAME_KEY "username" 00722 00723 /** A hash-key for passwords. 00724 * The password may be in plaintext or encrypted form, depending on 00725 * the authentication provider. 00726 * @since New in 1.9. 00727 */ 00728 #define SVN_CONFIG_AUTHN_PASSWORD_KEY "password" 00729 00730 /** A hash-key for passphrases, 00731 * such as SSL client ceritifcate passphrases. The passphrase may be in 00732 * plaintext or encrypted form, depending on the authentication provider. 00733 * @since New in 1.9. 00734 */ 00735 #define SVN_CONFIG_AUTHN_PASSPHRASE_KEY "passphrase" 00736 00737 /** A hash-key for the type of a password or passphrase. The type 00738 * indicates which provider owns the credential. 00739 * @since New in 1.9. 00740 */ 00741 #define SVN_CONFIG_AUTHN_PASSTYPE_KEY "passtype" 00742 00743 /** A hash-key for SSL certificates. The value is the base64-encoded DER form 00744 * certificate. 00745 * @since New in 1.9. 00746 * @note The value is not human readable. 00747 */ 00748 #define SVN_CONFIG_AUTHN_ASCII_CERT_KEY "ascii_cert" 00749 00750 /** A hash-key for recorded SSL certificate verification 00751 * failures. Failures encoded as an ASCII integer containing any of the 00752 * SVN_AUTH_SSL_* SSL server certificate failure bits defined in svn_auth.h. 00753 * @since New in 1.9. 00754 */ 00755 #define SVN_CONFIG_AUTHN_FAILURES_KEY "failures" 00756 00757 00758 /** @} */ 00759 00760 /** Use @a cred_kind and @a realmstring to locate a file within the 00761 * ~/.subversion/auth/ area. If the file exists, initialize @a *hash 00762 * and load the file contents into the hash, using @a pool. If the 00763 * file doesn't exist, set @a *hash to NULL. 00764 * 00765 * If @a config_dir is not NULL it specifies a directory from which to 00766 * read the config overriding all other sources. 00767 * 00768 * Besides containing the original credential fields, the hash will 00769 * also contain @c SVN_CONFIG_REALMSTRING_KEY. The caller can examine 00770 * this value as a sanity-check that the correct file was loaded. 00771 * 00772 * The hashtable will contain <tt>const char *</tt> keys and 00773 * <tt>svn_string_t *</tt> values. 00774 */ 00775 svn_error_t * 00776 svn_config_read_auth_data(apr_hash_t **hash, 00777 const char *cred_kind, 00778 const char *realmstring, 00779 const char *config_dir, 00780 apr_pool_t *pool); 00781 00782 /** Use @a cred_kind and @a realmstring to create or overwrite a file 00783 * within the ~/.subversion/auth/ area. Write the contents of @a hash into 00784 * the file. If @a config_dir is not NULL it specifies a directory to read 00785 * the config overriding all other sources. 00786 * 00787 * Also, add @a realmstring to the file, with key @c 00788 * SVN_CONFIG_REALMSTRING_KEY. This allows programs (or users) to 00789 * verify exactly which set credentials live within the file. 00790 * 00791 * The hashtable must contain <tt>const char *</tt> keys and 00792 * <tt>svn_string_t *</tt> values. 00793 */ 00794 svn_error_t * 00795 svn_config_write_auth_data(apr_hash_t *hash, 00796 const char *cred_kind, 00797 const char *realmstring, 00798 const char *config_dir, 00799 apr_pool_t *pool); 00800 00801 00802 /** Callback for svn_config_walk_auth_data(). 00803 * 00804 * Called for each credential walked by that function (and able to be 00805 * fully purged) to allow perusal and selective removal of credentials. 00806 * 00807 * @a cred_kind and @a realmstring specify the key of the credential. 00808 * @a hash contains the hash data associated with the record. @a walk_baton 00809 * is the baton passed to svn_config_walk_auth_data(). 00810 * 00811 * Before returning set @a *delete_cred to TRUE to remove the credential from 00812 * the cache; leave @a *delete_cred unchanged or set it to FALSE to keep the 00813 * credential. 00814 * 00815 * Implementations may return #SVN_ERR_CEASE_INVOCATION to indicate 00816 * that the callback should not be called again. Note that when that 00817 * error is returned, the value of @a delete_cred will still be 00818 * honored and action taken if necessary. (For other returned errors, 00819 * @a delete_cred is ignored by svn_config_walk_auth_data().) 00820 * 00821 * @since New in 1.8. 00822 */ 00823 typedef svn_error_t * 00824 (*svn_config_auth_walk_func_t)(svn_boolean_t *delete_cred, 00825 void *walk_baton, 00826 const char *cred_kind, 00827 const char *realmstring, 00828 apr_hash_t *hash, 00829 apr_pool_t *scratch_pool); 00830 00831 /** Call @a walk_func with @a walk_baton and information describing 00832 * each credential cached within the Subversion auth store located 00833 * under @a config_dir. If the callback sets its delete_cred return 00834 * flag, delete the associated credential. 00835 * 00836 * If @a config_dir is not NULL, it must point to an alternative 00837 * config directory location. If it is NULL, the default location 00838 * is used. 00839 * 00840 * @note @a config_dir may only be NULL in 1.8.2 and later. 00841 * 00842 * @note Removing credentials from the config-based disk store will 00843 * not purge them from any open svn_auth_baton_t instance. Consider 00844 * using svn_auth_forget_credentials() -- from the @a walk_func, 00845 * even -- for this purpose. 00846 * 00847 * @note Removing credentials from the config-based disk store will 00848 * not also remove any related credentials from third-party password 00849 * stores. (Implementations of @a walk_func which delete credentials 00850 * may wish to consult the "passtype" element of @a hash, if any, to 00851 * see if a third-party store -- such as "gnome-keyring" or "kwallet" 00852 * is being used to hold the most sensitive portion of the credentials 00853 * for this @a cred_kind and @a realmstring.) 00854 * 00855 * @see svn_auth_forget_credentials() 00856 * 00857 * @since New in 1.8. 00858 */ 00859 svn_error_t * 00860 svn_config_walk_auth_data(const char *config_dir, 00861 svn_config_auth_walk_func_t walk_func, 00862 void *walk_baton, 00863 apr_pool_t *scratch_pool); 00864 00865 /** Put the absolute path to the user's configuration directory, 00866 * or to a file within that directory, into @a *path. 00867 * 00868 * If @a config_dir is not NULL, it must point to an alternative 00869 * config directory location. If it is NULL, the default location 00870 * is used. If @a fname is not NULL, it must specify the last 00871 * component of the path to be returned. This can be used to create 00872 * a path to any file in the configuration directory. 00873 * 00874 * Do all allocations in @a pool. 00875 * 00876 * Hint: 00877 * To get the user configuration file, pass @c SVN_CONFIG_CATEGORY_CONFIG 00878 * for @a fname. To get the servers configuration file, pass 00879 * @c SVN_CONFIG_CATEGORY_SERVERS for @a fname. 00880 * 00881 * @since New in 1.6. 00882 */ 00883 svn_error_t * 00884 svn_config_get_user_config_path(const char **path, 00885 const char *config_dir, 00886 const char *fname, 00887 apr_pool_t *pool); 00888 00889 /** Create a deep copy of the config object @a src and return 00890 * it in @a cfgp, allocating the memory in @a pool. 00891 * 00892 * @since New in 1.8. 00893 */ 00894 svn_error_t * 00895 svn_config_dup(svn_config_t **cfgp, 00896 const svn_config_t *src, 00897 apr_pool_t *pool); 00898 00899 /** Create a deep copy of the config hash @a src_hash and return 00900 * it in @a cfg_hash, allocating the memory in @a pool. 00901 * 00902 * @since New in 1.8. 00903 */ 00904 svn_error_t * 00905 svn_config_copy_config(apr_hash_t **cfg_hash, 00906 apr_hash_t *src_hash, 00907 apr_pool_t *pool); 00908 00909 /** @} */ 00910 00911 #ifdef __cplusplus 00912 } 00913 #endif /* __cplusplus */ 00914 00915 #endif /* SVN_CONFIG_H */
1.6.1