]>
Commit | Line | Data |
---|---|---|
b75a7d8f A |
1 | /* |
2 | ******************************************************************************* | |
3 | * | |
4 | * Copyright (C) 1998-1999, 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 untranslitted data */ | |
42 | UTransliterator *translit; | |
43 | } UFILETranslitBuffer; | |
44 | ||
45 | #endif | |
46 | ||
47 | struct UFILE { | |
48 | FILE *fFile; /* the actual fs interface */ | |
49 | UBool fOwnFile; /* TRUE if fFile should be closed */ | |
50 | ||
51 | #if !UCONFIG_NO_FORMATTING | |
52 | ULocaleBundle *fBundle; /* formatters */ | |
53 | UBool fOwnBundle; /* TRUE if fBundle should be deleted */ | |
54 | #endif | |
55 | ||
56 | UConverter *fConverter; /* for codeset conversion */ | |
57 | ||
58 | /* buffer used for fromUnicode */ | |
59 | char fCharBuffer [UFILE_CHARBUFFER_SIZE]; | |
60 | ||
61 | /* buffer used for toUnicode */ | |
62 | UChar fUCBuffer [UFILE_UCHARBUFFER_SIZE]; | |
63 | ||
64 | UChar *fUCLimit; /* data limit in fUCBuffer */ | |
65 | UChar *fUCPos; /* current pos in fUCBuffer */ | |
66 | ||
67 | #if !UCONFIG_NO_TRANSLITERATION | |
68 | UFILETranslitBuffer *fTranslit; | |
69 | #endif | |
70 | }; | |
71 | ||
72 | /** | |
73 | * Like u_file_write but takes a flush parameter | |
74 | */ | |
75 | U_CAPI int32_t U_EXPORT2 | |
76 | u_file_write_flush( const UChar *chars, | |
77 | int32_t count, | |
78 | UFILE *f, | |
79 | UBool flush); | |
80 | ||
81 | /** | |
82 | * Fill a UFILE's buffer with converted codepage data. | |
83 | * @param f The UFILE containing the buffer to fill. | |
84 | */ | |
85 | void | |
86 | ufile_fill_uchar_buffer(UFILE *f); | |
87 | ||
88 | /** | |
89 | * Close out the transliterator and flush any data therein. | |
90 | * @param f flu | |
91 | */ | |
92 | void | |
93 | ufile_close_translit(UFILE *f); | |
94 | ||
95 | /** | |
96 | * Flush the buffer in the transliterator | |
97 | * @param f UFile to flush | |
98 | */ | |
99 | void | |
100 | ufile_flush_translit(UFILE *f); | |
101 | ||
102 | ||
103 | #endif |