198 ucx_list_free(list); |
198 ucx_list_free(list); |
199 return reqbuf; |
199 return reqbuf; |
200 } |
200 } |
201 |
201 |
202 static int reset_properties(DavSession *sn, DavResult *result, DavResource *res, UcxList *fields) { |
202 static int reset_properties(DavSession *sn, DavResult *result, DavResource *res, UcxList *fields) { |
203 return 0; |
203 //return 0; |
204 UcxMap *new_properties = ucx_map_new_a(sn->mp->allocator, 32); |
204 UcxMap *new_properties = ucx_map_new_a(sn->mp->allocator, 32); |
205 DavResourceData *data = (DavResourceData*)res->data; |
205 DavResourceData *data = (DavResourceData*)res->data; |
206 |
206 |
207 // add basic properties |
207 // add basic properties |
208 char *value; |
208 char *value; |
253 UCX_FOREACH(elm, fields) { |
253 UCX_FOREACH(elm, fields) { |
254 DavCompiledField *field = elm->data; |
254 DavCompiledField *field = elm->data; |
255 DavQLStackObj field_result; |
255 DavQLStackObj field_result; |
256 if(!dav_exec_expr(field->code, res, &field_result)) { |
256 if(!dav_exec_expr(field->code, res, &field_result)) { |
257 sstr_t str; |
257 sstr_t str; |
|
258 str.ptr = NULL; |
|
259 str.length = 0; |
258 if(field_result.type == 0) { |
260 if(field_result.type == 0) { |
259 str = ucx_asprintf( |
261 str = ucx_asprintf( |
260 sn->mp->allocator, |
262 sn->mp->allocator, |
261 "%d", |
263 "%d", |
262 field_result.data.integer); |
264 field_result.data.integer); |
263 } else { |
265 } else { |
264 str = sstrdup_a(sn->mp->allocator, sstrn( |
266 if(field_result.data.string) { |
265 field_result.data.string, |
267 str = sstrdup_a(sn->mp->allocator, sstrn( |
266 field_result.length)); |
268 field_result.data.string, |
|
269 field_result.length)); |
|
270 } |
267 } |
271 } |
268 if(str.ptr) { |
272 if(str.ptr) { |
269 UcxKey key = dav_property_key(field->ns, field->name); |
273 UcxKey key = dav_property_key(field->ns, field->name); |
270 ucx_map_put(new_properties, key, str.ptr); |
274 ucx_map_put(new_properties, key, str.ptr); |
271 } |
275 } |
282 ucx_map_remove(data->properties, ct_key); |
286 ucx_map_remove(data->properties, ct_key); |
283 ucx_map_remove(data->properties, rt_key); |
287 ucx_map_remove(data->properties, rt_key); |
284 ucx_map_remove(data->properties, cn_key); |
288 ucx_map_remove(data->properties, cn_key); |
285 ucx_map_remove(data->properties, ck_key); |
289 ucx_map_remove(data->properties, ck_key); |
286 |
290 |
287 resource_free_properties(sn, data->properties); |
291 //resource_free_properties(sn, data->properties); |
288 data->properties = new_properties; |
292 data->properties = new_properties; |
|
293 //printf("(%s) new properties: ", res->name, data->properties); |
|
294 |
|
295 free(cl_key.data); |
|
296 free(cd_key.data); |
|
297 free(lm_key.data); |
|
298 free(ct_key.data); |
|
299 free(rt_key.data); |
|
300 free(cn_key.data); |
|
301 free(ck_key.data); |
289 |
302 |
290 return 0; |
303 return 0; |
291 } |
304 } |
292 |
305 |
293 /* |
306 /* |
826 } |
839 } |
827 case DAVQL_CMD_TIMESTAMP: { |
840 case DAVQL_CMD_TIMESTAMP: { |
828 //printf("timestamp %d\n", cmd.data.timestamp); |
841 //printf("timestamp %d\n", cmd.data.timestamp); |
829 obj.type = 0; |
842 obj.type = 0; |
830 obj.length = 0; |
843 obj.length = 0; |
831 obj.data.integer = (int)cmd.data.timestamp; |
844 obj.data.integer = (int64_t)cmd.data.timestamp; |
832 DAVQL_PUSH(obj); |
845 DAVQL_PUSH(obj); |
833 break; |
846 break; |
834 } |
847 } |
835 case DAVQL_CMD_RES_IDENTIFIER: { |
848 case DAVQL_CMD_RES_IDENTIFIER: { |
836 char *rid[8] = {"name", "path", "href", "contentlength", "contenttype", "creationdate", "lastmodified", "iscollection"}; |
849 char *rid[8] = {"name", "path", "href", "contentlength", "contenttype", "creationdate", "lastmodified", "iscollection"}; |