285 *isallprop = 0; |
285 *isallprop = 0; |
286 |
286 |
287 CxIterator i = cxListIterator(fields); |
287 CxIterator i = cxListIterator(fields); |
288 cx_foreach(DavQLField*, field, i) { |
288 cx_foreach(DavQLField*, field, i) { |
289 if(!cx_strcmp(field->name, CX_STR("*"))) { |
289 if(!cx_strcmp(field->name, CX_STR("*"))) { |
290 cxMapDestroy(properties); |
290 cxMapFree(properties); |
291 *isallprop = 1; |
291 *isallprop = 1; |
292 return create_allprop_propfind_request(); |
292 return create_allprop_propfind_request(); |
293 } else if(!cx_strcmp(field->name, CX_STR("-"))) { |
293 } else if(!cx_strcmp(field->name, CX_STR("-"))) { |
294 cxMapDestroy(properties); |
294 cxMapFree(properties); |
295 return create_propfind_request(sn, NULL, "propfind", 0); |
295 return create_propfind_request(sn, NULL, "propfind", 0); |
296 } else { |
296 } else { |
297 if(fl_add_properties(sn, a, properties, field->expr)) { |
297 if(fl_add_properties(sn, a, properties, field->expr)) { |
298 // TODO: set error |
298 // TODO: set error |
299 cxMapDestroy(properties); |
299 cxMapFree(properties); |
300 return NULL; |
300 return NULL; |
301 } |
301 } |
302 } |
302 } |
303 } |
303 } |
304 |
304 |
307 cx_foreach(DavProperty*, value, i) { |
307 cx_foreach(DavProperty*, value, i) { |
308 cxListAdd(list, value); |
308 cxListAdd(list, value); |
309 } |
309 } |
310 |
310 |
311 CxBuffer *reqbuf = create_propfind_request(sn, list, "propfind", 0); |
311 CxBuffer *reqbuf = create_propfind_request(sn, list, "propfind", 0); |
312 cxListDestroy(list); |
312 cxListFree(list); |
313 cxMapDestroy(properties); |
313 cxMapFree(properties); |
314 return reqbuf; |
314 return reqbuf; |
315 } |
315 } |
316 |
316 |
317 static int reset_properties(DavSession *sn, DavResult *result, DavResource *res, CxList *fields) { |
317 static int reset_properties(DavSession *sn, DavResult *result, DavResource *res, CxList *fields) { |
318 CxMap *new_properties = cxHashMapCreate(sn->mp->allocator, CX_STORE_POINTERS, 32); |
318 CxMap *new_properties = cxHashMapCreate(sn->mp->allocator, CX_STORE_POINTERS, 32); |
476 cxMempoolRegister(mp, args, (cx_destructor_func)dav_ql_free_arglist); |
476 cxMempoolRegister(mp, args, (cx_destructor_func)dav_ql_free_arglist); |
477 |
477 |
478 int isallprop; |
478 int isallprop; |
479 CxBuffer *rqbuf = fieldlist2propfindrequest(sn, mp->allocator, st->fields, &isallprop); |
479 CxBuffer *rqbuf = fieldlist2propfindrequest(sn, mp->allocator, st->fields, &isallprop); |
480 if(!rqbuf) { |
480 if(!rqbuf) { |
481 cxMempoolDestroy(mp); |
481 cxMempoolFree(mp); |
482 return result; |
482 return result; |
483 } |
483 } |
484 cxMempoolRegister(mp, rqbuf, (cx_destructor_func)cxBufferFree); |
484 cxMempoolRegister(mp, rqbuf, (cx_destructor_func)cxBufferFree); |
485 |
485 |
486 // compile field list |
486 // compile field list |
525 // get path string |
525 // get path string |
526 davqlerror_t error; |
526 davqlerror_t error; |
527 cxmutstr path = dav_format_string(mp->allocator, st->path, args, &error); |
527 cxmutstr path = dav_format_string(mp->allocator, st->path, args, &error); |
528 if(error) { |
528 if(error) { |
529 // TODO: cleanup |
529 // TODO: cleanup |
530 cxMempoolDestroy(mp); |
530 cxMempoolFree(mp); |
531 return result; |
531 return result; |
532 } |
532 } |
533 |
533 |
534 int depth = st->depth == DAV_DEPTH_PLACEHOLDER ? |
534 int depth = st->depth == DAV_DEPTH_PLACEHOLDER ? |
535 dav_ql_getarg_int(args) : st->depth; |
535 dav_ql_getarg_int(args) : st->depth; |
536 |
536 |
537 CxBuffer *where = dav_compile_expr(sn->context, mp->allocator, st->where, args); |
537 CxBuffer *where = dav_compile_expr(sn->context, mp->allocator, st->where, args); |
538 if(st->where && !where) { |
538 if(st->where && !where) { |
539 // TODO: cleanup |
539 // TODO: cleanup |
540 cxMempoolDestroy(mp); |
540 cxMempoolFree(mp); |
541 return result; |
541 return result; |
542 } |
542 } |
543 |
543 |
544 // compile order criterion |
544 // compile order criterion |
545 CxList *ordercr = NULL; |
545 CxList *ordercr = NULL; |
569 cr.descending = oc->descending; |
569 cr.descending = oc->descending; |
570 cxListAdd(ordercr, &cr); |
570 cxListAdd(ordercr, &cr); |
571 } else { |
571 } else { |
572 // error |
572 // error |
573 // TODO: cleanup |
573 // TODO: cleanup |
574 cxMempoolDestroy(mp); |
574 cxMempoolFree(mp); |
575 return result; |
575 return result; |
576 } |
576 } |
577 } else if(dav_identifier2resprop(column->srctext, &resprop)) { |
577 } else if(dav_identifier2resprop(column->srctext, &resprop)) { |
578 DavOrderCriterion cr; |
578 DavOrderCriterion cr; |
579 cr.type = 0; |
579 cr.type = 0; |
581 cr.descending = oc->descending; |
581 cr.descending = oc->descending; |
582 cxListAdd(ordercr, &cr); |
582 cxListAdd(ordercr, &cr); |
583 } else { |
583 } else { |
584 // error |
584 // error |
585 // TODO: cleanup |
585 // TODO: cleanup |
586 cxMempoolDestroy(mp); |
586 cxMempoolFree(mp); |
587 return result; |
587 return result; |
588 } |
588 } |
589 |
589 |
590 } else if(column->type == DAVQL_NUMBER) { |
590 } else if(column->type == DAVQL_NUMBER) { |
591 // TODO: implement |
591 // TODO: implement |
592 fprintf(stderr, "order by number not supported\n"); |
592 fprintf(stderr, "order by number not supported\n"); |
593 return result; |
593 return result; |
594 } else { |
594 } else { |
595 // something is broken |
595 // something is broken |
596 // TODO: cleanup |
596 // TODO: cleanup |
597 cxMempoolDestroy(mp); |
597 cxMempoolFree(mp); |
598 return result; |
598 return result; |
599 } |
599 } |
600 } |
600 } |
601 } |
601 } |
602 |
602 |
611 |
611 |
612 // reuseable response buffer |
612 // reuseable response buffer |
613 CxBuffer *rpbuf = cxBufferCreate(NULL, 4096, mp->allocator, CX_BUFFER_FREE_CONTENTS|CX_BUFFER_AUTO_EXTEND); |
613 CxBuffer *rpbuf = cxBufferCreate(NULL, 4096, mp->allocator, CX_BUFFER_FREE_CONTENTS|CX_BUFFER_AUTO_EXTEND); |
614 if(!rpbuf) { |
614 if(!rpbuf) { |
615 // TODO: cleanup |
615 // TODO: cleanup |
616 cxMempoolDestroy(mp); |
616 cxMempoolFree(mp); |
617 return result; |
617 return result; |
618 } |
618 } |
619 |
619 |
620 result.result = selroot; |
620 result.result = selroot; |
621 result.status = 0; |
621 result.status = 0; |