sl@0: /* sl@0: ****************************************************************************** sl@0: * sl@0: * Copyright (C) 1999-2003, International Business Machines sl@0: * Corporation and others. All Rights Reserved. sl@0: * sl@0: ******************************************************************************/ sl@0: sl@0: sl@0: /*---------------------------------------------------------------------------------- sl@0: * sl@0: * UCommonData An abstract interface for dealing with ICU Common Data Files. sl@0: * ICU Common Data Files are a grouping of a number of individual sl@0: * data items (resources, converters, tables, anything) into a sl@0: * single file or dll. The combined format includes a table of sl@0: * contents for locating the individual items by name. sl@0: * sl@0: * Two formats for the table of contents are supported, which is sl@0: * why there is an abstract inteface involved. sl@0: * sl@0: * These functions are part of the ICU internal implementation, and sl@0: * are not inteded to be used directly by applications. sl@0: */ sl@0: sl@0: #ifndef __UCMNDATA_H__ sl@0: #define __UCMNDATA_H__ sl@0: sl@0: #include "unicode/udata.h" sl@0: #include "umapfile.h" sl@0: sl@0: sl@0: #define COMMON_DATA_NAME U_ICUDATA_NAME sl@0: sl@0: typedef struct { sl@0: uint16_t headerSize; sl@0: uint8_t magic1; sl@0: uint8_t magic2; sl@0: } MappedData; sl@0: sl@0: sl@0: typedef struct { sl@0: MappedData dataHeader; sl@0: UDataInfo info; sl@0: } DataHeader; sl@0: sl@0: typedef struct { sl@0: uint32_t nameOffset; sl@0: uint32_t dataOffset; sl@0: } UDataOffsetTOCEntry; sl@0: sl@0: typedef struct { sl@0: uint32_t count; sl@0: UDataOffsetTOCEntry entry[2]; /* Actual size of array is from count. */ sl@0: } UDataOffsetTOC; sl@0: sl@0: /** sl@0: * Get the header size from a const DataHeader *udh. sl@0: * Handles opposite-endian data. sl@0: * sl@0: * @internal sl@0: */ sl@0: U_CFUNC uint16_t sl@0: udata_getHeaderSize(const DataHeader *udh); sl@0: sl@0: /** sl@0: * Get the UDataInfo.size from a const UDataInfo *info. sl@0: * Handles opposite-endian data. sl@0: * sl@0: * @internal sl@0: */ sl@0: U_CFUNC uint16_t sl@0: udata_getInfoSize(const UDataInfo *info); sl@0: sl@0: /* sl@0: * "Virtual" functions for data lookup. sl@0: * To call one, given a UDataMemory *p, the code looks like this: sl@0: * p->vFuncs.Lookup(p, tocEntryName, pErrorCode); sl@0: * (I sure do wish this was written in C++, not C) sl@0: */ sl@0: sl@0: typedef const DataHeader * sl@0: (* LookupFn)(const UDataMemory *pData, sl@0: const char *tocEntryName, sl@0: int32_t *pLength, sl@0: UErrorCode *pErrorCode); sl@0: sl@0: typedef uint32_t sl@0: (* NumEntriesFn)(const UDataMemory *pData); sl@0: sl@0: typedef struct { sl@0: LookupFn Lookup; sl@0: NumEntriesFn NumEntries; sl@0: } commonDataFuncs; sl@0: sl@0: sl@0: /* sl@0: * Functions to check whether a UDataMemory refers to memory containing sl@0: * a recognizable header and table of contents a Common Data Format sl@0: * sl@0: * If a valid header and TOC are found, sl@0: * set the CommonDataFuncs function dispatch vector in the UDataMemory sl@0: * to point to the right functions for the TOC type. sl@0: * otherwise sl@0: * set an errorcode. sl@0: */ sl@0: void udata_checkCommonData(UDataMemory *pData, UErrorCode *pErrorCode); sl@0: sl@0: sl@0: #endif