]> mj.ucw.cz Git - eval.git/commitdiff
Fix libsh (I have pruned it too much).
authorMartin Mares <mj@ucw.cz>
Thu, 15 May 2008 10:14:34 +0000 (12:14 +0200)
committerMartin Mares <mj@ucw.cz>
Thu, 15 May 2008 10:14:34 +0000 (12:14 +0200)
sherlock/Makefile
sherlock/obj-linear.c [deleted file]
sherlock/sherlock.h [new file with mode: 0644]

index 23a6f26b87bb2c3ab45ec29ec729efc679cd5f57..e53f38310f657932d26ca43320b86597913db45b 100644 (file)
@@ -2,8 +2,10 @@
 
 DIRS+=sherlock
 
+LIBSH+=$(o)/sherlock/libsh.pc
+
 LIBSH_MODS= \
-       object bucket buck2obj obj2buck obj-linear obj-format \
+       object buck2obj obj2buck obj-format \
        attrset conf-parse
 
 LIBSH_MOD_PATHS=$(addprefix $(o)/sherlock/,$(LIBSH_MODS))
diff --git a/sherlock/obj-linear.c b/sherlock/obj-linear.c
deleted file mode 100644 (file)
index cfde3ad..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- *     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;
-}
diff --git a/sherlock/sherlock.h b/sherlock/sherlock.h
new file mode 100644 (file)
index 0000000..0f4b2da
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ *     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