diff options
author | Jeff Johnston <jjohnstn@redhat.com> | 2004-06-25 20:33:28 +0000 |
---|---|---|
committer | Jeff Johnston <jjohnstn@redhat.com> | 2004-06-25 20:33:28 +0000 |
commit | 660dade387b1e24665ea8826417b096df2f25e83 (patch) | |
tree | 611b5d25b92b226523a09d99f6dd4514acab5422 /newlib/libc/iconv/lib/conv.h | |
parent | 6778dc3f1a5e444c281bf39a3f199abde00478bd (diff) | |
download | cygnal-660dade387b1e24665ea8826417b096df2f25e83.tar.gz cygnal-660dade387b1e24665ea8826417b096df2f25e83.tar.bz2 cygnal-660dade387b1e24665ea8826417b096df2f25e83.zip |
2004-06-25 Artem B. Bityuckiy <dedekind@oktetlabs.ru>
* acinclude.m4: Move iconv options into configure.in.
* aclocal.m4: Regenerated.
* configure: Ditto.
* configure.in: Add iconv options.
* newlib.hin: Add new iconv encodings and remove deleted ones.
* doc/aclocal.m4: Regenerated.
* doc/configure: Ditto.
* iconvdata/aclocal.m4: Ditto.
* iconvdata/configure: Ditto.
* libc/iconv: Design change. New size-optimized ccs format.
* libc/iconv/AUTHORS: Removed.
* libc/iconv/COPYING: Ditto.
* libc/iconv/README.ORIGINAL: Ditto.
* libc/iconv/README.TODO: Ditto.
* libc/iconv/charset.aliases: Ditto.
* libc/iconv/encoding.aliases: New file.
* libc/iconv/Makefile.am: Updated.
* libc/iconv/Makefile.in: Regenerated.
* libc/iconv/iconv.tex: Updated.
* libc/iconv/ccs/Makefile.am: Ditto.
* libc/iconv/ccs/Makefile.in: Regenerated.
* libc/iconv/ccs/big5.c: Updated.
* libc/iconv/ccs/cns11643_plane1.c: Ditto.
* libc/iconv/ccs/cns11643_plane14.c: Ditto.
* libc/iconv/ccs/cns11643_plane2.c: Ditto.
* libc/iconv/ccs/cp775.c: Ditto.
* libc/iconv/ccs/cp850.c: Ditto.
* libc/iconv/ccs/cp852.c: Ditto.
* libc/iconv/ccs/cp855.c: Ditto.
* libc/iconv/ccs/cp866.c: Ditto.
* libc/iconv/ccs/iso_8859_1.c: Ditto.
* libc/iconv/ccs/README.CCS.SOURCES: Removed.
* libc/iconv/ccs/gb_2312_80.c: Ditto.
* libc/iconv/ccs/iconv_mktbl: Ditto.
* libc/iconv/ccs/jis_x0201.c: Ditto.
* libc/iconv/ccs/jis_x0208_1983.c: Ditto.
* libc/iconv/ccs/shift_jis.c: Ditto.
* libc/iconv/ccs/us_ascii.c: Ditto.
* libc/iconv/ccs/ccs.h: New file.
* libc/iconv/ccs/ccsbi.c: Ditto.
* libc/iconv/ccs/ccsbi.h: Ditto.
* libc/iconv/ccs/ccsnames.h: Ditto.
* libc/iconv/ccs/iso_8859_10.c: Ditto.
* libc/iconv/ccs/iso_8859_11.c: Ditto.
* libc/iconv/ccs/iso_8859_13.c: Ditto.
* libc/iconv/ccs/iso_8859_14.c: Ditto.
* libc/iconv/ccs/iso_8859_3.c: Ditto.
* libc/iconv/ccs/iso_8859_6.c: Ditto.
* libc/iconv/ccs/iso_8859_7.c: Ditto.
* libc/iconv/ccs/iso_8859_8.c: Ditto.
* libc/iconv/ccs/iso_8859_9.c: Ditto.
* libc/iconv/ccs/iso_ir_111.c: Ditto.
* libc/iconv/ccs/jis_x0201_1976.c: Ditto.
* libc/iconv/ccs/jis_x0208_1990.c: Ditto.
* libc/iconv/ccs/koi8_ru.c: Ditto.
* libc/iconv/ccs/koi8_uni.c: Ditto.
* libc/iconv/ccs/mktbl.pl: Ditto.
* libc/iconv/ccs/win_1250.c: Ditto.
* libc/iconv/ccs/win_1251.c: Ditto.
* libc/iconv/ccs/win_1252.c: Ditto.
* libc/iconv/ccs/win_1253.c: Ditto.
* libc/iconv/ccs/win_1254.c: Ditto.
* libc/iconv/ccs/win_1255.c: Ditto.
* libc/iconv/ccs/win_1256.c: Ditto.
* libc/iconv/ccs/win_1257.c: Ditto.
* libc/iconv/ccs/win_1258.c: Ditto.
* libc/iconv/ccs/iso_8859_15.c
* libc/iconv/ccs/iso_8859_2.c
* libc/iconv/ccs/iso_8859_4.c
* libc/iconv/ccs/iso_8859_5.c
* libc/iconv/ccs/jis_x0212_1990.c
* libc/iconv/ccs/koi8_r.c
* libc/iconv/ccs/koi8_u.c
* libc/iconv/ccs/ksx1001.c
* libc/iconv/ccs/binary/gb_2312_80.cct: Removed.
* libc/iconv/ccs/binary/jis_x0201.cct: Ditto.
* libc/iconv/ccs/binary/shift_jis.cct: Ditto.
* libc/iconv/ccs/binary/us_ascii.cct: Ditto.
* libc/iconv/ccs/binary/jis_x0208_1983.cct: Ditto.
* libc/iconv/ccs/binary/Makefile.am: Updated.
* libc/iconv/ccs/binary/Makefile.in: Regenerated.
* libc/iconv/ccs/binary/big5.cct: Updated.
* libc/iconv/ccs/binary/cns11643_plane1.cct: Ditto.
* libc/iconv/ccs/binary/cns11643_plane14.cct: Ditto.
* libc/iconv/ccs/binary/cns11643_plane2.cct: Ditto.
* libc/iconv/ccs/binary/cp775.cct: Updated.: Ditto.
* libc/iconv/ccs/binary/cp850.cct: Ditto.: Ditto.
* libc/iconv/ccs/binary/cp852.cct: Ditto.: Ditto.
* libc/iconv/ccs/binary/cp855.cct: Ditto.: Ditto.
* libc/iconv/ccs/binary/cp866.cct: Ditto.: Ditto.
* libc/iconv/ccs/binary/iso_8859_1.cct: Ditto.
* libc/iconv/ccs/binary/iso_8859_15.cct: Ditto.
* libc/iconv/ccs/binary/iso_8859_4.cct: Ditto.
* libc/iconv/ccs/binary/iso_8859_5.cct: Ditto.
* libc/iconv/ccs/binary/iso_8859_2.cct: Ditto.
* libc/iconv/ccs/binary/jis_x0212_1990.cct: Ditto.
* libc/iconv/ccs/binary/koi8_r.cct: Ditto.
* libc/iconv/ccs/binary/koi8_u.cct: Ditto.
* libc/iconv/ccs/binary/ksx1001.cct: Ditto.
* libc/iconv/ccs/binary/iso_8859_10.cct: New file.
* libc/iconv/ccs/binary/iso_8859_11.cct: Ditto.
* libc/iconv/ccs/binary/iso_8859_13.cct: Ditto.
* libc/iconv/ccs/binary/iso_8859_14.cct: Ditto.
* libc/iconv/ccs/binary/iso_8859_3.cct: Ditto.
* libc/iconv/ccs/binary/iso_8859_6.cct: Ditto.
* libc/iconv/ccs/binary/iso_8859_7.cct: Ditto.
* libc/iconv/ccs/binary/iso_8859_8.cct: Ditto.
* libc/iconv/ccs/binary/iso_8859_9.cct: Ditto.
* libc/iconv/ccs/binary/iso_ir_111.cct: Ditto.
* libc/iconv/ccs/binary/jis_x0201_1976.cct: Ditto.
* libc/iconv/ccs/binary/jis_x0208_1990.cct: Ditto.
* libc/iconv/ccs/binary/koi8_ru.cct: Ditto.
* libc/iconv/ccs/binary/koi8_uni.cct: Ditto.
* libc/iconv/ccs/binary/win_1250.cct: Ditto.
* libc/iconv/ccs/binary/win_1251.cct: Ditto.
* libc/iconv/ccs/binary/win_1252.cct: Ditto.
* libc/iconv/ccs/binary/win_1253.cct: Ditto.
* libc/iconv/ccs/binary/win_1254.cct: Ditto.
* libc/iconv/ccs/binary/win_1255.cct: Ditto.
* libc/iconv/ccs/binary/win_1256.cct: Ditto.
* libc/iconv/ccs/binary/win_1257.cct: Ditto.
* libc/iconv/ccs/binary/win_1258.cct: Ditto.
* libc/iconv/ces/Makefile.am: Updated.
* libc/iconv/ces/Makefile.in: Regenerated.
* libc/iconv/ces/ucs-2-internal.c: Updated.
* libc/iconv/ces/ucs-4-internal.c: Ditto.
* libc/iconv/ces/utf-16.c: Ditto.
* libc/iconv/ces/utf-8.c: Ditto.
* libc/iconv/ces/cesbi.c: New file.
* libc/iconv/ces/cesbi.h: Ditto.
* libc/iconv/ces/cesdeps.h: Ditto.
* libc/iconv/ces/euc.c: Ditto.
* libc/iconv/ces/mkdeps.pl: Ditto.
* libc/iconv/ces/table-pcs.c: Ditto.
* libc/iconv/ces/table.c: Ditto.
* libc/iconv/ces/ucs-2.c: Ditto.
* libc/iconv/ces/ucs-4.c: Ditto.
* libc/iconv/ces/us-ascii.c: Ditto.
* libc/iconv/ces/euc-jp.c: Removed.
* libc/iconv/ces/euc-kr.c: Ditto.
* libc/iconv/ces/euc-tw.c: Ditto.
* libc/iconv/ces/gb2312.c: Ditto.
* libc/iconv/ces/iso-10646-ucs-2.: Ditto.c
* libc/iconv/ces/iso-10646-ucs-4.c: Ditto.
* libc/iconv/lib/Makefile.am: Updated.
* libc/iconv/lib/Makefile.in: Regenerated.
* libc/iconv/lib/endian.h: Updated.
* libc/iconv/lib/iconv.c: Ditto.
* libc/iconv/lib/local.h: Ditto.
* libc/iconv/lib/aliases.c: Removed.
* libc/iconv/lib/bialiasesi.c: Ditto.
* libc/iconv/lib/biccs.c: Ditto.
* libc/iconv/lib/bices.c: Ditto.
* libc/iconv/lib/ccs.c: Ditto.
* libc/iconv/lib/ces.c: Ditto.
* libc/iconv/lib/ces_euc.c: Ditto.
* libc/iconv/lib/ces_iso2022.c: Ditto.
* libc/iconv/lib/ces_table.c: Ditto.
* libc/iconv/lib/converter.c: Ditto.
* libc/iconv/lib/deps.h: Ditto.
* libc/iconv/lib/aliasesbi.c: Ditto.
* libc/iconv/lib/aliasesi.c: Ditto.
* libc/iconv/lib/conv.h: Ditto.
* libc/iconv/lib/encnames.h: Ditto.
* libc/iconv/lib/encoding.deps: Ditto.
* libc/iconv/lib/iconvnls.c: Ditto.
* libc/iconv/lib/iconvnls.h: Ditto.
* libc/iconv/lib/loaddata.c: Ditto.
* libc/iconv/lib/nullconv.c: Ditto.
* libc/iconv/lib/ucsconv.c: Ditto.
* libc/iconv/lib/ucsconv.h: Ditto.
* libc/include/iconv.h: Update copyright.
* libc/*/aclocal.m4: Regenerated.
* libc/*/configure: Ditto.
* libm/*/aclocal.m4: Ditto.
* libm/*/configure: Ditto.
Diffstat (limited to 'newlib/libc/iconv/lib/conv.h')
-rw-r--r-- | newlib/libc/iconv/lib/conv.h | 221 |
1 files changed, 221 insertions, 0 deletions
diff --git a/newlib/libc/iconv/lib/conv.h b/newlib/libc/iconv/lib/conv.h new file mode 100644 index 000000000..03c7c119d --- /dev/null +++ b/newlib/libc/iconv/lib/conv.h @@ -0,0 +1,221 @@ +/* + * Copyright (c) 2003-2004, Artem B. Bityuckiy + * Copyright (c) 1999,2000, Konstantin Chuguev. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ +#ifndef __ICONV_CONVERSION_H__ +#define __ICONV_CONVERSION_H__ + +#include <_ansi.h> +#include <reent.h> +#include <sys/types.h> +#include <wchar.h> + +/* Bits for 'flags' parameter of 'convert' call */ +#define ICONV_DONT_SAVE_BIT 1 +#define ICONV_FAIL_BIT 2 + +/* + * iconv_conversion_handlers_t - keeps iconv conversion handlers. + * + * Keeps 6 interface function handlers: + * open(), close(), convert(), get_mb_cur_max(), get_state(), set_state(), + * get_mb_cur_max() and is_stateful(). Last 5 interface functions are needed to + * support locale subsystem. + * + * ============================================================================ + */ +typedef struct +{ + /* + * open - open and initialize conversion. + * + * PARAMETERS: + * struct _reent *rptr - reent structure of current thread/process; + * _CONST char *to - output encoding's normalized name; + * _CONST char *from - input encoding's normalized name. + * + * DESCRIPTION: + * This function is called from iconv_open() to open conversion. Returns + * a pointer to conversion-specific data. + * + * RETURN: + * Pointer to conversion-specific data if success. In case of error + * returns NULL and sets current thread's/process's errno. + */ + _VOID_PTR _EXPARM(open, (struct _reent *rptr, + _CONST char *to, + _CONST char *from)); + + /* + * close - close conversion. + * + * PARAMETRS: + * struct _reent *rptr - reent structure of current thread/process; + * _VOID_PTR data - conversion-specific data. + * + * DESCRIPTION: + * This function is called from iconv_close() to close conversion. + * + * RETURN: + * When successful, returns (size_t)0. In case of error, sets current + * thread's/process's errno and returns (size_t)-1 (same as iconv_open()). + */ + size_t _EXPARM(close, (struct _reent *rptr, + _VOID_PTR data)); + + /* convert - perform encoding conversion. + * + * PARAMETERS: + * struct _reent *rptr - reent structure of current thread/process. + * _VOID_PTR data - conversion-specific data; + * _CONST unsigned char **inbuf - input data buffer; + * size_t *inbytesleft - input buffer's length; + * unsigned char **outbuf - output data buffer; + * size_t *outbytesleft - output buffer free space; + * int flags - conversion options. + * + * DESCRIPTION: + * This function is called from iconv() to perform conversion and, if 'flags' + * is 0, behaves similarly to iconv(). 'inbuf', 'inbytesleft', 'outbuf' and + * 'outbytesleft' are same as in case of iconv() function. + * + * When flags & 1 isn't 0, 'outbuf' value is ignored and result isn't saved. + * Another conversion aspects aren't changed. + * + * When flags & 2 isn't 0, function changes it's behavior in situations, + * when there is no character in "to" encoding that corresponds to valid + * character from "from" encoding. iconv() specification stands to perform + * implimentation-spacific default conversion. If flag & 2 isn't 0, + * function generates error. + * + * RETURN: + * Returns the number of characters converted in a non-reversible way. + * Reversible conversions are not counted. In case of error, sets current + * thread's/process's errno and returns (size_t)-1 (same as iconv()). + */ + size_t _EXPARM(convert, (struct _reent *rptr, + _VOID_PTR data, + _CONST unsigned char **inbuf, + size_t *inbytesleft, + unsigned char **outbuf, + size_t *outbytesleft, + int flags)); + + /* + * get_state - get current shift state. + * + * PARAMETERS: + * _VOID_PTR data - conversion-specific data; + * mbstate_t *state - mbstate_t object where shift state will be written; + * int direction - 0-"from", 1-"to". + * + * DESCRIPTION: + * Returns encoding's current shift sequence. + * If 'direction' is 0, "from" encoding is tested, else + * "to" encoding is tested. + */ + _VOID _EXPARM(get_state, (_VOID_PTR data, + mbstate_t *state, + int direction)); + + /* + * set_state - set shift state. + * + * PARAMETERS: + * _VOID_PTR data - conversion-specific data; + * mbstate_t *state - mbstate_t object to which shift state will be set. + * int direction - 0-"from", 1-"to". + * + * DESCRIPTION: + * Sets encoding's current shift state to 'state'. if 'state' + * object is zero-object - reset current shift state. + * If 'direction' is 0, "from" encoding is set, else + * "to" encoding is set. + * Returns 0 if '*state' object has right format, -1 else. + */ + int _EXPARM(set_state, (_VOID_PTR data, + mbstate_t *state, + int direction)); + + /* + * get_mb_cur_max - get maximum character length in bytes. + * + * PARAMETERS: + * _VOID_PTR data - conversion-specific data; + * int direction - 0-"from", 1-"to". + * + * DESCRIPTION: + * Returns encoding's maximum character length. + * If 'direction' is 0, "from" encoding is tested, else + * "to" encoding is tested. + */ + int _EXPARM(get_mb_cur_max, (_VOID_PTR data, + int direction)); + + /* + * is_stateful - is encoding stateful or stateless. + * + * PARAMETERS: + * _VOID_PTR data - conversion-specific data; + * int direction - 0-"from", 1-"to". + * + * DESCRIPTION: + * Returns 0 if encoding is stateless and 1 if stateful. + * If 'direction' is 0, "from" encoding is tested, else + * "to" encoding is tested. + */ + int _EXPARM(is_stateful, (_VOID_PTR data, + int direction)); + +} iconv_conversion_handlers_t; + + +/* + * iconv_conversion_t - iconv conversion definition structure. + * + * ============================================================================ + */ +typedef struct +{ + /* Iconv conversion handlers. */ + _CONST iconv_conversion_handlers_t *handlers; + + /* + * Conversion-specific data (e.g., points to iconv_ucs_conversion_t + * object if UCS-based conversion is used). + */ + _VOID_PTR data; +} iconv_conversion_t; + + +/* UCS-based conversion handlers */ +extern _CONST iconv_conversion_handlers_t +_iconv_ucs_conversion_handlers; + +/* Null conversion handlers */ +extern _CONST iconv_conversion_handlers_t +_iconv_null_conversion_handlers; + +#endif /* !__ICONV_CONVERSION_H__ */ + |