]>
Commit | Line | Data |
---|---|---|
f3c0d7a5 A |
1 | // © 2016 and later: Unicode, Inc. and others. |
2 | // License & terms of use: http://www.unicode.org/copyright.html | |
b75a7d8f A |
3 | /* |
4 | ****************************************************************************** | |
5 | * | |
4388f060 | 6 | * Copyright (C) 1999-2011, International Business Machines |
b75a7d8f A |
7 | * Corporation and others. All Rights Reserved. |
8 | * | |
9 | ******************************************************************************/ | |
10 | ||
11 | ||
12 | /*---------------------------------------------------------------------------------- | |
13 | * | |
14 | * UCommonData An abstract interface for dealing with ICU Common Data Files. | |
15 | * ICU Common Data Files are a grouping of a number of individual | |
16 | * data items (resources, converters, tables, anything) into a | |
17 | * single file or dll. The combined format includes a table of | |
18 | * contents for locating the individual items by name. | |
19 | * | |
20 | * Two formats for the table of contents are supported, which is | |
21 | * why there is an abstract inteface involved. | |
22 | * | |
23 | * These functions are part of the ICU internal implementation, and | |
24 | * are not inteded to be used directly by applications. | |
25 | */ | |
26 | ||
27 | #ifndef __UCMNDATA_H__ | |
28 | #define __UCMNDATA_H__ | |
29 | ||
30 | #include "unicode/udata.h" | |
31 | #include "umapfile.h" | |
32 | ||
33 | ||
34 | #define COMMON_DATA_NAME U_ICUDATA_NAME | |
35 | ||
36 | typedef struct { | |
37 | uint16_t headerSize; | |
38 | uint8_t magic1; | |
39 | uint8_t magic2; | |
40 | } MappedData; | |
41 | ||
42 | ||
43 | typedef struct { | |
44 | MappedData dataHeader; | |
45 | UDataInfo info; | |
46 | } DataHeader; | |
47 | ||
374ca955 A |
48 | typedef struct { |
49 | uint32_t nameOffset; | |
50 | uint32_t dataOffset; | |
51 | } UDataOffsetTOCEntry; | |
52 | ||
53 | typedef struct { | |
54 | uint32_t count; | |
0f5d89e8 A |
55 | /** |
56 | * Variable-length array declared with length 1 to disable bounds checkers. | |
57 | * The actual array length is in the count field. | |
58 | */ | |
59 | UDataOffsetTOCEntry entry[1]; | |
374ca955 A |
60 | } UDataOffsetTOC; |
61 | ||
62 | /** | |
63 | * Get the header size from a const DataHeader *udh. | |
64 | * Handles opposite-endian data. | |
65 | * | |
66 | * @internal | |
67 | */ | |
68 | U_CFUNC uint16_t | |
69 | udata_getHeaderSize(const DataHeader *udh); | |
70 | ||
71 | /** | |
72 | * Get the UDataInfo.size from a const UDataInfo *info. | |
73 | * Handles opposite-endian data. | |
74 | * | |
75 | * @internal | |
76 | */ | |
77 | U_CFUNC uint16_t | |
78 | udata_getInfoSize(const UDataInfo *info); | |
b75a7d8f | 79 | |
4388f060 | 80 | U_CDECL_BEGIN |
b75a7d8f A |
81 | /* |
82 | * "Virtual" functions for data lookup. | |
83 | * To call one, given a UDataMemory *p, the code looks like this: | |
84 | * p->vFuncs.Lookup(p, tocEntryName, pErrorCode); | |
85 | * (I sure do wish this was written in C++, not C) | |
86 | */ | |
87 | ||
88 | typedef const DataHeader * | |
4388f060 A |
89 | (U_CALLCONV * LookupFn)(const UDataMemory *pData, |
90 | const char *tocEntryName, | |
91 | int32_t *pLength, | |
92 | UErrorCode *pErrorCode); | |
b75a7d8f A |
93 | |
94 | typedef uint32_t | |
4388f060 A |
95 | (U_CALLCONV * NumEntriesFn)(const UDataMemory *pData); |
96 | ||
97 | U_CDECL_END | |
b75a7d8f A |
98 | |
99 | typedef struct { | |
100 | LookupFn Lookup; | |
101 | NumEntriesFn NumEntries; | |
102 | } commonDataFuncs; | |
103 | ||
104 | ||
105 | /* | |
106 | * Functions to check whether a UDataMemory refers to memory containing | |
107 | * a recognizable header and table of contents a Common Data Format | |
108 | * | |
109 | * If a valid header and TOC are found, | |
110 | * set the CommonDataFuncs function dispatch vector in the UDataMemory | |
111 | * to point to the right functions for the TOC type. | |
112 | * otherwise | |
113 | * set an errorcode. | |
114 | */ | |
729e4ab9 | 115 | U_CFUNC void udata_checkCommonData(UDataMemory *pData, UErrorCode *pErrorCode); |
b75a7d8f A |
116 | |
117 | #endif |