Add PF_MCTP, AF_MCTP from Linux 5.15 to bits/socket.h
[glibc.git] / iconv / gconv_builtin.c
blob7ebfec8db0749792775402fb52e9df5178b171ef
1 /* Table for builtin transformation mapping.
2 Copyright (C) 1997-2021 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
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.
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
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
19 #include <endian.h>
20 #include <limits.h>
21 #include <stdint.h>
22 #include <string.h>
24 #include <gconv_int.h>
26 #include <assert.h>
29 static const struct builtin_map
31 const char *name;
32 __gconv_fct fct;
33 __gconv_btowc_fct btowc_fct;
35 int8_t min_needed_from;
36 int8_t max_needed_from;
37 int8_t min_needed_to;
38 int8_t max_needed_to;
40 } map[] =
42 #define BUILTIN_TRANSFORMATION(From, To, Cost, Name, Fct, BtowcFct, \
43 MinF, MaxF, MinT, MaxT) \
44 { \
45 .name = Name, \
46 .fct = Fct, \
47 .btowc_fct = BtowcFct, \
49 .min_needed_from = MinF, \
50 .max_needed_from = MaxF, \
51 .min_needed_to = MinT, \
52 .max_needed_to = MaxT \
54 #define BUILTIN_ALIAS(From, To)
56 #include <gconv_builtin.h>
60 void
61 __gconv_get_builtin_trans (const char *name, struct __gconv_step *step)
63 size_t cnt;
65 for (cnt = 0; cnt < sizeof (map) / sizeof (map[0]); ++cnt)
66 if (strcmp (name, map[cnt].name) == 0)
67 break;
69 assert (cnt < sizeof (map) / sizeof (map[0]));
71 step->__fct = map[cnt].fct;
72 step->__btowc_fct = map[cnt].btowc_fct;
73 step->__init_fct = NULL;
74 step->__end_fct = NULL;
75 step->__shlib_handle = NULL;
76 step->__modname = NULL;
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;
83 /* None of the builtin converters handles stateful encoding. */
84 step->__stateful = 0;