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