summaryrefslogtreecommitdiff
path: root/support/dktools/testlzw.ctr
blob: 037e0234b5a15d3cd03754e059ebcdd3ff051e83 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75

#include <stdio.h>

#include <dk4conf.h>
#include "dk4lzwe.h"
#include <dk4edstm.h>

$!trace-include


static const unsigned char teststr[] = {
  45, 45, 45, 45, 45, 65, 45, 45, 45, 66
};



static
void
show_bytes(dk4_lzwe_t *lzwe)
{
	const unsigned char	*cptr	= NULL;
	size_t				 nbt	= 0;
	size_t				 i;

	$? "+ show_bytes"
	if (0 != dk4lzwe_output(&cptr, &nbt, lzwe, NULL)) {
		if ((NULL != cptr) && (0 < nbt)) {
			for (i = 0; i < nbt; i++) {
				printf("%2x\n", (unsigned)(cptr[i]));
			}
		}
		else {			$? "! bug"
		}
	}
	else {				$? "! error"
	}
	$? "- show_bytes"
}



int main(int argc, char *argv[])
{
	dk4_lzwe_t	lzwe;
	size_t		i;

	$!trace-init	testlzwe.deb
	$? "+ main"
	if (0 != dk4lzwe_init(&lzwe, NULL)) {
		for (i = 0; i < sizeof(teststr); i++) {
			switch (dk4lzwe_add(&lzwe, teststr[i], NULL)) {
				case DK4_EDSTM_FINISHED : {
					show_bytes(&lzwe);
				} break;
				case DK4_EDSTM_ERROR : {	$? "! error indicated"
				} break;
			}
		}
		switch (dk4lzwe_finish(&lzwe, NULL)) {
			case DK4_EDSTM_FINISHED : {
				show_bytes(&lzwe);
			} break;
			case DK4_EDSTM_ERROR : {		$? "! error indicated"
			} break;
		}
	}
	else {
	}
	$? "- main"
	$!trace-end
	return 0;
}

/* vim: set ai sw=4 ts=4 : */