264 DavQLStackObj field_result; |
264 DavQLStackObj field_result; |
265 if(!dav_exec_expr(field->code, res, &field_result)) { |
265 if(!dav_exec_expr(field->code, res, &field_result)) { |
266 sstr_t str; |
266 sstr_t str; |
267 str.ptr = NULL; |
267 str.ptr = NULL; |
268 str.length = 0; |
268 str.length = 0; |
|
269 DavXmlNode *node = NULL; |
269 if(field_result.type == 0) { |
270 if(field_result.type == 0) { |
270 str = ucx_asprintf( |
271 str = ucx_asprintf( |
271 sn->mp->allocator, |
272 sn->mp->allocator, |
272 "%d", |
273 "%d", |
273 field_result.data.integer); |
274 field_result.data.integer); |
274 } else { |
275 } else if(field_result.type == 1) { |
275 if(field_result.data.string) { |
276 if(field_result.data.string) { |
276 str = sstrdup_a(sn->mp->allocator, sstrn( |
277 str = sstrdup_a(sn->mp->allocator, sstrn( |
277 field_result.data.string, |
278 field_result.data.string, |
278 field_result.length)); |
279 field_result.length)); |
279 } |
280 } |
|
281 } else if(field_result.type == 2) { |
|
282 // TODO: |
|
283 } else { |
|
284 // unknown type |
|
285 // TODO: error |
|
286 resource_free_properties(sn, new_properties); |
|
287 return -1; |
280 } |
288 } |
281 if(str.ptr) { |
289 if(str.ptr) { |
|
290 node = dav_session_malloc(sn, sizeof(DavXmlNode)); |
|
291 memset(node, 0, sizeof(DavXmlNode)); |
|
292 node->type = DAV_XML_TEXT; |
|
293 node->content = str.ptr; |
|
294 node->contentlength = str.length; |
|
295 } |
|
296 if(node) { |
282 UcxKey key = dav_property_key(field->ns, field->name); |
297 UcxKey key = dav_property_key(field->ns, field->name); |
283 ucx_map_put(new_properties, key, str.ptr); |
298 ucx_map_put(new_properties, key, node); |
284 free(key.data); |
299 free(key.data); |
285 } |
300 } |
286 } else { |
301 } else { |
287 // TODO: error |
302 // TODO: error |
288 resource_free_properties(sn, new_properties); |
303 resource_free_properties(sn, new_properties); |