1 /*
2 This product contains certain software code or other information
3 ("AT&T Software") proprietary to AT&T Corp. ("AT&T").  The AT&T
4 Software is provided to you "AS IS".  YOU ASSUME TOTAL RESPONSIBILITY
5 AND RISK FOR USE OF THE AT&T SOFTWARE.  AT&T DOES NOT MAKE, AND
6 EXPRESSLY DISCLAIMS, ANY EXPRESS OR IMPLIED WARRANTIES OF ANY KIND
7 WHATSOEVER, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
8 MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, WARRANTIES OF
9 TITLE OR NON-INFRINGEMENT OF ANY INTELLECTUAL PROPERTY RIGHTS, ANY
10 WARRANTIES ARISING BY USAGE OF TRADE, COURSE OF DEALING OR COURSE OF
11 PERFORMANCE, OR ANY WARRANTY THAT THE AT&T SOFTWARE IS "ERROR FREE" OR
12 WILL MEET YOUR REQUIREMENTS.
13 
14 Unless you accept a license to use the AT&T Software, you shall not
15 reverse compile, disassemble or otherwise reverse engineer this
16 product to ascertain the source code for any AT&T Software.
17 
18 (c) AT&T Corp. All rights reserved.  AT&T is a registered trademark of AT&T Corp.
19 
20 ***********************************************************************
21 
22 Description:
23 
24 		Program to test the in-memory API to the XMill (de)compression routines
25 
26 History:
27 
28       10/11/2002  - created by Hedzer Westra <hedzer@adlibsoft.com>
29 
30 */
31 
32 #include "stdafx.h"
33 
34 #define tryfree(c) {if (c) {free(c); c=NULL;}}
35 
36 #define MAXFILES 100
37 
38 #define BUFLEN 1024
39 #ifndef STRLEN
40 	#define STRLEN 4096
41 #endif
42 
43 #define TEST_COMPDECOMP		1
44 #define TEST_DECOMP			2
45 #define TEST_TARGETSIZE		3
46 
47 #define TEST_ERROR_NONE				0
48 #define TEST_ERROR_TARGETSIZE		-1
49 #define TEST_ERROR_NOEXACTMATCH	-2
50 #define TEST_ERROR_NOIGNMATCH		-3
51 #define TEST_ERROR_MODE				-4
52 #define TEST_ERROR_FILE				-5
53 #define TEST_ERROR_FOUND			-6
54 
55 #define TEST_STATS_NONE		0
56 #define TEST_STATS_ERR		1
57 #define TEST_STATS_WARN		2
58 #define TEST_STATS_TIMING  3
59 #define TEST_STATS_BPCTIME 4
60 #define TEST_STATS_ALL		5
61 
62 class testsettings {
63 	bool lossy;
64 	char bzip;
65 	int mode;
66 	bool exprs;
67 	XMill *xmill;
68 	char stats;
69 	bool ignorewhite;
70 	unsigned int blocksize;
71 	bool mustfail;
72    int gpcidx;
73 
74 	int compdecomp(char *buffer, int buflen, char *filename, int targetsize, clock_t *t2t, clock_t *t3t,
75                   int *xmibuflen, bool isFirst);
76 
77 public:
78 	int times;
79 
80 	testsettings();
81 	~testsettings();
82 
83 	int parsesetting(char *s, char *s1 = NULL, bool *usedboth = NULL);
84 	int run(char **files, int numfiles);
85 	int run(FILE *script);
86 
87 	int rundecomp(char *xmlfile, char *xmifile, int times);
88 	int runcompdecomp(char *filename, int targetsize = 0);
89 	int runcomptarget(char *filename, int targetsize);
90 
91 	int checkintegrity(char *buffer, int buflen, char *xmlbuf, int xmlbuflen);
92 	void setstats(char stats);
93 };
94