Back to index

glibc  2.9
gconv_builtin.c
Go to the documentation of this file.
00001 /* Table for builtin transformation mapping.
00002    Copyright (C) 1997-1999, 2000-2002, 2005 Free Software Foundation, Inc.
00003    This file is part of the GNU C Library.
00004    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
00005 
00006    The GNU C Library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Lesser General Public
00008    License as published by the Free Software Foundation; either
00009    version 2.1 of the License, or (at your option) any later version.
00010 
00011    The GNU C Library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Lesser General Public License for more details.
00015 
00016    You should have received a copy of the GNU Lesser General Public
00017    License along with the GNU C Library; if not, write to the Free
00018    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00019    02111-1307 USA.  */
00020 
00021 #include <endian.h>
00022 #include <limits.h>
00023 #include <stdint.h>
00024 #include <string.h>
00025 
00026 #include <gconv_int.h>
00027 
00028 #include <assert.h>
00029 
00030 
00031 static const struct builtin_map
00032 {
00033   const char *name;
00034   __gconv_fct fct;
00035   __gconv_btowc_fct btowc_fct;
00036 
00037   int8_t min_needed_from;
00038   int8_t max_needed_from;
00039   int8_t min_needed_to;
00040   int8_t max_needed_to;
00041 
00042 } map[] =
00043 {
00044 #define BUILTIN_TRANSFORMATION(From, To, Cost, Name, Fct, BtowcFct, \
00045                             MinF, MaxF, MinT, MaxT) \
00046   {                                                                  \
00047     .name = Name,                                                    \
00048     .fct = Fct,                                                             \
00049     .btowc_fct = BtowcFct,                                           \
00050                                                                      \
00051     .min_needed_from = MinF,                                                \
00052     .max_needed_from = MaxF,                                                \
00053     .min_needed_to = MinT,                                           \
00054     .max_needed_to = MaxT                                            \
00055   },
00056 #define BUILTIN_ALIAS(From, To)
00057 
00058 #include <gconv_builtin.h>
00059 };
00060 
00061 
00062 void
00063 internal_function
00064 __gconv_get_builtin_trans (const char *name, struct __gconv_step *step)
00065 {
00066   size_t cnt;
00067 
00068   for (cnt = 0; cnt < sizeof (map) / sizeof (map[0]); ++cnt)
00069     if (strcmp (name, map[cnt].name) == 0)
00070       break;
00071 
00072   assert (cnt < sizeof (map) / sizeof (map[0]));
00073 
00074   step->__fct = map[cnt].fct;
00075   step->__btowc_fct = map[cnt].btowc_fct;
00076   step->__init_fct = NULL;
00077   step->__end_fct = NULL;
00078   step->__shlib_handle = NULL;
00079   step->__modname = NULL;
00080 
00081   step->__min_needed_from = map[cnt].min_needed_from;
00082   step->__max_needed_from = map[cnt].max_needed_from;
00083   step->__min_needed_to = map[cnt].min_needed_to;
00084   step->__max_needed_to = map[cnt].max_needed_to;
00085 
00086   /* None of the builtin converters handles stateful encoding.  */
00087   step->__stateful = 0;
00088 }