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) 1998-2010, International Business Machines |
michael@0 | 5 | * Corporation and others. All Rights Reserved. |
michael@0 | 6 | * |
michael@0 | 7 | ******************************************************************************* |
michael@0 | 8 | * |
michael@0 | 9 | * File ufile.h |
michael@0 | 10 | * |
michael@0 | 11 | * Modification History: |
michael@0 | 12 | * |
michael@0 | 13 | * Date Name Description |
michael@0 | 14 | * 12/01/98 stephen Creation. |
michael@0 | 15 | * 03/12/99 stephen Modified for new C API. |
michael@0 | 16 | ******************************************************************************* |
michael@0 | 17 | */ |
michael@0 | 18 | |
michael@0 | 19 | #ifndef UFILE_H |
michael@0 | 20 | #define UFILE_H |
michael@0 | 21 | |
michael@0 | 22 | #include "unicode/utypes.h" |
michael@0 | 23 | #include "unicode/ucnv.h" |
michael@0 | 24 | #include "unicode/utrans.h" |
michael@0 | 25 | #include "locbund.h" |
michael@0 | 26 | |
michael@0 | 27 | /* The buffer size for fromUnicode calls */ |
michael@0 | 28 | #define UFILE_CHARBUFFER_SIZE 1024 |
michael@0 | 29 | |
michael@0 | 30 | /* The buffer size for toUnicode calls */ |
michael@0 | 31 | #define UFILE_UCHARBUFFER_SIZE 1024 |
michael@0 | 32 | |
michael@0 | 33 | /* A UFILE */ |
michael@0 | 34 | |
michael@0 | 35 | #if !UCONFIG_NO_TRANSLITERATION |
michael@0 | 36 | |
michael@0 | 37 | typedef struct { |
michael@0 | 38 | UChar *buffer; /* Beginning of buffer */ |
michael@0 | 39 | int32_t capacity; /* Capacity of buffer */ |
michael@0 | 40 | int32_t pos; /* Beginning of untranslitted data */ |
michael@0 | 41 | int32_t length; /* Length *from beginning of buffer* of untranslitted data */ |
michael@0 | 42 | UTransliterator *translit; |
michael@0 | 43 | } UFILETranslitBuffer; |
michael@0 | 44 | |
michael@0 | 45 | #endif |
michael@0 | 46 | |
michael@0 | 47 | typedef struct u_localized_string { |
michael@0 | 48 | UChar *fPos; /* current pos in fUCBuffer */ |
michael@0 | 49 | const UChar *fLimit; /* data limit in fUCBuffer */ |
michael@0 | 50 | UChar *fBuffer; /* Place to write the string */ |
michael@0 | 51 | |
michael@0 | 52 | #if !UCONFIG_NO_FORMATTING |
michael@0 | 53 | ULocaleBundle fBundle; /* formatters */ |
michael@0 | 54 | #endif |
michael@0 | 55 | } u_localized_string; |
michael@0 | 56 | |
michael@0 | 57 | struct UFILE { |
michael@0 | 58 | #if !UCONFIG_NO_TRANSLITERATION |
michael@0 | 59 | UFILETranslitBuffer *fTranslit; |
michael@0 | 60 | #endif |
michael@0 | 61 | |
michael@0 | 62 | FILE *fFile; /* the actual filesystem interface */ |
michael@0 | 63 | |
michael@0 | 64 | UConverter *fConverter; /* for codeset conversion */ |
michael@0 | 65 | |
michael@0 | 66 | u_localized_string str; /* struct to handle strings for number formatting */ |
michael@0 | 67 | |
michael@0 | 68 | UChar fUCBuffer[UFILE_UCHARBUFFER_SIZE];/* buffer used for toUnicode */ |
michael@0 | 69 | |
michael@0 | 70 | UBool fOwnFile; /* TRUE if fFile should be closed */ |
michael@0 | 71 | |
michael@0 | 72 | int32_t fFileno; /* File number. Useful to determine if it's stdin. */ |
michael@0 | 73 | }; |
michael@0 | 74 | |
michael@0 | 75 | /** |
michael@0 | 76 | * Like u_file_write but takes a flush parameter |
michael@0 | 77 | */ |
michael@0 | 78 | U_CFUNC int32_t U_EXPORT2 |
michael@0 | 79 | u_file_write_flush( const UChar *chars, |
michael@0 | 80 | int32_t count, |
michael@0 | 81 | UFILE *f, |
michael@0 | 82 | UBool flushIO, |
michael@0 | 83 | UBool flushTranslit); |
michael@0 | 84 | |
michael@0 | 85 | /** |
michael@0 | 86 | * Fill a UFILE's buffer with converted codepage data. |
michael@0 | 87 | * @param f The UFILE containing the buffer to fill. |
michael@0 | 88 | */ |
michael@0 | 89 | void |
michael@0 | 90 | ufile_fill_uchar_buffer(UFILE *f); |
michael@0 | 91 | |
michael@0 | 92 | /** |
michael@0 | 93 | * Get one code unit and detect whether the end of file has been reached. |
michael@0 | 94 | * @param f The UFILE containing the characters. |
michael@0 | 95 | * @param ch The read in character |
michael@0 | 96 | * @return TRUE if the character is valid, or FALSE when EOF has been detected |
michael@0 | 97 | */ |
michael@0 | 98 | U_CFUNC UBool U_EXPORT2 |
michael@0 | 99 | ufile_getch(UFILE *f, UChar *ch); |
michael@0 | 100 | |
michael@0 | 101 | /** |
michael@0 | 102 | * Get one character and detect whether the end of file has been reached. |
michael@0 | 103 | * @param f The UFILE containing the characters. |
michael@0 | 104 | * @param ch The read in character |
michael@0 | 105 | * @return TRUE if the character is valid, or FALSE when EOF has been detected |
michael@0 | 106 | */ |
michael@0 | 107 | U_CFUNC UBool U_EXPORT2 |
michael@0 | 108 | ufile_getch32(UFILE *f, UChar32 *ch); |
michael@0 | 109 | |
michael@0 | 110 | /** |
michael@0 | 111 | * Close out the transliterator and flush any data therein. |
michael@0 | 112 | * @param f flu |
michael@0 | 113 | */ |
michael@0 | 114 | void |
michael@0 | 115 | ufile_close_translit(UFILE *f); |
michael@0 | 116 | |
michael@0 | 117 | /** |
michael@0 | 118 | * Flush the buffer in the transliterator |
michael@0 | 119 | * @param f UFile to flush |
michael@0 | 120 | */ |
michael@0 | 121 | void |
michael@0 | 122 | ufile_flush_translit(UFILE *f); |
michael@0 | 123 | |
michael@0 | 124 | /** |
michael@0 | 125 | * Flush the IO buffer |
michael@0 | 126 | * @param f UFile to flush |
michael@0 | 127 | */ |
michael@0 | 128 | void |
michael@0 | 129 | ufile_flush_io(UFILE *f); |
michael@0 | 130 | |
michael@0 | 131 | |
michael@0 | 132 | #endif |