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