         "passtype"

/** A hash-key for SSL certificates.   The value is the base64-encoded DER form
 * certificate.
 * @since New in 1.9.
 * @note The value is not human readable.
 */
#define SVN_CONFIG_AUTHN_ASCII_CERT_KEY         "ascii_cert"

/** A hash-key for recorded SSL certificate verification
 * failures.  Failures encoded as an ASCII integer containing any of the
 * SVN_AUTH_SSL_* SSL server certificate failure bits defined in svn_auth.h.
 * @since New in 1.9.
 */
#define SVN_CONFIG_AUTHN_FAILURES_KEY           "failures"


/** @} */

/** Use @a cred_kind and @a realmstring to locate a file within the
 * ~/.subversion/auth/ area.  If the file exists, initialize @a *hash
 * and load the file contents into the hash, using @a pool.  If the
 * file doesn't exist, set @a *hash to NULL.
 *
 * If @a config_dir is not NULL it specifies a directory from which to
 * read the config overriding all other sources.
 *
 * Besides containing the original credential fields, the hash will
 * also contain @c SVN_CONFIG_REALMSTRING_KEY.  The caller can examine
 * this value as a sanity-check that the correct file was loaded.
 *
 * The hashtable will contain <tt>const char *</tt> keys and
 * <tt>svn_string_t *</tt> values.
 */
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 @a cred_kind and @a realmstring to create or overwrite a file
 * within the ~/.subversion/auth/ area.  Write the contents of @a hash into
 * the file.  If @a config_dir is not NULL it specifies a directory to read
 * the config overriding all other sources.
 *
 * Also, add @a realmstring to the file, with key @c
 * SVN_CONFIG_REALMSTRING_KEY.  This allows programs (or users) to
 * verify exactly which set credentials live within the file.
 *
 * The hashtable must contain <tt>const char *</tt> keys and
 * <tt>svn_string_t *</tt> values.
 */
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);


/** Callback for svn_config_walk_auth_data().
 *
 * Called for each credential walked by that function (and able to be
 * fully purged) to allow perusal and selective removal of credentials.
 *
 * @a cred_kind and @a realmstring specify the key of the credential.
 * @a hash contains the hash data associated with the record. @a walk_baton
 * is the baton passed to svn_config_walk_auth_data().
 *
 * Before returning set @a *delete_cred to TRUE to remove the credential from
 * the cache; leave @a *delete_cred unchanged or set it to FALSE to keep the
 * credential.
 *
 * Implementations may return #SVN_ERR_CEASE_INVOCATION to indicate
 * that the callback should not be called again.  Note that when that
 * error is returned, the value of @a delete_cred will still be
 * honored and action taken if necessary.  (For other returned errors,
 * @a delete_cred is ignored by svn_config_walk_auth_data().)
 *
 * @since New in 1.8.
 */
typedef 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);

/** Call @a walk_func with @a walk_baton and information describing
 * each credential cached within the Subversion auth store located
 * under @a config_dir.  If the callback sets its delete_cred return
 * flag, delete the associated credential.
 *
 * If @a config_dir is not NULL, it must point to an alternative
 * config directory location. If it is NULL, the default location
 * is used.
 *
 * @note @a config_dir may only be NULL in 1.8.2 and later.
 *
 * @note Removing credentials from the config-based disk store will
 * not purge them from any open svn_auth_baton_t instance.  Consider
 * using svn_auth_forget_credentials() -- from the @a walk_func,
 * even -- for this purpose.
 *
 * @note Removing credentials from the config-based disk store will
 * not also remove any related credentials from third-party password
 * stores.  (Implementations of @a walk_func which delete credentials
 * may wish to consult the "passtype" element of @a hash, if any, to
 * see if a third-party store -- such as "gnome-keyring" or "kwallet"
 * is being used to hold the most sensitive portion of the credentials
 * for this @a cred_kind and @a realmstring.)
 *
 * @see svn_auth_forget_credentials()
 *
 * @since New in 1.8.
 */
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);

/** Put the absolute path to the user's configuration directory,
 * or to a file within that directory, into @a *path.
 *
 * If @a config_dir is not NULL, it must point to an alternative
 * config directory location. If it is NULL, the default location
 * is used.  If @a fname is not NULL, it must specify the last
 * component of the path to be returned. This can be used to create
 * a path to any file in the configuration directory.
 *
 * Do all allocations in @a pool.
 *
 * Hint:
 * To get the user configuration file, pass @c SVN_CONFIG_CATEGORY_CONFIG
 * for @a fname. To get the servers configuration file, pass
 * @c SVN_CONFIG_CATEGORY_SERVERS for @a fname.
 *
 * @since New in 1.6.
 */
svn_error_t *
svn_config_get_user_config_path(const char **path,
                                const char *config_dir,
                                const char *fname,
                                apr_pool_t *pool);

/** Create a deep copy of the config object @a src and return
 * it in @a cfgp, allocating the memory in @a pool.
 *
 * @since New in 1.8.
 */
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 hash @a src_hash and return
 * it in @a cfg_hash, allocating the memory in @a pool.
 *
 * @since New in 1.8.
 */
svn_error_t *
svn_config_copy_config(apr_hash_t **cfg_hash,
                       apr_hash_t *src_hash,
                       apr_pool_t *pool);

/** @} */

#ifdef __cplusplus
}
#endif /* __cplusplus */

#endif /* SVN_CONFIG_H */
