|
|
1.1 root 1: #ifndef lint
2: static char sccsid[] = "@(#)mktable.c 1.2 (Berkeley) 1/24/88";
3: #endif /* not lint */
4:
5: #ifndef lint
6: static char *mktable_c = "$Header: mktable.c,v 10.5 86/02/01 15:44:59 tony Rel $";
7: #endif lint
8:
9: #include <stdio.h>
10:
11: char reverse_byte[0x100] = { 0 };
12:
13: main()
14: {
15: seed_table();
16: fill_in_table();
17: print_table();
18: exit(0);
19: }
20:
21: seed_table()
22: {
23: int i = 0;
24: int j = 0x100/2;
25: int b = 0;
26:
27: for (;;) {
28: reverse_byte[i] = b;
29: if (j == 0)
30: break;
31: i = 2*i + 1;
32: b = b + j;
33: j = j/2;
34: }
35: }
36:
37: fill_in_table()
38: {
39: int b;
40:
41: for (b = 1; b < 0x100-2; b += 1)
42: reverse_byte[b+1] =
43: reverse_byte[b] ^ reverse_byte[b^(b+1)];
44: }
45:
46: print_table()
47: {
48: int b;
49:
50: printf("char reverse_byte[0x100] = {\n\t");
51: b = 0;
52: for (;;) {
53: printf("0x%02x", reverse_byte[b] & 0xff);
54: b += 1;
55: if (b == 0x100) {
56: printf("\n};\n");
57: return;
58: } else if (b % 8 == 0) {
59: printf(",\n\t");
60: } else {
61: printf(", ");
62: }
63: }
64: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.