1 /* @(#)repair.c	1.5 21/07/22 Copyright 2001-2021 J. Schilling */
2 #include <schily/mconfig.h>
3 #ifndef lint
4 static	UConst char sccsid[] =
5 	"@(#)repair.c	1.5 21/07/22 Copyright 2001-2021 J. Schilling";
6 #endif
7 /*
8  * Code to check libedc_ecc_dec
9  */
10 /*
11  * The contents of this file are subject to the terms of the
12  * Common Development and Distribution License, Version 1.0 only
13  * (the "License").  You may not use this file except in compliance
14  * with the License.
15  *
16  * See the file CDDL.Schily.txt in this distribution for details.
17  * A copy of the CDDL is also available via the Internet at
18  * http://www.opensource.org/licenses/cddl1.txt
19  *
20  * When distributing Covered Code, include this CDDL HEADER in each
21  * file and include the License file CDDL.Schily.txt from this distribution.
22  */
23 
24 #include <schily/stdio.h>
25 #include <schily/fcntl.h>
26 #include <schily/unistd.h>
27 
28 #define	LAYER2
29 #define	ENCODER
30 #define	EDC_LAYER2
31 #define	EDC_ENCODER
32 
33 #define	EDC_DECODER
34 #define	EDC_SUBCHANNEL
35 
36 #include "ecc.h"
37 #include "edc.h"
38 
39 #ifndef	EDC_MODE_1
40 #define	EDC_MODE_1		MODE_1
41 #endif
42 
43 char	ooo[2352];
44 char	xxx[2352];
45 
46 int
main()47 main()
48 {
49 	int	f = open("OOO", O_RDONLY);
50 	int	f2;
51 	int	f3;
52 	int	f4;
53 	int	i;
54 
55 	read(f, ooo, 16);
56 	read(f, &xxx[16], 2048);
57 
58 	do_encode_L2((unsigned char *)xxx, EDC_MODE_1, 0 + 150);
59 
60 	f2 = creat("out", 0666);
61 	write(f2, xxx, 2352);
62 
63 printf("crc_check %d\n", crc_check((unsigned char *)xxx, EDC_MODE_1));
64 
65 	xxx[123] = 123;
66 
67 	f3 = creat("out-def", 0666);
68 	write(f3, xxx, 2352);
69 
70 printf("crc_check %d\n", crc_check((unsigned char *)xxx, EDC_MODE_1));
71 
72 #define	FALSE	0
73 	do_decode_L2((unsigned char *)xxx, EDC_MODE_1, FALSE, 0);
74 
75 printf("crc_check %d\n", crc_check((unsigned char *)xxx, EDC_MODE_1));
76 
77 	f4 = creat("out-rep", 0666);
78 	write(f4, xxx, 2352);
79 
80 	return (0);
81 }
82