1 /* 2 * config_impl.h : private header for the config file implementation. 3 * 4 * ==================================================================== 5 * Licensed to the Apache Software Foundation (ASF) under one 6 * or more contributor license agreements. See the NOTICE file 7 * distributed with this work for additional information 8 * regarding copyright ownership. The ASF licenses this file 9 * to you under the Apache License, Version 2.0 (the 10 * "License"); you may not use this file except in compliance 11 * with the License. You may obtain a copy of the License at 12 * 13 * http://www.apache.org/licenses/LICENSE-2.0 14 * 15 * Unless required by applicable law or agreed to in writing, 16 * software distributed under the License is distributed on an 17 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 18 * KIND, either express or implied. See the License for the 19 * specific language governing permissions and limitations 20 * under the License. 21 * ==================================================================== 22 */ 23 24 25 26 #ifndef SVN_LIBSVN_SUBR_CONFIG_IMPL_H 27 #define SVN_LIBSVN_SUBR_CONFIG_IMPL_H 28 29 #define APR_WANT_STDIO 30 #include <apr_want.h> 31 32 #include <apr_hash.h> 33 #include "svn_types.h" 34 #include "svn_string.h" 35 #include "svn_io.h" 36 #include "svn_config.h" 37 #include "svn_private_config.h" 38 39 #ifdef __cplusplus 40 extern "C" { 41 #endif /* __cplusplus */ 42 43 44 /* The configuration data. This is a superhash of sections and options. */ 45 struct svn_config_t 46 { 47 /* Table of cfg_section_t's. */ 48 apr_hash_t *sections; 49 50 /* Pool for hash tables, table entries and unexpanded values */ 51 apr_pool_t *pool; 52 53 /* Pool for expanded values -- this is separate, so that we can 54 clear it when modifying the config data. */ 55 apr_pool_t *x_pool; 56 57 /* Indicates that some values in the configuration have been expanded. */ 58 svn_boolean_t x_values; 59 60 /* Temporary string used for lookups. (Using a stringbuf so that 61 frequent resetting is efficient.) */ 62 svn_stringbuf_t *tmp_key; 63 64 /* Temporary value used for expanded default values in svn_config_get. 65 (Using a stringbuf so that frequent resetting is efficient.) */ 66 svn_stringbuf_t *tmp_value; 67 68 /* Specifies whether section names are populated case sensitively. */ 69 svn_boolean_t section_names_case_sensitive; 70 71 /* Specifies whether option names are populated case sensitively. */ 72 svn_boolean_t option_names_case_sensitive; 73 }; 74 75 76 /* Read sections and options from a file. */ 77 svn_error_t *svn_config__parse_file(svn_config_t *cfg, 78 const char *file, 79 svn_boolean_t must_exist, 80 apr_pool_t *pool); 81 82 /* Read sections and options from a stream. */ 83 svn_error_t *svn_config__parse_stream(svn_config_t *cfg, 84 svn_stream_t *stream, 85 apr_pool_t *result_pool, 86 apr_pool_t *scratch_pool); 87 88 /* The name of the magic [DEFAULT] section. */ 89 #define SVN_CONFIG__DEFAULT_SECTION "DEFAULT" 90 91 92 #ifdef WIN32 93 /* Get the common or user-specific AppData folder */ 94 svn_error_t *svn_config__win_config_path(const char **folder, 95 int system_path, 96 apr_pool_t *pool); 97 98 /* Read sections and options from the Windows Registry. */ 99 svn_error_t *svn_config__parse_registry(svn_config_t *cfg, 100 const char *file, 101 svn_boolean_t must_exist, 102 apr_pool_t *pool); 103 104 /* ### It's unclear to me whether this registry stuff should get the 105 double underscore or not, and if so, where the extra underscore 106 would go. Thoughts? -kff */ 107 # define SVN_REGISTRY_PREFIX "REGISTRY:" 108 # define SVN_REGISTRY_PREFIX_LEN ((sizeof(SVN_REGISTRY_PREFIX)) - 1) 109 # define SVN_REGISTRY_HKLM "HKLM\\" 110 # define SVN_REGISTRY_HKLM_LEN ((sizeof(SVN_REGISTRY_HKLM)) - 1) 111 # define SVN_REGISTRY_HKCU "HKCU\\" 112 # define SVN_REGISTRY_HKCU_LEN ((sizeof(SVN_REGISTRY_HKCU)) - 1) 113 # define SVN_REGISTRY_PATH "Software\\Tigris.org\\Subversion\\" 114 # define SVN_REGISTRY_PATH_LEN ((sizeof(SVN_REGISTRY_PATH)) - 1) 115 # define SVN_REGISTRY_SYS_CONFIG_PATH \ 116 SVN_REGISTRY_PREFIX \ 117 SVN_REGISTRY_HKLM \ 118 SVN_REGISTRY_PATH 119 # define SVN_REGISTRY_USR_CONFIG_PATH \ 120 SVN_REGISTRY_PREFIX \ 121 SVN_REGISTRY_HKCU \ 122 SVN_REGISTRY_PATH 123 #endif /* WIN32 */ 124 125 /* System-wide and configuration subdirectory names. 126 NOTE: Don't use these directly; call svn_config__sys_config_path() 127 or svn_config_get_user_config_path() instead. */ 128 #ifdef WIN32 129 # define SVN_CONFIG__SUBDIRECTORY "Subversion" 130 #elif defined __HAIKU__ /* HAIKU */ 131 # define SVN_CONFIG__SYS_DIRECTORY "subversion" 132 # define SVN_CONFIG__USR_DIRECTORY "subversion" 133 #else /* ! WIN32 && ! __HAIKU__ */ 134 # define SVN_CONFIG__SYS_DIRECTORY "/etc/subversion" 135 # define SVN_CONFIG__USR_DIRECTORY ".subversion" 136 #endif /* WIN32 */ 137 138 /* The description/instructions file in the config directory. */ 139 #define SVN_CONFIG__USR_README_FILE "README.txt" 140 141 /* The name of the main authentication subdir in the config directory */ 142 #define SVN_CONFIG__AUTH_SUBDIR "auth" 143 144 /* Set *PATH_P to the path to config file FNAME in the system 145 configuration area, allocated in POOL. If FNAME is NULL, set 146 *PATH_P to the directory name of the system config area, either 147 allocated in POOL or a static constant string. 148 149 If the system configuration area cannot be located (possible under 150 Win32), set *PATH_P to NULL regardless of FNAME. */ 151 svn_error_t * 152 svn_config__sys_config_path(const char **path_p, 153 const char *fname, 154 apr_pool_t *pool); 155 156 157 #ifdef __cplusplus 158 } 159 #endif /* __cplusplus */ 160 161 #endif /* SVN_LIBSVN_SUBR_CONFIG_IMPL_H */ 162