From fd456bc8fba828a8ca32945cc0ab574d555c2547 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Thu, 15 May 2008 12:14:34 +0200 Subject: [PATCH] Fix libsh (I have pruned it too much). --- sherlock/Makefile | 4 ++- sherlock/obj-linear.c | 65 ------------------------------------------- sherlock/sherlock.h | 60 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+), 66 deletions(-) delete mode 100644 sherlock/obj-linear.c create mode 100644 sherlock/sherlock.h diff --git a/sherlock/Makefile b/sherlock/Makefile index 23a6f26..e53f383 100644 --- a/sherlock/Makefile +++ b/sherlock/Makefile @@ -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 index cfde3ad..0000000 --- a/sherlock/obj-linear.c +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Sherlock Library -- Linear Representation of Objects - * - * (c) 2005 Martin Mares - * (c) 2005 Robert Spalek - * - * 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 index 0000000..0f4b2da --- /dev/null +++ b/sherlock/sherlock.h @@ -0,0 +1,60 @@ +/* + * Sherlock Library -- Main Include File + * + * (c) 1997--2004 Martin Mares + */ + +/* + * 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 -- 2.39.2