29 #ifndef RESOURCE_H |
29 #ifndef RESOURCE_H |
30 #define RESOURCE_H |
30 #define RESOURCE_H |
31 |
31 |
32 #include "webdav.h" |
32 #include "webdav.h" |
33 #include "crypto.h" |
33 #include "crypto.h" |
34 #include <ucx/string.h> |
34 #include <cx/string.h> |
|
35 #include <cx/hash_key.h> |
35 |
36 |
36 #ifdef __cplusplus |
37 #ifdef __cplusplus |
37 extern "C" { |
38 extern "C" { |
38 #endif |
39 #endif |
39 |
40 |
40 typedef struct DavResourceData DavResourceData; |
41 typedef struct DavResourceData DavResourceData; |
41 |
42 |
42 struct DavResourceData { |
43 struct DavResourceData { |
43 UcxMap *properties; |
44 CxMap *properties; |
44 UcxList *set; |
45 CxList *set; |
45 UcxList *remove; |
46 CxList *remove; |
46 UcxList *crypto_set; |
47 CxList *crypto_set; |
47 UcxList *crypto_remove; |
48 CxList *crypto_remove; |
48 |
49 |
49 /* |
50 /* |
50 * properties encapsulated in a crypto-prop property or NULL |
51 * properties encapsulated in a crypto-prop property or NULL |
51 */ |
52 */ |
52 UcxMap *crypto_properties; |
53 CxMap *crypto_properties; |
53 |
54 |
54 /* |
55 /* |
55 * char* or stream |
56 * char* or stream |
56 */ |
57 */ |
57 void *content; |
58 void *content; |
58 /* |
59 /* |
59 * if NULL, content is a char* |
60 * if NULL, content is a char* |
60 */ |
61 */ |
61 read_func read; |
62 dav_read_func read; |
62 /* |
63 /* |
63 * curl seek func |
64 * curl seek func |
64 */ |
65 */ |
65 dav_seek_func seek; |
66 dav_seek_func seek; |
66 /* |
67 /* |
107 size_t size; |
108 size_t size; |
108 size_t pos; |
109 size_t pos; |
109 int eof; |
110 int eof; |
110 }; |
111 }; |
111 |
112 |
112 DavResource* dav_resource_new_full(DavSession *sn, char *parent_path, char *name, char *href); |
113 DavResource* dav_resource_new_full(DavSession *sn, const char *parent_path, const char *name, char *href); |
113 |
114 |
114 void resource_free_properties(DavSession *sn, UcxMap *properties); |
115 void resource_free_properties(DavSession *sn, CxMap *properties); |
115 |
116 |
116 void resource_set_href(DavResource *res, sstr_t href); |
117 void resource_set_href(DavResource *res, cxstring href); |
117 |
118 |
118 void resource_set_info(DavResource *res, char *href_str); |
119 void resource_set_info(DavResource *res, const char *href_str); |
119 DavResourceData* resource_data_new(DavSession *sn); |
120 DavResourceData* resource_data_new(DavSession *sn); |
120 void resource_add_property(DavResource *res, const char *ns, const char *name, xmlNode *val); |
121 void resource_add_property(DavResource *res, const char *ns, const char *name, xmlNode *val); |
121 void resource_set_crypto_properties(DavResource *res, UcxMap *cprops); |
122 void resource_set_crypto_properties(DavResource *res, CxMap *cprops); |
122 DavXmlNode* resource_get_property(DavResource *res, const char *ns, const char *name); |
123 DavXmlNode* resource_get_property(DavResource *res, const char *ns, const char *name); |
123 DavXmlNode* resource_get_encrypted_property(DavResource *res, const char *ns, const char *name); |
124 DavXmlNode* resource_get_encrypted_property(DavResource *res, const char *ns, const char *name); |
124 DavXmlNode* resource_get_property_k(DavResource *res, UcxKey key); |
125 DavXmlNode* resource_get_property_k(DavResource *res, CxHashKey key); |
125 DavXmlNode* resource_get_encrypted_property_k(DavResource *res, UcxKey key); |
126 DavXmlNode* resource_get_encrypted_property_k(DavResource *res, CxHashKey key); |
126 void resource_add_child(DavResource *parent, DavResource *child); |
127 void resource_add_child(DavResource *parent, DavResource *child); |
127 void resource_add_ordered_child(DavResource *parent, DavResource *child, UcxList *ordercr); |
128 void resource_add_ordered_child(DavResource *parent, DavResource *child, CxList *ordercr); |
128 int resource_add_crypto_info(DavSession *sn, const char *href, const char *name, const char *hash); |
129 int resource_add_crypto_info(DavSession *sn, const char *href, const char *name, const char *hash); |
129 |
130 |
130 sstr_t dav_property_key_a(UcxAllocator *a, const char *ns, const char *name); |
131 cxmutstr dav_property_key_a(const CxAllocator *a, const char *ns, const char *name); |
131 |
132 |
132 DavXmlNode* create_crypto_prop(DavSession *sn, UcxMap *properties); |
133 DavXmlNode* create_crypto_prop(DavSession *sn, CxMap *properties); |
133 UcxMap* parse_crypto_prop(DavSession *sn, DavKey *key, DavXmlNode *node); |
134 CxMap* parse_crypto_prop(DavSession *sn, DavKey *key, DavXmlNode *node); |
134 UcxMap* parse_crypto_prop_str(DavSession *sn, DavKey *key, const char *content); |
135 CxMap* parse_crypto_prop_str(DavSession *sn, DavKey *key, const char *content); |
135 |
136 |
136 #ifdef __cplusplus |
137 #ifdef __cplusplus |
137 } |
138 } |
138 #endif |
139 #endif |
139 |
140 |