Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
att
GitHub Repository: att/ast
Path: blob/master/src/cmd/vczip/tests/tvctable.c
1810 views
1
/***********************************************************************
2
* *
3
* This software is part of the ast package *
4
* Copyright (c) 2003-2011 AT&T Intellectual Property *
5
* and is licensed under the *
6
* Eclipse Public License, Version 1.0 *
7
* by AT&T Intellectual Property *
8
* *
9
* A copy of the License is available at *
10
* http://www.eclipse.org/org/documents/epl-v10.html *
11
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
12
* *
13
* Information and Software Systems Research *
14
* AT&T Research *
15
* Florham Park NJ *
16
* *
17
* Phong Vo <[email protected]> *
18
* Glenn Fowler <[email protected]> *
19
* *
20
***********************************************************************/
21
#include "vctest.h"
22
23
typedef Vcchar_t Matrix_t[16][8];
24
25
static Matrix_t Mt =
26
{ 'a', '0', 'u', 'd', 'i', 'e', 'a', 'b',
27
'a', '1', 'v', 'd', 'j', 'e', 'b', 'c',
28
'b', '0', 'x', 'd', 'i', 'e', 'c', 'd',
29
'b', '1', 'y', 'd', 'j', 'e', 'd', 'e',
30
31
'b', '2', 'z', 'd', 'i', 'e', 'e', 'f',
32
'a', '0', 'u', 'd', 'j', 'e', 'f', 'g',
33
'a', '2', 'w', 'd', 'i', 'e', 'g', 'h',
34
'b', '1', 'y', 'd', 'j', 'e', 'h', 'i',
35
36
'a', '0', 'u', 'd', 'i', 'e', 'i', 'j',
37
'a', '1', 'v', 'd', 'j', 'e', 'j', 'k',
38
'a', '2', 'w', 'd', 'i', 'e', 'k', 'l',
39
'b', '0', 'x', 'd', 'j', 'e', 'l', 'm',
40
41
'b', '1', 'y', 'd', 'i', 'e', 'm', 'n',
42
'b', '2', 'z', 'd', 'j', 'e', 'n', 'o',
43
'b', '1', 'y', 'd', 'i', 'e', 'o', 'p',
44
'a', '0', 'u', 'd', 'j', 'e', 'p', 'q'
45
};
46
47
int main()
48
{
49
Vcodex_t *tz, *uz;
50
Vcodex_t *huf, *rle, *mtf;
51
Vcchar_t *mt, *cmp, *tstr;
52
Vcchar_t store[2*sizeof(Mt)];
53
ssize_t nc, nu, n;
54
Vcmethod_t *Vctable;
55
56
if(!(Vctable = vcgetmeth("table", 0)))
57
terror("table plugin not found");
58
59
if(!(huf = vcopen(0, Vchuffgroup, 0, 0, VC_ENCODE)) )
60
terror("Can't open Vchuffgroup handle to compress");
61
if(!(rle = vcopen(0, Vcrle, "0", huf, VC_ENCODE|VC_CLOSECODER)) )
62
terror("Can't open Vcrle handle to compress");
63
if(!(mtf = vcopen(0, Vcmtf, 0, rle, VC_ENCODE|VC_CLOSECODER)) )
64
terror("Can't open Vcrle handle to compress");
65
if(!(tz = vcopen(0, Vctable, 0, mtf, VC_ENCODE)) )
66
terror("Vctable: could not open handle to transform");
67
68
if((n = vcextract(tz, (Void_t**)(&tstr))) <= 0)
69
terror("Cannot get encoding string");
70
memcpy(store,tstr,n);
71
72
if((nc = vcapply(tz, Mt, sizeof(Mt), &cmp)) <= 0 )
73
terror("Vctable: fail transforming");
74
twarn("Vctable: rawsz=%d cmpsz=%d\n", sizeof(Mt), nc);
75
76
if(!(uz = vcrestore(store, n)) )
77
terror("Vctable: could not recreate handle to decode");
78
79
if((nu = vcapply(uz, cmp, nc, &mt)) != sizeof(Mt))
80
terror("Vctable: fail untransforming");
81
82
if(memcmp(mt, Mt, nu) != 0)
83
terror("Vctable: results did not match");
84
85
exit(0);
86
}
87
88