]>
Commit | Line | Data |
---|---|---|
6973fc01 | 1 | /* Table for builtin transformation mapping. |
dff8da6b | 2 | Copyright (C) 1997-2024 Free Software Foundation, Inc. |
6973fc01 | 3 | This file is part of the GNU C Library. |
6973fc01 UD |
4 | |
5 | The GNU C Library is free software; you can redistribute it and/or | |
41bdb6e2 AJ |
6 | modify it under the terms of the GNU Lesser General Public |
7 | License as published by the Free Software Foundation; either | |
8 | version 2.1 of the License, or (at your option) any later version. | |
6973fc01 UD |
9 | |
10 | The GNU C Library is distributed in the hope that it will be useful, | |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
41bdb6e2 | 13 | Lesser General Public License for more details. |
6973fc01 | 14 | |
41bdb6e2 | 15 | You should have received a copy of the GNU Lesser General Public |
59ba27a6 | 16 | License along with the GNU C Library; if not, see |
5a82c748 | 17 | <https://www.gnu.org/licenses/>. */ |
6973fc01 | 18 | |
8d617a71 | 19 | #include <endian.h> |
7919ea15 | 20 | #include <limits.h> |
477aa869 | 21 | #include <stdint.h> |
6973fc01 UD |
22 | #include <string.h> |
23 | ||
e62c19f1 UD |
24 | #include <gconv_int.h> |
25 | ||
6973fc01 UD |
26 | #include <assert.h> |
27 | ||
28 | ||
477aa869 | 29 | static const struct builtin_map |
6973fc01 UD |
30 | { |
31 | const char *name; | |
d64b6ad0 | 32 | __gconv_fct fct; |
f9ad060c | 33 | __gconv_btowc_fct btowc_fct; |
6973fc01 | 34 | |
477aa869 UD |
35 | int8_t min_needed_from; |
36 | int8_t max_needed_from; | |
37 | int8_t min_needed_to; | |
38 | int8_t max_needed_to; | |
8619129f | 39 | |
477aa869 | 40 | } map[] = |
6973fc01 | 41 | { |
f9ad060c UD |
42 | #define BUILTIN_TRANSFORMATION(From, To, Cost, Name, Fct, BtowcFct, \ |
43 | MinF, MaxF, MinT, MaxT) \ | |
6973fc01 | 44 | { \ |
d64b6ad0 UD |
45 | .name = Name, \ |
46 | .fct = Fct, \ | |
f9ad060c | 47 | .btowc_fct = BtowcFct, \ |
8619129f | 48 | \ |
d64b6ad0 UD |
49 | .min_needed_from = MinF, \ |
50 | .max_needed_from = MaxF, \ | |
51 | .min_needed_to = MinT, \ | |
52 | .max_needed_to = MaxT \ | |
6973fc01 | 53 | }, |
5891046a | 54 | #define BUILTIN_ALIAS(From, To) |
6973fc01 UD |
55 | |
56 | #include <gconv_builtin.h> | |
57 | }; | |
58 | ||
59 | ||
60 | void | |
d64b6ad0 | 61 | __gconv_get_builtin_trans (const char *name, struct __gconv_step *step) |
6973fc01 UD |
62 | { |
63 | size_t cnt; | |
64 | ||
65 | for (cnt = 0; cnt < sizeof (map) / sizeof (map[0]); ++cnt) | |
66 | if (strcmp (name, map[cnt].name) == 0) | |
67 | break; | |
68 | ||
69 | assert (cnt < sizeof (map) / sizeof (map[0])); | |
70 | ||
d64b6ad0 | 71 | step->__fct = map[cnt].fct; |
f9ad060c | 72 | step->__btowc_fct = map[cnt].btowc_fct; |
2c422366 UD |
73 | step->__init_fct = NULL; |
74 | step->__end_fct = NULL; | |
d64b6ad0 | 75 | step->__shlib_handle = NULL; |
9f835f5f | 76 | step->__modname = NULL; |
8619129f | 77 | |
d64b6ad0 UD |
78 | step->__min_needed_from = map[cnt].min_needed_from; |
79 | step->__max_needed_from = map[cnt].max_needed_from; | |
80 | step->__min_needed_to = map[cnt].min_needed_to; | |
81 | step->__max_needed_to = map[cnt].max_needed_to; | |
9ce5071a UD |
82 | |
83 | /* None of the builtin converters handles stateful encoding. */ | |
d64b6ad0 | 84 | step->__stateful = 0; |
6973fc01 | 85 | } |