svn_config.h

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

Generated on Tue Jul 28 13:23:52 2015 for Subversion by  doxygen 1.4.7