59 xmlGenericErrorFunc fnc = xmlerrorfnc; |
59 xmlGenericErrorFunc fnc = xmlerrorfnc; |
60 initGenericErrorDefaultFunc(&fnc); |
60 initGenericErrorDefaultFunc(&fnc); |
61 ctx = dav_context_new(); |
61 ctx = dav_context_new(); |
62 load_config(ctx); |
62 load_config(ctx); |
63 //dav_add_namespace(ctx, "U", "http://www.uap-core.de/"); |
63 //dav_add_namespace(ctx, "U", "http://www.uap-core.de/"); |
64 |
|
65 //test(); |
64 //test(); |
66 |
65 |
67 memcpy(ctx->http_proxy, get_http_proxy(), sizeof(Proxy)); |
66 memcpy(ctx->http_proxy, get_http_proxy(), sizeof(Proxy)); |
68 memcpy(ctx->https_proxy, get_https_proxy(), sizeof(Proxy)); |
67 memcpy(ctx->https_proxy, get_https_proxy(), sizeof(Proxy)); |
69 |
68 |
102 } else if(!strcasecmp(cmd, "get-property")) { |
102 } else if(!strcasecmp(cmd, "get-property")) { |
103 ret = cmd_get_property(args); |
103 ret = cmd_get_property(args); |
104 } else { |
104 } else { |
105 print_usage(argv[0]); |
105 print_usage(argv[0]); |
106 } |
106 } |
|
107 |
107 dav_context_destroy(ctx); |
108 dav_context_destroy(ctx); |
|
109 cmd_args_free(args); |
|
110 free_config(); |
|
111 xmlCleanupParser(); |
|
112 curl_global_cleanup(); |
108 |
113 |
109 return ret; |
114 return ret; |
110 } |
115 } |
111 |
116 |
112 void print_usage(char *cmd) { |
117 void print_usage(char *cmd) { |
583 return -1; |
590 return -1; |
584 } |
591 } |
585 |
592 |
586 int ret = get_resource(repo, res, a, outfile); |
593 int ret = get_resource(repo, res, a, outfile); |
587 |
594 |
|
595 free(path); |
588 return ret; |
596 return ret; |
589 } |
597 } |
590 |
598 |
591 int get_resource(Repository *repo, DavResource *res, CmdArgs *a, char *out) { |
599 int get_resource(Repository *repo, DavResource *res, CmdArgs *a, char *out) { |
592 size_t outlen = strlen(out); |
600 size_t outlen = strlen(out); |
675 ret = put_file(repo, a, sn, path, "stdin", in); |
683 ret = put_file(repo, a, sn, path, "stdin", in); |
676 } else { |
684 } else { |
677 ret = put_entry(repo, a, sn, path, file); |
685 ret = put_entry(repo, a, sn, path, file); |
678 } |
686 } |
679 |
687 |
|
688 free(path); |
680 return ret; |
689 return ret; |
681 } |
690 } |
682 |
691 |
683 int put_entry(Repository *repo, CmdArgs *a, DavSession *sn, char *path, char *file) { |
692 int put_entry(Repository *repo, CmdArgs *a, DavSession *sn, char *path, char *file) { |
684 int recursive = cmd_getoption(a, "recursive") ? 1 : 0; |
693 int recursive = cmd_getoption(a, "recursive") ? 1 : 0; |
754 return -1; |
763 return -1; |
755 } |
764 } |
756 } else if(res->iscollection) { |
765 } else if(res->iscollection) { |
757 // TODO: free res |
766 // TODO: free res |
758 char *newpath = util_concat_path(path, name); |
767 char *newpath = util_concat_path(path, name); |
759 free(path); |
|
760 path = newpath; |
768 path = newpath; |
761 res = dav_resource_new(sn, path); |
769 res = dav_resource_new(sn, path); |
|
770 free(newpath); |
762 int ret = put_file(repo, a, sn, res->path, NULL, in); |
771 int ret = put_file(repo, a, sn, res->path, NULL, in); |
763 // TODO: free res |
772 // TODO: free res |
764 return ret; |
773 return ret; |
765 } |
774 } |
766 |
775 |
847 print_resource_error(sn, res->path); |
857 print_resource_error(sn, res->path); |
848 fprintf(stderr, "Cannot create collection.\n"); |
858 fprintf(stderr, "Cannot create collection.\n"); |
849 return -1; |
859 return -1; |
850 } |
860 } |
851 |
861 |
|
862 free(path); |
852 return 0; |
863 return 0; |
853 } |
864 } |
854 |
865 |
855 |
866 |
856 static size_t get_date_header_cb(void *header, int s, int n, void *data) { |
867 static size_t get_date_header_cb(void *header, int s, int n, void *data) { |
973 print_resource_error(sn, res->path); |
986 print_resource_error(sn, res->path); |
974 fprintf(stderr, "Cannot set property.\n"); |
987 fprintf(stderr, "Cannot set property.\n"); |
975 return -1; |
988 return -1; |
976 } |
989 } |
977 |
990 |
|
991 free(path); |
978 return 0; |
992 return 0; |
979 } |
993 } |
980 |
994 |
981 char* stdin2str() { |
995 char* stdin2str() { |
982 UcxBuffer *buf = ucx_buffer_new(NULL, 1024, UCX_BUFFER_AUTOEXTEND); |
996 UcxBuffer *buf = ucx_buffer_new(NULL, 1024, UCX_BUFFER_AUTOEXTEND); |