1 |
frodo |
75 |
/* |
2 |
|
|
checkuid.c - Part of psiconv, a PSION 5 file formats converter |
3 |
frodo |
270 |
Copyright (c) 1999-2004 Frodo Looijaard <frodo@frodo.looijaard.name> |
4 |
frodo |
75 |
|
5 |
|
|
This program is free software; you can redistribute it and/or modify |
6 |
|
|
it under the terms of the GNU General Public License as published by |
7 |
|
|
the Free Software Foundation; either version 2 of the License, or |
8 |
|
|
(at your option) any later version. |
9 |
|
|
|
10 |
|
|
This program is distributed in the hope that it will be useful, |
11 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 |
|
|
GNU General Public License for more details. |
14 |
|
|
|
15 |
|
|
You should have received a copy of the GNU General Public License |
16 |
|
|
along with this program; if not, write to the Free Software |
17 |
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
18 |
|
|
*/ |
19 |
|
|
|
20 |
|
|
|
21 |
|
|
#include <stdio.h> |
22 |
frodo |
348 |
#include <stdlib.h> |
23 |
frodo |
75 |
|
24 |
frodo |
2 |
unsigned long uid1[32] = { /* bit 0 */ 0x000045A0, |
25 |
|
|
/* bit 1 */ 0x00008B40, |
26 |
|
|
/* bit 2 */ 0x000006A1, |
27 |
|
|
/* bit 3 */ 0x00000D42, |
28 |
|
|
/* bit 4 */ 0x00001A84, |
29 |
|
|
/* bit 5 */ 0x00003508, |
30 |
|
|
/* bit 6 */ 0x00006A10, |
31 |
|
|
/* bit 7 */ 0x0000D420, |
32 |
|
|
/* bit 8 */ 0x45A00000, |
33 |
|
|
/* bit 9 */ 0x8B400000, |
34 |
|
|
/* bit 10 */ 0x06A10000, |
35 |
|
|
/* bit 11 */ 0x0D420000, |
36 |
|
|
/* bit 12 */ 0x1A840000, |
37 |
|
|
/* bit 13 */ 0x35080000, |
38 |
|
|
/* bit 14 */ 0x6A100000, |
39 |
|
|
/* bit 15 */ 0xD4200000, |
40 |
|
|
/* bit 16 */ 0x0000AA51, |
41 |
|
|
/* bit 17 */ 0x00004483, |
42 |
|
|
/* bit 18 */ 0x00008906, |
43 |
|
|
/* bit 19 */ 0x0000022D, |
44 |
|
|
/* bit 20 */ 0x0000045A, |
45 |
|
|
/* bit 21 */ 0x000008B4, |
46 |
|
|
/* bit 22 */ 0x00001168, |
47 |
|
|
/* bit 23 */ 0x000022D0, |
48 |
|
|
/* bit 24 */ 0xAA510000, |
49 |
|
|
/* bit 25 */ 0x44830000, |
50 |
|
|
/* bit 26 */ 0x89060000, |
51 |
|
|
/* bit 27 */ 0x022D0000, |
52 |
|
|
/* bit 28 */ 0x045A0000, |
53 |
|
|
/* bit 29 */ 0x08B40000, |
54 |
|
|
/* bit 30 */ 0x11680000, |
55 |
|
|
/* bit 31 */ 0x22D00000}; |
56 |
|
|
|
57 |
|
|
unsigned long uid2[32] = { /* bit 0 */ 0x000076B4, |
58 |
|
|
/* bit 1 */ 0x0000ED68, |
59 |
|
|
/* bit 2 */ 0x0000CAF1, |
60 |
|
|
/* bit 3 */ 0x000085C3, |
61 |
|
|
/* bit 4 */ 0x000018A7, |
62 |
|
|
/* bit 5 */ 0x0000374E, |
63 |
|
|
/* bit 6 */ 0x00006E9C, |
64 |
|
|
/* bit 7 */ 0x0000DD38, |
65 |
|
|
/* bit 8 */ 0x76B40000, |
66 |
|
|
/* bit 9 */ 0xED680000, |
67 |
|
|
/* bit 10 */ 0xCAF10000, |
68 |
|
|
/* bit 11 */ 0x85C30000, |
69 |
|
|
/* bit 12 */ 0x18A70000, |
70 |
|
|
/* bit 13 */ 0x374E0000, |
71 |
|
|
/* bit 14 */ 0x6E9C0000, |
72 |
|
|
/* bit 15 */ 0xDD380000, |
73 |
|
|
/* bit 16 */ 0x00003730, |
74 |
|
|
/* bit 17 */ 0x00006E60, |
75 |
|
|
/* bit 18 */ 0x0000DCC0, |
76 |
|
|
/* bit 19 */ 0x0000A9A1, |
77 |
|
|
/* bit 20 */ 0x00004363, |
78 |
|
|
/* bit 21 */ 0x000086C6, |
79 |
|
|
/* bit 22 */ 0x00001DAD, |
80 |
|
|
/* bit 23 */ 0x00003B5A, |
81 |
|
|
/* bit 24 */ 0x37300000, |
82 |
|
|
/* bit 25 */ 0x6E600000, |
83 |
|
|
/* bit 26 */ 0xDCC00000, |
84 |
|
|
/* bit 27 */ 0xA9A10000, |
85 |
|
|
/* bit 28 */ 0x43630000, |
86 |
|
|
/* bit 29 */ 0x86C60000, |
87 |
|
|
/* bit 30 */ 0x1DAD0000, |
88 |
|
|
/* bit 31 */ 0x3B5A0000 }; |
89 |
|
|
|
90 |
|
|
unsigned long uid3[32] = { /* bit 0 */ 0x00003331, |
91 |
|
|
/* bit 1 */ 0x00006662, |
92 |
|
|
/* bit 2 */ 0x0000CCC4, |
93 |
|
|
/* bit 3 */ 0x000089A9, |
94 |
|
|
/* bit 4 */ 0x00000373, |
95 |
|
|
/* bit 5 */ 0x000006E6, |
96 |
|
|
/* bit 6 */ 0x00000DCC, |
97 |
|
|
/* bit 7 */ 0x00001B98, |
98 |
|
|
/* bit 8 */ 0x33310000, |
99 |
|
|
/* bit 9 */ 0x66620000, |
100 |
|
|
/* bit 10 */ 0xCCC40000, |
101 |
|
|
/* bit 11 */ 0x89A90000, |
102 |
|
|
/* bit 12 */ 0x03730000, |
103 |
|
|
/* bit 13 */ 0x06E60000, |
104 |
|
|
/* bit 14 */ 0x0DCC0000, |
105 |
|
|
/* bit 15 */ 0x1B980000, |
106 |
|
|
/* bit 16 */ 0x00001021, |
107 |
|
|
/* bit 17 */ 0x00002042, |
108 |
|
|
/* bit 18 */ 0x00004084, |
109 |
|
|
/* bit 19 */ 0x00008108, |
110 |
|
|
/* bit 20 */ 0x00001231, |
111 |
|
|
/* bit 21 */ 0x00002462, |
112 |
|
|
/* bit 22 */ 0x000048C4, |
113 |
|
|
/* bit 23 */ 0x00009188, |
114 |
|
|
/* bit 24 */ 0x10210000, |
115 |
|
|
/* bit 25 */ 0x20420000, |
116 |
|
|
/* bit 26 */ 0x40840000, |
117 |
|
|
/* bit 27 */ 0x81080000, |
118 |
|
|
/* bit 28 */ 0x12310000, |
119 |
|
|
/* bit 29 */ 0x24620000, |
120 |
|
|
/* bit 30 */ 0x48C40000, |
121 |
|
|
/* bit 31 */ 0x91880000 }; |
122 |
|
|
|
123 |
|
|
|
124 |
|
|
unsigned long checkuid(unsigned long id1,unsigned long id2, unsigned long id3) |
125 |
|
|
{ |
126 |
|
|
int i; |
127 |
|
|
unsigned long res = 0; |
128 |
|
|
for (i = 0; i < 32; i++) { |
129 |
|
|
if (id1 & (1 << i)) |
130 |
|
|
res = res ^ uid1[i]; |
131 |
|
|
if (id2 & (1 << i)) |
132 |
|
|
res = res ^ uid2[i]; |
133 |
|
|
if (id3 & (1 << i)) |
134 |
|
|
res = res ^ uid3[i]; |
135 |
|
|
} |
136 |
|
|
return res; |
137 |
|
|
} |
138 |
|
|
|
139 |
|
|
void printhexdigit(char digit) |
140 |
|
|
{ |
141 |
|
|
if (digit < 10) |
142 |
|
|
putchar(digit + '0'); |
143 |
|
|
else |
144 |
|
|
putchar(digit + 'A' - 10); |
145 |
|
|
} |
146 |
|
|
|
147 |
|
|
void printhex(unsigned long id) |
148 |
|
|
{ |
149 |
|
|
int i; |
150 |
|
|
for (i = 0; i < 8; i ++) { |
151 |
|
|
printhexdigit((id & 0xf0000000) >> 28); |
152 |
|
|
id = id << 4; |
153 |
|
|
} |
154 |
|
|
} |
155 |
|
|
|
156 |
|
|
int main(int argc, char *argv[]) |
157 |
|
|
{ |
158 |
frodo |
75 |
unsigned long res; |
159 |
frodo |
2 |
res = checkuid(0x10000037,0x1000006D,0x1000007F); |
160 |
|
|
printhex(res); |
161 |
|
|
putchar('\n'); |
162 |
frodo |
75 |
exit(0); |
163 |
frodo |
2 |
} |