Back to index

glibc  2.9
iso_11548-1.c
Go to the documentation of this file.
00001 /* Conversion to and from ISO 11548-1.
00002    Copyright (C) 1997-1999, 2000-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        Samuel Thibault <samuel.thibault@ens-lyon.org>, 2005.
00006 
00007    The GNU C Library is free software; you can redistribute it and/or
00008    modify it under the terms of the GNU Lesser General Public
00009    License as published by the Free Software Foundation; either
00010    version 2.1 of the License, or (at your option) any later version.
00011 
00012    The GNU C Library is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015    Lesser General Public License for more details.
00016 
00017    You should have received a copy of the GNU Lesser General Public
00018    License along with the GNU C Library; if not, write to the Free
00019    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00020    02111-1307 USA.  */
00021 
00022 #include <dlfcn.h>
00023 #include <stdint.h>
00024 
00025 /* Definitions used in the body of the `gconv' function.  */
00026 #define CHARSET_NAME        "ISO_11548-1//"
00027 #define FROM_LOOP           from_iso11548_1
00028 #define TO_LOOP                    to_iso11548_1
00029 #define DEFINE_INIT         1
00030 #define DEFINE_FINI         1
00031 #define MIN_NEEDED_FROM            1
00032 #define MIN_NEEDED_TO              4
00033 
00034 #define BRAILLE_UCS_BASE    0x2800
00035 
00036 /* First define the conversion function from ISO 11548-1 to UCS4.  */
00037 #define MIN_NEEDED_INPUT    MIN_NEEDED_FROM
00038 #define MIN_NEEDED_OUTPUT   MIN_NEEDED_TO
00039 #define LOOPFCT                    FROM_LOOP
00040 #define BODY \
00041   *((uint32_t *) outptr) = BRAILLE_UCS_BASE | (*inptr++);                   \
00042   outptr += sizeof (uint32_t);
00043 #define ONEBYTE_BODY \
00044   {                                                                  \
00045     return BRAILLE_UCS_BASE | c;                                     \
00046   }
00047 #include <iconv/loop.c>
00048 
00049 
00050 /* Next, define the other direction.  */
00051 #define MIN_NEEDED_INPUT    MIN_NEEDED_TO
00052 #define MIN_NEEDED_OUTPUT   MIN_NEEDED_FROM
00053 #define LOOPFCT                    TO_LOOP
00054 #define BODY \
00055   {                                                                  \
00056     uint32_t ch = *((const uint32_t *) inptr);                              \
00057     if (__builtin_expect ((ch & 0xffffff00u) != BRAILLE_UCS_BASE, 0))       \
00058       {                                                                     \
00059        UNICODE_TAG_HANDLER (ch, 4);                                         \
00060                                                                      \
00061        /* We have an illegal character.  */                                 \
00062        STANDARD_TO_LOOP_ERR_HANDLER (4);                             \
00063       }                                                                     \
00064     else                                                             \
00065       *outptr++ = (unsigned char) (ch & 0xff);                              \
00066     inptr += 4;                                                             \
00067   }
00068 #define LOOP_NEED_FLAGS
00069 #include <iconv/loop.c>
00070 
00071 
00072 /* Now define the toplevel functions.  */
00073 #include <iconv/skeleton.c>