From 719ccdc5a58efc9531a9b0d35ee358da7650cef3 Mon Sep 17 00:00:00 2001 From: Stella Lau Date: Sun, 9 Jul 2017 22:45:54 -0700 Subject: [PATCH] Update mainfile --- contrib/long_distance_matching/main.c | 29 +++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/contrib/long_distance_matching/main.c b/contrib/long_distance_matching/main.c index ddf5145f..67144166 100644 --- a/contrib/long_distance_matching/main.c +++ b/contrib/long_distance_matching/main.c @@ -1,12 +1,31 @@ +#include #include #include #include +#include +#include #include "ldm.h" #define BUF_SIZE 16*1024 // Block size #define LDM_HEADER_SIZE 8 +/* +static size_t compress_file_mmap(FILE *in, FILE *out, size_t *size_in, + size_t *size_out) { + char *src, *dst; + struct stat statbuf; + + if (fstat(in, &statbuf) < 0) { + printf("fstat error\n"); + return 1; + } + + + return 0; +} +*/ + static size_t compress_file(FILE *in, FILE *out, size_t *size_in, size_t *size_out) { char *src, *buf = NULL; @@ -26,7 +45,6 @@ static size_t compress_file(FILE *in, FILE *out, size_t *size_in, goto cleanup; } - for (;;) { k = fread(src, 1, BUF_SIZE, in); if (k == 0) @@ -37,10 +55,8 @@ static size_t compress_file(FILE *in, FILE *out, size_t *size_in, // n = k; // offset += n; - offset = k; - count_out += k; - -// k = fwrite(src, 1, offset, out); + offset = n; + count_out += n; k = fwrite(buf, 1, offset, out); if (k < offset) { @@ -94,8 +110,6 @@ static size_t decompress_file(FILE *in, FILE *out) { } } - // TODO - /* Decompress: * Continue while there is more input to read. */ @@ -220,7 +234,6 @@ int main(int argc, char *argv[]) { fclose(inpFp); } - return 0; }