annotate Meerwald/signature.c @ 0:be303a3f5ea8

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

Repositories maintained by Peter Meerwald, pmeerw@pmeerw.net.