annotate tests/testdmzlib.c @ 1068:01114659bdd3

Oops, fix a nasty bug.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 02 Mar 2015 02:12:47 +0200
parents b3a54ecdb86f
children e98bc627ad08
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1064
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1 #include "dmlib.h"
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
2 #include "dmzlib.h"
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
3 #include "dmfile.h"
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
4 #include "dmargs.h"
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
5 #include <zlib.h>
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
6
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
7
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
8 #define SET_TMPBUF_SIZE (16 * 1024)
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
9
1065
2e997dd888b9 Work on testdmzlib.
Matti Hamalainen <ccr@tnsp.org>
parents: 1064
diff changeset
10 char *optInFilename = NULL,
2e997dd888b9 Work on testdmzlib.
Matti Hamalainen <ccr@tnsp.org>
parents: 1064
diff changeset
11 *optOutFilename = NULL;
1064
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
12
1065
2e997dd888b9 Work on testdmzlib.
Matti Hamalainen <ccr@tnsp.org>
parents: 1064
diff changeset
13 int optCompressLevel = Z_BEST_COMPRESSION;
2e997dd888b9 Work on testdmzlib.
Matti Hamalainen <ccr@tnsp.org>
parents: 1064
diff changeset
14 BOOL optCompress = FALSE,
2e997dd888b9 Work on testdmzlib.
Matti Hamalainen <ccr@tnsp.org>
parents: 1064
diff changeset
15 optUseZLIB = FALSE;
1064
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
16
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
17
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
18 static const DMOptArg optList[] =
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
19 {
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
20 { 0, '?', "help", "Show this help", OPT_NONE },
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
21 { 1, 'q', "quiet", "Decrease verbosity", OPT_NONE },
1065
2e997dd888b9 Work on testdmzlib.
Matti Hamalainen <ccr@tnsp.org>
parents: 1064
diff changeset
22 { 2, 'Z', "zlib", "Use ZLIB instead of dmzlib", OPT_NONE },
2e997dd888b9 Work on testdmzlib.
Matti Hamalainen <ccr@tnsp.org>
parents: 1064
diff changeset
23 { 3, 'c', "compress", "Compress instead of decompressing (ZLIB only)", OPT_NONE },
2e997dd888b9 Work on testdmzlib.
Matti Hamalainen <ccr@tnsp.org>
parents: 1064
diff changeset
24 { 10, 'l', "level", "Set zlib compression level 1-9", OPT_ARGREQ },
1064
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
25 };
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
26
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
27 static const int optListN = sizeof(optList) / sizeof(optList[0]);
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
28
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
29
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
30 void argShowHelp()
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
31 {
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
32 dmPrintBanner(stdout, dmProgName, "[options] [input filename] [output filename]");
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
33 dmArgsPrintHelp(stdout, optList, optListN, 0);
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
34 }
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
35
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
36
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
37 BOOL argHandleOpt(const int optN, char *optArg, char *currArg)
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
38 {
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
39 (void) currArg;
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
40
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
41 switch (optN)
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
42 {
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
43 case 0:
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
44 argShowHelp();
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
45 exit(0);
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
46 break;
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
47
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
48 case 1:
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
49 dmVerbosity = 0;
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
50 break;
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
51
1065
2e997dd888b9 Work on testdmzlib.
Matti Hamalainen <ccr@tnsp.org>
parents: 1064
diff changeset
52 case 2:
2e997dd888b9 Work on testdmzlib.
Matti Hamalainen <ccr@tnsp.org>
parents: 1064
diff changeset
53 optUseZLIB = TRUE;
2e997dd888b9 Work on testdmzlib.
Matti Hamalainen <ccr@tnsp.org>
parents: 1064
diff changeset
54 break;
1066
dfde748d9c1f Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 1065
diff changeset
55
1065
2e997dd888b9 Work on testdmzlib.
Matti Hamalainen <ccr@tnsp.org>
parents: 1064
diff changeset
56 case 3:
2e997dd888b9 Work on testdmzlib.
Matti Hamalainen <ccr@tnsp.org>
parents: 1064
diff changeset
57 optCompress = TRUE;
2e997dd888b9 Work on testdmzlib.
Matti Hamalainen <ccr@tnsp.org>
parents: 1064
diff changeset
58 break;
2e997dd888b9 Work on testdmzlib.
Matti Hamalainen <ccr@tnsp.org>
parents: 1064
diff changeset
59
1064
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
60 case 10:
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
61 optCompressLevel = atoi(optArg);
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
62 if (optCompressLevel < 1 || optCompressLevel > 9)
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
63 {
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
64 dmErrorMsg("Invalid compression level argument '%s', must be 1 .. 9.\n", optArg);
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
65 return FALSE;
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
66 }
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
67 break;
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
68
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
69 default:
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
70 return FALSE;
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
71 }
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
72
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
73 return TRUE;
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
74 }
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
75
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
76
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
77 BOOL argHandleFile(char *currArg)
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
78 {
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
79 if (optInFilename == NULL)
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
80 optInFilename = currArg;
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
81 else
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
82 if (optOutFilename == NULL)
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
83 optOutFilename = currArg;
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
84 else
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
85 {
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
86 dmErrorMsg("Excess filenames specified.\n");
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
87 return FALSE;
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
88 }
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
89 return TRUE;
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
90 }
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
91
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
92
1065
2e997dd888b9 Work on testdmzlib.
Matti Hamalainen <ccr@tnsp.org>
parents: 1064
diff changeset
93 int dmTestDMZlib(FILE *inFile, FILE *outFile, size_t *inSize, size_t *outSize, BOOL compress, int level)
1064
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
94 {
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
95 Uint8 *inBuffer = NULL, *outBuffer = NULL;
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
96 DMZLibContext ctx;
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
97 int ret;
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
98
1065
2e997dd888b9 Work on testdmzlib.
Matti Hamalainen <ccr@tnsp.org>
parents: 1064
diff changeset
99 (void) level;
2e997dd888b9 Work on testdmzlib.
Matti Hamalainen <ccr@tnsp.org>
parents: 1064
diff changeset
100
2e997dd888b9 Work on testdmzlib.
Matti Hamalainen <ccr@tnsp.org>
parents: 1064
diff changeset
101 if (compress)
2e997dd888b9 Work on testdmzlib.
Matti Hamalainen <ccr@tnsp.org>
parents: 1064
diff changeset
102 {
2e997dd888b9 Work on testdmzlib.
Matti Hamalainen <ccr@tnsp.org>
parents: 1064
diff changeset
103 ret = dmError(DMERR_NOT_SUPPORTED,
2e997dd888b9 Work on testdmzlib.
Matti Hamalainen <ccr@tnsp.org>
parents: 1064
diff changeset
104 "Compression is not supported with dmzlib.\n");
2e997dd888b9 Work on testdmzlib.
Matti Hamalainen <ccr@tnsp.org>
parents: 1064
diff changeset
105 goto out;
2e997dd888b9 Work on testdmzlib.
Matti Hamalainen <ccr@tnsp.org>
parents: 1064
diff changeset
106 }
2e997dd888b9 Work on testdmzlib.
Matti Hamalainen <ccr@tnsp.org>
parents: 1064
diff changeset
107
1064
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
108 if ((ret = dmReadDataFile(inFile, "-", &inBuffer, inSize)) != DMERR_OK)
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
109 {
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
110 dmErrorMsg("Failed to read file.\n");
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
111 goto out;
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
112 }
1066
dfde748d9c1f Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 1065
diff changeset
113
1064
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
114 if ((outBuffer = dmMalloc(SET_TMPBUF_SIZE)) == NULL)
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
115 {
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
116 ret = dmError(DMERR_MALLOC,
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
117 "Malloc failed.\n");
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
118 goto out;
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
119 }
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
120
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
121 // Initialize decompression structures
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
122 ctx.zbuffer = inBuffer;
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
123 ctx.zbufferEnd = inBuffer + *inSize;
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
124
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
125 ctx.zout = ctx.zoutStart = outBuffer;
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
126 ctx.zoutEnd = outBuffer + SET_TMPBUF_SIZE;
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
127 ctx.expandable = TRUE;
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
128
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
129 // Attempt decompression
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
130 if ((ret = dmZLibParseHeader(&ctx, TRUE)) != DMERR_OK)
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
131 {
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
132 dmErrorMsg("Error parsing ZLIB header: %d, %s\n", ret, dmErrorStr(ret));
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
133 goto out;
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
134 }
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
135
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
136 if ((ret = dmZLibDecode(&ctx)) != DMERR_OK)
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
137 {
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
138 dmErrorMsg("Error in ZLIB decompress: %d, %s\n", ret, dmErrorStr(ret));
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
139 goto out;
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
140 }
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
141
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
142 outBuffer = ctx.zoutStart;
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
143 *outSize = ctx.zout - ctx.zoutStart;
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
144
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
145 if (fwrite(outBuffer, sizeof(Uint8), *outSize, outFile) != *outSize)
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
146 {
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
147 ret = dmError(DMERR_FWRITE, "File write error.\n");
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
148 goto out;
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
149 }
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
150
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
151 out:
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
152
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
153 dmFree(inBuffer);
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
154 dmFree(outBuffer);
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
155 return ret;
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
156 }
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
157
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
158
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
159 int dmTestZlib(FILE *inFile, FILE *outFile, size_t *inSize, size_t *outSize, BOOL compress, int level)
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
160 {
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
161 Uint8 *inBuffer = NULL, *outBuffer = NULL;
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
162 int zret, zinit = FALSE;
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
163 int ret = DMERR_OK;
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
164 z_stream zstr;
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
165
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
166 dmMsg(0, "Operating mode: %s\n",
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
167 compress ? "compress" : "decompress");
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
168
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
169 if ((inBuffer = malloc(SET_TMPBUF_SIZE)) == NULL ||
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
170 (outBuffer = malloc(SET_TMPBUF_SIZE)) == NULL)
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
171 {
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
172 ret = dmError(DMERR_MALLOC, "Malloc failed.\n");
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
173 goto out;
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
174 }
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
175
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
176 memset(&zstr, 0, sizeof(zstr));
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
177 if (compress)
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
178 zret = deflateInit(&zstr, level);
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
179 else
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
180 zret = inflateInit(&zstr);
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
181
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
182 if (zret != Z_OK)
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
183 {
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
184 ret = dmError(DMERR_INIT_FAIL, "Zlib init fail.\n");
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
185 goto out;
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
186 }
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
187 zinit = TRUE;
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
188
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
189 // Initialize compression streams
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
190 zret = Z_OK;
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
191 *outSize = 0;
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
192 while (!feof(inFile) && zret == Z_OK)
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
193 {
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
194 zstr.avail_in = fread(inBuffer, sizeof(Uint8), SET_TMPBUF_SIZE, inFile);
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
195
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
196 zstr.next_in = inBuffer;
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
197 zstr.next_out = outBuffer;
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
198 zstr.avail_out = SET_TMPBUF_SIZE;
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
199 zstr.total_out = 0;
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
200
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
201 if (compress)
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
202 zret = deflate(&zstr, Z_FULL_FLUSH);
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
203 else
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
204 zret = inflate(&zstr, Z_FULL_FLUSH);
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
205
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
206 if (zret == Z_OK && zstr.total_out > 0)
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
207 {
1068
01114659bdd3 Oops, fix a nasty bug.
Matti Hamalainen <ccr@tnsp.org>
parents: 1067
diff changeset
208 *outSize += zstr.total_out;
1064
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
209 if (fwrite(outBuffer, sizeof(Uint8), zstr.total_out, outFile) != zstr.total_out)
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
210 {
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
211 ret = dmError(DMERR_FWRITE,
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
212 "File write error.\n");
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
213 goto out;
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
214 }
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
215 }
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
216 }
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
217
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
218
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
219 switch (zret)
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
220 {
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
221 case Z_OK:
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
222 break;
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
223
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
224 case Z_ERRNO:
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
225 dmErrorMsg("Error: errno\n");
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
226 break;
1066
dfde748d9c1f Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 1065
diff changeset
227
1064
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
228 case Z_STREAM_END:
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
229 dmErrorMsg("Stream end.\n");
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
230 break;
1066
dfde748d9c1f Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 1065
diff changeset
231
1064
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
232 default:
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
233 ret = dmError(DMERR_COMPRESSION,
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
234 "Error: %d, %s\n", zret, zError(zret));
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
235 }
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
236
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
237 out:
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
238 *inSize = zstr.total_in;
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
239
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
240 if (zinit)
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
241 {
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
242 if (compress)
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
243 deflateEnd(&zstr);
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
244 else
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
245 inflateEnd(&zstr);
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
246 }
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
247
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
248 dmFree(inBuffer);
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
249 dmFree(outBuffer);
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
250
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
251 return ret;
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
252 }
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
253
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
254
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
255 int main(int argc, char *argv[])
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
256 {
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
257 FILE *inFile = NULL, *outFile = NULL;
1067
b3a54ecdb86f Initialize output and input size variables.
Matti Hamalainen <ccr@tnsp.org>
parents: 1066
diff changeset
258 size_t inSize = 0, outSize = 0;
1065
2e997dd888b9 Work on testdmzlib.
Matti Hamalainen <ccr@tnsp.org>
parents: 1064
diff changeset
259 int ret;
1064
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
260
1065
2e997dd888b9 Work on testdmzlib.
Matti Hamalainen <ccr@tnsp.org>
parents: 1064
diff changeset
261 dmInitProg("testdmzlib", "ZLIB/dmzlib tester", NULL, NULL, NULL);
1064
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
262 dmVerbosity = 1;
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
263
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
264 if (!dmArgsProcess(argc, argv, optList, optListN,
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
265 argHandleOpt, argHandleFile, OPTH_BAILOUT))
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
266 exit(1);
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
267
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
268 // Input and output files
1065
2e997dd888b9 Work on testdmzlib.
Matti Hamalainen <ccr@tnsp.org>
parents: 1064
diff changeset
269 if (optInFilename == NULL)
2e997dd888b9 Work on testdmzlib.
Matti Hamalainen <ccr@tnsp.org>
parents: 1064
diff changeset
270 inFile = stdin;
2e997dd888b9 Work on testdmzlib.
Matti Hamalainen <ccr@tnsp.org>
parents: 1064
diff changeset
271 else
2e997dd888b9 Work on testdmzlib.
Matti Hamalainen <ccr@tnsp.org>
parents: 1064
diff changeset
272 if ((inFile = fopen(optInFilename, "rb")) == NULL)
2e997dd888b9 Work on testdmzlib.
Matti Hamalainen <ccr@tnsp.org>
parents: 1064
diff changeset
273 {
2e997dd888b9 Work on testdmzlib.
Matti Hamalainen <ccr@tnsp.org>
parents: 1064
diff changeset
274 int res = dmGetErrno();
2e997dd888b9 Work on testdmzlib.
Matti Hamalainen <ccr@tnsp.org>
parents: 1064
diff changeset
275 dmErrorMsg("Failed to open input file '%s': %s\n",
2e997dd888b9 Work on testdmzlib.
Matti Hamalainen <ccr@tnsp.org>
parents: 1064
diff changeset
276 optInFilename, dmErrorStr(res));
2e997dd888b9 Work on testdmzlib.
Matti Hamalainen <ccr@tnsp.org>
parents: 1064
diff changeset
277 goto out;
2e997dd888b9 Work on testdmzlib.
Matti Hamalainen <ccr@tnsp.org>
parents: 1064
diff changeset
278 }
1066
dfde748d9c1f Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 1065
diff changeset
279
1065
2e997dd888b9 Work on testdmzlib.
Matti Hamalainen <ccr@tnsp.org>
parents: 1064
diff changeset
280 if (optOutFilename == NULL)
2e997dd888b9 Work on testdmzlib.
Matti Hamalainen <ccr@tnsp.org>
parents: 1064
diff changeset
281 outFile = stdout;
2e997dd888b9 Work on testdmzlib.
Matti Hamalainen <ccr@tnsp.org>
parents: 1064
diff changeset
282 else
2e997dd888b9 Work on testdmzlib.
Matti Hamalainen <ccr@tnsp.org>
parents: 1064
diff changeset
283 if ((outFile = fopen(optOutFilename, "wb")) == NULL)
2e997dd888b9 Work on testdmzlib.
Matti Hamalainen <ccr@tnsp.org>
parents: 1064
diff changeset
284 {
2e997dd888b9 Work on testdmzlib.
Matti Hamalainen <ccr@tnsp.org>
parents: 1064
diff changeset
285 int res = dmGetErrno();
2e997dd888b9 Work on testdmzlib.
Matti Hamalainen <ccr@tnsp.org>
parents: 1064
diff changeset
286 dmErrorMsg("Failed to open output file '%s': %s\n",
2e997dd888b9 Work on testdmzlib.
Matti Hamalainen <ccr@tnsp.org>
parents: 1064
diff changeset
287 optOutFilename, dmErrorStr(res));
2e997dd888b9 Work on testdmzlib.
Matti Hamalainen <ccr@tnsp.org>
parents: 1064
diff changeset
288 goto out;
2e997dd888b9 Work on testdmzlib.
Matti Hamalainen <ccr@tnsp.org>
parents: 1064
diff changeset
289 }
1064
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
290
1065
2e997dd888b9 Work on testdmzlib.
Matti Hamalainen <ccr@tnsp.org>
parents: 1064
diff changeset
291 if (optUseZLIB)
2e997dd888b9 Work on testdmzlib.
Matti Hamalainen <ccr@tnsp.org>
parents: 1064
diff changeset
292 ret = dmTestZlib(inFile, outFile, &inSize, &outSize, optCompress, optCompressLevel);
2e997dd888b9 Work on testdmzlib.
Matti Hamalainen <ccr@tnsp.org>
parents: 1064
diff changeset
293 else
2e997dd888b9 Work on testdmzlib.
Matti Hamalainen <ccr@tnsp.org>
parents: 1064
diff changeset
294 ret = dmTestDMZlib(inFile, outFile, &inSize, &outSize, optCompress, optCompressLevel);
1064
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
295
1065
2e997dd888b9 Work on testdmzlib.
Matti Hamalainen <ccr@tnsp.org>
parents: 1064
diff changeset
296 dmMsg(0, "[%d] In %d, out %d bytes.\n", ret, inSize, outSize);
2e997dd888b9 Work on testdmzlib.
Matti Hamalainen <ccr@tnsp.org>
parents: 1064
diff changeset
297
2e997dd888b9 Work on testdmzlib.
Matti Hamalainen <ccr@tnsp.org>
parents: 1064
diff changeset
298 out:
1064
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
299 // Cleanup
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
300 if (outFile != NULL)
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
301 fclose(outFile);
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
302
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
303 if (inFile != NULL)
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
304 fclose(inFile);
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
305
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
306 return 0;
a6c5be712b53 Add dmzlib / zlib test utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
307 }