]>
Commit | Line | Data |
---|---|---|
d4697bc9 | 1 | /* Copyright (C) 1997-2014 Free Software Foundation, Inc. |
6973fc01 | 2 | This file is part of the GNU C Library. |
6973fc01 UD |
3 | |
4 | The GNU C Library is free software; you can redistribute it and/or | |
41bdb6e2 AJ |
5 | modify it under the terms of the GNU Lesser General Public |
6 | License as published by the Free Software Foundation; either | |
7 | version 2.1 of the License, or (at your option) any later version. | |
6973fc01 UD |
8 | |
9 | The GNU C Library is distributed in the hope that it will be useful, | |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
41bdb6e2 | 12 | Lesser General Public License for more details. |
6973fc01 | 13 | |
41bdb6e2 | 14 | You should have received a copy of the GNU Lesser General Public |
59ba27a6 PE |
15 | License along with the GNU C Library; if not, see |
16 | <http://www.gnu.org/licenses/>. */ | |
6973fc01 | 17 | |
e62c19f1 UD |
18 | /* This header provides no interface for a user to the internals of |
19 | the gconv implementation in the libc. Therefore there is no use | |
20 | for these definitions beside for writing additional gconv modules. */ | |
21 | ||
6973fc01 UD |
22 | #ifndef _GCONV_H |
23 | #define _GCONV_H 1 | |
24 | ||
25 | #include <features.h> | |
d64b6ad0 | 26 | #define __need_mbstate_t |
7b503bcc | 27 | #define __need_wint_t |
0d9f6793 | 28 | #include <wchar.h> |
e62c19f1 | 29 | #define __need_size_t |
68984987 | 30 | #define __need_wchar_t |
e62c19f1 | 31 | #include <stddef.h> |
f43ce637 | 32 | |
04be94a8 | 33 | /* ISO 10646 value used to signal invalid value. */ |
d64b6ad0 | 34 | #define __UNKNOWN_10646_CHAR ((wchar_t) 0xfffd) |
04be94a8 | 35 | |
6973fc01 UD |
36 | /* Error codes for gconv functions. */ |
37 | enum | |
38 | { | |
d64b6ad0 UD |
39 | __GCONV_OK = 0, |
40 | __GCONV_NOCONV, | |
41 | __GCONV_NODB, | |
42 | __GCONV_NOMEM, | |
43 | ||
44 | __GCONV_EMPTY_INPUT, | |
45 | __GCONV_FULL_OUTPUT, | |
46 | __GCONV_ILLEGAL_INPUT, | |
47 | __GCONV_INCOMPLETE_INPUT, | |
48 | ||
49 | __GCONV_ILLEGAL_DESCRIPTOR, | |
50 | __GCONV_INTERNAL_ERROR | |
6973fc01 UD |
51 | }; |
52 | ||
53 | ||
85830c4c UD |
54 | /* Flags the `__gconv_open' function can set. */ |
55 | enum | |
56 | { | |
57 | __GCONV_IS_LAST = 0x0001, | |
ee190f67 UD |
58 | __GCONV_IGNORE_ERRORS = 0x0002, |
59 | __GCONV_SWAP = 0x0004 | |
85830c4c UD |
60 | }; |
61 | ||
62 | ||
6973fc01 | 63 | /* Forward declarations. */ |
d64b6ad0 UD |
64 | struct __gconv_step; |
65 | struct __gconv_step_data; | |
66 | struct __gconv_loaded_object; | |
55985355 | 67 | struct __gconv_trans_data; |
6973fc01 UD |
68 | |
69 | ||
70 | /* Type of a conversion function. */ | |
c1422e5b | 71 | typedef int (*__gconv_fct) (struct __gconv_step *, struct __gconv_step_data *, |
a784e502 | 72 | const unsigned char **, const unsigned char *, |
f1d5c60d | 73 | unsigned char **, size_t *, int, int); |
6973fc01 | 74 | |
bfa934e7 UD |
75 | /* Type of a specialized conversion function for a single byte to INTERNAL. */ |
76 | typedef wint_t (*__gconv_btowc_fct) (struct __gconv_step *, unsigned char); | |
77 | ||
6973fc01 | 78 | /* Constructor and destructor for local data for conversion step. */ |
c1422e5b UD |
79 | typedef int (*__gconv_init_fct) (struct __gconv_step *); |
80 | typedef void (*__gconv_end_fct) (struct __gconv_step *); | |
6973fc01 UD |
81 | |
82 | ||
55985355 | 83 | /* Type of a transliteration/transscription function. */ |
d6204268 UD |
84 | typedef int (*__gconv_trans_fct) (struct __gconv_step *, |
85 | struct __gconv_step_data *, void *, | |
a784e502 UD |
86 | const unsigned char *, |
87 | const unsigned char **, | |
88 | const unsigned char *, unsigned char **, | |
f1d5c60d | 89 | size_t *); |
55985355 UD |
90 | |
91 | /* Function to call to provide transliteration module with context. */ | |
a784e502 UD |
92 | typedef int (*__gconv_trans_context_fct) (void *, const unsigned char *, |
93 | const unsigned char *, | |
4d37e19c | 94 | unsigned char *, unsigned char *); |
55985355 UD |
95 | |
96 | /* Function to query module about supported encoded character sets. */ | |
a784e502 | 97 | typedef int (*__gconv_trans_query_fct) (const char *, const char ***, |
d6204268 | 98 | size_t *); |
55985355 UD |
99 | |
100 | /* Constructor and destructor for local data for transliteration. */ | |
101 | typedef int (*__gconv_trans_init_fct) (void **, const char *); | |
102 | typedef void (*__gconv_trans_end_fct) (void *); | |
103 | ||
104 | struct __gconv_trans_data | |
105 | { | |
106 | /* Transliteration/Transscription function. */ | |
107 | __gconv_trans_fct __trans_fct; | |
108 | __gconv_trans_context_fct __trans_context_fct; | |
109 | __gconv_trans_end_fct __trans_end_fct; | |
110 | void *__data; | |
d6204268 | 111 | struct __gconv_trans_data *__next; |
55985355 UD |
112 | }; |
113 | ||
114 | ||
6973fc01 | 115 | /* Description of a conversion step. */ |
d64b6ad0 | 116 | struct __gconv_step |
6973fc01 | 117 | { |
d64b6ad0 | 118 | struct __gconv_loaded_object *__shlib_handle; |
a784e502 | 119 | const char *__modname; |
0d9f6793 | 120 | |
d64b6ad0 | 121 | int __counter; |
6973fc01 | 122 | |
17427edd UD |
123 | char *__from_name; |
124 | char *__to_name; | |
6973fc01 | 125 | |
d64b6ad0 | 126 | __gconv_fct __fct; |
bfa934e7 | 127 | __gconv_btowc_fct __btowc_fct; |
d64b6ad0 UD |
128 | __gconv_init_fct __init_fct; |
129 | __gconv_end_fct __end_fct; | |
0d9f6793 | 130 | |
8619129f UD |
131 | /* Information about the number of bytes needed or produced in this |
132 | step. This helps optimizing the buffer sizes. */ | |
d64b6ad0 UD |
133 | int __min_needed_from; |
134 | int __max_needed_from; | |
135 | int __min_needed_to; | |
136 | int __max_needed_to; | |
8619129f | 137 | |
9ce5071a | 138 | /* Flag whether this is a stateful encoding or not. */ |
d64b6ad0 | 139 | int __stateful; |
9ce5071a | 140 | |
d64b6ad0 | 141 | void *__data; /* Pointer to step-local data. */ |
6973fc01 UD |
142 | }; |
143 | ||
144 | /* Additional data for steps in use of conversion descriptor. This is | |
145 | allocated by the `init' function. */ | |
d64b6ad0 | 146 | struct __gconv_step_data |
6973fc01 | 147 | { |
d64b6ad0 UD |
148 | unsigned char *__outbuf; /* Output buffer for this step. */ |
149 | unsigned char *__outbufend; /* Address of first byte after the output | |
0aece08d | 150 | buffer. */ |
6973fc01 | 151 | |
e3e0a182 | 152 | /* Is this the last module in the chain. */ |
85830c4c | 153 | int __flags; |
6973fc01 | 154 | |
e3e0a182 | 155 | /* Counter for number of invocations of the module function for this |
390955cb | 156 | descriptor. */ |
d64b6ad0 | 157 | int __invocation_counter; |
e3e0a182 UD |
158 | |
159 | /* Flag whether this is an internal use of the module (in the mb*towc* | |
160 | and wc*tomb* functions) or regular with iconv(3). */ | |
d64b6ad0 | 161 | int __internal_use; |
e3e0a182 | 162 | |
d64b6ad0 | 163 | __mbstate_t *__statep; |
0aece08d | 164 | __mbstate_t __state; /* This element must not be used directly by |
0d9f6793 | 165 | any module; always use STATEP! */ |
55985355 UD |
166 | |
167 | /* Transliteration information. */ | |
d6204268 | 168 | struct __gconv_trans_data *__trans; |
6973fc01 UD |
169 | }; |
170 | ||
e62c19f1 | 171 | |
6973fc01 | 172 | /* Combine conversion step description with data. */ |
d64b6ad0 | 173 | typedef struct __gconv_info |
6973fc01 | 174 | { |
d64b6ad0 UD |
175 | size_t __nsteps; |
176 | struct __gconv_step *__steps; | |
a1620a4c | 177 | __extension__ struct __gconv_step_data __data __flexarr; |
d64b6ad0 | 178 | } *__gconv_t; |
6973fc01 | 179 | |
6973fc01 | 180 | #endif /* gconv.h */ |