00001 /**
00002 * @copyright
00003 * ====================================================================
00004 * Copyright (c) 2000-2004 CollabNet. All rights reserved.
00005 *
00006 * This software is licensed as described in the file COPYING, which
00007 * you should have received as part of this distribution. The terms
00008 * are also available at http://subversion.tigris.org/license-1.html.
00009 * If newer versions of this license are posted there, you may use a
00010 * newer version instead, at your option.
00011 *
00012 * This software consists of voluntary contributions made by many
00013 * individuals. For exact contribution history, see the revision
00014 * history and logs, available at http://subversion.tigris.org/.
00015 * ====================================================================
00016 * @endcopyright
00017 *
00018 * @file svn_config.h
00019 * @brief Functions for accessing SVN configuration files.
00020 */
00021
00022
00023
00024 #ifndef SVN_CONFIG_H
00025 #define SVN_CONFIG_H
00026
00027 #include <apr_pools.h>
00028
00029 #include "svn_types.h"
00030 #include "svn_error.h"
00031
00032
00033 #ifdef __cplusplus
00034 extern "C" {
00035 #endif /* __cplusplus */
00036
00037
00038 /**************************************************************************
00039 *** ***
00040 *** For a description of the SVN configuration file syntax, see ***
00041 *** your ~/.subversion/README, which is written out automatically by ***
00042 *** svn_config_ensure(). ***
00043 *** ***
00044 **************************************************************************/
00045
00046
00047 /** Opaque structure describing a set of configuration options. */
00048 typedef struct svn_config_t svn_config_t;
00049
00050
00051 /*** Configuration Defines ***/
00052
00053 #define SVN_CONFIG_CATEGORY_SERVERS "servers"
00054 #define SVN_CONFIG_SECTION_GROUPS "groups"
00055 #define SVN_CONFIG_SECTION_GLOBAL "global"
00056 #define SVN_CONFIG_OPTION_HTTP_PROXY_HOST "http-proxy-host"
00057 #define SVN_CONFIG_OPTION_HTTP_PROXY_PORT "http-proxy-port"
00058 #define SVN_CONFIG_OPTION_HTTP_PROXY_USERNAME "http-proxy-username"
00059 #define SVN_CONFIG_OPTION_HTTP_PROXY_PASSWORD "http-proxy-password"
00060 #define SVN_CONFIG_OPTION_HTTP_PROXY_EXCEPTIONS "http-proxy-exceptions"
00061 #define SVN_CONFIG_OPTION_HTTP_TIMEOUT "http-timeout"
00062 #define SVN_CONFIG_OPTION_HTTP_COMPRESSION "http-compression"
00063 #define SVN_CONFIG_OPTION_NEON_DEBUG_MASK "neon-debug-mask"
00064 #define SVN_CONFIG_OPTION_SSL_AUTHORITY_FILES "ssl-authority-files"
00065 #define SVN_CONFIG_OPTION_SSL_TRUST_DEFAULT_CA "ssl-trust-default-ca"
00066 #define SVN_CONFIG_OPTION_SSL_CLIENT_CERT_FILE "ssl-client-cert-file"
00067 #define SVN_CONFIG_OPTION_SSL_CLIENT_CERT_PASSWORD "ssl-client-cert-password"
00068
00069 #define SVN_CONFIG_CATEGORY_CONFIG "config"
00070 #define SVN_CONFIG_SECTION_AUTH "auth"
00071 #define SVN_CONFIG_OPTION_STORE_AUTH_CREDS "store-auth-creds"
00072 #define SVN_CONFIG_SECTION_HELPERS "helpers"
00073 #define SVN_CONFIG_OPTION_EDITOR_CMD "editor-cmd"
00074 #define SVN_CONFIG_OPTION_DIFF_CMD "diff-cmd"
00075 #define SVN_CONFIG_OPTION_DIFF3_CMD "diff3-cmd"
00076 #define SVN_CONFIG_OPTION_DIFF3_HAS_PROGRAM_ARG "diff3-has-program-arg"
00077 #define SVN_CONFIG_SECTION_MISCELLANY "miscellany"
00078 #define SVN_CONFIG_OPTION_GLOBAL_IGNORES "global-ignores"
00079 #define SVN_CONFIG_OPTION_LOG_ENCODING "log-encoding"
00080 #define SVN_CONFIG_OPTION_USE_COMMIT_TIMES "use-commit-times"
00081 #define SVN_CONFIG_OPTION_TEMPLATE_ROOT "template-root"
00082 #define SVN_CONFIG_OPTION_ENABLE_AUTO_PROPS "enable-auto-props"
00083 #define SVN_CONFIG_SECTION_TUNNELS "tunnels"
00084 #define SVN_CONFIG_SECTION_AUTO_PROPS "auto-props"
00085
00086 /* For repository svnserve.conf files */
00087 #define SVN_CONFIG_SECTION_GENERAL "general"
00088 #define SVN_CONFIG_OPTION_ANON_ACCESS "anon-access"
00089 #define SVN_CONFIG_OPTION_AUTH_ACCESS "auth-access"
00090 #define SVN_CONFIG_OPTION_PASSWORD_DB "password-db"
00091 #define SVN_CONFIG_OPTION_REALM "realm"
00092
00093 /* For repository password database */
00094 #define SVN_CONFIG_SECTION_USERS "users"
00095
00096 /*** Configuration Default Values ***/
00097
00098 #define SVN_CONFIG_DEFAULT_GLOBAL_IGNORES \
00099 "*.o *.lo *.la #*# .*.rej *.rej .*~ *~ .#* .DS_Store"
00100
00101 #define SVN_CONFIG_TRUE "true"
00102 #define SVN_CONFIG_FALSE "false"
00103
00104
00105 /** Read configuration information from the standard sources and merge it
00106 * into the hash @a *cfg_hash. If @a config_dir is not NULL it specifies a
00107 * directory from which to read the configuration files, overriding all
00108 * other sources. Otherwise, first read any system-wide configurations
00109 * (from a file or from the registry), then merge in personal
00110 * configurations (again from file or registry). The hash and all its data
00111 * are allocated in @a pool.
00112 *
00113 * @a *cfg_hash is a hash whose keys are @c const char * configuration
00114 * categories (@c SVN_CONFIG_CATEGORY_SERVERS,
00115 * @c SVN_CONFIG_CATEGORY_CONFIG, etc.) and whose values are the @c
00116 * svn_config_t * items representing the configuration values for that
00117 * category.
00118 */
00119 svn_error_t *svn_config_get_config (apr_hash_t **cfg_hash,
00120 const char *config_dir,
00121 apr_pool_t *pool);
00122
00123
00124 /** Read configuration data from @a file (a file or registry path) into
00125 * @a *cfgp, allocated in @a pool.
00126 *
00127 * If @a file does not exist, then if @a must_exist, return an error,
00128 * otherwise return an empty @c svn_config_t.
00129 */
00130 svn_error_t *svn_config_read (svn_config_t **cfgp,
00131 const char *file,
00132 svn_boolean_t must_exist,
00133 apr_pool_t *pool);
00134
00135 /** Like @c svn_config_read, but merges the configuration data from @a file
00136 * (a file or registry path) into @a *cfg, which was previously returned
00137 * from @c svn_config_read. This function invalidates all value
00138 * expansions in @a cfg, so that the next @c svn_option_get takes the
00139 * modifications into account.
00140 */
00141 svn_error_t *svn_config_merge (svn_config_t *cfg,
00142 const char *file,
00143 svn_boolean_t must_exist);
00144
00145
00146 /** Find the value of a (@a section, @a option) pair in @a cfg, set @a
00147 * *valuep to the value.
00148 *
00149 * If @a cfg is @c NULL, just sets @a *valuep to @a default_value. If
00150 * the value does not exist, expand and return @a default_value.
00151 *
00152 * The returned value will be valid at least until the next call to @t
00153 * svn_config_get, or for the lifetime of @a default_value. It is
00154 * safest to consume the returned value immediately.
00155 *
00156 * This function may change @a cfg by expanding option values.
00157 */
00158 void svn_config_get (svn_config_t *cfg, const char **valuep,
00159 const char *section, const char *option,
00160 const char *default_value);
00161
00162 /** Add or replace the value of a (@a section, @a option) pair in @a cfg with
00163 * @a value.
00164 *
00165 * This function invalidates all value expansions in @a cfg.
00166 */
00167 void svn_config_set (svn_config_t *cfg,
00168 const char *section, const char *option,
00169 const char *value);
00170
00171 /** Like @t svn_config_get, but for boolean values.
00172 *
00173 * Parses the option as a boolean value. The recoginzed representations
00174 * are 'true'/'false', 'yes'/'no', 'on'/'off', '1'/'0'; case does not
00175 * matter. Returns an error if the option doesn't contain a known string.
00176 */
00177 svn_error_t *svn_config_get_bool (svn_config_t *cfg, svn_boolean_t *valuep,
00178 const char *section, const char *option,
00179 svn_boolean_t default_value);
00180
00181 /** Like @t svn_config_set, but for boolean values.
00182 *
00183 * Sets the option to 'true'/'false', depending on @a value.
00184 */
00185 void svn_config_set_bool (svn_config_t *cfg,
00186 const char *section, const char *option,
00187 svn_boolean_t value);
00188
00189
00190 /** A callback function used in enumerating config options.
00191 *
00192 * See @c svn_config_enumerate for the details of this type.
00193 */
00194 typedef svn_boolean_t (*svn_config_enumerator_t)
00195 (const char *name, const char *value, void *baton);
00196
00197 /** Enumerate the options in @a section, passing @a baton and the current
00198 * option's name and value to @a callback. Continue the enumeration if
00199 * @a callback returns @c TRUE. Return the number of times @a callback
00200 * was called.
00201 *
00202 * ### kff asks: A more usual interface is to continue enumerating
00203 * while @a callback does not return error, and if @a callback does
00204 * return error, to return the same error (or a wrapping of it)
00205 * from @c svn_config_enumerate. What's the use case for
00206 * @c svn_config_enumerate? Is it more likely to need to break out
00207 * of an enumeration early, with no error, than an invocation of
00208 * @a callback is likely to need to return an error? ###
00209 *
00210 * @a callback's @a name and @a value parameters are only valid for the
00211 * duration of the call.
00212 */
00213 int svn_config_enumerate (svn_config_t *cfg, const char *section,
00214 svn_config_enumerator_t callback, void *baton);
00215
00216
00217 /** Enumerate the group @a master_section in @a cfg. Each variable
00218 * value is interpreted as a list of glob patterns (separated by comma
00219 * and optional whitespace). Return the name of the first variable
00220 * whose value matches @a key, or @c NULL if no variable matches.
00221 */
00222 const char *svn_config_find_group (svn_config_t *cfg, const char *key,
00223 const char *master_section,
00224 apr_pool_t *pool);
00225
00226 /** Retrieve value corresponding to @a option_name for a given
00227 * @a server_group in @a cfg , or return @a default_value if none is found.
00228 *
00229 * The config will first be checked for a default, then will be checked for
00230 * an override in a server group.
00231 */
00232 const char *svn_config_get_server_setting(svn_config_t *cfg,
00233 const char* server_group,
00234 const char* option_name,
00235 const char* default_value);
00236
00237 /** Retrieve value into @a result_value corresponding to @a option_name for a
00238 * given @a server_group in @a cfg, or return @a default_value if none is
00239 * found.
00240 *
00241 * The config will first be checked for a default, then will be checked for
00242 * an override in a server group. If the value found is not a valid integer,
00243 * a @c svn_error_t* will be returned.
00244 */
00245 svn_error_t *svn_config_get_server_setting_int(svn_config_t *cfg,
00246 const char *server_group,
00247 const char *option_name,
00248 apr_int64_t default_value,
00249 apr_int64_t *result_value,
00250 apr_pool_t *pool);
00251
00252
00253 /** Try to ensure that the user's ~/.subversion/ area exists, and create
00254 * no-op template files for any absent config files. Use @a pool for any
00255 * temporary allocation. If @a config_dir is not NULL it specifies a
00256 * directory from which to read the config overriding all other sources.
00257 *
00258 * Don't error if something exists but is the wrong kind (for example,
00259 * ~/.subversion exists but is a file, or ~/.subversion/servers exists
00260 * but is a directory).
00261 *
00262 * Also don't error if try to create something and fail -- it's okay
00263 * for the config area or its contents not to be created. But if
00264 * succeed in creating a config template file, return error if unable
00265 * to initialize its contents.
00266 */
00267 svn_error_t *svn_config_ensure (const char *config_dir, apr_pool_t *pool);
00268
00269
00270
00271
00272 /** Accessing cached authentication data in the user config area.
00273 *
00274 * @defgroup cached_authentication_data cached authentication data.
00275 * @{
00276 */
00277
00278
00279 /** A hash-key pointing to a realmstring. Every file containing
00280 * authentication data should have this key.
00281 */
00282 #define SVN_CONFIG_REALMSTRING_KEY "svn:realmstring"
00283
00284 /** Use @a cred_kind and @a realmstring to locate a file within the
00285 * ~/.subversion/auth/ area. If the file exists, initialize @a *hash
00286 * and load the file contents into the hash, using @a pool. If the
00287 * file doesn't exist, set @a *hash to NULL.
00288 *
00289 * If @a config_dir is not NULL it specifies a directory from which to
00290 * read the config overriding all other sources.
00291 *
00292 * Besides containing the original credential fields, the hash will
00293 * also contain @c SVN_CONFIG_REALMSTRING_KEY. The caller can examine
00294 * this value as a sanity-check that the correct file was loaded.
00295 *
00296 * The hashtable will contain <tt>const char *</tt>keys and
00297 * <tt>svn_string_t *</tt> values.
00298 */
00299 svn_error_t * svn_config_read_auth_data (apr_hash_t **hash,
00300 const char *cred_kind,
00301 const char *realmstring,
00302 const char *config_dir,
00303 apr_pool_t *pool);
00304
00305 /** Use @a cred_kind and @a realmstring to create or overwrite a file
00306 * within the ~/.subversion/auth/ area. Write the contents of @a hash into
00307 * the file. If @a config_dir is not NULL it specifies a directory to read
00308 * the config overriding all other sources.
00309 *
00310 * Also, add @a realmstring to the file, with key @c
00311 * SVN_CONFIG_REALMSTRING_KEY. This allows programs (or users) to
00312 * verify exactly which set credentials live within the file.
00313 *
00314 * The hashtable must contain <tt>const char *</tt>keys and
00315 * <tt>svn_string_t *</tt> values.
00316 */
00317 svn_error_t * svn_config_write_auth_data (apr_hash_t *hash,
00318 const char *cred_kind,
00319 const char *realmstring,
00320 const char *config_dir,
00321 apr_pool_t *pool);
00322
00323 /** @} */
00324
00325 #ifdef __cplusplus
00326 }
00327 #endif /* __cplusplus */
00328
00329 #endif /* SVN_CONFIG_H */
1.2.14 written by Dimitri van Heesch,
© 1997-2002