| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef THIRD_PARTY_HUNSPELL_GOOGLE_BDICT_H_ | 5 #ifndef THIRD_PARTY_HUNSPELL_GOOGLE_BDICT_H_ |
| 6 #define THIRD_PARTY_HUNSPELL_GOOGLE_BDICT_H_ | 6 #define THIRD_PARTY_HUNSPELL_GOOGLE_BDICT_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include <stddef.h> |
| 9 #include <stdint.h> |
| 10 |
| 9 #include "base/md5.h" | 11 #include "base/md5.h" |
| 10 | 12 |
| 11 // BDict (binary dictionary) format. All offsets are little endian. | 13 // BDict (binary dictionary) format. All offsets are little endian. |
| 12 // | 14 // |
| 13 // Header (28 bytes). | 15 // Header (28 bytes). |
| 14 // "BDic" Signature (4 bytes) | 16 // "BDic" Signature (4 bytes) |
| 15 // Version (little endian 4 bytes) | 17 // Version (little endian 4 bytes) |
| 16 // Absolute offset in file of the aff info. (4 bytes) | 18 // Absolute offset in file of the aff info. (4 bytes) |
| 17 // Absolute offset in file of the dic table. (4 bytes) | 19 // Absolute offset in file of the dic table. (4 bytes) |
| 18 // (Added by v2.0) MD5 checksum of the aff info and the dic table. (16 bytes) | 20 // (Added by v2.0) MD5 checksum of the aff info and the dic table. (16 bytes) |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 | 102 |
| 101 class BDict { | 103 class BDict { |
| 102 public: | 104 public: |
| 103 // File header. | 105 // File header. |
| 104 enum { SIGNATURE = 0x63694442 }; | 106 enum { SIGNATURE = 0x63694442 }; |
| 105 enum { | 107 enum { |
| 106 MAJOR_VERSION = 2, | 108 MAJOR_VERSION = 2, |
| 107 MINOR_VERSION = 0 | 109 MINOR_VERSION = 0 |
| 108 }; | 110 }; |
| 109 struct Header { | 111 struct Header { |
| 110 uint32 signature; | 112 uint32_t signature; |
| 111 | 113 |
| 112 // Major versions are incompatible with other major versions. Minor versions | 114 // Major versions are incompatible with other major versions. Minor versions |
| 113 // should be readable by older programs expecting the same major version. | 115 // should be readable by older programs expecting the same major version. |
| 114 uint16 major_version; | 116 uint16_t major_version; |
| 115 uint16 minor_version; | 117 uint16_t minor_version; |
| 116 | 118 |
| 117 uint32 aff_offset; // Offset of the aff data. | 119 uint32_t aff_offset; // Offset of the aff data. |
| 118 uint32 dic_offset; // Offset of the dic data. | 120 uint32_t dic_offset; // Offset of the dic data. |
| 119 | 121 |
| 120 // Added by version 2.0. | 122 // Added by version 2.0. |
| 121 base::MD5Digest digest; // MD5 digest of the aff data and the dic data. | 123 base::MD5Digest digest; // MD5 digest of the aff data and the dic data. |
| 122 }; | 124 }; |
| 123 | 125 |
| 124 // AFF section =============================================================== | 126 // AFF section =============================================================== |
| 125 | 127 |
| 126 struct AffHeader { | 128 struct AffHeader { |
| 127 uint32 affix_group_offset; | 129 uint32_t affix_group_offset; |
| 128 uint32 affix_rule_offset; | 130 uint32_t affix_rule_offset; |
| 129 uint32 rep_offset; // Replacements table. | 131 uint32_t rep_offset; // Replacements table. |
| 130 uint32 other_offset; | 132 uint32_t other_offset; |
| 131 }; | 133 }; |
| 132 | 134 |
| 133 // DIC section =============================================================== | 135 // DIC section =============================================================== |
| 134 | 136 |
| 135 // Leaf ---------------------------------------------------------------------- | 137 // Leaf ---------------------------------------------------------------------- |
| 136 | 138 |
| 137 // Leaf nodes have the high bit set to 0. | 139 // Leaf nodes have the high bit set to 0. |
| 138 enum { LEAF_NODE_TYPE_MASK = 0x80 }; // 10000000 | 140 enum { LEAF_NODE_TYPE_MASK = 0x80 }; // 10000000 |
| 139 enum { LEAF_NODE_TYPE_VALUE = 0 }; // 00000000 | 141 enum { LEAF_NODE_TYPE_VALUE = 0 }; // 00000000 |
| 140 | 142 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 // Verifies the specified BDICT is sane. This function checks the BDICT header | 204 // Verifies the specified BDICT is sane. This function checks the BDICT header |
| 203 // and compares the MD5 digest of the data with the one in the header. | 205 // and compares the MD5 digest of the data with the one in the header. |
| 204 static bool Verify(const char* bdict_data, size_t bdict_length); | 206 static bool Verify(const char* bdict_data, size_t bdict_length); |
| 205 }; | 207 }; |
| 206 | 208 |
| 207 #pragma pack(pop) | 209 #pragma pack(pop) |
| 208 | 210 |
| 209 } // namespace hunspell | 211 } // namespace hunspell |
| 210 | 212 |
| 211 #endif // THIRD_PARTY_HUNSPELL_GOOGLE_BDICT_H_ | 213 #endif // THIRD_PARTY_HUNSPELL_GOOGLE_BDICT_H_ |
| OLD | NEW |