| 35 #include "utils.h" |
35 #include "utils.h" |
| 36 #include "session.h" |
36 #include "session.h" |
| 37 #include "methods.h" |
37 #include "methods.h" |
| 38 #include "crypto.h" |
38 #include "crypto.h" |
| 39 #include <cx/buffer.h> |
39 #include <cx/buffer.h> |
| 40 #include <cx/utils.h> |
|
| 41 #include <cx/hash_map.h> |
40 #include <cx/hash_map.h> |
| 42 #include <cx/printf.h> |
41 #include <cx/printf.h> |
| 43 #include <cx/mempool.h> |
42 #include <cx/mempool.h> |
| 44 #include <cx/array_list.h> |
43 #include <cx/array_list.h> |
| 45 |
44 |
| 833 |
832 |
| 834 static int dav_seek_h(void *stream, long offset, int whence) { |
833 static int dav_seek_h(void *stream, long offset, int whence) { |
| 835 HashStream *s = stream; |
834 HashStream *s = stream; |
| 836 if(offset == 0 && whence == SEEK_SET) { |
835 if(offset == 0 && whence == SEEK_SET) { |
| 837 unsigned char buf[DAV_SHA256_DIGEST_LENGTH]; |
836 unsigned char buf[DAV_SHA256_DIGEST_LENGTH]; |
| 838 dav_sha256_final(s->sha, buf); |
837 dav_sha256_final_free(s->sha, buf); |
| 839 s->sha = NULL; |
838 s->sha = NULL; |
| 840 } else { |
839 } else { |
| 841 s->error = 1; |
840 s->error = 1; |
| 842 } |
841 } |
| 843 return s->seek(s->stream, offset, whence); |
842 return s->seek(s->stream, offset, whence); |
| 936 dav_read_h, |
935 dav_read_h, |
| 937 (dav_seek_func)dav_seek_h, |
936 (dav_seek_func)dav_seek_h, |
| 938 data->length); |
937 data->length); |
| 939 |
938 |
| 940 if(hstr.sha) { |
939 if(hstr.sha) { |
| 941 dav_sha256_final(hstr.sha, (unsigned char*)data->hash); |
940 dav_sha256_final_free(hstr.sha, (unsigned char*)data->hash); |
| 942 char *hash = util_hexstr((unsigned char*)data->hash, 32); |
941 char *hash = util_hexstr((unsigned char*)data->hash, 32); |
| 943 dav_set_string_property_ns(res, DAV_NS, "content-hash", hash); |
942 dav_set_string_property_ns(res, DAV_NS, "content-hash", hash); |
| 944 free(hash); |
943 free(hash); |
| 945 } |
944 } |
| 946 } else { |
945 } else { |
| 1597 property->ns->prefix = n->ns->prefix ? |
1596 property->ns->prefix = n->ns->prefix ? |
| 1598 dav_session_strdup(sn, (const char*)n->ns->prefix) : NULL; |
1597 dav_session_strdup(sn, (const char*)n->ns->prefix) : NULL; |
| 1599 property->value = n->children ? dav_convert_xml(sn, n->children) : NULL; |
1598 property->value = n->children ? dav_convert_xml(sn, n->children) : NULL; |
| 1600 |
1599 |
| 1601 cxmutstr propkey = dav_property_key(property->ns->name, property->name); |
1600 cxmutstr propkey = dav_property_key(property->ns->name, property->name); |
| 1602 cxMapPut(map, cx_hash_key_cxstr(propkey), property); |
1601 cxMapPut(map, propkey, property); |
| 1603 cx_strfree(&propkey); |
1602 cx_strfree(&propkey); |
| 1604 } |
1603 } |
| 1605 n = n->next; |
1604 n = n->next; |
| 1606 } |
1605 } |
| 1607 |
1606 |