hjl / source-git / glibc

Forked from source-git/glibc 3 years ago
Clone

Blame iconv/gconv_builtin.c

Packit 6c4009
/* Table for builtin transformation mapping.
Packit 6c4009
   Copyright (C) 1997-2018 Free Software Foundation, Inc.
Packit 6c4009
   This file is part of the GNU C Library.
Packit 6c4009
   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
Packit 6c4009
Packit 6c4009
   The GNU C Library is free software; you can redistribute it and/or
Packit 6c4009
   modify it under the terms of the GNU Lesser General Public
Packit 6c4009
   License as published by the Free Software Foundation; either
Packit 6c4009
   version 2.1 of the License, or (at your option) any later version.
Packit 6c4009
Packit 6c4009
   The GNU C Library is distributed in the hope that it will be useful,
Packit 6c4009
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6c4009
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 6c4009
   Lesser General Public License for more details.
Packit 6c4009
Packit 6c4009
   You should have received a copy of the GNU Lesser General Public
Packit 6c4009
   License along with the GNU C Library; if not, see
Packit 6c4009
   <http://www.gnu.org/licenses/>.  */
Packit 6c4009
Packit 6c4009
#include <endian.h>
Packit 6c4009
#include <limits.h>
Packit 6c4009
#include <stdint.h>
Packit 6c4009
#include <string.h>
Packit 6c4009
Packit 6c4009
#include <gconv_int.h>
Packit 6c4009
Packit 6c4009
#include <assert.h>
Packit 6c4009
Packit 6c4009
Packit 6c4009
static const struct builtin_map
Packit 6c4009
{
Packit 6c4009
  const char *name;
Packit 6c4009
  __gconv_fct fct;
Packit 6c4009
  __gconv_btowc_fct btowc_fct;
Packit 6c4009
Packit 6c4009
  int8_t min_needed_from;
Packit 6c4009
  int8_t max_needed_from;
Packit 6c4009
  int8_t min_needed_to;
Packit 6c4009
  int8_t max_needed_to;
Packit 6c4009
Packit 6c4009
} map[] =
Packit 6c4009
{
Packit 6c4009
#define BUILTIN_TRANSFORMATION(From, To, Cost, Name, Fct, BtowcFct, \
Packit 6c4009
			       MinF, MaxF, MinT, MaxT) \
Packit 6c4009
  {									      \
Packit 6c4009
    .name = Name,							      \
Packit 6c4009
    .fct = Fct,								      \
Packit 6c4009
    .btowc_fct = BtowcFct,						      \
Packit 6c4009
									      \
Packit 6c4009
    .min_needed_from = MinF,						      \
Packit 6c4009
    .max_needed_from = MaxF,						      \
Packit 6c4009
    .min_needed_to = MinT,						      \
Packit 6c4009
    .max_needed_to = MaxT						      \
Packit 6c4009
  },
Packit 6c4009
#define BUILTIN_ALIAS(From, To)
Packit 6c4009
Packit 6c4009
#include <gconv_builtin.h>
Packit 6c4009
};
Packit 6c4009
Packit 6c4009
Packit 6c4009
void
Packit 6c4009
__gconv_get_builtin_trans (const char *name, struct __gconv_step *step)
Packit 6c4009
{
Packit 6c4009
  size_t cnt;
Packit 6c4009
Packit 6c4009
  for (cnt = 0; cnt < sizeof (map) / sizeof (map[0]); ++cnt)
Packit 6c4009
    if (strcmp (name, map[cnt].name) == 0)
Packit 6c4009
      break;
Packit 6c4009
Packit 6c4009
  assert (cnt < sizeof (map) / sizeof (map[0]));
Packit 6c4009
Packit 6c4009
  step->__fct = map[cnt].fct;
Packit 6c4009
  step->__btowc_fct = map[cnt].btowc_fct;
Packit 6c4009
  step->__init_fct = NULL;
Packit 6c4009
  step->__end_fct = NULL;
Packit 6c4009
  step->__shlib_handle = NULL;
Packit 6c4009
  step->__modname = NULL;
Packit 6c4009
Packit 6c4009
  step->__min_needed_from = map[cnt].min_needed_from;
Packit 6c4009
  step->__max_needed_from = map[cnt].max_needed_from;
Packit 6c4009
  step->__min_needed_to = map[cnt].min_needed_to;
Packit 6c4009
  step->__max_needed_to = map[cnt].max_needed_to;
Packit 6c4009
Packit 6c4009
  /* None of the builtin converters handles stateful encoding.  */
Packit 6c4009
  step->__stateful = 0;
Packit 6c4009
}