40 |
40 |
41 #ifdef __cplusplus |
41 #ifdef __cplusplus |
42 extern "C" { |
42 extern "C" { |
43 #endif |
43 #endif |
44 |
44 |
45 typedef struct PropfindResponse PropfindResponse; |
45 #define DAV_FOREACH(elem, list) \ |
46 typedef struct DAVPropertyBackend DAVPropertyBackend; |
46 for (UcxDlist *elem = list ; elem != NULL ; elem = elem->next) |
|
47 |
|
48 typedef struct PropfindResponse PropfindResponse; |
|
49 typedef struct DAVPropertyBackend DAVPropertyBackend; |
47 |
50 |
48 typedef struct PropfindRequest PropfindRequest; |
51 typedef struct PropfindRequest PropfindRequest; |
49 typedef struct DavProperty DavProperty; |
52 typedef struct DavProperty DavProperty; |
50 |
53 |
51 struct PropfindRequest { |
54 struct PropfindRequest { |
52 Session *sn; |
55 Session *sn; |
53 Request *rq; |
56 Request *rq; |
54 |
57 |
55 UcxDlist *properties; /* DavProperty list */ |
58 UcxDlist *properties; /* DavProperty list, requested props */ |
56 int8_t allprop; |
59 int8_t allprop; |
57 int8_t propname; |
60 int8_t propname; |
58 |
61 |
|
62 int8_t prop; |
59 UcxDlist *notFoundProps; |
63 UcxDlist *notFoundProps; |
60 UcxDlist *forbiddenProps; |
64 UcxDlist *forbiddenProps; |
61 DAVPropertyBackend *propertyBackend; |
65 DAVPropertyBackend *propertyBackend; |
62 |
66 |
63 char *path; |
67 char *path; |
69 struct DavProperty { |
73 struct DavProperty { |
70 char *xmlns; |
74 char *xmlns; |
71 char *name; |
75 char *name; |
72 }; |
76 }; |
73 |
77 |
74 typedef char*(*prop_get_func)( |
78 /* |
75 DAVPropertyBackend*, |
79 * dav_res_propfind_f |
76 PropfindRequest*, |
80 * |
77 char*, |
81 * Gets all requested properties of a WebDAV resource(file). This function |
78 char*, |
82 * should add properties with dav_propfind_add_str_prop or |
79 char*, |
83 * dav_prop_add_xml_prop. Unavailable properties should be added with |
80 int*); |
84 * |
|
85 * |
|
86 * arg0: property backend |
|
87 * arg1: current PropfindRequest object |
|
88 * arg2: the webdav resource path |
|
89 */ |
|
90 typedef void(*dav_res_propfind_f)(DAVPropertyBackend*,PropfindRequest*,char*); |
81 |
91 |
82 struct DAVPropertyBackend { |
92 struct DAVPropertyBackend { |
83 prop_get_func get_property; |
93 dav_res_propfind_f propfind; |
84 }; |
94 }; |
85 |
95 |
86 int webdav_service(pblock *pb, Session *sn, Request *rq); |
96 int webdav_service(pblock *pb, Session *sn, Request *rq); |
|
97 int webdav_propfind(pblock *pb, Session *sn, Request *rq); |
87 |
98 |
88 void dav_create_response(PropfindRequest *davrq); |
99 void dav_resource_response(PropfindRequest *rq, sstr_t path, sstr_t uri); |
89 |
100 |
90 int dav_foreach_reqprop(UcxDlist *list, PropfindRequest *davrq); |
101 /* |
|
102 * dav_propfind_add_str_prop |
|
103 * |
|
104 * Adds a string property to the current WebDAV resource response |
|
105 */ |
|
106 void dav_propfind_add_str_prop( |
|
107 PropfindRequest *rq, |
|
108 DavProperty* prop, |
|
109 char *str, |
|
110 size_t len); |
91 |
111 |
92 char* dav_get_property( |
112 //void dav_propfind_add_xml_prop(); |
93 DAVPropertyBackend *b, |
113 |
94 PropfindRequest *davrq, |
114 /* |
95 char *path, |
115 * dav_propfind_add_prop_error |
96 char *xmlns, |
116 * |
97 char *name, |
117 * Adds a unavailable property to the response |
98 int *error); |
118 * |
|
119 * rq: propfind request object |
|
120 * prop: unavailable property |
|
121 * error: HTTP status code |
|
122 */ |
|
123 void dav_propfind_add_prop_error( |
|
124 PropfindRequest *rq, |
|
125 DavProperty *prop, |
|
126 int error); |
|
127 |
|
128 |
99 |
129 |
100 DAVPropertyBackend* create_property_backend(); |
130 DAVPropertyBackend* create_property_backend(); |
101 |
131 void dav_rq_propfind(DAVPropertyBackend *b,PropfindRequest *rq ,char *path); |
102 typedef struct { |
|
103 DAVPropertyBackend backend; |
|
104 char *path; |
|
105 struct stat st; |
|
106 int s; |
|
107 } DAVDefaultBackend; |
|
108 |
|
109 |
132 |
110 #ifdef __cplusplus |
133 #ifdef __cplusplus |
111 } |
134 } |
112 #endif |
135 #endif |
113 |
136 |