libidav/config.h

changeset 795
05647e862a17
child 796
81e0f67386a6
equal deleted inserted replaced
794:29d544c3c2b8 795:05647e862a17
1 /*
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3 *
4 * Copyright 2023 Olaf Wintermann. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
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 #define DAV_HTTP_PROXY 1
53 #define DAV_HTTPS_PROXY 2
54
55 enum dav_cfg_key_type {
56 DAV_KEY_TYPE_AES256 = 0,
57 DAV_KEY_TYPE_AES128,
58 DAV_KEY_TYPE_UNKNOWN
59 };
60
61 struct DavConfig {
62 CxMempool *mp;
63
64 DavCfgRepository *repositories;
65 DavCfgKey *keys;
66 DavCfgNamespace *namespaces;
67 DavCfgProxy *http_proxy;
68 DavCfgProxy *https_proxy;
69 DavCfgSecretStore *secretstore;
70
71 xmlDoc *doc;
72 };
73
74 struct CfgString {
75 cxmutstr value;
76 xmlNode *node;
77 };
78
79 struct CfgInt {
80 int64_t value;
81 xmlNode *node;
82 };
83
84 struct CfgUInt {
85 uint64_t value;
86 xmlNode *node;
87 };
88
89 struct CfgBool {
90 bool value;
91 xmlNode *node;
92 };
93
94
95 struct DavCfgRepository {
96 xmlNode *node;
97
98 CfgString name;
99 CfgString url;
100 CfgString user;
101 CfgString password;
102 CfgString stored_user;
103 CfgString default_key;
104 CfgString cert;
105 CfgBool verification;
106
107 CfgBool full_encryption;
108 CfgBool content_encryption;
109 CfgBool decrypt_content;
110 CfgBool decrypt_name;
111 CfgBool decrypt_properties;
112
113 CfgInt ssl_version;
114 CfgUInt authmethods;
115
116 int unknown_elements;
117
118 DavCfgRepository *prev;
119 DavCfgRepository *next;
120 };
121
122 struct DavCfgProxy {
123 CfgString url;
124 CfgString user;
125 CfgString password;
126 CfgString noproxy;
127
128 int unknown_elements;
129 };
130
131 struct DavCfgKey {
132 CfgString name;
133 CfgString file;
134 DavCfgKeyType type;
135 xmlNode *type_node;
136
137 DavCfgKey *prev;
138 DavCfgKey *next;
139
140 int unknown_elements;
141 };
142
143 struct DavCfgNamespace {
144 xmlNode *node;
145 cxmutstr prefix;
146 cxmutstr uri;
147
148 DavCfgNamespace *prev;
149 DavCfgNamespace *next;
150 };
151
152 struct DavCfgSecretStore {
153 CfgString unlock_cmd;
154 CfgString lock_cmd;
155 };
156
157 enum DavConfigError {
158 DAV_CONFIG_ERROR_XML = 0
159 };
160
161 DavConfig* dav_config_load(cxmutstr xmlfilecontent, int *error);
162
163 CxBuffer* dav_config2buf(DavConfig *config);
164
165 void dav_config_add_repository(DavConfig *config, DavCfgRepository *repo);
166
167 DavCfgRepository* dav_repository_new(DavConfig *config);
168 void dav_repository_free(DavConfig *config, DavCfgRepository *repo);
169 void dav_repository_remove_and_free(DavConfig *config, DavCfgRepository *repo);
170 int dav_repository_get_flags(DavCfgRepository *repo);
171 void dav_repository_set_url(DavConfig *config, DavCfgRepository *repo, cxstring newurl);
172 void dav_repository_set_auth(DavConfig *config, DavCfgRepository *repo, cxstring user, cxstring password);
173 cxmutstr dav_repository_get_decodedpassword(DavCfgRepository *repo);
174
175 int dav_cfg_string_set_value(DavConfig *config, CfgString *str, xmlNode *node);
176 void dav_cfg_bool_set_value(DavConfig *config, CfgBool *cbool, xmlNode *node);
177
178 DavCfgRepository* dav_config_get_repository(DavConfig *config, cxstring name);
179 DavCfgRepository* dav_config_url2repo(DavConfig *config, const char *url, char **path);
180 DavCfgRepository* dav_config_url2repo_s(DavConfig *config, cxstring url, cxmutstr *path);
181
182
183 #ifdef __cplusplus
184 }
185 #endif
186
187 #endif /* LIBIDAV_CONFIG_H */
188

mercurial