libidav/resource.c

branch
v1.2
changeset 481
ff477f1f7765
parent 480
7bb47ddc1b5e
child 593
3d02420c4392
--- a/libidav/resource.c	Sun Oct 07 09:14:03 2018 +0200
+++ b/libidav/resource.c	Thu Oct 11 19:29:45 2018 +0200
@@ -225,6 +225,7 @@
     data->remove = NULL;
     data->content = NULL;
     data->read = NULL;
+    data->seek = NULL;
     data->length = 0;
     return data;
 }
@@ -600,10 +601,11 @@
 }
 
 
-void dav_set_content(DavResource *res, void *stream, dav_read_func read_func) {
+void dav_set_content(DavResource *res, void *stream, dav_read_func read_func, dav_seek_func seek_func) {
     DavResourceData *data = res->data;
     data->content = stream;
     data->read = read_func;
+    data->seek = seek_func;
     data->length = 0;
 }
 
@@ -613,6 +615,7 @@
     data->content = dav_session_malloc(sn, length);
     memcpy(data->content, content, length);
     data->read = NULL;
+    data->seek = NULL;
     data->length = length;
 }
 
@@ -671,14 +674,19 @@
             AESEncrypter *enc = NULL;
             UcxBuffer *buf = NULL;
             if(data->read) {
-                enc = aes_encrypter_new(sn->key, data->content, data->read);
+                enc = aes_encrypter_new(
+                        sn->key,
+                        data->content,
+                        data->read,
+                        data->seek);
             } else {
                 buf = ucx_buffer_new(data->content, data->length, 0);
                 buf->size = data->length;
                 enc = aes_encrypter_new(
                         sn->key,
                         buf,
-                        (dav_read_func)ucx_buffer_read);
+                        (dav_read_func)ucx_buffer_read,
+                        (dav_seek_func)dav_buffer_seek);
             }
               
             // put resource
@@ -688,6 +696,7 @@
                     TRUE,
                     enc,
                     (dav_read_func)aes_read,
+                    (dav_seek_func)aes_encrypter_reset,
                     0);
             
             // get sha256 hash
@@ -715,6 +724,7 @@
                     TRUE,
                     data->content,
                     data->read,
+                    data->seek,
                     data->length);
         }
         
@@ -977,7 +987,7 @@
     if(res->iscollection) {
         code = do_mkcol_request(sn, locktoken);
     } else {
-        code = do_put_request(sn, locktoken, TRUE, "", NULL, 0); 
+        code = do_put_request(sn, locktoken, TRUE, "", NULL, NULL, 0); 
     }
     long s = 0;
     curl_easy_getinfo(handle, CURLINFO_RESPONSE_CODE, &s);

mercurial