1*0e209d39SAndroid Build Coastguard Worker // © 2016 and later: Unicode, Inc. and others. 2*0e209d39SAndroid Build Coastguard Worker // License & terms of use: http://www.unicode.org/copyright.html 3*0e209d39SAndroid Build Coastguard Worker /* 4*0e209d39SAndroid Build Coastguard Worker ******************************************************************************* 5*0e209d39SAndroid Build Coastguard Worker * 6*0e209d39SAndroid Build Coastguard Worker * Copyright (C) 2003-2014, International Business Machines 7*0e209d39SAndroid Build Coastguard Worker * Corporation and others. All Rights Reserved. 8*0e209d39SAndroid Build Coastguard Worker * 9*0e209d39SAndroid Build Coastguard Worker ******************************************************************************* 10*0e209d39SAndroid Build Coastguard Worker * file name: udataswp.h 11*0e209d39SAndroid Build Coastguard Worker * encoding: UTF-8 12*0e209d39SAndroid Build Coastguard Worker * tab size: 8 (not used) 13*0e209d39SAndroid Build Coastguard Worker * indentation:4 14*0e209d39SAndroid Build Coastguard Worker * 15*0e209d39SAndroid Build Coastguard Worker * created on: 2003jun05 16*0e209d39SAndroid Build Coastguard Worker * created by: Markus W. Scherer 17*0e209d39SAndroid Build Coastguard Worker * 18*0e209d39SAndroid Build Coastguard Worker * Definitions for ICU data transformations for different platforms, 19*0e209d39SAndroid Build Coastguard Worker * changing between big- and little-endian data and/or between 20*0e209d39SAndroid Build Coastguard Worker * charset families (ASCII<->EBCDIC). 21*0e209d39SAndroid Build Coastguard Worker */ 22*0e209d39SAndroid Build Coastguard Worker 23*0e209d39SAndroid Build Coastguard Worker #ifndef __UDATASWP_H__ 24*0e209d39SAndroid Build Coastguard Worker #define __UDATASWP_H__ 25*0e209d39SAndroid Build Coastguard Worker 26*0e209d39SAndroid Build Coastguard Worker #include <stdarg.h> 27*0e209d39SAndroid Build Coastguard Worker #include "unicode/utypes.h" 28*0e209d39SAndroid Build Coastguard Worker 29*0e209d39SAndroid Build Coastguard Worker /* forward declaration */ 30*0e209d39SAndroid Build Coastguard Worker 31*0e209d39SAndroid Build Coastguard Worker U_CDECL_BEGIN 32*0e209d39SAndroid Build Coastguard Worker 33*0e209d39SAndroid Build Coastguard Worker struct UDataSwapper; 34*0e209d39SAndroid Build Coastguard Worker typedef struct UDataSwapper UDataSwapper; 35*0e209d39SAndroid Build Coastguard Worker 36*0e209d39SAndroid Build Coastguard Worker /** 37*0e209d39SAndroid Build Coastguard Worker * Function type for data transformation. 38*0e209d39SAndroid Build Coastguard Worker * Transforms data, or just returns the length of the data if 39*0e209d39SAndroid Build Coastguard Worker * the input length is -1. 40*0e209d39SAndroid Build Coastguard Worker * Swap functions assume that their data pointers are aligned properly. 41*0e209d39SAndroid Build Coastguard Worker * 42*0e209d39SAndroid Build Coastguard Worker * Quick implementation outline: 43*0e209d39SAndroid Build Coastguard Worker * (best to copy and adapt and existing swapper implementation) 44*0e209d39SAndroid Build Coastguard Worker * check that the data looks like the expected format 45*0e209d39SAndroid Build Coastguard Worker * if(length<0) { 46*0e209d39SAndroid Build Coastguard Worker * preflight: 47*0e209d39SAndroid Build Coastguard Worker * never dereference outData 48*0e209d39SAndroid Build Coastguard Worker * read inData and determine the data size 49*0e209d39SAndroid Build Coastguard Worker * assume that inData is long enough for this 50*0e209d39SAndroid Build Coastguard Worker * } else { 51*0e209d39SAndroid Build Coastguard Worker * outData can be NULL if length==0 52*0e209d39SAndroid Build Coastguard Worker * inData==outData (in-place swapping) possible but not required! 53*0e209d39SAndroid Build Coastguard Worker * verify that length>=(actual size) 54*0e209d39SAndroid Build Coastguard Worker * if there is a chance that not every byte up to size is reached 55*0e209d39SAndroid Build Coastguard Worker * due to padding etc.: 56*0e209d39SAndroid Build Coastguard Worker * if(inData!=outData) { 57*0e209d39SAndroid Build Coastguard Worker * memcpy(outData, inData, actual size); 58*0e209d39SAndroid Build Coastguard Worker * } 59*0e209d39SAndroid Build Coastguard Worker * swap contents 60*0e209d39SAndroid Build Coastguard Worker * } 61*0e209d39SAndroid Build Coastguard Worker * return actual size 62*0e209d39SAndroid Build Coastguard Worker * 63*0e209d39SAndroid Build Coastguard Worker * Further implementation notes: 64*0e209d39SAndroid Build Coastguard Worker * - read integers from inData before swapping them 65*0e209d39SAndroid Build Coastguard Worker * because in-place swapping can make them unreadable 66*0e209d39SAndroid Build Coastguard Worker * - compareInvChars compares a local Unicode string with already-swapped 67*0e209d39SAndroid Build Coastguard Worker * output charset strings 68*0e209d39SAndroid Build Coastguard Worker * 69*0e209d39SAndroid Build Coastguard Worker * @param ds Pointer to UDataSwapper containing global data about the 70*0e209d39SAndroid Build Coastguard Worker * transformation and function pointers for handling primitive 71*0e209d39SAndroid Build Coastguard Worker * types. 72*0e209d39SAndroid Build Coastguard Worker * @param inData Pointer to the input data to be transformed or examined. 73*0e209d39SAndroid Build Coastguard Worker * @param length Length of the data, counting bytes. May be -1 for preflighting. 74*0e209d39SAndroid Build Coastguard Worker * If length>=0, then transform the data. 75*0e209d39SAndroid Build Coastguard Worker * If length==-1, then only determine the length of the data. 76*0e209d39SAndroid Build Coastguard Worker * The length cannot be determined from the data itself for all 77*0e209d39SAndroid Build Coastguard Worker * types of data (e.g., not for simple arrays of integers). 78*0e209d39SAndroid Build Coastguard Worker * @param outData Pointer to the output data buffer. 79*0e209d39SAndroid Build Coastguard Worker * If length>=0 (transformation), then the output buffer must 80*0e209d39SAndroid Build Coastguard Worker * have a capacity of at least length. 81*0e209d39SAndroid Build Coastguard Worker * If length==-1, then outData will not be used and can be NULL. 82*0e209d39SAndroid Build Coastguard Worker * @param pErrorCode ICU UErrorCode parameter, must not be NULL and must 83*0e209d39SAndroid Build Coastguard Worker * fulfill U_SUCCESS on input. 84*0e209d39SAndroid Build Coastguard Worker * @return The actual length of the data. 85*0e209d39SAndroid Build Coastguard Worker * 86*0e209d39SAndroid Build Coastguard Worker * @see UDataSwapper 87*0e209d39SAndroid Build Coastguard Worker * @internal ICU 2.8 88*0e209d39SAndroid Build Coastguard Worker */ 89*0e209d39SAndroid Build Coastguard Worker typedef int32_t U_CALLCONV 90*0e209d39SAndroid Build Coastguard Worker UDataSwapFn(const UDataSwapper *ds, 91*0e209d39SAndroid Build Coastguard Worker const void *inData, int32_t length, void *outData, 92*0e209d39SAndroid Build Coastguard Worker UErrorCode *pErrorCode); 93*0e209d39SAndroid Build Coastguard Worker 94*0e209d39SAndroid Build Coastguard Worker /** 95*0e209d39SAndroid Build Coastguard Worker * Convert one uint16_t from input to platform endianness. 96*0e209d39SAndroid Build Coastguard Worker * @internal ICU 2.8 97*0e209d39SAndroid Build Coastguard Worker */ 98*0e209d39SAndroid Build Coastguard Worker typedef uint16_t U_CALLCONV 99*0e209d39SAndroid Build Coastguard Worker UDataReadUInt16(uint16_t x); 100*0e209d39SAndroid Build Coastguard Worker 101*0e209d39SAndroid Build Coastguard Worker /** 102*0e209d39SAndroid Build Coastguard Worker * Convert one uint32_t from input to platform endianness. 103*0e209d39SAndroid Build Coastguard Worker * @internal ICU 2.8 104*0e209d39SAndroid Build Coastguard Worker */ 105*0e209d39SAndroid Build Coastguard Worker typedef uint32_t U_CALLCONV 106*0e209d39SAndroid Build Coastguard Worker UDataReadUInt32(uint32_t x); 107*0e209d39SAndroid Build Coastguard Worker 108*0e209d39SAndroid Build Coastguard Worker /** 109*0e209d39SAndroid Build Coastguard Worker * Convert one uint16_t from platform to input endianness. 110*0e209d39SAndroid Build Coastguard Worker * @internal ICU 2.8 111*0e209d39SAndroid Build Coastguard Worker */ 112*0e209d39SAndroid Build Coastguard Worker typedef void U_CALLCONV 113*0e209d39SAndroid Build Coastguard Worker UDataWriteUInt16(uint16_t *p, uint16_t x); 114*0e209d39SAndroid Build Coastguard Worker 115*0e209d39SAndroid Build Coastguard Worker /** 116*0e209d39SAndroid Build Coastguard Worker * Convert one uint32_t from platform to input endianness. 117*0e209d39SAndroid Build Coastguard Worker * @internal ICU 2.8 118*0e209d39SAndroid Build Coastguard Worker */ 119*0e209d39SAndroid Build Coastguard Worker typedef void U_CALLCONV 120*0e209d39SAndroid Build Coastguard Worker UDataWriteUInt32(uint32_t *p, uint32_t x); 121*0e209d39SAndroid Build Coastguard Worker 122*0e209d39SAndroid Build Coastguard Worker /** 123*0e209d39SAndroid Build Coastguard Worker * Compare invariant-character strings, one in the output data and the 124*0e209d39SAndroid Build Coastguard Worker * other one caller-provided in Unicode. 125*0e209d39SAndroid Build Coastguard Worker * An output data string is compared because strings are usually swapped 126*0e209d39SAndroid Build Coastguard Worker * before the rest of the data, to allow for sorting of string tables 127*0e209d39SAndroid Build Coastguard Worker * according to the output charset. 128*0e209d39SAndroid Build Coastguard Worker * You can use -1 for the length parameters of NUL-terminated strings as usual. 129*0e209d39SAndroid Build Coastguard Worker * Returns Unicode code point order for invariant characters. 130*0e209d39SAndroid Build Coastguard Worker * @internal ICU 2.8 131*0e209d39SAndroid Build Coastguard Worker */ 132*0e209d39SAndroid Build Coastguard Worker typedef int32_t U_CALLCONV 133*0e209d39SAndroid Build Coastguard Worker UDataCompareInvChars(const UDataSwapper *ds, 134*0e209d39SAndroid Build Coastguard Worker const char *outString, int32_t outLength, 135*0e209d39SAndroid Build Coastguard Worker const UChar *localString, int32_t localLength); 136*0e209d39SAndroid Build Coastguard Worker 137*0e209d39SAndroid Build Coastguard Worker /** 138*0e209d39SAndroid Build Coastguard Worker * Function for message output when an error occurs during data swapping. 139*0e209d39SAndroid Build Coastguard Worker * A format string and variable number of arguments are passed 140*0e209d39SAndroid Build Coastguard Worker * like for vprintf(). 141*0e209d39SAndroid Build Coastguard Worker * 142*0e209d39SAndroid Build Coastguard Worker * @param context A function-specific context pointer. 143*0e209d39SAndroid Build Coastguard Worker * @param fmt The format string. 144*0e209d39SAndroid Build Coastguard Worker * @param args The arguments for format string inserts. 145*0e209d39SAndroid Build Coastguard Worker * 146*0e209d39SAndroid Build Coastguard Worker * @internal ICU 2.8 147*0e209d39SAndroid Build Coastguard Worker */ 148*0e209d39SAndroid Build Coastguard Worker typedef void U_CALLCONV 149*0e209d39SAndroid Build Coastguard Worker UDataPrintError(void *context, const char *fmt, va_list args); 150*0e209d39SAndroid Build Coastguard Worker 151*0e209d39SAndroid Build Coastguard Worker struct UDataSwapper { 152*0e209d39SAndroid Build Coastguard Worker /** Input endianness. @internal ICU 2.8 */ 153*0e209d39SAndroid Build Coastguard Worker UBool inIsBigEndian; 154*0e209d39SAndroid Build Coastguard Worker /** Input charset family. @see U_CHARSET_FAMILY @internal ICU 2.8 */ 155*0e209d39SAndroid Build Coastguard Worker uint8_t inCharset; 156*0e209d39SAndroid Build Coastguard Worker /** Output endianness. @internal ICU 2.8 */ 157*0e209d39SAndroid Build Coastguard Worker UBool outIsBigEndian; 158*0e209d39SAndroid Build Coastguard Worker /** Output charset family. @see U_CHARSET_FAMILY @internal ICU 2.8 */ 159*0e209d39SAndroid Build Coastguard Worker uint8_t outCharset; 160*0e209d39SAndroid Build Coastguard Worker 161*0e209d39SAndroid Build Coastguard Worker /* basic functions for reading data values */ 162*0e209d39SAndroid Build Coastguard Worker 163*0e209d39SAndroid Build Coastguard Worker /** Convert one uint16_t from input to platform endianness. @internal ICU 2.8 */ 164*0e209d39SAndroid Build Coastguard Worker UDataReadUInt16 *readUInt16; 165*0e209d39SAndroid Build Coastguard Worker /** Convert one uint32_t from input to platform endianness. @internal ICU 2.8 */ 166*0e209d39SAndroid Build Coastguard Worker UDataReadUInt32 *readUInt32; 167*0e209d39SAndroid Build Coastguard Worker /** Compare an invariant-character output string with a local one. @internal ICU 2.8 */ 168*0e209d39SAndroid Build Coastguard Worker UDataCompareInvChars *compareInvChars; 169*0e209d39SAndroid Build Coastguard Worker 170*0e209d39SAndroid Build Coastguard Worker /* basic functions for writing data values */ 171*0e209d39SAndroid Build Coastguard Worker 172*0e209d39SAndroid Build Coastguard Worker /** Convert one uint16_t from platform to input endianness. @internal ICU 2.8 */ 173*0e209d39SAndroid Build Coastguard Worker UDataWriteUInt16 *writeUInt16; 174*0e209d39SAndroid Build Coastguard Worker /** Convert one uint32_t from platform to input endianness. @internal ICU 2.8 */ 175*0e209d39SAndroid Build Coastguard Worker UDataWriteUInt32 *writeUInt32; 176*0e209d39SAndroid Build Coastguard Worker 177*0e209d39SAndroid Build Coastguard Worker /* basic functions for data transformations */ 178*0e209d39SAndroid Build Coastguard Worker 179*0e209d39SAndroid Build Coastguard Worker /** Transform an array of 16-bit integers. @internal ICU 2.8 */ 180*0e209d39SAndroid Build Coastguard Worker UDataSwapFn *swapArray16; 181*0e209d39SAndroid Build Coastguard Worker /** Transform an array of 32-bit integers. @internal ICU 2.8 */ 182*0e209d39SAndroid Build Coastguard Worker UDataSwapFn *swapArray32; 183*0e209d39SAndroid Build Coastguard Worker /** Transform an array of 64-bit integers. @internal ICU 53 */ 184*0e209d39SAndroid Build Coastguard Worker UDataSwapFn *swapArray64; 185*0e209d39SAndroid Build Coastguard Worker /** Transform an invariant-character string. @internal ICU 2.8 */ 186*0e209d39SAndroid Build Coastguard Worker UDataSwapFn *swapInvChars; 187*0e209d39SAndroid Build Coastguard Worker 188*0e209d39SAndroid Build Coastguard Worker /** 189*0e209d39SAndroid Build Coastguard Worker * Function for message output when an error occurs during data swapping. 190*0e209d39SAndroid Build Coastguard Worker * Can be NULL. 191*0e209d39SAndroid Build Coastguard Worker * @internal ICU 2.8 192*0e209d39SAndroid Build Coastguard Worker */ 193*0e209d39SAndroid Build Coastguard Worker UDataPrintError *printError; 194*0e209d39SAndroid Build Coastguard Worker /** Context pointer for printError. @internal ICU 2.8 */ 195*0e209d39SAndroid Build Coastguard Worker void *printErrorContext; 196*0e209d39SAndroid Build Coastguard Worker }; 197*0e209d39SAndroid Build Coastguard Worker 198*0e209d39SAndroid Build Coastguard Worker U_CDECL_END 199*0e209d39SAndroid Build Coastguard Worker 200*0e209d39SAndroid Build Coastguard Worker U_CAPI UDataSwapper * U_EXPORT2 201*0e209d39SAndroid Build Coastguard Worker udata_openSwapper(UBool inIsBigEndian, uint8_t inCharset, 202*0e209d39SAndroid Build Coastguard Worker UBool outIsBigEndian, uint8_t outCharset, 203*0e209d39SAndroid Build Coastguard Worker UErrorCode *pErrorCode); 204*0e209d39SAndroid Build Coastguard Worker 205*0e209d39SAndroid Build Coastguard Worker /** 206*0e209d39SAndroid Build Coastguard Worker * Open a UDataSwapper for the given input data and the specified output 207*0e209d39SAndroid Build Coastguard Worker * characteristics. 208*0e209d39SAndroid Build Coastguard Worker * Values of -1 for any of the characteristics mean the local platform's 209*0e209d39SAndroid Build Coastguard Worker * characteristics. 210*0e209d39SAndroid Build Coastguard Worker * 211*0e209d39SAndroid Build Coastguard Worker * @see udata_swap 212*0e209d39SAndroid Build Coastguard Worker * @internal ICU 2.8 213*0e209d39SAndroid Build Coastguard Worker */ 214*0e209d39SAndroid Build Coastguard Worker U_CAPI UDataSwapper * U_EXPORT2 215*0e209d39SAndroid Build Coastguard Worker udata_openSwapperForInputData(const void *data, int32_t length, 216*0e209d39SAndroid Build Coastguard Worker UBool outIsBigEndian, uint8_t outCharset, 217*0e209d39SAndroid Build Coastguard Worker UErrorCode *pErrorCode); 218*0e209d39SAndroid Build Coastguard Worker 219*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2 220*0e209d39SAndroid Build Coastguard Worker udata_closeSwapper(UDataSwapper *ds); 221*0e209d39SAndroid Build Coastguard Worker 222*0e209d39SAndroid Build Coastguard Worker /** 223*0e209d39SAndroid Build Coastguard Worker * Read the beginning of an ICU data piece, recognize magic bytes, 224*0e209d39SAndroid Build Coastguard Worker * swap the structure. 225*0e209d39SAndroid Build Coastguard Worker * Set a U_UNSUPPORTED_ERROR if it does not look like an ICU data piece. 226*0e209d39SAndroid Build Coastguard Worker * 227*0e209d39SAndroid Build Coastguard Worker * @return The size of the data header, in bytes. 228*0e209d39SAndroid Build Coastguard Worker * 229*0e209d39SAndroid Build Coastguard Worker * @internal ICU 2.8 230*0e209d39SAndroid Build Coastguard Worker */ 231*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 232*0e209d39SAndroid Build Coastguard Worker udata_swapDataHeader(const UDataSwapper *ds, 233*0e209d39SAndroid Build Coastguard Worker const void *inData, int32_t length, void *outData, 234*0e209d39SAndroid Build Coastguard Worker UErrorCode *pErrorCode); 235*0e209d39SAndroid Build Coastguard Worker 236*0e209d39SAndroid Build Coastguard Worker /** 237*0e209d39SAndroid Build Coastguard Worker * Convert one int16_t from input to platform endianness. 238*0e209d39SAndroid Build Coastguard Worker * @internal ICU 2.8 239*0e209d39SAndroid Build Coastguard Worker */ 240*0e209d39SAndroid Build Coastguard Worker U_CAPI int16_t U_EXPORT2 241*0e209d39SAndroid Build Coastguard Worker udata_readInt16(const UDataSwapper *ds, int16_t x); 242*0e209d39SAndroid Build Coastguard Worker 243*0e209d39SAndroid Build Coastguard Worker /** 244*0e209d39SAndroid Build Coastguard Worker * Convert one int32_t from input to platform endianness. 245*0e209d39SAndroid Build Coastguard Worker * @internal ICU 2.8 246*0e209d39SAndroid Build Coastguard Worker */ 247*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 248*0e209d39SAndroid Build Coastguard Worker udata_readInt32(const UDataSwapper *ds, int32_t x); 249*0e209d39SAndroid Build Coastguard Worker 250*0e209d39SAndroid Build Coastguard Worker /** 251*0e209d39SAndroid Build Coastguard Worker * Swap a block of invariant, NUL-terminated strings, but not padding 252*0e209d39SAndroid Build Coastguard Worker * bytes after the last string. 253*0e209d39SAndroid Build Coastguard Worker * @internal 254*0e209d39SAndroid Build Coastguard Worker */ 255*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 256*0e209d39SAndroid Build Coastguard Worker udata_swapInvStringBlock(const UDataSwapper *ds, 257*0e209d39SAndroid Build Coastguard Worker const void *inData, int32_t length, void *outData, 258*0e209d39SAndroid Build Coastguard Worker UErrorCode *pErrorCode); 259*0e209d39SAndroid Build Coastguard Worker 260*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2 261*0e209d39SAndroid Build Coastguard Worker udata_printError(const UDataSwapper *ds, 262*0e209d39SAndroid Build Coastguard Worker const char *fmt, 263*0e209d39SAndroid Build Coastguard Worker ...); 264*0e209d39SAndroid Build Coastguard Worker 265*0e209d39SAndroid Build Coastguard Worker /* internal exports from putil.c -------------------------------------------- */ 266*0e209d39SAndroid Build Coastguard Worker 267*0e209d39SAndroid Build Coastguard Worker /* declared here to keep them out of the public putil.h */ 268*0e209d39SAndroid Build Coastguard Worker 269*0e209d39SAndroid Build Coastguard Worker /** 270*0e209d39SAndroid Build Coastguard Worker * Swap invariant char * strings ASCII->EBCDIC. 271*0e209d39SAndroid Build Coastguard Worker * @internal 272*0e209d39SAndroid Build Coastguard Worker */ 273*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 274*0e209d39SAndroid Build Coastguard Worker uprv_ebcdicFromAscii(const UDataSwapper *ds, 275*0e209d39SAndroid Build Coastguard Worker const void *inData, int32_t length, void *outData, 276*0e209d39SAndroid Build Coastguard Worker UErrorCode *pErrorCode); 277*0e209d39SAndroid Build Coastguard Worker 278*0e209d39SAndroid Build Coastguard Worker /** 279*0e209d39SAndroid Build Coastguard Worker * Copy invariant ASCII char * strings and verify they are invariant. 280*0e209d39SAndroid Build Coastguard Worker * @internal 281*0e209d39SAndroid Build Coastguard Worker */ 282*0e209d39SAndroid Build Coastguard Worker U_CFUNC int32_t 283*0e209d39SAndroid Build Coastguard Worker uprv_copyAscii(const UDataSwapper *ds, 284*0e209d39SAndroid Build Coastguard Worker const void *inData, int32_t length, void *outData, 285*0e209d39SAndroid Build Coastguard Worker UErrorCode *pErrorCode); 286*0e209d39SAndroid Build Coastguard Worker 287*0e209d39SAndroid Build Coastguard Worker /** 288*0e209d39SAndroid Build Coastguard Worker * Swap invariant char * strings EBCDIC->ASCII. 289*0e209d39SAndroid Build Coastguard Worker * @internal 290*0e209d39SAndroid Build Coastguard Worker */ 291*0e209d39SAndroid Build Coastguard Worker U_CFUNC int32_t 292*0e209d39SAndroid Build Coastguard Worker uprv_asciiFromEbcdic(const UDataSwapper *ds, 293*0e209d39SAndroid Build Coastguard Worker const void *inData, int32_t length, void *outData, 294*0e209d39SAndroid Build Coastguard Worker UErrorCode *pErrorCode); 295*0e209d39SAndroid Build Coastguard Worker 296*0e209d39SAndroid Build Coastguard Worker /** 297*0e209d39SAndroid Build Coastguard Worker * Copy invariant EBCDIC char * strings and verify they are invariant. 298*0e209d39SAndroid Build Coastguard Worker * @internal 299*0e209d39SAndroid Build Coastguard Worker */ 300*0e209d39SAndroid Build Coastguard Worker U_CFUNC int32_t 301*0e209d39SAndroid Build Coastguard Worker uprv_copyEbcdic(const UDataSwapper *ds, 302*0e209d39SAndroid Build Coastguard Worker const void *inData, int32_t length, void *outData, 303*0e209d39SAndroid Build Coastguard Worker UErrorCode *pErrorCode); 304*0e209d39SAndroid Build Coastguard Worker 305*0e209d39SAndroid Build Coastguard Worker /** 306*0e209d39SAndroid Build Coastguard Worker * Compare ASCII invariant char * with Unicode invariant UChar * 307*0e209d39SAndroid Build Coastguard Worker * @internal 308*0e209d39SAndroid Build Coastguard Worker */ 309*0e209d39SAndroid Build Coastguard Worker U_CFUNC int32_t 310*0e209d39SAndroid Build Coastguard Worker uprv_compareInvAscii(const UDataSwapper *ds, 311*0e209d39SAndroid Build Coastguard Worker const char *outString, int32_t outLength, 312*0e209d39SAndroid Build Coastguard Worker const UChar *localString, int32_t localLength); 313*0e209d39SAndroid Build Coastguard Worker 314*0e209d39SAndroid Build Coastguard Worker /** 315*0e209d39SAndroid Build Coastguard Worker * Compare EBCDIC invariant char * with Unicode invariant UChar * 316*0e209d39SAndroid Build Coastguard Worker * @internal 317*0e209d39SAndroid Build Coastguard Worker */ 318*0e209d39SAndroid Build Coastguard Worker U_CFUNC int32_t 319*0e209d39SAndroid Build Coastguard Worker uprv_compareInvEbcdic(const UDataSwapper *ds, 320*0e209d39SAndroid Build Coastguard Worker const char *outString, int32_t outLength, 321*0e209d39SAndroid Build Coastguard Worker const UChar *localString, int32_t localLength); 322*0e209d39SAndroid Build Coastguard Worker 323*0e209d39SAndroid Build Coastguard Worker /** 324*0e209d39SAndroid Build Coastguard Worker * \def uprv_compareInvWithUChar 325*0e209d39SAndroid Build Coastguard Worker * Compare an invariant-character strings with a UChar string 326*0e209d39SAndroid Build Coastguard Worker * @internal 327*0e209d39SAndroid Build Coastguard Worker */ 328*0e209d39SAndroid Build Coastguard Worker #if U_CHARSET_FAMILY==U_ASCII_FAMILY 329*0e209d39SAndroid Build Coastguard Worker # define uprv_compareInvWithUChar uprv_compareInvAscii 330*0e209d39SAndroid Build Coastguard Worker #elif U_CHARSET_FAMILY==U_EBCDIC_FAMILY 331*0e209d39SAndroid Build Coastguard Worker # define uprv_compareInvWithUChar uprv_compareInvEbcdic 332*0e209d39SAndroid Build Coastguard Worker #else 333*0e209d39SAndroid Build Coastguard Worker # error Unknown charset family! 334*0e209d39SAndroid Build Coastguard Worker #endif 335*0e209d39SAndroid Build Coastguard Worker 336*0e209d39SAndroid Build Coastguard Worker // utrie_swap.cpp -----------------------------------------------------------*** 337*0e209d39SAndroid Build Coastguard Worker 338*0e209d39SAndroid Build Coastguard Worker /** 339*0e209d39SAndroid Build Coastguard Worker * Swaps a serialized UTrie. 340*0e209d39SAndroid Build Coastguard Worker * @internal 341*0e209d39SAndroid Build Coastguard Worker */ 342*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 343*0e209d39SAndroid Build Coastguard Worker utrie_swap(const UDataSwapper *ds, 344*0e209d39SAndroid Build Coastguard Worker const void *inData, int32_t length, void *outData, 345*0e209d39SAndroid Build Coastguard Worker UErrorCode *pErrorCode); 346*0e209d39SAndroid Build Coastguard Worker 347*0e209d39SAndroid Build Coastguard Worker /** 348*0e209d39SAndroid Build Coastguard Worker * Swaps a serialized UTrie2. 349*0e209d39SAndroid Build Coastguard Worker * @internal 350*0e209d39SAndroid Build Coastguard Worker */ 351*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 352*0e209d39SAndroid Build Coastguard Worker utrie2_swap(const UDataSwapper *ds, 353*0e209d39SAndroid Build Coastguard Worker const void *inData, int32_t length, void *outData, 354*0e209d39SAndroid Build Coastguard Worker UErrorCode *pErrorCode); 355*0e209d39SAndroid Build Coastguard Worker 356*0e209d39SAndroid Build Coastguard Worker /** 357*0e209d39SAndroid Build Coastguard Worker * Swaps a serialized UCPTrie. 358*0e209d39SAndroid Build Coastguard Worker * @internal 359*0e209d39SAndroid Build Coastguard Worker */ 360*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 361*0e209d39SAndroid Build Coastguard Worker ucptrie_swap(const UDataSwapper *ds, 362*0e209d39SAndroid Build Coastguard Worker const void *inData, int32_t length, void *outData, 363*0e209d39SAndroid Build Coastguard Worker UErrorCode *pErrorCode); 364*0e209d39SAndroid Build Coastguard Worker 365*0e209d39SAndroid Build Coastguard Worker /** 366*0e209d39SAndroid Build Coastguard Worker * Swaps a serialized UTrie, UTrie2, or UCPTrie. 367*0e209d39SAndroid Build Coastguard Worker * @internal 368*0e209d39SAndroid Build Coastguard Worker */ 369*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 370*0e209d39SAndroid Build Coastguard Worker utrie_swapAnyVersion(const UDataSwapper *ds, 371*0e209d39SAndroid Build Coastguard Worker const void *inData, int32_t length, void *outData, 372*0e209d39SAndroid Build Coastguard Worker UErrorCode *pErrorCode); 373*0e209d39SAndroid Build Coastguard Worker 374*0e209d39SAndroid Build Coastguard Worker /* material... -------------------------------------------------------------- */ 375*0e209d39SAndroid Build Coastguard Worker 376*0e209d39SAndroid Build Coastguard Worker #if 0 377*0e209d39SAndroid Build Coastguard Worker 378*0e209d39SAndroid Build Coastguard Worker /* udata.h */ 379*0e209d39SAndroid Build Coastguard Worker 380*0e209d39SAndroid Build Coastguard Worker /** 381*0e209d39SAndroid Build Coastguard Worker * Public API function in udata.c 382*0e209d39SAndroid Build Coastguard Worker * 383*0e209d39SAndroid Build Coastguard Worker * Same as udata_openChoice() but automatically swaps the data. 384*0e209d39SAndroid Build Coastguard Worker * isAcceptable, if not NULL, may accept data with endianness and charset family 385*0e209d39SAndroid Build Coastguard Worker * different from the current platform's properties. 386*0e209d39SAndroid Build Coastguard Worker * If the data is acceptable and the platform properties do not match, then 387*0e209d39SAndroid Build Coastguard Worker * the swap function is called to swap an allocated version of the data. 388*0e209d39SAndroid Build Coastguard Worker * Preflighting may or may not be performed depending on whether the size of 389*0e209d39SAndroid Build Coastguard Worker * the loaded data item is known. 390*0e209d39SAndroid Build Coastguard Worker * 391*0e209d39SAndroid Build Coastguard Worker * @param isAcceptable Same as for udata_openChoice(). May be NULL. 392*0e209d39SAndroid Build Coastguard Worker * 393*0e209d39SAndroid Build Coastguard Worker * @internal ICU 2.8 394*0e209d39SAndroid Build Coastguard Worker */ 395*0e209d39SAndroid Build Coastguard Worker U_CAPI UDataMemory * U_EXPORT2 396*0e209d39SAndroid Build Coastguard Worker udata_openSwap(const char *path, const char *type, const char *name, 397*0e209d39SAndroid Build Coastguard Worker UDataMemoryIsAcceptable *isAcceptable, void *isAcceptableContext, 398*0e209d39SAndroid Build Coastguard Worker UDataSwapFn *swap, 399*0e209d39SAndroid Build Coastguard Worker UDataPrintError *printError, void *printErrorContext, 400*0e209d39SAndroid Build Coastguard Worker UErrorCode *pErrorCode); 401*0e209d39SAndroid Build Coastguard Worker 402*0e209d39SAndroid Build Coastguard Worker #endif 403*0e209d39SAndroid Build Coastguard Worker 404*0e209d39SAndroid Build Coastguard Worker #endif 405