Date: Wed, 21 Aug 2013 13:57:48 GMT From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r256237 - in soc2013/dpl/head/lib/libzcap: . test zlibworker Message-ID: <201308211357.r7LDvm5S016151@socsvn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: dpl Date: Wed Aug 21 13:57:48 2013 New Revision: 256237 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=256237 Log: Simplified code. Deleted: soc2013/dpl/head/lib/libzcap/inffast.c soc2013/dpl/head/lib/libzcap/inffast.h soc2013/dpl/head/lib/libzcap/inftrees.c soc2013/dpl/head/lib/libzcap/inftrees.h soc2013/dpl/head/lib/libzcap/trees.c soc2013/dpl/head/lib/libzcap/trees.h Modified: soc2013/dpl/head/lib/libzcap/Makefile soc2013/dpl/head/lib/libzcap/capsicum.c soc2013/dpl/head/lib/libzcap/commands.c soc2013/dpl/head/lib/libzcap/infback.c soc2013/dpl/head/lib/libzcap/inflate.c soc2013/dpl/head/lib/libzcap/inflate.h soc2013/dpl/head/lib/libzcap/test/zcaplibtest.c soc2013/dpl/head/lib/libzcap/zlibworker/commands.c soc2013/dpl/head/lib/libzcap/zlibworker/zlibworker.c Modified: soc2013/dpl/head/lib/libzcap/Makefile ============================================================================== --- soc2013/dpl/head/lib/libzcap/Makefile Wed Aug 21 08:01:52 2013 (r256236) +++ soc2013/dpl/head/lib/libzcap/Makefile Wed Aug 21 13:57:48 2013 (r256237) @@ -26,10 +26,7 @@ SRCS+= gzread.c SRCS+= gzwrite.c SRCS+= infback.c -SRCS+= inffast.c SRCS+= inflate.c -SRCS+= inftrees.c -SRCS+= trees.c SRCS+= uncompr.c SRCS+= zopen.c SRCS+= zutil.c Modified: soc2013/dpl/head/lib/libzcap/capsicum.c ============================================================================== --- soc2013/dpl/head/lib/libzcap/capsicum.c Wed Aug 21 08:01:52 2013 (r256236) +++ soc2013/dpl/head/lib/libzcap/capsicum.c Wed Aug 21 13:57:48 2013 (r256237) @@ -54,13 +54,12 @@ nvlist_t * sendCommand( nvlist_t *nvl ) { + nvlist_t *new; if( nvlist_send(sv[1], nvl) != 0 ) err(1, "zcaplib: nvlist_send()"); - - if ((nvl = nvlist_recv(sv[1])) == NULL) + if ((new = nvlist_recv(sv[1])) == NULL) err(1, "nvlist_recv(): nvl is NULL"); - - return (nvl); + return (new); } void killChild(void) { Modified: soc2013/dpl/head/lib/libzcap/commands.c ============================================================================== --- soc2013/dpl/head/lib/libzcap/commands.c Wed Aug 21 08:01:52 2013 (r256236) +++ soc2013/dpl/head/lib/libzcap/commands.c Wed Aug 21 13:57:48 2013 (r256237) @@ -98,8 +98,8 @@ void destroy(void) { - nvlist_destroy(nvl); nvlist_destroy(args); + nvlist_destroy(nvl); nvlist_destroy(result); } @@ -1259,8 +1259,9 @@ nvlist_add_binary(args, "buf", buf, len); nvlist_add_number(args, "len", len); nvlist_add_nvlist(nvl, "args", args); - + fprintf(stderr, "Before sending: %p\n", nvl); result = sendCommand(nvl); + fprintf(stderr, "After sending: %p\n", result); ret = nvlist_take_number(result, "result"); destroy(); return(ret); Modified: soc2013/dpl/head/lib/libzcap/infback.c ============================================================================== --- soc2013/dpl/head/lib/libzcap/infback.c Wed Aug 21 08:01:52 2013 (r256236) +++ soc2013/dpl/head/lib/libzcap/infback.c Wed Aug 21 13:57:48 2013 (r256237) @@ -4,9 +4,6 @@ */ #include "zutil.h" -#include "inftrees.h" -#include "inflate.h" -#include "inffast.h" extern int zcapcmd_inflateBackInit(); int ZEXPORT inflateBackInit_(strm, windowBits, window, version, stream_size) Modified: soc2013/dpl/head/lib/libzcap/inflate.c ============================================================================== --- soc2013/dpl/head/lib/libzcap/inflate.c Wed Aug 21 08:01:52 2013 (r256236) +++ soc2013/dpl/head/lib/libzcap/inflate.c Wed Aug 21 13:57:48 2013 (r256237) @@ -4,9 +4,7 @@ */ #include "zutil.h" -#include "inftrees.h" #include "inflate.h" -#include "inffast.h" #ifdef MAKEFIXED # ifndef BUILDFIXED Modified: soc2013/dpl/head/lib/libzcap/inflate.h ============================================================================== --- soc2013/dpl/head/lib/libzcap/inflate.h Wed Aug 21 08:01:52 2013 (r256236) +++ soc2013/dpl/head/lib/libzcap/inflate.h Wed Aug 21 13:57:48 2013 (r256237) @@ -3,10 +3,34 @@ * For conditions of distribution and use, see copyright notice in zlib.h */ -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ +typedef struct { + unsigned char op; /* operation, extra bits, table bits */ + unsigned char bits; /* bits in this part of the code */ + unsigned short val; /* offset in table or code value */ +} code; + + +/* Maximum size of the dynamic table. The maximum number of code structures is + 1444, which is the sum of 852 for literal/length codes and 592 for distance + codes. These values were found by exhaustive searches using the program + examples/enough.c found in the zlib distribtution. The arguments to that + program are the number of symbols, the initial root table size, and the + maximum bit length of a code. "enough 286 9 15" for literal/length codes + returns returns 852, and "enough 30 6 15" for distance codes returns 592. + The initial root table size (9 or 6) is found in the fifth argument of the + inflate_table() calls in inflate.c and infback.c. If the root table size is + changed, then these maximum sizes would be need to be recalculated and + updated. */ +#define ENOUGH_LENS 852 +#define ENOUGH_DISTS 592 +#define ENOUGH (ENOUGH_LENS+ENOUGH_DISTS) + +/* Type of code to build for inflate_table() */ +typedef enum { + CODES, + LENS, + DISTS +} codetype; /* define NO_GZIP when compiling if you want to disable gzip header and trailer decoding by inflate(). NO_GZIP would be used to avoid linking in Modified: soc2013/dpl/head/lib/libzcap/test/zcaplibtest.c ============================================================================== --- soc2013/dpl/head/lib/libzcap/test/zcaplibtest.c Wed Aug 21 08:01:52 2013 (r256236) +++ soc2013/dpl/head/lib/libzcap/test/zcaplibtest.c Wed Aug 21 13:57:48 2013 (r256237) @@ -29,7 +29,7 @@ if ( (data = malloc(10*1024)) == NULL) err(1, "zcaplibtest: malloc()"); - for (i=0; i < (10*1024); i++) { + for (i=0; i < (10*1024); i+=sizeof(long)) { data[i] = rand(); } @@ -42,7 +42,7 @@ /* testinflateEnd(strm);*/ testzlibCompileFlags(); -/* testCompressBound();*/ + testCompressBound(); testchecksums(); return 0; @@ -97,7 +97,12 @@ void testCompressBound(void) { + uLong ret = compressBound(10L); + printf("Compressbound: %lu\n", ret); printf("compressBound()\t...\t"); + + if (ret) printf("OK\n"); + else printf("Error\n"); return; } @@ -106,7 +111,7 @@ { uLong first, second, combined; first = second = combined = 0; - + first = adler32(0L, Z_NULL, 0); printf("adler32: %ld\n", first ); first = adler32(first, (void *)data, 5*1024); @@ -130,6 +135,5 @@ else err(1, "Error\n"); - return; } \ No newline at end of file Modified: soc2013/dpl/head/lib/libzcap/zlibworker/commands.c ============================================================================== --- soc2013/dpl/head/lib/libzcap/zlibworker/commands.c Wed Aug 21 08:01:52 2013 (r256236) +++ soc2013/dpl/head/lib/libzcap/zlibworker/commands.c Wed Aug 21 13:57:48 2013 (r256237) @@ -45,14 +45,14 @@ void zcapcmd_deflateEnd(nvlist_t *nvl, nvlist_t *result) -{ +{ /* uLong ret = -1; if ((args = nvlist_take_nvlist(nvl, "args")) == NULL) - ret = compressBound( + ret = deflateEnd( nvlist_take_number(args, "sourceLen") ); - nvlist_add_number(result, "result", ret ); + nvlist_add_number(result, "result", ret ); */ } void @@ -70,13 +70,13 @@ void zcapcmd_inflateEnd(nvlist_t *nvl, nvlist_t *result) { - uLong ret = -1; + /*uLong ret = -1; if ((args = nvlist_take_nvlist(nvl, "args")) == NULL) - ret = compressBound( + ret = inflateEnd( nvlist_take_number(args, "sourceLen") ); - nvlist_add_number(result, "result", ret ); + nvlist_add_number(result, "result", ret ); */ } /* Advanced functions */ Modified: soc2013/dpl/head/lib/libzcap/zlibworker/zlibworker.c ============================================================================== --- soc2013/dpl/head/lib/libzcap/zlibworker/zlibworker.c Wed Aug 21 08:01:52 2013 (r256236) +++ soc2013/dpl/head/lib/libzcap/zlibworker/zlibworker.c Wed Aug 21 13:57:48 2013 (r256237) @@ -267,7 +267,6 @@ if( nvlist_send(3, result) != 0 ) err(1, "Couldn't send response\n"); - nvlist_destroy(nvl); if (zero) memset(data, 0, 5*1024); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201308211357.r7LDvm5S016151>