libidav/methods.c

changeset 118
6d0da97105d8
parent 117
b174e721663e
equal deleted inserted replaced
117:b174e721663e 118:6d0da97105d8
101 * => try with depth 0 next time, it's not a collection 101 * => try with depth 0 next time, it's not a collection
102 * 2. Other cases 102 * 2. Other cases
103 * => the server handled our request and we can stop requesting 103 * => the server handled our request and we can stop requesting
104 */ 104 */
105 char *msdavexterror; 105 char *msdavexterror;
106 msdavexterror = cxMapGet(respheaders, cx_hash_key_str("x-msdavext_error")); 106 msdavexterror = cxMapGet(respheaders, "x-msdavext_error");
107 int iishack = depth == 1 && 107 int iishack = depth == 1 &&
108 msdavexterror && !strncmp(msdavexterror, "589831;", 7); 108 msdavexterror && !strncmp(msdavexterror, "589831;", 7);
109 109
110 if(iishack) { 110 if(iishack) {
111 depth = 0; 111 depth = 0;
164 CxMap *namespaces = cxHashMapCreate(cxDefaultAllocator, CX_STORE_POINTERS, 8); 164 CxMap *namespaces = cxHashMapCreate(cxDefaultAllocator, CX_STORE_POINTERS, 8);
165 if(properties) { 165 if(properties) {
166 CxIterator i = cxListIterator(properties); 166 CxIterator i = cxListIterator(properties);
167 cx_foreach(DavProperty*, p, i) { 167 cx_foreach(DavProperty*, p, i) {
168 if(strcmp(p->ns->name, "DAV:")) { 168 if(strcmp(p->ns->name, "DAV:")) {
169 cxMapPut(namespaces, cx_hash_key_str(p->ns->prefix), p->ns); 169 cxMapPut(namespaces, p->ns->prefix, p->ns);
170 } 170 }
171 171
172 // if the properties list contains the idav properties crypto-name 172 // if the properties list contains the idav properties crypto-name
173 // and crypto-key, mark them as existent 173 // and crypto-key, mark them as existent
174 if(!strcmp(p->ns->name, DAV_NS)) { 174 if(!strcmp(p->ns->name, DAV_NS)) {
188 188
189 DavNamespace idav_ns; 189 DavNamespace idav_ns;
190 if(add_crypto_name && add_crypto_key && DAV_CRYPTO(sn) && !nocrypt) { 190 if(add_crypto_name && add_crypto_key && DAV_CRYPTO(sn) && !nocrypt) {
191 idav_ns.prefix = "idav"; 191 idav_ns.prefix = "idav";
192 idav_ns.name = DAV_NS; 192 idav_ns.name = DAV_NS;
193 cxMapPut(namespaces, cx_hash_key_str("idav"), &idav_ns); 193 cxMapPut(namespaces, "idav", &idav_ns);
194 } 194 }
195 195
196 s = cx_str("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"); 196 cxBufferPutString(buf, "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n");
197 cxBufferWrite(s.ptr, 1, s.length, buf);
198 197
199 // write root element and namespaces 198 // write root element and namespaces
200 cx_bprintf(buf, "<D:%s xmlns:D=\"DAV:\"", rootelm); 199 cx_bprintf(buf, "<D:%s xmlns:D=\"DAV:\"", rootelm);
201 200
202 CxMapIterator mapi = cxMapIteratorValues(namespaces); 201 CxMapIterator mapi = cxMapIteratorValues(namespaces);
203 cx_foreach(DavNamespace*, ns, mapi) { 202 cx_foreach(DavNamespace*, ns, mapi) {
204 s = cx_str(" xmlns:"); 203 cxBufferPutString(buf, " xmlns:");
205 cxBufferWrite(s.ptr, 1, s.length, buf); 204 cxBufferPutString(buf, ns->prefix);
206 s = cx_str(ns->prefix); 205 cxBufferPutString(buf, "=\"");
207 cxBufferWrite(s.ptr, 1, s.length, buf); 206 cxBufferPutString(buf, ns->name);
208 s = cx_str("=\""); 207 cxBufferPutString(buf, "\"");
209 cxBufferWrite(s.ptr, 1, s.length, buf); 208 }
210 s = cx_str(ns->name); 209 cxBufferPutString(buf, ">\n");
211 cxBufferWrite(s.ptr, 1, s.length, buf);
212 s = cx_str("\"");
213 cxBufferWrite(s.ptr, 1, s.length, buf);
214 }
215 s = cx_str(">\n");
216 cxBufferWrite(s.ptr, 1, s.length, buf);
217 210
218 // default properties 211 // default properties
219 s = cx_str("<D:prop>\n"); 212 cxBufferPutString(buf, "<D:prop>\n");
220 cxBufferWrite(s.ptr, 1, s.length, buf); 213 cxBufferPutString(buf, "<D:creationdate />\n<D:getlastmodified />\n");
221 214 cxBufferPutString(buf, "<D:getcontentlength />\n<D:getcontenttype />\n");
222 s = cx_str("<D:creationdate />\n<D:getlastmodified />\n"); 215
223 cxBufferWrite(s.ptr, 1, s.length, buf); 216 cxBufferPutString(buf, "<D:resourcetype />\n");
224
225 s = cx_str("<D:getcontentlength />\n<D:getcontenttype />\n");
226 cxBufferWrite(s.ptr, 1, s.length, buf);
227
228 s = cx_str("<D:resourcetype />\n");
229 cxBufferWrite(s.ptr, 1, s.length, buf);
230 217
231 // crypto properties 218 // crypto properties
232 if(DAV_CRYPTO(sn) && !nocrypt) { 219 if(DAV_CRYPTO(sn) && !nocrypt) {
233 if(add_crypto_name) { 220 if(add_crypto_name) {
234 cxBufferPut(buf, '<'); 221 cxBufferPut(buf, '<');
235 cxBufferPutString(buf, crypto_ns); 222 cxBufferPutString(buf, crypto_ns);
236 s = cx_str(":crypto-name />\n"); 223 cxBufferPutString(buf, ":crypto-name />\n");
237 cxBufferWrite(s.ptr, 1, s.length, buf);
238 } 224 }
239 if(add_crypto_key) { 225 if(add_crypto_key) {
240 cxBufferPut(buf, '<'); 226 cxBufferPut(buf, '<');
241 cxBufferPutString(buf, crypto_ns); 227 cxBufferPutString(buf, crypto_ns);
242 s = cx_str(":crypto-key />\n"); 228 cxBufferPutString(buf, ":crypto-key />\n");
243 cxBufferWrite(s.ptr, 1, s.length, buf);
244 } 229 }
245 if(add_crypto_hash) { 230 if(add_crypto_hash) {
246 cxBufferPut(buf, '<'); 231 cxBufferPut(buf, '<');
247 cxBufferPutString(buf, crypto_ns); 232 cxBufferPutString(buf, crypto_ns);
248 s = cx_str(":crypto-hash />\n"); 233 cxBufferPutString(buf, ":crypto-hash />\n");
249 cxBufferWrite(s.ptr, 1, s.length, buf);
250 } 234 }
251 } 235 }
252 236
253 // extra properties 237 // extra properties
254 if(properties) { 238 if(properties) {
255 CxIterator i = cxListIterator(properties); 239 CxIterator i = cxListIterator(properties);
256 cx_foreach(DavProperty*, prop, i) { 240 cx_foreach(DavProperty*, prop, i) {
257 s = cx_str("<"); 241 cxBufferPutString(buf, "<");
258 cxBufferWrite(s.ptr, 1, s.length, buf); 242 cxBufferPutString(buf, prop->ns->prefix);
259 s = cx_str(prop->ns->prefix); 243 cxBufferPutString(buf, ":");
260 cxBufferWrite(s.ptr, 1, s.length, buf); 244 cxBufferPutString(buf, prop->name);
261 s = cx_str(":"); 245 cxBufferPutString(buf, " />\n");
262 cxBufferWrite(s.ptr, 1, s.length, buf);
263 s = cx_str(prop->name);
264 cxBufferWrite(s.ptr, 1, s.length, buf);
265 s = cx_str(" />\n");
266 cxBufferWrite(s.ptr, 1, s.length, buf);
267 } 246 }
268 } 247 }
269 248
270 // end 249 // end
271 cx_bprintf(buf, "</D:prop>\n</D:%s>\n", rootelm); 250 cx_bprintf(buf, "</D:prop>\n</D:%s>\n", rootelm);
276 255
277 CxBuffer* create_basic_propfind_request(void) { 256 CxBuffer* create_basic_propfind_request(void) {
278 CxBuffer *buf = cxBufferCreate(cxDefaultAllocator, NULL, 512, CX_BUFFER_FREE_CONTENTS|CX_BUFFER_AUTO_EXTEND); 257 CxBuffer *buf = cxBufferCreate(cxDefaultAllocator, NULL, 512, CX_BUFFER_FREE_CONTENTS|CX_BUFFER_AUTO_EXTEND);
279 cxstring s; 258 cxstring s;
280 259
281 s = cx_str("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"); 260 cxBufferPutString(buf, "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n");
282 cxBufferWrite(s.ptr, 1, s.length, buf); 261
283 262 cxBufferPutString(buf, "<D:propfind xmlns:D=\"DAV:\" xmlns:i=\"");
284 s = cx_str("<D:propfind xmlns:D=\"DAV:\" xmlns:i=\""); 263 cxBufferPutString(buf, DAV_NS);
285 cxBufferWrite(s.ptr, 1, s.length, buf); 264 cxBufferPutString(buf, "\" >\n");
286 s = cx_str(DAV_NS);
287 cxBufferWrite(s.ptr, 1, s.length, buf);
288 s = cx_str("\" >\n");
289 cxBufferWrite(s.ptr, 1, s.length, buf);
290 265
291 // properties 266 // properties
292 s = cx_str("<D:prop>\n"); 267 cxBufferPutString(buf, "<D:prop>\n");
293 cxBufferWrite(s.ptr, 1, s.length, buf); 268 cxBufferPutString(buf, "<D:resourcetype />\n");
294 s = cx_str("<D:resourcetype />\n"); 269 cxBufferPutString(buf, "<i:crypto-key />\n");
295 cxBufferWrite(s.ptr, 1, s.length, buf); 270 cxBufferPutString(buf, "<i:crypto-name />\n");
296 s = cx_str("<i:crypto-key />\n"); 271 cxBufferPutString(buf, "<i:crypto-hash />\n");
297 cxBufferWrite(s.ptr, 1, s.length, buf); 272 cxBufferPutString(buf, "</D:prop>\n");
298 s = cx_str("<i:crypto-name />\n");
299 cxBufferWrite(s.ptr, 1, s.length, buf);
300 s = cx_str("<i:crypto-hash />\n");
301 cxBufferWrite(s.ptr, 1, s.length, buf);
302 s = cx_str("</D:prop>\n");
303 cxBufferWrite(s.ptr, 1, s.length, buf);
304 273
305 // end 274 // end
306 s = cx_str("</D:propfind>\n"); 275 cxBufferPutString(buf, "</D:propfind>\n");
307 cxBufferWrite(s.ptr, 1, s.length, buf);
308 276
309 return buf; 277 return buf;
310 } 278 }
311 279
312 PropfindParser* create_propfind_parser(CxBuffer *response, char *url) { 280 PropfindParser* create_propfind_parser(CxBuffer *response, char *url) {
834 if (data->set && cxListSize(data->set) > 0) { 802 if (data->set && cxListSize(data->set) > 0) {
835 CxIterator i = cxListIterator(data->set); 803 CxIterator i = cxListIterator(data->set);
836 cx_foreach(DavProperty*, p, i) { 804 cx_foreach(DavProperty*, p, i) {
837 if (strcmp(p->ns->name, "DAV:")) { 805 if (strcmp(p->ns->name, "DAV:")) {
838 snprintf(prefix, 8, "x%d", pfxnum++); 806 snprintf(prefix, 8, "x%d", pfxnum++);
839 cxMapPut(namespaces, cx_hash_key_str(p->ns->name), strdup(prefix)); 807 cxMapPut(namespaces, p->ns->name, strdup(prefix));
840 } 808 }
841 } 809 }
842 } 810 }
843 if (data->remove && cxListSize(data->remove) > 0) { 811 if (data->remove && cxListSize(data->remove) > 0) {
844 CxIterator i = cxListIterator(data->remove); 812 CxIterator i = cxListIterator(data->remove);
845 cx_foreach(DavProperty*, p, i) { 813 cx_foreach(DavProperty*, p, i) {
846 if (strcmp(p->ns->name, "DAV:")) { 814 if (strcmp(p->ns->name, "DAV:")) {
847 snprintf(prefix, 8, "x%d", pfxnum++); 815 snprintf(prefix, 8, "x%d", pfxnum++);
848 cxMapPut(namespaces, cx_hash_key_str(p->ns->name), strdup(prefix)); 816 cxMapPut(namespaces, p->ns->name, strdup(prefix));
849 } 817 }
850 } 818 }
851 } 819 }
852 } 820 }
853 821
854 s = cx_str("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"); 822 cxBufferPutString(buf, "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n");
855 cxBufferWrite(s.ptr, 1, s.length, buf);
856 823
857 // write root element and namespaces 824 // write root element and namespaces
858 s = cx_str("<D:propertyupdate xmlns:D=\"DAV:\""); 825 cxBufferPutString(buf, "<D:propertyupdate xmlns:D=\"DAV:\"");
859 cxBufferWrite(s.ptr, 1, s.length, buf);
860 CxMapIterator mapi = cxMapIterator(namespaces); 826 CxMapIterator mapi = cxMapIterator(namespaces);
861 cx_foreach(CxMapEntry*, entry, mapi) { 827 cx_foreach(CxMapEntry*, entry, mapi) {
862 s = cx_str(" xmlns:"); 828 cxBufferPutString(buf, " xmlns:");
863 cxBufferWrite(s.ptr, 1, s.length, buf); 829 cxBufferPutString(buf, cx_str(entry->value));
864 s = cx_str(entry->value); 830 cxBufferPutString(buf, "=\"");
865 cxBufferWrite(s.ptr, 1, s.length, buf); 831 cxBufferPutString(buf, cx_strn(entry->key->data, entry->key->len));
866 s = cx_str("=\""); 832 cxBufferPutString(buf, "\"");
867 cxBufferWrite(s.ptr, 1, s.length, buf); 833 }
868 s = cx_strn(entry->key->data, entry->key->len); 834 cxBufferPutString(buf, ">\n");
869 cxBufferWrite(s.ptr, 1, s.length, buf);
870 s = cx_str("\"");
871 cxBufferWrite(s.ptr, 1, s.length, buf);
872 }
873 s = cx_str(">\n");
874 cxBufferWrite(s.ptr, 1, s.length, buf);
875 835
876 if(data->set) { 836 if(data->set) {
877 s = cx_str("<D:set>\n<D:prop>\n"); 837 cxBufferPutString(buf, "<D:set>\n<D:prop>\n");
878 cxBufferWrite(s.ptr, 1, s.length, buf);
879 CxIterator i = cxListIterator(data->set); 838 CxIterator i = cxListIterator(data->set);
880 cx_foreach(DavProperty*, property, i) { 839 cx_foreach(DavProperty*, property, i) {
881 char *prefix = cxMapGet(namespaces, cx_hash_key_str(property->ns->name)); 840 char *prefix = cxMapGet(namespaces, property->ns->name);
882 if(!prefix) { 841 if(!prefix) {
883 prefix = "D"; 842 prefix = "D";
884 } 843 }
885 844
886 // begin tag 845 // begin tag
887 s = cx_str("<"); 846 cxBufferPutString(buf, "<");
888 cxBufferWrite(s.ptr, 1, s.length, buf); 847 cxBufferPutString(buf, prefix);
889 s = cx_str(prefix); 848 cxBufferPutString(buf, ":");
890 cxBufferWrite(s.ptr, 1, s.length, buf); 849 cxBufferPutString(buf, property->name);
891 s = cx_str(":"); 850 cxBufferPutString(buf, ">");
892 cxBufferWrite(s.ptr, 1, s.length, buf);
893 s = cx_str(property->name);
894 cxBufferWrite(s.ptr, 1, s.length, buf);
895 s = cx_str(">");
896 cxBufferWrite(s.ptr, 1, s.length, buf);
897 851
898 // content 852 // content
899 DavXmlNode *content = property->value; 853 DavXmlNode *content = property->value;
900 if(content->type == DAV_XML_TEXT && !content->next) { 854 if(content->type == DAV_XML_TEXT && !content->next) {
901 cxBufferWrite(content->content, 1, content->contentlength, buf); 855 cxBufferWrite(content->content, 1, content->contentlength, buf);
902 } else { 856 } else {
903 dav_print_node(buf, (cx_write_func)cxBufferWrite, namespaces, content); 857 dav_print_node(buf, (cx_write_func)cxBufferWrite, namespaces, content);
904 } 858 }
905 859
906 // end tag 860 // end tag
907 s = cx_str("</"); 861 cxBufferPutString(buf, "</");
908 cxBufferWrite(s.ptr, 1, s.length, buf); 862 cxBufferPutString(buf, prefix);
909 s = cx_str(prefix); 863 cxBufferPutString(buf, ":");
910 cxBufferWrite(s.ptr, 1, s.length, buf); 864 cxBufferPutString(buf, property->name);
911 s = cx_str(":"); 865 cxBufferPutString(buf, ">\n");
912 cxBufferWrite(s.ptr, 1, s.length, buf); 866 }
913 s = cx_str(property->name); 867 cxBufferPutString(buf, "</D:prop>\n</D:set>\n");
914 cxBufferWrite(s.ptr, 1, s.length, buf);
915 s = cx_str(">\n");
916 cxBufferWrite(s.ptr, 1, s.length, buf);
917 }
918 s = cx_str("</D:prop>\n</D:set>\n");
919 cxBufferWrite(s.ptr, 1, s.length, buf);
920 } 868 }
921 if(data->remove) { 869 if(data->remove) {
922 s = cx_str("<D:remove>\n<D:prop>\n"); 870 cxBufferPutString(buf, "<D:remove>\n<D:prop>\n");
923 cxBufferWrite(s.ptr, 1, s.length, buf);
924 CxIterator i = cxListIterator(data->remove); 871 CxIterator i = cxListIterator(data->remove);
925 cx_foreach(DavProperty*, property, i) { 872 cx_foreach(DavProperty*, property, i) {
926 char *prefix = cxMapGet(namespaces, cx_hash_key_str(property->ns->name)); 873 char *prefix = cxMapGet(namespaces, property->ns->name);
927 874
928 s = cx_str("<"); 875 cxBufferPutString(buf, "<");
929 cxBufferWrite(s.ptr, 1, s.length, buf); 876 cxBufferPutString(buf, prefix);
930 s = cx_str(prefix); 877 cxBufferPutString(buf, ":");
931 cxBufferWrite(s.ptr, 1, s.length, buf); 878 cxBufferPutString(buf, property->name);
932 s = cx_str(":"); 879 cxBufferPutString(buf, " />\n");
933 cxBufferWrite(s.ptr, 1, s.length, buf); 880 }
934 s = cx_str(property->name); 881 cxBufferPutString(buf, "</D:prop>\n</D:remove>\n");
935 cxBufferWrite(s.ptr, 1, s.length, buf); 882 }
936 s = cx_str(" />\n"); 883
937 cxBufferWrite(s.ptr, 1, s.length, buf); 884 cxBufferPutString(buf, "</D:propertyupdate>\n");
938 }
939 s = cx_str("</D:prop>\n</D:remove>\n");
940 cxBufferWrite(s.ptr, 1, s.length, buf);
941 }
942
943 s = cx_str("</D:propertyupdate>\n");
944 cxBufferWrite(s.ptr, 1, s.length, buf);
945 885
946 // cleanup namespace map 886 // cleanup namespace map
947 cxMapFree(namespaces); 887 cxMapFree(namespaces);
948 888
949 return buf; 889 return buf;
951 891
952 CxBuffer* create_crypto_proppatch_request(DavSession *sn, DavKey *key, const char *name, const char *hash) { 892 CxBuffer* create_crypto_proppatch_request(DavSession *sn, DavKey *key, const char *name, const char *hash) {
953 CxBuffer *buf = cxBufferCreate(cxDefaultAllocator, NULL, 512, CX_BUFFER_FREE_CONTENTS|CX_BUFFER_AUTO_EXTEND); 893 CxBuffer *buf = cxBufferCreate(cxDefaultAllocator, NULL, 512, CX_BUFFER_FREE_CONTENTS|CX_BUFFER_AUTO_EXTEND);
954 cxstring s; 894 cxstring s;
955 895
956 s = cx_str("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"); 896 cxBufferPutString(buf, "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n");
957 cxBufferWrite(s.ptr, 1, s.length, buf); 897
958 898 cxBufferPutString(buf, "<D:propertyupdate xmlns:D=\"DAV:\" xmlns:idav=\"" DAV_NS "\">\n");
959 s = cx_str("<D:propertyupdate xmlns:D=\"DAV:\" xmlns:idav=\"" DAV_NS "\">\n"); 899
960 cxBufferWrite(s.ptr, 1, s.length, buf); 900 cxBufferPutString(buf, "<D:set>\n<D:prop>\n");
961
962 s = cx_str("<D:set>\n<D:prop>\n");
963 cxBufferWrite(s.ptr, 1, s.length, buf);
964 901
965 if(DAV_ENCRYPT_NAME(sn)) { 902 if(DAV_ENCRYPT_NAME(sn)) {
966 s = cx_str("<idav:crypto-name>"); 903 cxBufferPutString(buf, "<idav:crypto-name>");
967 cxBufferWrite(s.ptr, 1, s.length, buf);
968 char *crname = aes_encrypt(name, strlen(name), key); 904 char *crname = aes_encrypt(name, strlen(name), key);
969 cxBufferPutString(buf, crname); 905 cxBufferPutString(buf, crname);
970 free(crname); 906 free(crname);
971 s = cx_str("</idav:crypto-name>\n"); 907 cxBufferPutString(buf, "</idav:crypto-name>\n");
972 cxBufferWrite(s.ptr, 1, s.length, buf); 908 }
973 } 909
974 910 cxBufferPutString(buf, "<idav:crypto-key>");
975 s = cx_str("<idav:crypto-key>");
976 cxBufferWrite(s.ptr, 1, s.length, buf);
977 cxBufferPutString(buf, key->name); 911 cxBufferPutString(buf, key->name);
978 s = cx_str("</idav:crypto-key>\n"); 912 cxBufferPutString(buf, "</idav:crypto-key>\n");
979 cxBufferWrite(s.ptr, 1, s.length, buf);
980 913
981 if(hash) { 914 if(hash) {
982 s = cx_str("<idav:crypto-hash>"); 915 cxBufferPutString(buf, "<idav:crypto-hash>");
983 cxBufferWrite(s.ptr, 1, s.length, buf);
984 cxBufferPutString(buf, hash); 916 cxBufferPutString(buf, hash);
985 s = cx_str("</idav:crypto-hash>\n"); 917 cxBufferPutString(buf, "</idav:crypto-hash>\n");
986 cxBufferWrite(s.ptr, 1, s.length, buf); 918 }
987 } 919
988 920 cxBufferPutString(buf, "</D:prop>\n</D:set>\n</D:propertyupdate>\n");
989 s = cx_str("</D:prop>\n</D:set>\n</D:propertyupdate>\n");
990 cxBufferWrite(s.ptr, 1, s.length, buf);
991 921
992 return buf; 922 return buf;
993 } 923 }
994 924
995 /* ----------------------------- PUT ----------------------------- */ 925 /* ----------------------------- PUT ----------------------------- */
1146 char *ltheader = cx_asprintf("If: <%s> (<%s>)", url, lock).ptr; 1076 char *ltheader = cx_asprintf("If: <%s> (<%s>)", url, lock).ptr;
1147 headers = curl_slist_append(headers, ltheader); 1077 headers = curl_slist_append(headers, ltheader);
1148 free(ltheader); 1078 free(ltheader);
1149 } 1079 }
1150 //cxstring deststr = ucx_sprintf("Destination: %s", dest); 1080 //cxstring deststr = ucx_sprintf("Destination: %s", dest);
1151 cxmutstr deststr = cx_strcat(2, cx_str("Destination: "), cx_str(dest)); 1081 cxmutstr deststr = cx_strcat(CX_NULLSTR, 2, cx_str("Destination: "), cx_str(dest));
1152 headers = curl_slist_append(headers, deststr.ptr); 1082 headers = curl_slist_append(headers, deststr.ptr);
1153 if(override) { 1083 if(override) {
1154 headers = curl_slist_append(headers, "Overwrite: T"); 1084 headers = curl_slist_append(headers, "Overwrite: T");
1155 } else { 1085 } else {
1156 headers = curl_slist_append(headers, "Overwrite: F"); 1086 headers = curl_slist_append(headers, "Overwrite: F");
1168 1098
1169 CxBuffer* create_lock_request(void) { 1099 CxBuffer* create_lock_request(void) {
1170 CxBuffer *buf = cxBufferCreate(cxDefaultAllocator, NULL, 512, CX_BUFFER_FREE_CONTENTS|CX_BUFFER_AUTO_EXTEND); 1100 CxBuffer *buf = cxBufferCreate(cxDefaultAllocator, NULL, 512, CX_BUFFER_FREE_CONTENTS|CX_BUFFER_AUTO_EXTEND);
1171 cxstring s; 1101 cxstring s;
1172 1102
1173 s = cx_str("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"); 1103 cxBufferPutString(buf, "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n");
1174 cxBufferWrite(s.ptr, 1, s.length, buf);
1175 1104
1176 s = cx_str("<D:lockinfo xmlns:D=\"DAV:\">\n" 1105 s = cx_str("<D:lockinfo xmlns:D=\"DAV:\">\n"
1177 "<D:lockscope><D:exclusive/></D:lockscope>\n" 1106 "<D:lockscope><D:exclusive/></D:lockscope>\n"
1178 "<D:locktype><D:write/></D:locktype>\n" 1107 "<D:locktype><D:write/></D:locktype>\n"
1179 "<D:owner><D:href>http://davutils.org/libidav/</D:href></D:owner>\n"); 1108 "<D:owner><D:href>http://davutils.org/libidav/</D:href></D:owner>\n");
1180 cxBufferWrite(s.ptr, 1, s.length, buf); 1109 cxBufferPutString(buf, s);
1181 1110
1182 s = cx_str("</D:lockinfo>\n"); 1111 cxBufferPutString(buf, "</D:lockinfo>\n");
1183 cxBufferWrite(s.ptr, 1, s.length, buf);
1184 1112
1185 return buf; 1113 return buf;
1186 } 1114 }
1187 1115
1188 int parse_lock_response(DavSession *sn, CxBuffer *response, LockDiscovery *lock) { 1116 int parse_lock_response(DavSession *sn, CxBuffer *response, LockDiscovery *lock) {

mercurial