Back to index

glibc  2.9
iso8859-1.c
Go to the documentation of this file.
00001 /* Conversion to and from ISO 8859-1.
00002    Copyright (C) 1997-1999, 2000-2004 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 <dlfcn.h>
00022 #include <stdint.h>
00023 
00024 /* Definitions used in the body of the `gconv' function.  */
00025 #define CHARSET_NAME        "ISO-8859-1//"
00026 #define FROM_LOOP           from_iso8859_1
00027 #define TO_LOOP                    to_iso8859_1
00028 #define DEFINE_INIT         1
00029 #define DEFINE_FINI         1
00030 #define MIN_NEEDED_FROM            1
00031 #define MIN_NEEDED_TO              4
00032 
00033 /* First define the conversion function from ISO 8859-1 to UCS4.  */
00034 #define MIN_NEEDED_INPUT    MIN_NEEDED_FROM
00035 #define MIN_NEEDED_OUTPUT   MIN_NEEDED_TO
00036 #define LOOPFCT                    FROM_LOOP
00037 #define BODY \
00038   *((uint32_t *) outptr) = *inptr++;                                        \
00039   outptr += sizeof (uint32_t);
00040 #define ONEBYTE_BODY \
00041   {                                                                  \
00042     return c;                                                        \
00043   }
00044 #include <iconv/loop.c>
00045 
00046 
00047 /* Next, define the other direction.  */
00048 #define MIN_NEEDED_INPUT    MIN_NEEDED_TO
00049 #define MIN_NEEDED_OUTPUT   MIN_NEEDED_FROM
00050 #define LOOPFCT                    TO_LOOP
00051 #define BODY \
00052   {                                                                  \
00053     uint32_t ch = *((const uint32_t *) inptr);                              \
00054     if (__builtin_expect (ch > 0xff, 0))                             \
00055       {                                                                     \
00056        UNICODE_TAG_HANDLER (ch, 4);                                         \
00057                                                                      \
00058        /* We have an illegal character.  */                                 \
00059        STANDARD_TO_LOOP_ERR_HANDLER (4);                             \
00060       }                                                                     \
00061     else                                                             \
00062       *outptr++ = (unsigned char) ch;                                       \
00063     inptr += 4;                                                             \
00064   }
00065 #define LOOP_NEED_FLAGS
00066 #include <iconv/loop.c>
00067 
00068 
00069 /* Now define the toplevel functions.  */
00070 #include <iconv/skeleton.c>