]> mj.ucw.cz Git - libucw.git/blobdiff - lib/buckettool.c
`buckettool -c' (cat) now separates buckets by an empty line.
[libucw.git] / lib / buckettool.c
index f825957e3415b7854045a68c180e85be249cdeec..76b8fc37c21f5586074490981ecee352eefbf23a 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *     Sherlock Library -- Bucket Manipulation Tool
  *
- *     (c) 2001 Martin Mares <mj@ucw.cz>
+ *     (c) 2001--2004 Martin Mares <mj@ucw.cz>
  *     (c) 2004 Robert Spalek <robert@ucw.cz>
  *
  *     This software may be freely distributed and used according to the terms
 #include "lib/fastbuf.h"
 #include "lib/lfs.h"
 #include "lib/conf.h"
-#include "lib/pools.h"
+#include "lib/mempool.h"
 #include "lib/object.h"
-#include "lib/buck2obj.h"
-#include "lib/obj2buck.h"
 #include "lib/lizard.h"
-#include "charset/unistream.h"
+#include "lib/bbuf.h"
+#include "lib/ff-utf8.h"
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -141,10 +140,6 @@ extract(char *id)
   obuck_cleanup();
 }
 
-#define        GBUF_TYPE       byte
-#define        GBUF_PREFIX(x)  bb_##x
-#include "lib/gbuf.h"
-
 static void
 insert(byte *arg)
 {
@@ -161,6 +156,8 @@ insert(byte *arg)
     type = BUCKET_TYPE_PLAIN;
   else if (sscanf(arg, "%x", &type) != 1)
     die("Type `%s' is not a hexadecimal number");
+  if (type < 10)
+    type += BUCKET_TYPE_PLAIN;
   attr_set_type(type);
 
   in = bfdopen_shared(0, 4096);
@@ -204,6 +201,11 @@ insert(byte *arg)
        bputl(b, lizard_filled
 #if 0  //TEST error resilience: write wrong length
            +1
+#endif
+           );
+       bputl(b, adler32(lizard_buf.ptr, lizard_filled)
+#if 0  //TEST error resilience: write wrong checksum
+           +1
 #endif
            );
        uns want_len = lizard_filled * LIZARD_MAX_MULTIPLY + LIZARD_MAX_ADD;
@@ -252,6 +254,7 @@ cat(void)
       }
       else
        dump_parsed_bucket(out, &h, b);
+      bputc(out, '\n');
     }
   bclose(out);
   obuck_cleanup();