libidav/resource.c

changeset 587
3c917df041b8
parent 558
1a9e6a5c1e79
child 589
2514559a6367
equal deleted inserted replaced
586:b45719a52ea6 587:3c917df041b8
1285 dav_session_set_error(sn, ret, status); 1285 dav_session_set_error(sn, ret, status);
1286 ucx_buffer_free(response); 1286 ucx_buffer_free(response);
1287 return 1; 1287 return 1;
1288 } 1288 }
1289 } 1289 }
1290
1291 /* ----------------------------- crypto-prop ----------------------------- */
1292
1293 DavXmlNode* create_crypto_prop(DavSession *sn, UcxMap *properties) {
1294 if(!sn->key) {
1295 return NULL;
1296 }
1297
1298 UcxBuffer *content = ucx_buffer_new(NULL, 2048, UCX_BUFFER_AUTOEXTEND);
1299
1300 // create an xml document containing all properties
1301 UcxMap *nsmap = ucx_map_new(8);
1302 ucx_map_cstr_put(nsmap, "DAV:", strdup("D"));
1303
1304 ucx_buffer_puts(content, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
1305 ucx_buffer_puts(content, "<D:prop xmlns:D=\"DAV:\">\n");
1306
1307 UcxMapIterator i = ucx_map_iterator(properties);
1308 DavProperty *prop;
1309 UCX_MAP_FOREACH(key, prop, i) {
1310 DavXmlNode pnode;
1311 pnode.type = DAV_XML_ELEMENT;
1312 pnode.namespace = prop->ns->name;
1313 pnode.name = prop->name;
1314 pnode.prev = NULL;
1315 pnode.next = NULL;
1316 pnode.children = prop->value;
1317 pnode.parent = NULL;
1318 pnode.attributes = NULL;
1319 pnode.content = NULL;
1320 pnode.contentlength = 0;
1321
1322 dav_print_node(content, (write_func)ucx_buffer_write, nsmap, &pnode);
1323 ucx_buffer_putc(content, '\n');
1324 }
1325
1326 ucx_buffer_puts(content, "</D:prop>");
1327
1328 ucx_map_free_content(nsmap, (ucx_destructor)free);
1329 ucx_map_free(nsmap);
1330
1331 // encrypt xml document
1332 char *crypto_prop_content = aes_encrypt(content->space, content->size, sn->key);
1333 ucx_buffer_free(content);
1334
1335 DavXmlNode *ret = NULL;
1336 if(crypto_prop_content) {
1337 ret = dav_text_node(sn, crypto_prop_content);
1338 free(crypto_prop_content);
1339 }
1340 return ret;
1341 }
1342
1343 UcxMap* parse_crypto_prop(DavSession *sn, DavXmlNode *node) {
1344
1345 }

mercurial