1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 #ifndef LIBIDAV_CONFIG_H
30 #define LIBIDAV_CONFIG_H
31
32 #include "webdav.h"
33
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37
38 typedef struct DavConfig DavConfig;
39 typedef struct DavCfgRepository DavCfgRepository;
40 typedef struct DavCfgProxy DavCfgProxy;
41 typedef struct DavCfgKey DavCfgKey;
42 typedef struct DavCfgNamespace DavCfgNamespace;
43 typedef struct DavCfgSecretStore DavCfgSecretStore;
44
45 typedef struct CfgString CfgString;
46 typedef struct CfgInt CfgInt;
47 typedef struct CfgUInt CfgUInt;
48 typedef struct CfgBool CfgBool;
49
50 typedef enum dav_cfg_key_type DavCfgKeyType;
51
52 typedef cxmutstr (*dav_loadkeyfile_func)(
const char *filename);
53
54 #define DAV_HTTP_PROXY 1
55 #define DAV_HTTPS_PROXY 2
56
57 enum dav_cfg_key_type {
58 DAV_KEY_TYPE_AES256 =
0,
59 DAV_KEY_TYPE_AES128,
60 DAV_KEY_TYPE_UNKNOWN
61 };
62
63 struct DavConfig {
64 CxMempool *mp;
65
66 DavCfgRepository *repositories;
67 DavCfgKey *keys;
68 DavCfgNamespace *namespaces;
69 DavCfgProxy *http_proxy;
70 DavCfgProxy *https_proxy;
71 DavCfgSecretStore *secretstore;
72
73 xmlDoc *doc;
74 };
75
76 struct CfgString {
77 cxmutstr value;
78 xmlNode *node;
79 };
80
81 struct CfgInt {
82 int64_t value;
83 xmlNode *node;
84 };
85
86 struct CfgUInt {
87 uint64_t value;
88 xmlNode *node;
89 };
90
91 struct CfgBool {
92 bool value;
93 xmlNode *node;
94 };
95
96
97 struct DavCfgRepository {
98 xmlNode *node;
99
100 CfgString name;
101 CfgString url;
102 CfgString user;
103 CfgString password;
104 CfgString stored_user;
105 CfgString default_key;
106 CfgString cert;
107 CfgBool verification;
108
109 CfgBool full_encryption;
110 CfgBool content_encryption;
111 CfgBool decrypt_content;
112 CfgBool decrypt_name;
113 CfgBool decrypt_properties;
114
115 CfgInt ssl_version;
116 CfgUInt authmethods;
117
118 int unknown_elements;
119
120 DavCfgRepository *prev;
121 DavCfgRepository *next;
122 };
123
124 struct DavCfgProxy {
125 CfgString url;
126 CfgString user;
127 CfgString password;
128 CfgString noproxy;
129
130 int unknown_elements;
131 };
132
133 struct DavCfgKey {
134 CfgString name;
135 CfgString file;
136 DavCfgKeyType type;
137 xmlNode *type_node;
138
139 DavCfgKey *prev;
140 DavCfgKey *next;
141
142 int unknown_elements;
143 };
144
145 struct DavCfgNamespace {
146 xmlNode *node;
147 cxmutstr prefix;
148 cxmutstr uri;
149
150 DavCfgNamespace *prev;
151 DavCfgNamespace *next;
152 };
153
154 struct DavCfgSecretStore {
155 CfgString unlock_cmd;
156 CfgString lock_cmd;
157 };
158
159 enum DavConfigError {
160 DAV_CONFIG_ERROR_XML =
0
161 };
162
163 DavConfig* dav_config_load(cxmutstr xmlfilecontent,
int *error);
164
165 void dav_config_free(DavConfig *config);
166
167 CxBuffer* dav_config2buf(DavConfig *config);
168
169 void dav_config_add_repository(DavConfig *config, DavCfgRepository *repo);
170
171 DavCfgRepository* dav_repository_new(DavConfig *config);
172 void dav_repository_free(DavConfig *config, DavCfgRepository *repo);
173 void dav_repository_remove_and_free(DavConfig *config, DavCfgRepository *repo);
174 int dav_repository_get_flags(DavCfgRepository *repo);
175 void dav_repository_set_url(DavConfig *config, DavCfgRepository *repo, cxstring newurl);
176 void dav_repository_set_auth(DavConfig *config, DavCfgRepository *repo, cxstring user, cxstring password);
177 cxmutstr dav_repository_get_decodedpassword(DavCfgRepository *repo);
178
179 int dav_cfg_string_set_value(DavConfig *config, CfgString *str, xmlNode *node);
180 void dav_cfg_bool_set_value(DavConfig *config, CfgBool *cbool, xmlNode *node);
181
182 DavCfgRepository* dav_config_get_repository(DavConfig *config, cxstring name);
183 DavCfgRepository* dav_config_url2repo(DavConfig *config,
const char *url,
char **path);
184 DavCfgRepository* dav_config_url2repo_s(DavConfig *config, cxstring url, cxmutstr *path);
185
186 int dav_config_keytype(DavCfgKeyType type);
187 int dav_config_register_keys(DavConfig *config, DavContext *ctx, dav_loadkeyfile_func loadkey);
188
189 #ifdef __cplusplus
190 }
191 #endif
192
193 #endif
194
195