/[public]/psiconv/trunk/program/extra/checkuid.c
ViewVC logotype

Contents of /psiconv/trunk/program/extra/checkuid.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 75 - (show annotations)
Sun Dec 24 17:26:24 2000 UTC (18 years, 11 months ago) by frodo
File MIME type: text/plain
File size: 6696 byte(s)
(Frodo) Several things:

 * Added the extra directory to the build process, added a README.
 * Made checkuid compile cleanly
 * Added rewrite utility

1 /*
2 checkuid.c - Part of psiconv, a PSION 5 file formats converter
3 Copyright (c) 1999, 2000 Frodo Looijaard <frodol@dds.nl>
4
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
23 unsigned long uid1[32] = { /* bit 0 */ 0x000045A0,
24 /* bit 1 */ 0x00008B40,
25 /* bit 2 */ 0x000006A1,
26 /* bit 3 */ 0x00000D42,
27 /* bit 4 */ 0x00001A84,
28 /* bit 5 */ 0x00003508,
29 /* bit 6 */ 0x00006A10,
30 /* bit 7 */ 0x0000D420,
31 /* bit 8 */ 0x45A00000,
32 /* bit 9 */ 0x8B400000,
33 /* bit 10 */ 0x06A10000,
34 /* bit 11 */ 0x0D420000,
35 /* bit 12 */ 0x1A840000,
36 /* bit 13 */ 0x35080000,
37 /* bit 14 */ 0x6A100000,
38 /* bit 15 */ 0xD4200000,
39 /* bit 16 */ 0x0000AA51,
40 /* bit 17 */ 0x00004483,
41 /* bit 18 */ 0x00008906,
42 /* bit 19 */ 0x0000022D,
43 /* bit 20 */ 0x0000045A,
44 /* bit 21 */ 0x000008B4,
45 /* bit 22 */ 0x00001168,
46 /* bit 23 */ 0x000022D0,
47 /* bit 24 */ 0xAA510000,
48 /* bit 25 */ 0x44830000,
49 /* bit 26 */ 0x89060000,
50 /* bit 27 */ 0x022D0000,
51 /* bit 28 */ 0x045A0000,
52 /* bit 29 */ 0x08B40000,
53 /* bit 30 */ 0x11680000,
54 /* bit 31 */ 0x22D00000};
55
56 unsigned long uid2[32] = { /* bit 0 */ 0x000076B4,
57 /* bit 1 */ 0x0000ED68,
58 /* bit 2 */ 0x0000CAF1,
59 /* bit 3 */ 0x000085C3,
60 /* bit 4 */ 0x000018A7,
61 /* bit 5 */ 0x0000374E,
62 /* bit 6 */ 0x00006E9C,
63 /* bit 7 */ 0x0000DD38,
64 /* bit 8 */ 0x76B40000,
65 /* bit 9 */ 0xED680000,
66 /* bit 10 */ 0xCAF10000,
67 /* bit 11 */ 0x85C30000,
68 /* bit 12 */ 0x18A70000,
69 /* bit 13 */ 0x374E0000,
70 /* bit 14 */ 0x6E9C0000,
71 /* bit 15 */ 0xDD380000,
72 /* bit 16 */ 0x00003730,
73 /* bit 17 */ 0x00006E60,
74 /* bit 18 */ 0x0000DCC0,
75 /* bit 19 */ 0x0000A9A1,
76 /* bit 20 */ 0x00004363,
77 /* bit 21 */ 0x000086C6,
78 /* bit 22 */ 0x00001DAD,
79 /* bit 23 */ 0x00003B5A,
80 /* bit 24 */ 0x37300000,
81 /* bit 25 */ 0x6E600000,
82 /* bit 26 */ 0xDCC00000,
83 /* bit 27 */ 0xA9A10000,
84 /* bit 28 */ 0x43630000,
85 /* bit 29 */ 0x86C60000,
86 /* bit 30 */ 0x1DAD0000,
87 /* bit 31 */ 0x3B5A0000 };
88
89 unsigned long uid3[32] = { /* bit 0 */ 0x00003331,
90 /* bit 1 */ 0x00006662,
91 /* bit 2 */ 0x0000CCC4,
92 /* bit 3 */ 0x000089A9,
93 /* bit 4 */ 0x00000373,
94 /* bit 5 */ 0x000006E6,
95 /* bit 6 */ 0x00000DCC,
96 /* bit 7 */ 0x00001B98,
97 /* bit 8 */ 0x33310000,
98 /* bit 9 */ 0x66620000,
99 /* bit 10 */ 0xCCC40000,
100 /* bit 11 */ 0x89A90000,
101 /* bit 12 */ 0x03730000,
102 /* bit 13 */ 0x06E60000,
103 /* bit 14 */ 0x0DCC0000,
104 /* bit 15 */ 0x1B980000,
105 /* bit 16 */ 0x00001021,
106 /* bit 17 */ 0x00002042,
107 /* bit 18 */ 0x00004084,
108 /* bit 19 */ 0x00008108,
109 /* bit 20 */ 0x00001231,
110 /* bit 21 */ 0x00002462,
111 /* bit 22 */ 0x000048C4,
112 /* bit 23 */ 0x00009188,
113 /* bit 24 */ 0x10210000,
114 /* bit 25 */ 0x20420000,
115 /* bit 26 */ 0x40840000,
116 /* bit 27 */ 0x81080000,
117 /* bit 28 */ 0x12310000,
118 /* bit 29 */ 0x24620000,
119 /* bit 30 */ 0x48C40000,
120 /* bit 31 */ 0x91880000 };
121
122
123 unsigned long checkuid(unsigned long id1,unsigned long id2, unsigned long id3)
124 {
125 int i;
126 unsigned long res = 0;
127 for (i = 0; i < 32; i++) {
128 if (id1 & (1 << i))
129 res = res ^ uid1[i];
130 if (id2 & (1 << i))
131 res = res ^ uid2[i];
132 if (id3 & (1 << i))
133 res = res ^ uid3[i];
134 }
135 return res;
136 }
137
138 void printhexdigit(char digit)
139 {
140 if (digit < 10)
141 putchar(digit + '0');
142 else
143 putchar(digit + 'A' - 10);
144 }
145
146 void printhex(unsigned long id)
147 {
148 int i;
149 for (i = 0; i < 8; i ++) {
150 printhexdigit((id & 0xf0000000) >> 28);
151 id = id << 4;
152 }
153 }
154
155 int main(int argc, char *argv[])
156 {
157 unsigned long res;
158 res = checkuid(0x10000037,0x1000006D,0x1000007F);
159 printhex(res);
160 putchar('\n');
161 exit(0);
162 }

frodo@frodo.looijaard.name
ViewVC Help
Powered by ViewVC 1.1.26