+++ /dev/null
-/*
- * Sherlock Library -- Linear Representation of Objects
- *
- * (c) 2005 Martin Mares <mj@ucw.cz>
- * (c) 2005 Robert Spalek <robert@ucw.cz>
- *
- * This software may be freely distributed and used according to the terms
- * of the GNU Lesser General Public License.
- */
-
-#include "sherlock/sherlock.h"
-#include "lib/fastbuf.h"
-#include "lib/unaligned.h"
-#include "lib/lizard.h"
-#include "sherlock/object.h"
-#include "sherlock/lizard-fb.h"
-
-byte *
-obj_linearize(struct odes *d, uns min_compress, uns *plen)
-{
- // Create uncompressed linearization
- put_attr_set_type(BUCKET_TYPE_V33);
- uns size = size_object(d);
- byte *out = xmalloc(size+LIZARD_COMPRESS_HEADER + LIZARD_NEEDS_CHARS) + LIZARD_COMPRESS_HEADER;
- byte *t = put_object(out, d);
- ASSERT(t == out+size);
-
- struct lizard_block_req req = {
- .type = BUCKET_TYPE_V33_LIZARD,
- .ratio = min_compress / 100.,
- .in_ptr = out,
- .in_len = size,
- .out_ptr = NULL,
- .out_len = 0,
- };
- // Allocate a buffer for compressed data
- int res = lizard_compress_req(&req);
- ASSERT(res <= 0);
- byte *buf = res<0 ? req.out_ptr=xmalloc(req.out_len+=LIZARD_COMPRESS_HEADER) : NULL;
- res = lizard_compress_req_header(&req, 1);
- ASSERT(res > 0);
- if (req.out_ptr != out-LIZARD_COMPRESS_HEADER)
- xfree(out-LIZARD_COMPRESS_HEADER);
- else if (buf)
- xfree(buf);
-
- *plen = req.out_len;
- return req.out_ptr;
-}
-
-struct odes *
-obj_delinearize(struct buck2obj_buf *bbuf, struct mempool *mp, byte *buf, uns len, uns destructive)
-{
- struct odes *o = obj_new(mp);
- ASSERT(len >= LIZARD_COMPRESS_HEADER);
- uns buck_type = buf[0] + BUCKET_TYPE_PLAIN;
-
- struct fastbuf fb;
- uns sh = LIZARD_COMPRESS_HEADER - 1;
- fbbuf_init_read(&fb, buf+sh, len-sh, destructive);
- if (buck2obj_parse(bbuf, buck_type, len-sh, &fb, NULL, NULL, o, 1) < 0)
- return NULL;
- else
- return o;
-}
--- /dev/null
+/*
+ * Sherlock Library -- Main Include File
+ *
+ * (c) 1997--2004 Martin Mares <mj@ucw.cz>
+ */
+
+/*
+ * This file should be included as the very first include in all
+ * source files, especially before all OS includes since it sets
+ * up libc feature macros.
+ */
+
+#ifndef _SHERLOCK_LIB_H
+#define _SHERLOCK_LIB_H
+
+#include "lib/lib.h"
+
+#ifdef CONFIG_MAX_CONTEXTS
+#define CONFIG_CONTEXTS
+#endif
+
+/* Version string */
+
+#define SHER_VER SHERLOCK_VERSION SHERLOCK_VERSION_SUFFIX
+
+/* Types */
+
+typedef u32 oid_t; /* Object ID */
+
+#ifdef CONFIG_LARGE_FILES /* File positions */
+#define BYTES_PER_O 5
+#define bgeto(f) bget5(f)
+#define bputo(f,l) bput5(f,l)
+#define GET_O(p) GET_U40(p)
+#define PUT_O(p,x) PUT_U40(p,x)
+#else
+#define BYTES_PER_O 4
+#define bgeto(f) bgetl(f)
+#define bputo(f,l) bputl(f,l)
+#define GET_O(p) GET_U32(p)
+#define PUT_O(p,x) PUT_U32(p,x)
+#endif
+
+/* Area ID's */
+
+#ifdef CONFIG_AREAS
+typedef u32 area_t;
+#define AREA_NONE 0
+#define AREA_ANY ~0U
+#else
+typedef struct { } area_t;
+#define AREA_NONE (area_t){}
+#define AREA_ANY (area_t){}
+#endif
+
+/* An alias for the libucw logging function */
+
+#define log msg
+
+#endif