2 * Bucket -> Object converter
4 * (c) 2004, Robert Spalek <robert@ucw.cz>
8 #include "lib/fastbuf.h"
9 #include "charset/unicode.h"
10 #include "lib/object.h"
11 #include "lib/bucket.h"
12 #include "lib/lizard.h"
13 #include "lib/buck2obj.h"
18 decode_attributes(byte *ptr, byte *end, struct odes *o)
20 /* FIXME: this forbids storing attributes with empty string as a value.
21 * Verify whether it is used or not. */
30 obj_add_attr(o, type, ptr);
37 extract_odes(struct obuck_header *hdr, struct fastbuf *body, struct odes *o, byte *buf, uns buf_len, struct lizard_buffer *lizard_buf)
39 if (hdr->type < BUCKET_TYPE_V30C)
42 obj_read_multi(body, o);
48 /* Read all the bucket into 1 buffer, 0-copy if possible. */
50 uns len = bdirect_read_prepare(body, &ptr); // WARNING: must NOT use mmaped-I/O
51 if (len < hdr->length)
53 if (hdr->length > buf_len)
58 len = bread(body, buf, hdr->length);
63 ptr = decode_attributes(ptr, end, o); // header
64 if (hdr->type == BUCKET_TYPE_V30C) // decompression
67 int res = lizard_decompress_safe(ptr, lizard_buf, len);
75 ptr = lizard_buf->ptr;
78 ptr = decode_attributes(ptr, end, o); // body