158 if(dav_config_register_namespaces(davconfig, ctx)) { |
158 if(dav_config_register_namespaces(davconfig, ctx)) { |
159 return 1; |
159 return 1; |
160 } |
160 } |
161 |
161 |
162 return dav_config_register_keys(davconfig, ctx, load_key_file); |
162 return dav_config_register_keys(davconfig, ctx, load_key_file); |
|
163 } |
|
164 |
|
165 DavConfig* load_config_file(void) { |
|
166 char *file = util_concat_path(ENV_HOME, ".dav/config.xml"); |
|
167 |
|
168 struct stat s; |
|
169 if(stat(file, &s)) { |
|
170 switch(errno) { |
|
171 case ENOENT: { |
|
172 davconfig = dav_config_new(NULL); |
|
173 return NULL; |
|
174 } |
|
175 default: { |
|
176 perror("Cannot load config.xml"); |
|
177 } |
|
178 } |
|
179 return NULL; |
|
180 } |
|
181 |
|
182 cxmutstr config_content = config_load_file(file); |
|
183 int config_error; |
|
184 DavConfig *cfg = dav_config_load(config_content, &config_error); |
|
185 free(config_content.ptr); |
|
186 free(file); |
|
187 return cfg; |
|
188 } |
|
189 |
|
190 |
|
191 void set_config(DavConfig *cfg) { |
|
192 davconfig = cfg; |
163 } |
193 } |
164 |
194 |
165 DavConfig* get_config(void) { |
195 DavConfig* get_config(void) { |
166 return davconfig; |
196 return davconfig; |
167 } |
197 } |