]>
Commit | Line | Data |
---|---|---|
2b778ceb | 1 | /* Copyright (C) 1997-2021 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 | 15 | License along with the GNU C Library; if not, see |
5a82c748 | 16 | <https://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> | |
199fc19d ZW |
26 | #include <bits/types/__mbstate_t.h> |
27 | #include <bits/types/wint_t.h> | |
28 | ||
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 | 58 | __GCONV_IGNORE_ERRORS = 0x0002, |
ba7b4d29 FW |
59 | __GCONV_SWAP = 0x0004, |
60 | __GCONV_TRANSLIT = 0x0008 | |
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; | |
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 | ||
83 | /* Description of a conversion step. */ | |
d64b6ad0 | 84 | struct __gconv_step |
6973fc01 | 85 | { |
d64b6ad0 | 86 | struct __gconv_loaded_object *__shlib_handle; |
a784e502 | 87 | const char *__modname; |
0d9f6793 | 88 | |
c9c15ac3 FW |
89 | /* For internal use by glibc. (Accesses to this member must occur |
90 | when the internal __gconv_lock mutex is acquired). */ | |
d64b6ad0 | 91 | int __counter; |
6973fc01 | 92 | |
17427edd UD |
93 | char *__from_name; |
94 | char *__to_name; | |
6973fc01 | 95 | |
d64b6ad0 | 96 | __gconv_fct __fct; |
bfa934e7 | 97 | __gconv_btowc_fct __btowc_fct; |
d64b6ad0 UD |
98 | __gconv_init_fct __init_fct; |
99 | __gconv_end_fct __end_fct; | |
0d9f6793 | 100 | |
8619129f UD |
101 | /* Information about the number of bytes needed or produced in this |
102 | step. This helps optimizing the buffer sizes. */ | |
d64b6ad0 UD |
103 | int __min_needed_from; |
104 | int __max_needed_from; | |
105 | int __min_needed_to; | |
106 | int __max_needed_to; | |
8619129f | 107 | |
9ce5071a | 108 | /* Flag whether this is a stateful encoding or not. */ |
d64b6ad0 | 109 | int __stateful; |
9ce5071a | 110 | |
d64b6ad0 | 111 | void *__data; /* Pointer to step-local data. */ |
6973fc01 UD |
112 | }; |
113 | ||
114 | /* Additional data for steps in use of conversion descriptor. This is | |
115 | allocated by the `init' function. */ | |
d64b6ad0 | 116 | struct __gconv_step_data |
6973fc01 | 117 | { |
d64b6ad0 UD |
118 | unsigned char *__outbuf; /* Output buffer for this step. */ |
119 | unsigned char *__outbufend; /* Address of first byte after the output | |
0aece08d | 120 | buffer. */ |
6973fc01 | 121 | |
e3e0a182 | 122 | /* Is this the last module in the chain. */ |
85830c4c | 123 | int __flags; |
6973fc01 | 124 | |
e3e0a182 | 125 | /* Counter for number of invocations of the module function for this |
390955cb | 126 | descriptor. */ |
d64b6ad0 | 127 | int __invocation_counter; |
e3e0a182 UD |
128 | |
129 | /* Flag whether this is an internal use of the module (in the mb*towc* | |
130 | and wc*tomb* functions) or regular with iconv(3). */ | |
d64b6ad0 | 131 | int __internal_use; |
e3e0a182 | 132 | |
d64b6ad0 | 133 | __mbstate_t *__statep; |
0aece08d | 134 | __mbstate_t __state; /* This element must not be used directly by |
0d9f6793 | 135 | any module; always use STATEP! */ |
6973fc01 UD |
136 | }; |
137 | ||
e62c19f1 | 138 | |
6973fc01 | 139 | /* Combine conversion step description with data. */ |
d64b6ad0 | 140 | typedef struct __gconv_info |
6973fc01 | 141 | { |
d64b6ad0 UD |
142 | size_t __nsteps; |
143 | struct __gconv_step *__steps; | |
0623b9e6 | 144 | __extension__ struct __gconv_step_data __data[0]; |
d64b6ad0 | 145 | } *__gconv_t; |
6973fc01 | 146 | |
6973fc01 | 147 | #endif /* gconv.h */ |