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