311 ucx_map_free(nsmap); |
312 ucx_map_free(nsmap); |
312 return list; |
313 return list; |
313 } |
314 } |
314 |
315 |
315 |
316 |
|
317 static ssize_t buf_writefunc(void *buf, const void *s, size_t len) { |
|
318 int w = ucx_buffer_write(s, 1, len, buf); |
|
319 return w == 0 ? IO_ERROR : w; |
|
320 } |
|
321 |
|
322 WSXmlData* wsxml_node2data( |
|
323 pool_handle_t *pool, |
|
324 WSXmlNode *node) |
|
325 { |
|
326 UcxBuffer *buf = ucx_buffer_new(NULL, 1024, UCX_BUFFER_AUTOEXTEND); |
|
327 if(!buf) { |
|
328 return NULL; |
|
329 } |
|
330 |
|
331 int error = 0; |
|
332 WebdavNSList *nslist = wsxml_get_required_namespaces(pool, node, &error); |
|
333 if(error) { |
|
334 return NULL; |
|
335 } |
|
336 |
|
337 Writer writer; |
|
338 char buffer[512]; |
|
339 writer_init_with_stream(&writer, buf, buf_writefunc, buffer, 512); |
|
340 |
|
341 WSXmlData *data = NULL; |
|
342 if(!wsxml_write_nodes_without_nsdef(pool, &writer, node) && !writer_flush(&writer)) { |
|
343 data = pool_malloc(pool, sizeof(WSXmlData)); |
|
344 if(data) { |
|
345 data->data = pool_malloc(pool, buf->size + 1); |
|
346 if(data->data) { |
|
347 memcpy(data->data, buf->space, buf->size); |
|
348 data->data[buf->size] = '\0'; |
|
349 data->length = buf->size; |
|
350 data->namespaces = nslist; |
|
351 } |
|
352 } |
|
353 } |
|
354 |
|
355 ucx_buffer_free(buf); |
|
356 |
|
357 return data; |
|
358 } |
|
359 |
316 /***************************************************************************** |
360 /***************************************************************************** |
317 * Non public functions |
361 * Non public functions |
318 *****************************************************************************/ |
362 *****************************************************************************/ |
319 |
363 |
320 typedef struct XmlWriter { |
364 typedef struct XmlWriter { |