48 |
48 |
49 static void xmlerrorfnc(void * c, const char * msg, ... ) { |
49 static void xmlerrorfnc(void * c, const char * msg, ... ) { |
50 // nothing |
50 // nothing |
51 } |
51 } |
52 |
52 |
53 #define DO_THE_TEST |
53 //define DO_THE_TEST |
54 #include <libidav/davqlparser.h> |
54 #include <libidav/davqlparser.h> |
55 #include <libidav/davqlexec.h> |
55 #include <libidav/davqlexec.h> |
56 void test() { |
56 void test() { |
57 DavQLStatement *stmt = dav_parse_statement(S( |
57 |
58 "get * from / where lastmodified > 12")); |
|
59 |
|
60 DavSession *sn = dav_session_new(ctx, "http://test/"); |
|
61 dav_statement_exec(sn, stmt, 123, "txt"); |
|
62 |
|
63 //dav_debug_statement(stmt); |
|
64 dav_free_statement(stmt); |
|
65 } |
58 } |
66 |
59 |
67 int main(int argc, char **argv) { |
60 int main(int argc, char **argv) { |
68 xmlGenericErrorFunc fnc = xmlerrorfnc; |
61 xmlGenericErrorFunc fnc = xmlerrorfnc; |
69 initGenericErrorDefaultFunc(&fnc); |
62 initGenericErrorDefaultFunc(&fnc); |
369 if(set_session_config(sn, a)) { |
362 if(set_session_config(sn, a)) { |
370 return -1; |
363 return -1; |
371 } |
364 } |
372 |
365 |
373 char *update = cmd_getoption(a, "update"); |
366 char *update = cmd_getoption(a, "update"); |
374 time_t t = -1; |
367 time_t t = 1; |
375 if(update) { |
368 if(update) { |
376 t = util_parse_lastmodified(update); |
369 t = util_parse_lastmodified(update); |
377 } |
370 } |
378 |
371 |
379 int depth = cmd_getoption(a, "recursive") ? -1 : 1; |
372 int depth = cmd_getoption(a, "recursive") ? -1 : 1; |
380 int ret = -1; |
373 int ret = -1; |
381 DavResource *ls; |
374 DavResource *ls; |
382 while(ret != 0) { |
375 while(ret != 0) { |
|
376 /* |
383 ls = dav_query( |
377 ls = dav_query( |
384 sn, |
378 sn, |
385 "get idav:crypto-name,idav:crypto-key from %s where lastmodified > %t with depth %d", |
379 "select `idav:crypto-name`,`idav:crypto-key` from %s with depth = %d where lastmodified > %t", |
386 path, |
380 path, |
387 t, |
381 depth, |
388 depth); |
382 t); |
|
383 */ |
|
384 ls = dav_query(sn, "select * from %s", path); |
389 |
385 |
390 if(!ls) { |
386 if(!ls) { |
391 if(sn->error == DAV_UNAUTHORIZED) { |
387 if(sn->error == DAV_UNAUTHORIZED) { |
392 if(request_auth(repo, sn)) { |
388 if(request_auth(repo, sn)) { |
393 continue; |
389 continue; |
403 if(cmd_getoption(a, "list")) { |
399 if(cmd_getoption(a, "list")) { |
404 print_func = ls_print_list_elm; |
400 print_func = ls_print_list_elm; |
405 } else { |
401 } else { |
406 print_func = ls_print_elm; |
402 print_func = ls_print_elm; |
407 } |
403 } |
|
404 |
408 DavResource *child = ls->children; |
405 DavResource *child = ls->children; |
409 while(child) { |
406 while(child) { |
410 if(child->name[0] != '.' || show_all) { |
407 if(child->name[0] != '.' || show_all) { |
411 print_func(child, a); |
408 print_func(child, a); |
412 } |
409 } |
592 if(set_session_config(sn, a)) { |
589 if(set_session_config(sn, a)) { |
593 return -1; |
590 return -1; |
594 } |
591 } |
595 |
592 |
596 char *update = cmd_getoption(a, "update"); |
593 char *update = cmd_getoption(a, "update"); |
597 time_t t = 0; |
594 time_t t = -1; |
598 if(update) { |
595 if(update) { |
599 t = util_parse_lastmodified(update); |
596 t = util_parse_lastmodified(update); |
600 } |
597 } |
601 |
598 |
602 int recursive = cmd_getoption(a, "recursive") ? 1 : 0; |
599 int recursive = cmd_getoption(a, "recursive") ? 1 : 0; |
603 DavResource *res; |
600 DavResource *res; |
604 |
601 |
605 int depth = recursive ? -1 : 1; |
602 int depth = recursive ? -1 : 1; |
606 res = dav_query( |
603 res = dav_query( |
607 sn, |
604 sn, |
608 "get - from %s where lastmodified > %t with depth %d", |
605 "select - from %s with = depth %d where lastmodified > %t", |
609 path, |
606 path, |
610 t, |
607 t, |
611 depth); |
608 depth); |
612 |
609 |
613 if(!res) { |
610 if(!res) { |
795 |
792 |
796 return ret; |
793 return ret; |
797 } |
794 } |
798 |
795 |
799 int put_file(Repository *repo, CmdArgs *a, DavSession *sn, char *path, char *name, FILE *in) { |
796 int put_file(Repository *repo, CmdArgs *a, DavSession *sn, char *path, char *name, FILE *in) { |
800 DavResource *res = dav_query(sn, "get - from %s", path); |
797 DavResource *res = dav_query(sn, "select - from %s", path); |
801 if(!res) { |
798 if(!res) { |
802 if(sn->error == DAV_NOT_FOUND) { |
799 if(sn->error == DAV_NOT_FOUND) { |
803 res = dav_resource_new(sn, path); |
800 res = dav_resource_new(sn, path); |
804 if(dav_create(res)) { |
801 if(dav_create(res)) { |
805 fprintf(stderr, "Cannot create resource.\n"); |
802 fprintf(stderr, "Cannot create resource.\n"); |