11cb0ef41Sopenharmony_ci// © 2016 and later: Unicode, Inc. and others.
21cb0ef41Sopenharmony_ci// License & terms of use: http://www.unicode.org/copyright.html
31cb0ef41Sopenharmony_ci/*
41cb0ef41Sopenharmony_ci*******************************************************************************
51cb0ef41Sopenharmony_ci*
61cb0ef41Sopenharmony_ci*   Copyright (C) 2003-2014, International Business Machines
71cb0ef41Sopenharmony_ci*   Corporation and others.  All Rights Reserved.
81cb0ef41Sopenharmony_ci*
91cb0ef41Sopenharmony_ci*******************************************************************************
101cb0ef41Sopenharmony_ci*   file name:  udataswp.h
111cb0ef41Sopenharmony_ci*   encoding:   UTF-8
121cb0ef41Sopenharmony_ci*   tab size:   8 (not used)
131cb0ef41Sopenharmony_ci*   indentation:4
141cb0ef41Sopenharmony_ci*
151cb0ef41Sopenharmony_ci*   created on: 2003jun05
161cb0ef41Sopenharmony_ci*   created by: Markus W. Scherer
171cb0ef41Sopenharmony_ci*
181cb0ef41Sopenharmony_ci*   Definitions for ICU data transformations for different platforms,
191cb0ef41Sopenharmony_ci*   changing between big- and little-endian data and/or between
201cb0ef41Sopenharmony_ci*   charset families (ASCII<->EBCDIC).
211cb0ef41Sopenharmony_ci*/
221cb0ef41Sopenharmony_ci
231cb0ef41Sopenharmony_ci#ifndef __UDATASWP_H__
241cb0ef41Sopenharmony_ci#define __UDATASWP_H__
251cb0ef41Sopenharmony_ci
261cb0ef41Sopenharmony_ci#include <stdarg.h>
271cb0ef41Sopenharmony_ci#include "unicode/utypes.h"
281cb0ef41Sopenharmony_ci
291cb0ef41Sopenharmony_ci/* forward declaration */
301cb0ef41Sopenharmony_ci
311cb0ef41Sopenharmony_ciU_CDECL_BEGIN
321cb0ef41Sopenharmony_ci
331cb0ef41Sopenharmony_cistruct UDataSwapper;
341cb0ef41Sopenharmony_citypedef struct UDataSwapper UDataSwapper;
351cb0ef41Sopenharmony_ci
361cb0ef41Sopenharmony_ci/**
371cb0ef41Sopenharmony_ci * Function type for data transformation.
381cb0ef41Sopenharmony_ci * Transforms data, or just returns the length of the data if
391cb0ef41Sopenharmony_ci * the input length is -1.
401cb0ef41Sopenharmony_ci * Swap functions assume that their data pointers are aligned properly.
411cb0ef41Sopenharmony_ci *
421cb0ef41Sopenharmony_ci * Quick implementation outline:
431cb0ef41Sopenharmony_ci * (best to copy and adapt and existing swapper implementation)
441cb0ef41Sopenharmony_ci * check that the data looks like the expected format
451cb0ef41Sopenharmony_ci * if(length<0) {
461cb0ef41Sopenharmony_ci *   preflight:
471cb0ef41Sopenharmony_ci *   never dereference outData
481cb0ef41Sopenharmony_ci *   read inData and determine the data size
491cb0ef41Sopenharmony_ci *   assume that inData is long enough for this
501cb0ef41Sopenharmony_ci * } else {
511cb0ef41Sopenharmony_ci *   outData can be NULL if length==0
521cb0ef41Sopenharmony_ci *   inData==outData (in-place swapping) possible but not required!
531cb0ef41Sopenharmony_ci *   verify that length>=(actual size)
541cb0ef41Sopenharmony_ci *   if there is a chance that not every byte up to size is reached
551cb0ef41Sopenharmony_ci *     due to padding etc.:
561cb0ef41Sopenharmony_ci *   if(inData!=outData) {
571cb0ef41Sopenharmony_ci *     memcpy(outData, inData, actual size);
581cb0ef41Sopenharmony_ci *   }
591cb0ef41Sopenharmony_ci *   swap contents
601cb0ef41Sopenharmony_ci * }
611cb0ef41Sopenharmony_ci * return actual size
621cb0ef41Sopenharmony_ci *
631cb0ef41Sopenharmony_ci * Further implementation notes:
641cb0ef41Sopenharmony_ci * - read integers from inData before swapping them
651cb0ef41Sopenharmony_ci *   because in-place swapping can make them unreadable
661cb0ef41Sopenharmony_ci * - compareInvChars compares a local Unicode string with already-swapped
671cb0ef41Sopenharmony_ci *   output charset strings
681cb0ef41Sopenharmony_ci *
691cb0ef41Sopenharmony_ci * @param ds Pointer to UDataSwapper containing global data about the
701cb0ef41Sopenharmony_ci *           transformation and function pointers for handling primitive
711cb0ef41Sopenharmony_ci *           types.
721cb0ef41Sopenharmony_ci * @param inData Pointer to the input data to be transformed or examined.
731cb0ef41Sopenharmony_ci * @param length Length of the data, counting bytes. May be -1 for preflighting.
741cb0ef41Sopenharmony_ci *               If length>=0, then transform the data.
751cb0ef41Sopenharmony_ci *               If length==-1, then only determine the length of the data.
761cb0ef41Sopenharmony_ci *               The length cannot be determined from the data itself for all
771cb0ef41Sopenharmony_ci *               types of data (e.g., not for simple arrays of integers).
781cb0ef41Sopenharmony_ci * @param outData Pointer to the output data buffer.
791cb0ef41Sopenharmony_ci *                If length>=0 (transformation), then the output buffer must
801cb0ef41Sopenharmony_ci *                have a capacity of at least length.
811cb0ef41Sopenharmony_ci *                If length==-1, then outData will not be used and can be NULL.
821cb0ef41Sopenharmony_ci * @param pErrorCode ICU UErrorCode parameter, must not be NULL and must
831cb0ef41Sopenharmony_ci *                   fulfill U_SUCCESS on input.
841cb0ef41Sopenharmony_ci * @return The actual length of the data.
851cb0ef41Sopenharmony_ci *
861cb0ef41Sopenharmony_ci * @see UDataSwapper
871cb0ef41Sopenharmony_ci * @internal ICU 2.8
881cb0ef41Sopenharmony_ci */
891cb0ef41Sopenharmony_citypedef int32_t U_CALLCONV
901cb0ef41Sopenharmony_ciUDataSwapFn(const UDataSwapper *ds,
911cb0ef41Sopenharmony_ci            const void *inData, int32_t length, void *outData,
921cb0ef41Sopenharmony_ci            UErrorCode *pErrorCode);
931cb0ef41Sopenharmony_ci
941cb0ef41Sopenharmony_ci/**
951cb0ef41Sopenharmony_ci * Convert one uint16_t from input to platform endianness.
961cb0ef41Sopenharmony_ci * @internal ICU 2.8
971cb0ef41Sopenharmony_ci */
981cb0ef41Sopenharmony_citypedef uint16_t U_CALLCONV
991cb0ef41Sopenharmony_ciUDataReadUInt16(uint16_t x);
1001cb0ef41Sopenharmony_ci
1011cb0ef41Sopenharmony_ci/**
1021cb0ef41Sopenharmony_ci * Convert one uint32_t from input to platform endianness.
1031cb0ef41Sopenharmony_ci * @internal ICU 2.8
1041cb0ef41Sopenharmony_ci */
1051cb0ef41Sopenharmony_citypedef uint32_t U_CALLCONV
1061cb0ef41Sopenharmony_ciUDataReadUInt32(uint32_t x);
1071cb0ef41Sopenharmony_ci
1081cb0ef41Sopenharmony_ci/**
1091cb0ef41Sopenharmony_ci * Convert one uint16_t from platform to input endianness.
1101cb0ef41Sopenharmony_ci * @internal ICU 2.8
1111cb0ef41Sopenharmony_ci */
1121cb0ef41Sopenharmony_citypedef void U_CALLCONV
1131cb0ef41Sopenharmony_ciUDataWriteUInt16(uint16_t *p, uint16_t x);
1141cb0ef41Sopenharmony_ci
1151cb0ef41Sopenharmony_ci/**
1161cb0ef41Sopenharmony_ci * Convert one uint32_t from platform to input endianness.
1171cb0ef41Sopenharmony_ci * @internal ICU 2.8
1181cb0ef41Sopenharmony_ci */
1191cb0ef41Sopenharmony_citypedef void U_CALLCONV
1201cb0ef41Sopenharmony_ciUDataWriteUInt32(uint32_t *p, uint32_t x);
1211cb0ef41Sopenharmony_ci
1221cb0ef41Sopenharmony_ci/**
1231cb0ef41Sopenharmony_ci * Compare invariant-character strings, one in the output data and the
1241cb0ef41Sopenharmony_ci * other one caller-provided in Unicode.
1251cb0ef41Sopenharmony_ci * An output data string is compared because strings are usually swapped
1261cb0ef41Sopenharmony_ci * before the rest of the data, to allow for sorting of string tables
1271cb0ef41Sopenharmony_ci * according to the output charset.
1281cb0ef41Sopenharmony_ci * You can use -1 for the length parameters of NUL-terminated strings as usual.
1291cb0ef41Sopenharmony_ci * Returns Unicode code point order for invariant characters.
1301cb0ef41Sopenharmony_ci * @internal ICU 2.8
1311cb0ef41Sopenharmony_ci */
1321cb0ef41Sopenharmony_citypedef int32_t U_CALLCONV
1331cb0ef41Sopenharmony_ciUDataCompareInvChars(const UDataSwapper *ds,
1341cb0ef41Sopenharmony_ci                     const char *outString, int32_t outLength,
1351cb0ef41Sopenharmony_ci                     const UChar *localString, int32_t localLength);
1361cb0ef41Sopenharmony_ci
1371cb0ef41Sopenharmony_ci/**
1381cb0ef41Sopenharmony_ci * Function for message output when an error occurs during data swapping.
1391cb0ef41Sopenharmony_ci * A format string and variable number of arguments are passed
1401cb0ef41Sopenharmony_ci * like for vprintf().
1411cb0ef41Sopenharmony_ci *
1421cb0ef41Sopenharmony_ci * @param context A function-specific context pointer.
1431cb0ef41Sopenharmony_ci * @param fmt The format string.
1441cb0ef41Sopenharmony_ci * @param args The arguments for format string inserts.
1451cb0ef41Sopenharmony_ci *
1461cb0ef41Sopenharmony_ci * @internal ICU 2.8
1471cb0ef41Sopenharmony_ci */
1481cb0ef41Sopenharmony_citypedef void U_CALLCONV
1491cb0ef41Sopenharmony_ciUDataPrintError(void *context, const char *fmt, va_list args);
1501cb0ef41Sopenharmony_ci
1511cb0ef41Sopenharmony_cistruct UDataSwapper {
1521cb0ef41Sopenharmony_ci    /** Input endianness. @internal ICU 2.8 */
1531cb0ef41Sopenharmony_ci    UBool inIsBigEndian;
1541cb0ef41Sopenharmony_ci    /** Input charset family. @see U_CHARSET_FAMILY @internal ICU 2.8 */
1551cb0ef41Sopenharmony_ci    uint8_t inCharset;
1561cb0ef41Sopenharmony_ci    /** Output endianness. @internal ICU 2.8 */
1571cb0ef41Sopenharmony_ci    UBool outIsBigEndian;
1581cb0ef41Sopenharmony_ci    /** Output charset family. @see U_CHARSET_FAMILY @internal ICU 2.8 */
1591cb0ef41Sopenharmony_ci    uint8_t outCharset;
1601cb0ef41Sopenharmony_ci
1611cb0ef41Sopenharmony_ci    /* basic functions for reading data values */
1621cb0ef41Sopenharmony_ci
1631cb0ef41Sopenharmony_ci    /** Convert one uint16_t from input to platform endianness. @internal ICU 2.8 */
1641cb0ef41Sopenharmony_ci    UDataReadUInt16 *readUInt16;
1651cb0ef41Sopenharmony_ci    /** Convert one uint32_t from input to platform endianness. @internal ICU 2.8 */
1661cb0ef41Sopenharmony_ci    UDataReadUInt32 *readUInt32;
1671cb0ef41Sopenharmony_ci    /** Compare an invariant-character output string with a local one. @internal ICU 2.8 */
1681cb0ef41Sopenharmony_ci    UDataCompareInvChars *compareInvChars;
1691cb0ef41Sopenharmony_ci
1701cb0ef41Sopenharmony_ci    /* basic functions for writing data values */
1711cb0ef41Sopenharmony_ci
1721cb0ef41Sopenharmony_ci    /** Convert one uint16_t from platform to input endianness. @internal ICU 2.8 */
1731cb0ef41Sopenharmony_ci    UDataWriteUInt16 *writeUInt16;
1741cb0ef41Sopenharmony_ci    /** Convert one uint32_t from platform to input endianness. @internal ICU 2.8 */
1751cb0ef41Sopenharmony_ci    UDataWriteUInt32 *writeUInt32;
1761cb0ef41Sopenharmony_ci
1771cb0ef41Sopenharmony_ci    /* basic functions for data transformations */
1781cb0ef41Sopenharmony_ci
1791cb0ef41Sopenharmony_ci    /** Transform an array of 16-bit integers. @internal ICU 2.8 */
1801cb0ef41Sopenharmony_ci    UDataSwapFn *swapArray16;
1811cb0ef41Sopenharmony_ci    /** Transform an array of 32-bit integers. @internal ICU 2.8 */
1821cb0ef41Sopenharmony_ci    UDataSwapFn *swapArray32;
1831cb0ef41Sopenharmony_ci    /** Transform an array of 64-bit integers. @internal ICU 53 */
1841cb0ef41Sopenharmony_ci    UDataSwapFn *swapArray64;
1851cb0ef41Sopenharmony_ci    /** Transform an invariant-character string. @internal ICU 2.8 */
1861cb0ef41Sopenharmony_ci    UDataSwapFn *swapInvChars;
1871cb0ef41Sopenharmony_ci
1881cb0ef41Sopenharmony_ci    /**
1891cb0ef41Sopenharmony_ci     * Function for message output when an error occurs during data swapping.
1901cb0ef41Sopenharmony_ci     * Can be NULL.
1911cb0ef41Sopenharmony_ci     * @internal ICU 2.8
1921cb0ef41Sopenharmony_ci     */
1931cb0ef41Sopenharmony_ci    UDataPrintError *printError;
1941cb0ef41Sopenharmony_ci    /** Context pointer for printError. @internal ICU 2.8 */
1951cb0ef41Sopenharmony_ci    void *printErrorContext;
1961cb0ef41Sopenharmony_ci};
1971cb0ef41Sopenharmony_ci
1981cb0ef41Sopenharmony_ciU_CDECL_END
1991cb0ef41Sopenharmony_ci
2001cb0ef41Sopenharmony_ciU_CAPI UDataSwapper * U_EXPORT2
2011cb0ef41Sopenharmony_ciudata_openSwapper(UBool inIsBigEndian, uint8_t inCharset,
2021cb0ef41Sopenharmony_ci                  UBool outIsBigEndian, uint8_t outCharset,
2031cb0ef41Sopenharmony_ci                  UErrorCode *pErrorCode);
2041cb0ef41Sopenharmony_ci
2051cb0ef41Sopenharmony_ci/**
2061cb0ef41Sopenharmony_ci * Open a UDataSwapper for the given input data and the specified output
2071cb0ef41Sopenharmony_ci * characteristics.
2081cb0ef41Sopenharmony_ci * Values of -1 for any of the characteristics mean the local platform's
2091cb0ef41Sopenharmony_ci * characteristics.
2101cb0ef41Sopenharmony_ci *
2111cb0ef41Sopenharmony_ci * @see udata_swap
2121cb0ef41Sopenharmony_ci * @internal ICU 2.8
2131cb0ef41Sopenharmony_ci */
2141cb0ef41Sopenharmony_ciU_CAPI UDataSwapper * U_EXPORT2
2151cb0ef41Sopenharmony_ciudata_openSwapperForInputData(const void *data, int32_t length,
2161cb0ef41Sopenharmony_ci                              UBool outIsBigEndian, uint8_t outCharset,
2171cb0ef41Sopenharmony_ci                              UErrorCode *pErrorCode);
2181cb0ef41Sopenharmony_ci
2191cb0ef41Sopenharmony_ciU_CAPI void U_EXPORT2
2201cb0ef41Sopenharmony_ciudata_closeSwapper(UDataSwapper *ds);
2211cb0ef41Sopenharmony_ci
2221cb0ef41Sopenharmony_ci/**
2231cb0ef41Sopenharmony_ci * Read the beginning of an ICU data piece, recognize magic bytes,
2241cb0ef41Sopenharmony_ci * swap the structure.
2251cb0ef41Sopenharmony_ci * Set a U_UNSUPPORTED_ERROR if it does not look like an ICU data piece.
2261cb0ef41Sopenharmony_ci *
2271cb0ef41Sopenharmony_ci * @return The size of the data header, in bytes.
2281cb0ef41Sopenharmony_ci *
2291cb0ef41Sopenharmony_ci * @internal ICU 2.8
2301cb0ef41Sopenharmony_ci */
2311cb0ef41Sopenharmony_ciU_CAPI int32_t U_EXPORT2
2321cb0ef41Sopenharmony_ciudata_swapDataHeader(const UDataSwapper *ds,
2331cb0ef41Sopenharmony_ci                     const void *inData, int32_t length, void *outData,
2341cb0ef41Sopenharmony_ci                     UErrorCode *pErrorCode);
2351cb0ef41Sopenharmony_ci
2361cb0ef41Sopenharmony_ci/**
2371cb0ef41Sopenharmony_ci * Convert one int16_t from input to platform endianness.
2381cb0ef41Sopenharmony_ci * @internal ICU 2.8
2391cb0ef41Sopenharmony_ci */
2401cb0ef41Sopenharmony_ciU_CAPI int16_t U_EXPORT2
2411cb0ef41Sopenharmony_ciudata_readInt16(const UDataSwapper *ds, int16_t x);
2421cb0ef41Sopenharmony_ci
2431cb0ef41Sopenharmony_ci/**
2441cb0ef41Sopenharmony_ci * Convert one int32_t from input to platform endianness.
2451cb0ef41Sopenharmony_ci * @internal ICU 2.8
2461cb0ef41Sopenharmony_ci */
2471cb0ef41Sopenharmony_ciU_CAPI int32_t U_EXPORT2
2481cb0ef41Sopenharmony_ciudata_readInt32(const UDataSwapper *ds, int32_t x);
2491cb0ef41Sopenharmony_ci
2501cb0ef41Sopenharmony_ci/**
2511cb0ef41Sopenharmony_ci * Swap a block of invariant, NUL-terminated strings, but not padding
2521cb0ef41Sopenharmony_ci * bytes after the last string.
2531cb0ef41Sopenharmony_ci * @internal
2541cb0ef41Sopenharmony_ci */
2551cb0ef41Sopenharmony_ciU_CAPI int32_t U_EXPORT2
2561cb0ef41Sopenharmony_ciudata_swapInvStringBlock(const UDataSwapper *ds,
2571cb0ef41Sopenharmony_ci                         const void *inData, int32_t length, void *outData,
2581cb0ef41Sopenharmony_ci                         UErrorCode *pErrorCode);
2591cb0ef41Sopenharmony_ci
2601cb0ef41Sopenharmony_ciU_CAPI void U_EXPORT2
2611cb0ef41Sopenharmony_ciudata_printError(const UDataSwapper *ds,
2621cb0ef41Sopenharmony_ci                 const char *fmt,
2631cb0ef41Sopenharmony_ci                 ...);
2641cb0ef41Sopenharmony_ci
2651cb0ef41Sopenharmony_ci/* internal exports from putil.c -------------------------------------------- */
2661cb0ef41Sopenharmony_ci
2671cb0ef41Sopenharmony_ci/* declared here to keep them out of the public putil.h */
2681cb0ef41Sopenharmony_ci
2691cb0ef41Sopenharmony_ci/**
2701cb0ef41Sopenharmony_ci * Swap invariant char * strings ASCII->EBCDIC.
2711cb0ef41Sopenharmony_ci * @internal
2721cb0ef41Sopenharmony_ci */
2731cb0ef41Sopenharmony_ciU_CAPI int32_t U_EXPORT2
2741cb0ef41Sopenharmony_ciuprv_ebcdicFromAscii(const UDataSwapper *ds,
2751cb0ef41Sopenharmony_ci                     const void *inData, int32_t length, void *outData,
2761cb0ef41Sopenharmony_ci                     UErrorCode *pErrorCode);
2771cb0ef41Sopenharmony_ci
2781cb0ef41Sopenharmony_ci/**
2791cb0ef41Sopenharmony_ci * Copy invariant ASCII char * strings and verify they are invariant.
2801cb0ef41Sopenharmony_ci * @internal
2811cb0ef41Sopenharmony_ci */
2821cb0ef41Sopenharmony_ciU_CFUNC int32_t
2831cb0ef41Sopenharmony_ciuprv_copyAscii(const UDataSwapper *ds,
2841cb0ef41Sopenharmony_ci               const void *inData, int32_t length, void *outData,
2851cb0ef41Sopenharmony_ci               UErrorCode *pErrorCode);
2861cb0ef41Sopenharmony_ci
2871cb0ef41Sopenharmony_ci/**
2881cb0ef41Sopenharmony_ci * Swap invariant char * strings EBCDIC->ASCII.
2891cb0ef41Sopenharmony_ci * @internal
2901cb0ef41Sopenharmony_ci */
2911cb0ef41Sopenharmony_ciU_CFUNC int32_t
2921cb0ef41Sopenharmony_ciuprv_asciiFromEbcdic(const UDataSwapper *ds,
2931cb0ef41Sopenharmony_ci                     const void *inData, int32_t length, void *outData,
2941cb0ef41Sopenharmony_ci                     UErrorCode *pErrorCode);
2951cb0ef41Sopenharmony_ci
2961cb0ef41Sopenharmony_ci/**
2971cb0ef41Sopenharmony_ci * Copy invariant EBCDIC char * strings and verify they are invariant.
2981cb0ef41Sopenharmony_ci * @internal
2991cb0ef41Sopenharmony_ci */
3001cb0ef41Sopenharmony_ciU_CFUNC int32_t
3011cb0ef41Sopenharmony_ciuprv_copyEbcdic(const UDataSwapper *ds,
3021cb0ef41Sopenharmony_ci                const void *inData, int32_t length, void *outData,
3031cb0ef41Sopenharmony_ci                UErrorCode *pErrorCode);
3041cb0ef41Sopenharmony_ci
3051cb0ef41Sopenharmony_ci/**
3061cb0ef41Sopenharmony_ci * Compare ASCII invariant char * with Unicode invariant UChar *
3071cb0ef41Sopenharmony_ci * @internal
3081cb0ef41Sopenharmony_ci */
3091cb0ef41Sopenharmony_ciU_CFUNC int32_t
3101cb0ef41Sopenharmony_ciuprv_compareInvAscii(const UDataSwapper *ds,
3111cb0ef41Sopenharmony_ci                     const char *outString, int32_t outLength,
3121cb0ef41Sopenharmony_ci                     const UChar *localString, int32_t localLength);
3131cb0ef41Sopenharmony_ci
3141cb0ef41Sopenharmony_ci/**
3151cb0ef41Sopenharmony_ci * Compare EBCDIC invariant char * with Unicode invariant UChar *
3161cb0ef41Sopenharmony_ci * @internal
3171cb0ef41Sopenharmony_ci */
3181cb0ef41Sopenharmony_ciU_CFUNC int32_t
3191cb0ef41Sopenharmony_ciuprv_compareInvEbcdic(const UDataSwapper *ds,
3201cb0ef41Sopenharmony_ci                      const char *outString, int32_t outLength,
3211cb0ef41Sopenharmony_ci                      const UChar *localString, int32_t localLength);
3221cb0ef41Sopenharmony_ci
3231cb0ef41Sopenharmony_ci/**
3241cb0ef41Sopenharmony_ci * \def uprv_compareInvWithUChar
3251cb0ef41Sopenharmony_ci * Compare an invariant-character strings with a UChar string
3261cb0ef41Sopenharmony_ci * @internal
3271cb0ef41Sopenharmony_ci */
3281cb0ef41Sopenharmony_ci#if U_CHARSET_FAMILY==U_ASCII_FAMILY
3291cb0ef41Sopenharmony_ci#   define uprv_compareInvWithUChar uprv_compareInvAscii
3301cb0ef41Sopenharmony_ci#elif U_CHARSET_FAMILY==U_EBCDIC_FAMILY
3311cb0ef41Sopenharmony_ci#   define uprv_compareInvWithUChar uprv_compareInvEbcdic
3321cb0ef41Sopenharmony_ci#else
3331cb0ef41Sopenharmony_ci#   error Unknown charset family!
3341cb0ef41Sopenharmony_ci#endif
3351cb0ef41Sopenharmony_ci
3361cb0ef41Sopenharmony_ci// utrie_swap.cpp -----------------------------------------------------------***
3371cb0ef41Sopenharmony_ci
3381cb0ef41Sopenharmony_ci/**
3391cb0ef41Sopenharmony_ci * Swaps a serialized UTrie.
3401cb0ef41Sopenharmony_ci * @internal
3411cb0ef41Sopenharmony_ci */
3421cb0ef41Sopenharmony_ciU_CAPI int32_t U_EXPORT2
3431cb0ef41Sopenharmony_ciutrie_swap(const UDataSwapper *ds,
3441cb0ef41Sopenharmony_ci           const void *inData, int32_t length, void *outData,
3451cb0ef41Sopenharmony_ci           UErrorCode *pErrorCode);
3461cb0ef41Sopenharmony_ci
3471cb0ef41Sopenharmony_ci/**
3481cb0ef41Sopenharmony_ci * Swaps a serialized UTrie2.
3491cb0ef41Sopenharmony_ci * @internal
3501cb0ef41Sopenharmony_ci */
3511cb0ef41Sopenharmony_ciU_CAPI int32_t U_EXPORT2
3521cb0ef41Sopenharmony_ciutrie2_swap(const UDataSwapper *ds,
3531cb0ef41Sopenharmony_ci            const void *inData, int32_t length, void *outData,
3541cb0ef41Sopenharmony_ci            UErrorCode *pErrorCode);
3551cb0ef41Sopenharmony_ci
3561cb0ef41Sopenharmony_ci/**
3571cb0ef41Sopenharmony_ci * Swaps a serialized UCPTrie.
3581cb0ef41Sopenharmony_ci * @internal
3591cb0ef41Sopenharmony_ci */
3601cb0ef41Sopenharmony_ciU_CAPI int32_t U_EXPORT2
3611cb0ef41Sopenharmony_ciucptrie_swap(const UDataSwapper *ds,
3621cb0ef41Sopenharmony_ci             const void *inData, int32_t length, void *outData,
3631cb0ef41Sopenharmony_ci             UErrorCode *pErrorCode);
3641cb0ef41Sopenharmony_ci
3651cb0ef41Sopenharmony_ci/**
3661cb0ef41Sopenharmony_ci * Swaps a serialized UTrie, UTrie2, or UCPTrie.
3671cb0ef41Sopenharmony_ci * @internal
3681cb0ef41Sopenharmony_ci */
3691cb0ef41Sopenharmony_ciU_CAPI int32_t U_EXPORT2
3701cb0ef41Sopenharmony_ciutrie_swapAnyVersion(const UDataSwapper *ds,
3711cb0ef41Sopenharmony_ci                     const void *inData, int32_t length, void *outData,
3721cb0ef41Sopenharmony_ci                     UErrorCode *pErrorCode);
3731cb0ef41Sopenharmony_ci
3741cb0ef41Sopenharmony_ci/* material... -------------------------------------------------------------- */
3751cb0ef41Sopenharmony_ci
3761cb0ef41Sopenharmony_ci#if 0
3771cb0ef41Sopenharmony_ci
3781cb0ef41Sopenharmony_ci/* udata.h */
3791cb0ef41Sopenharmony_ci
3801cb0ef41Sopenharmony_ci/**
3811cb0ef41Sopenharmony_ci * Public API function in udata.c
3821cb0ef41Sopenharmony_ci *
3831cb0ef41Sopenharmony_ci * Same as udata_openChoice() but automatically swaps the data.
3841cb0ef41Sopenharmony_ci * isAcceptable, if not NULL, may accept data with endianness and charset family
3851cb0ef41Sopenharmony_ci * different from the current platform's properties.
3861cb0ef41Sopenharmony_ci * If the data is acceptable and the platform properties do not match, then
3871cb0ef41Sopenharmony_ci * the swap function is called to swap an allocated version of the data.
3881cb0ef41Sopenharmony_ci * Preflighting may or may not be performed depending on whether the size of
3891cb0ef41Sopenharmony_ci * the loaded data item is known.
3901cb0ef41Sopenharmony_ci *
3911cb0ef41Sopenharmony_ci * @param isAcceptable Same as for udata_openChoice(). May be NULL.
3921cb0ef41Sopenharmony_ci *
3931cb0ef41Sopenharmony_ci * @internal ICU 2.8
3941cb0ef41Sopenharmony_ci */
3951cb0ef41Sopenharmony_ciU_CAPI UDataMemory * U_EXPORT2
3961cb0ef41Sopenharmony_ciudata_openSwap(const char *path, const char *type, const char *name,
3971cb0ef41Sopenharmony_ci               UDataMemoryIsAcceptable *isAcceptable, void *isAcceptableContext,
3981cb0ef41Sopenharmony_ci               UDataSwapFn *swap,
3991cb0ef41Sopenharmony_ci               UDataPrintError *printError, void *printErrorContext,
4001cb0ef41Sopenharmony_ci               UErrorCode *pErrorCode);
4011cb0ef41Sopenharmony_ci
4021cb0ef41Sopenharmony_ci#endif
4031cb0ef41Sopenharmony_ci
4041cb0ef41Sopenharmony_ci#endif
405