Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* |
michael@0 | 2 | ******************************************************************************* |
michael@0 | 3 | * |
michael@0 | 4 | * Copyright (C) 1999-2010, International Business Machines |
michael@0 | 5 | * Corporation and others. All Rights Reserved. |
michael@0 | 6 | * |
michael@0 | 7 | ******************************************************************************* |
michael@0 | 8 | * file name: unewdata.h |
michael@0 | 9 | * encoding: US-ASCII |
michael@0 | 10 | * tab size: 8 (not used) |
michael@0 | 11 | * indentation:4 |
michael@0 | 12 | * |
michael@0 | 13 | * created on: 1999oct25 |
michael@0 | 14 | * created by: Markus W. Scherer |
michael@0 | 15 | */ |
michael@0 | 16 | |
michael@0 | 17 | #ifndef __UNEWDATA_H__ |
michael@0 | 18 | #define __UNEWDATA_H__ |
michael@0 | 19 | |
michael@0 | 20 | #include "unicode/utypes.h" |
michael@0 | 21 | #include "unicode/udata.h" |
michael@0 | 22 | |
michael@0 | 23 | /* API for writing data -----------------------------------------------------*/ |
michael@0 | 24 | |
michael@0 | 25 | /** @memo Forward declaration of the data memory creation type. */ |
michael@0 | 26 | typedef struct UNewDataMemory UNewDataMemory; |
michael@0 | 27 | |
michael@0 | 28 | /** |
michael@0 | 29 | * Create a new binary data file. |
michael@0 | 30 | * The file-writing <code>udata_</code> functions facilitate writing |
michael@0 | 31 | * binary data files that can be read by ICU's <code>udata</code> API. |
michael@0 | 32 | * This function opens a new file with a filename determined from its |
michael@0 | 33 | * parameters - of the form "name.type". |
michael@0 | 34 | * It then writes a short header, followed by the <code>UDataInfo</code> |
michael@0 | 35 | * structure and, optionally, by the comment string. |
michael@0 | 36 | * It then writes padding bytes to round up to a multiple of 16 bytes. |
michael@0 | 37 | * Subsequent write operations will thus start at an offset in the file |
michael@0 | 38 | * that is a multiple of 16. <code>udata_getMemory()</code> will return |
michael@0 | 39 | * a pointer to this same starting offset. |
michael@0 | 40 | * |
michael@0 | 41 | * See udata.h . |
michael@0 | 42 | * |
michael@0 | 43 | * @param dir A string that specifies the directory where the data will be |
michael@0 | 44 | * written. If <code>NULL</code>, then |
michael@0 | 45 | * <code>u_getDataDirectory</code> is used. |
michael@0 | 46 | * @param type A string that specifies the type of data to be written. |
michael@0 | 47 | * For example, resource bundles are written with type "res", |
michael@0 | 48 | * conversion tables with type "cnv". |
michael@0 | 49 | * This may be <code>NULL</code> or empty. |
michael@0 | 50 | * @param name A string that specifies the name of the data. |
michael@0 | 51 | * @param pInfo A pointer to a correctly filled <code>UDataInfo</code> |
michael@0 | 52 | * structure that will be copied into the file. |
michael@0 | 53 | * @param comment A string (e.g., a copyright statement) that will be |
michael@0 | 54 | * copied into the file if it is not <code>NULL</code> |
michael@0 | 55 | * or empty. This string serves only as a comment in the binary |
michael@0 | 56 | * file. It will not be accessible by any API. |
michael@0 | 57 | * @param pErrorCode An ICU UErrorCode parameter. It must not be <code>NULL</code>. |
michael@0 | 58 | */ |
michael@0 | 59 | U_CAPI UNewDataMemory * U_EXPORT2 |
michael@0 | 60 | udata_create(const char *dir, const char *type, const char *name, |
michael@0 | 61 | const UDataInfo *pInfo, |
michael@0 | 62 | const char *comment, |
michael@0 | 63 | UErrorCode *pErrorCode); |
michael@0 | 64 | |
michael@0 | 65 | /** @memo Close a newly written binary file. */ |
michael@0 | 66 | U_CAPI uint32_t U_EXPORT2 |
michael@0 | 67 | udata_finish(UNewDataMemory *pData, UErrorCode *pErrorCode); |
michael@0 | 68 | |
michael@0 | 69 | /** @memo Write a dummy data file. */ |
michael@0 | 70 | U_CAPI void U_EXPORT2 |
michael@0 | 71 | udata_createDummy(const char *dir, const char *type, const char *name, UErrorCode *pErrorCode); |
michael@0 | 72 | |
michael@0 | 73 | /** @memo Write an 8-bit byte to the file. */ |
michael@0 | 74 | U_CAPI void U_EXPORT2 |
michael@0 | 75 | udata_write8(UNewDataMemory *pData, uint8_t byte); |
michael@0 | 76 | |
michael@0 | 77 | /** @memo Write a 16-bit word to the file. */ |
michael@0 | 78 | U_CAPI void U_EXPORT2 |
michael@0 | 79 | udata_write16(UNewDataMemory *pData, uint16_t word); |
michael@0 | 80 | |
michael@0 | 81 | /** @memo Write a 32-bit word to the file. */ |
michael@0 | 82 | U_CAPI void U_EXPORT2 |
michael@0 | 83 | udata_write32(UNewDataMemory *pData, uint32_t wyde); |
michael@0 | 84 | |
michael@0 | 85 | /** @memo Write a block of bytes to the file. */ |
michael@0 | 86 | U_CAPI void U_EXPORT2 |
michael@0 | 87 | udata_writeBlock(UNewDataMemory *pData, const void *s, int32_t length); |
michael@0 | 88 | |
michael@0 | 89 | /** @memo Write a block of arbitrary padding bytes to the file. */ |
michael@0 | 90 | U_CAPI void U_EXPORT2 |
michael@0 | 91 | udata_writePadding(UNewDataMemory *pData, int32_t length); |
michael@0 | 92 | |
michael@0 | 93 | /** @memo Write a <code>char*</code> string of platform "invariant characters" to the file. */ |
michael@0 | 94 | U_CAPI void U_EXPORT2 |
michael@0 | 95 | udata_writeString(UNewDataMemory *pData, const char *s, int32_t length); |
michael@0 | 96 | |
michael@0 | 97 | /** @memo Write a <code>UChar*</code> string of Unicode character code units to the file. */ |
michael@0 | 98 | U_CAPI void U_EXPORT2 |
michael@0 | 99 | udata_writeUString(UNewDataMemory *pData, const UChar *s, int32_t length); |
michael@0 | 100 | |
michael@0 | 101 | |
michael@0 | 102 | /* |
michael@0 | 103 | * Hey, Emacs, please set the following: |
michael@0 | 104 | * |
michael@0 | 105 | * Local Variables: |
michael@0 | 106 | * indent-tabs-mode: nil |
michael@0 | 107 | * End: |
michael@0 | 108 | * |
michael@0 | 109 | */ |
michael@0 | 110 | |
michael@0 | 111 | #endif |