| 1 | /* | 
| 2 | checkuid.c - Part of psiconv, a PSION 5 file formats converter | 
| 3 | Copyright (c) 1999  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 | #include "config.h" | 
| 21 | #include "data.h" | 
| 22 |  | 
| 23 | static psiconv_u32 uid1[32] = | 
| 24 | { /* 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 | static psiconv_u32 uid2[32] = | 
| 58 | { /* bit 0  */  0x000076B4, | 
| 59 | /* bit 1  */  0x0000ED68, | 
| 60 | /* bit 2  */  0x0000CAF1, | 
| 61 | /* bit 3  */  0x000085C3, | 
| 62 | /* bit 4  */  0x000018A7, | 
| 63 | /* bit 5  */  0x0000374E, | 
| 64 | /* bit 6  */  0x00006E9C, | 
| 65 | /* bit 7  */  0x0000DD38, | 
| 66 | /* bit 8  */  0x76B40000, | 
| 67 | /* bit 9  */  0xED680000, | 
| 68 | /* bit 10 */  0xCAF10000, | 
| 69 | /* bit 11 */  0x85C30000, | 
| 70 | /* bit 12 */  0x18A70000, | 
| 71 | /* bit 13 */  0x374E0000, | 
| 72 | /* bit 14 */  0x6E9C0000, | 
| 73 | /* bit 15 */  0xDD380000, | 
| 74 | /* bit 16 */  0x00003730, | 
| 75 | /* bit 17 */  0x00006E60, | 
| 76 | /* bit 18 */  0x0000DCC0, | 
| 77 | /* bit 19 */  0x0000A9A1, | 
| 78 | /* bit 20 */  0x00004363, | 
| 79 | /* bit 21 */  0x000086C6, | 
| 80 | /* bit 22 */  0x00001DAD, | 
| 81 | /* bit 23 */  0x00003B5A, | 
| 82 | /* bit 24 */  0x37300000, | 
| 83 | /* bit 25 */  0x6E600000, | 
| 84 | /* bit 26 */  0xDCC00000, | 
| 85 | /* bit 27 */  0xA9A10000, | 
| 86 | /* bit 28 */  0x43630000, | 
| 87 | /* bit 29 */  0x86C60000, | 
| 88 | /* bit 30 */  0x1DAD0000, | 
| 89 | /* bit 31 */  0x3B5A0000 }; | 
| 90 |  | 
| 91 | static psiconv_u32 uid3[32] = | 
| 92 | { /* bit 0  */  0x00003331, | 
| 93 | /* bit 1  */  0x00006662, | 
| 94 | /* bit 2  */  0x0000CCC4, | 
| 95 | /* bit 3  */  0x000089A9, | 
| 96 | /* bit 4  */  0x00000373, | 
| 97 | /* bit 5  */  0x000006E6, | 
| 98 | /* bit 6  */  0x00000DCC, | 
| 99 | /* bit 7  */  0x00001B98, | 
| 100 | /* bit 8  */  0x33310000, | 
| 101 | /* bit 9  */  0x66620000, | 
| 102 | /* bit 10 */  0xCCC40000, | 
| 103 | /* bit 11 */  0x89A90000, | 
| 104 | /* bit 12 */  0x03730000, | 
| 105 | /* bit 13 */  0x06E60000, | 
| 106 | /* bit 14 */  0x0DCC0000, | 
| 107 | /* bit 15 */  0x1B980000, | 
| 108 | /* bit 16 */  0x00001021, | 
| 109 | /* bit 17 */  0x00002042, | 
| 110 | /* bit 18 */  0x00004084, | 
| 111 | /* bit 19 */  0x00008108, | 
| 112 | /* bit 20 */  0x00001231, | 
| 113 | /* bit 21 */  0x00002462, | 
| 114 | /* bit 22 */  0x000048C4, | 
| 115 | /* bit 23 */  0x00009188, | 
| 116 | /* bit 24 */  0x10210000, | 
| 117 | /* bit 25 */  0x20420000, | 
| 118 | /* bit 26 */  0x40840000, | 
| 119 | /* bit 27 */  0x81080000, | 
| 120 | /* bit 28 */  0x12310000, | 
| 121 | /* bit 29 */  0x24620000, | 
| 122 | /* bit 30 */  0x48C40000, | 
| 123 | /* bit 31 */  0x91880000 }; | 
| 124 |  | 
| 125 |  | 
| 126 | psiconv_u32 psiconv_checkuid(psiconv_u32 id1,psiconv_u32 id2,psiconv_u32 id3) | 
| 127 | { | 
| 128 | psiconv_u32 i; | 
| 129 | psiconv_u32 res = 0; | 
| 130 | for (i = 0; i < 32; i++) { | 
| 131 | if (id1 & (1 << i)) | 
| 132 | res = res ^ uid1[i]; | 
| 133 | if (id2 & (1 << i)) | 
| 134 | res = res ^ uid2[i]; | 
| 135 | if (id3 & (1 << i)) | 
| 136 | res = res ^ uid3[i]; | 
| 137 | } | 
| 138 | return res; | 
| 139 | } |