0
|
1 #include "signature.h"
|
|
2
|
|
3 void init_signature_bits() {
|
|
4 bzero(signature, sizeof(signature));
|
|
5 }
|
|
6
|
|
7 void init_signature1_bits() {
|
|
8 bzero(signature1, sizeof(signature1));
|
|
9 }
|
|
10
|
|
11 void init_signature2_bits() {
|
|
12 bzero(signature2, sizeof(signature2));
|
|
13 }
|
|
14
|
|
15 int get_signature_bit(int n) {
|
|
16 int byte = n >> 3;
|
|
17 int bit = n & 7;
|
|
18
|
|
19 #ifdef DEBUG
|
|
20 if (byte < 0 || byte >= NSIGNATURE)
|
|
21 fprintf(stderr, "get_signature_bit(): index out of range\n");
|
|
22 #endif
|
|
23
|
|
24 return (signature[byte] & (1 << bit)) >> bit;
|
|
25 }
|
|
26
|
|
27 int get_signature1_bit(int n) {
|
|
28 int byte = n >> 3;
|
|
29 int bit = n & 7;
|
|
30
|
|
31 #ifdef DEBUG
|
|
32 if (byte < 0 || byte >= NSIGNATURE)
|
|
33 fprintf(stderr, "get_signature1_bit(): index out of range\n");
|
|
34 #endif
|
|
35
|
|
36 return (signature1[byte] & (1 << bit)) >> bit;
|
|
37 }
|
|
38
|
|
39 int get_signature2_bit(int n) {
|
|
40 int byte = n >> 3;
|
|
41 int bit = n & 7;
|
|
42
|
|
43 #ifdef DEBUG
|
|
44 if (byte < 0 || byte >= NSIGNATURE)
|
|
45 fprintf(stderr, "get_signature2_bit(): index out of range\n");
|
|
46 #endif
|
|
47
|
|
48 return (signature2[byte] & (1 << bit)) >> bit;
|
|
49 }
|
|
50
|
|
51 void set_signature_bit(int n, int v) {
|
|
52 int byte = n >> 3;
|
|
53 int bit = n & 7;
|
|
54
|
|
55 #ifdef DEBUG
|
|
56 if (byte < 0 || byte >= NSIGNATURE)
|
|
57 fprintf(stderr, "get_signature_bit(): index out of range\n");
|
|
58 #endif
|
|
59
|
|
60 if (v)
|
|
61 signature[byte] |= (1 << bit);
|
|
62 else
|
|
63 signature[byte] &= ~(1 << bit);
|
|
64 }
|
|
65
|
|
66 void set_signature1_bit(int n, int v) {
|
|
67 int byte = n >> 3;
|
|
68 int bit = n & 7;
|
|
69
|
|
70 #ifdef DEBUG
|
|
71 if (byte < 0 || byte >= NSIGNATURE)
|
|
72 fprintf(stderr, "get_signature1_bit(): index out of range\n");
|
|
73 #endif
|
|
74
|
|
75 if (v)
|
|
76 signature1[byte] |= (1 << bit);
|
|
77 else
|
|
78 signature1[byte] &= ~(1 << bit);
|
|
79 }
|
|
80
|
|
81 void set_signature2_bit(int n, int v) {
|
|
82 int byte = n >> 3;
|
|
83 int bit = n & 7;
|
|
84
|
|
85 #ifdef DEBUG
|
|
86 if (byte < 0 || byte >= NSIGNATURE)
|
|
87 fprintf(stderr, "get_signature2_bit(): index out of range\n");
|
|
88 #endif
|
|
89
|
|
90 if (v)
|
|
91 signature2[byte] |= (1 << bit);
|
|
92 else
|
|
93 signature2[byte] &= ~(1 << bit);
|
|
94 }
|
|
95
|