From: Jonathan Dieter Date: Thu, 3 May 2018 08:00:11 +0000 (+0300) Subject: Buzhash integration into zck and some small changes to make buzhash work X-Git-Tag: archive/raspbian/1.1.9+ds1-1+rpi1~1^2~295 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=800c0914227ea996202649b1441357909d0b3ffc;p=zchunk.git Buzhash integration into zck and some small changes to make buzhash work correctly Signed-off-by: Jonathan Dieter --- diff --git a/src/buzhash/buzhash.c b/src/buzhash/buzhash.c index f3da669..7806271 100644 --- a/src/buzhash/buzhash.c +++ b/src/buzhash/buzhash.c @@ -1,8 +1,32 @@ +/* + * Copyright (c) 2015, the urlblock developers. + * Copyright (c) 2018 Jonathan Dieter + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +y #include "buzhash.h" -#include "util.h" #include +#define rol32(v,s) (((v) << (s)) | ((v) >> (32 - (s)))) + const uint32_t buzhash_table[] = { 0x458be752, 0xc10748cc, 0xfbbcdbb8, 0x6ded5b68, 0xb10a82b5, 0x20d75648, 0xdfc5665f, 0xa8428801, @@ -70,7 +94,7 @@ const uint32_t buzhash_table[] = { 0x7bf7cabc, 0xf9c18d66, 0x593ade65, 0xd95ddf11, }; -const size_t buzhash_width = 4; +const size_t buzhash_width = 4096; uint32_t buzhash (const char *s) @@ -87,5 +111,5 @@ buzhash (const char *s) uint32_t buzhash_update (const char *s, uint32_t h) { - return rol32 (h, 1) ^ rol32 (buzhash_table[(size_t) s[0]], buzhash_width) ^ buzhash_table[(size_t) s[buzhash_width]]; + return rol32 (h, 1) ^ rol32 (buzhash_table[(size_t) (s-buzhash_width)[0]], buzhash_width) ^ buzhash_table[(size_t) s[0]]; } diff --git a/src/zck.c b/src/zck.c index 7594d76..3d2a7f0 100644 --- a/src/zck.c +++ b/src/zck.c @@ -34,11 +34,9 @@ #include #include +#include "buzhash/buzhash.h" #include "memmem.h" -#define WINDOW_SIZE 4096 -#define MATCH_SUM WINDOW_SIZE-1 - int main (int argc, char *argv[]) { char *out_name; char *dict = NULL; @@ -134,7 +132,7 @@ int main (int argc, char *argv[]) { close(in_fd); /* Chunk based on string in argv[2] (Currently with ugly hack to group srpms together) */ - if(True) { + if(False) { char *found = data; char *search = found; char *prev_srpm = memmem(search, in_size - (search-data), "