2.9
[glibc/nacl-glibc.git] / iconvdata / iso_11548-1.c
blob6543c61f325990a4252e47f3485d8cb41aacc76a
1 /* Conversion to and from ISO 11548-1.
2 Copyright (C) 1997-1999, 2000-2005 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997,
5 Samuel Thibault <samuel.thibault@ens-lyon.org>, 2005.
7 The GNU C Library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
12 The GNU C Library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
17 You should have received a copy of the GNU Lesser General Public
18 License along with the GNU C Library; if not, write to the Free
19 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20 02111-1307 USA. */
22 #include <dlfcn.h>
23 #include <stdint.h>
25 /* Definitions used in the body of the `gconv' function. */
26 #define CHARSET_NAME "ISO_11548-1//"
27 #define FROM_LOOP from_iso11548_1
28 #define TO_LOOP to_iso11548_1
29 #define DEFINE_INIT 1
30 #define DEFINE_FINI 1
31 #define MIN_NEEDED_FROM 1
32 #define MIN_NEEDED_TO 4
34 #define BRAILLE_UCS_BASE 0x2800
36 /* First define the conversion function from ISO 11548-1 to UCS4. */
37 #define MIN_NEEDED_INPUT MIN_NEEDED_FROM
38 #define MIN_NEEDED_OUTPUT MIN_NEEDED_TO
39 #define LOOPFCT FROM_LOOP
40 #define BODY \
41 *((uint32_t *) outptr) = BRAILLE_UCS_BASE | (*inptr++); \
42 outptr += sizeof (uint32_t);
43 #define ONEBYTE_BODY \
44 { \
45 return BRAILLE_UCS_BASE | c; \
47 #include <iconv/loop.c>
50 /* Next, define the other direction. */
51 #define MIN_NEEDED_INPUT MIN_NEEDED_TO
52 #define MIN_NEEDED_OUTPUT MIN_NEEDED_FROM
53 #define LOOPFCT TO_LOOP
54 #define BODY \
55 { \
56 uint32_t ch = *((const uint32_t *) inptr); \
57 if (__builtin_expect ((ch & 0xffffff00u) != BRAILLE_UCS_BASE, 0)) \
58 { \
59 UNICODE_TAG_HANDLER (ch, 4); \
61 /* We have an illegal character. */ \
62 STANDARD_TO_LOOP_ERR_HANDLER (4); \
63 } \
64 else \
65 *outptr++ = (unsigned char) (ch & 0xff); \
66 inptr += 4; \
68 #define LOOP_NEED_FLAGS
69 #include <iconv/loop.c>
72 /* Now define the toplevel functions. */
73 #include <iconv/skeleton.c>