2 * Copyright (c) 2003-2004, Artem B. Bityuckiy
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 #if defined (ICONV_TO_UCS_CES_US_ASCII) \
28 || defined (ICONV_FROM_UCS_CES_US_ASCII)
32 #include <sys/types.h>
33 #include "../lib/local.h"
34 #include "../lib/ucsconv.h"
37 * For optimization purposes us_ascii is implemented as separate CES converter.
38 * Another possible way is to add us_ascii CCS and use table-based CES converter.
41 #if defined (ICONV_FROM_UCS_CES_US_ASCII)
43 us_ascii_convert_from_ucs (void *data
,
45 unsigned char **outbuf
,
49 return (size_t)ICONV_CES_INVALID_CHARACTER
;
51 *((char *)(*outbuf
)) = (char)in
;
58 #endif /* ICONV_FROM_UCS_CES_US_ASCII */
60 #if defined (ICONV_TO_UCS_CES_US_ASCII)
62 us_ascii_convert_to_ucs (void *data
,
63 const unsigned char **inbuf
,
69 return (ucs4_t
)ICONV_CES_BAD_SEQUENCE
;
71 res
= (ucs4_t
)**inbuf
;
74 return (ucs4_t
)ICONV_CES_INVALID_CHARACTER
;
81 #endif /* ICONV_TO_UCS_CES_US_ASCII */
84 us_ascii_get_mb_cur_max (void *data
)
89 #if defined (ICONV_TO_UCS_CES_US_ASCII)
90 const iconv_to_ucs_ces_handlers_t
91 _iconv_to_ucs_ces_handlers_us_ascii
=
95 us_ascii_get_mb_cur_max
,
99 us_ascii_convert_to_ucs
103 #if defined (ICONV_FROM_UCS_CES_US_ASCII)
104 const iconv_from_ucs_ces_handlers_t
105 _iconv_from_ucs_ces_handlers_us_ascii
=
109 us_ascii_get_mb_cur_max
,
113 us_ascii_convert_from_ucs
117 #endif /* ICONV_TO_UCS_CES_US_ASCII || ICONV_FROM_UCS_CES_US_ASCII */