1/* 2 * Copyright (C) 1999-2002, 2004-2006 Free Software Foundation, Inc. 3 * This file is part of the GNU LIBICONV Library. 4 * 5 * The GNU LIBICONV Library is free software; you can redistribute it 6 * and/or modify it under the terms of the GNU Library General Public 7 * License as published by the Free Software Foundation; either version 2 8 * of the License, or (at your option) any later version. 9 * 10 * The GNU LIBICONV Library is distributed in the hope that it will be 11 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * Library General Public License for more details. 14 * 15 * You should have received a copy of the GNU Library General Public 16 * License along with the GNU LIBICONV Library; see the file COPYING.LIB. 17 * If not, write to the Free Software Foundation, Inc., 51 Franklin Street, 18 * Fifth Floor, Boston, MA 02110-1301, USA. 19 */ 20 21/* This file defines all the converters. */ 22 23 24/* Our own notion of wide character, as UCS-4, according to ISO-10646-1. */ 25typedef unsigned int ucs4_t; 26 27/* State used by a conversion. 0 denotes the initial state. */ 28typedef unsigned int state_t; 29 30/* iconv_t is an opaque type. This is the real iconv_t type. */ 31typedef struct conv_struct * conv_t; 32 33/* 34 * Data type for conversion multibyte -> unicode 35 */ 36struct mbtowc_funcs { 37 int (*xxx_mbtowc) (conv_t conv, ucs4_t *pwc, unsigned char const *s, int n); 38 /* 39 * int xxx_mbtowc (conv_t conv, ucs4_t *pwc, unsigned char const *s, int n) 40 * converts the byte sequence starting at s to a wide character. Up to n bytes 41 * are available at s. n is >= 1. 42 * Result is number of bytes consumed (if a wide character was read), 43 * or -1 if invalid, or -2 if n too small, or -2-(number of bytes consumed) 44 * if only a shift sequence was read. 45 */ 46 int (*xxx_flushwc) (conv_t conv, ucs4_t *pwc); 47 /* 48 * int xxx_flushwc (conv_t conv, ucs4_t *pwc) 49 * returns to the initial state and stores the pending wide character, if any. 50 * Result is 1 (if a wide character was read) or 0 if none was pending. 51 */ 52}; 53 54/* Return code if invalid. (xxx_mbtowc) */ 55#define RET_ILSEQ -1 56/* Return code if only a shift sequence of n bytes was read. (xxx_mbtowc) */ 57#define RET_TOOFEW(n) (-2-(n)) 58 59/* 60 * Data type for conversion unicode -> multibyte 61 */ 62struct wctomb_funcs { 63 int (*xxx_wctomb) (conv_t conv, unsigned char *r, ucs4_t wc, int n); 64 /* 65 * int xxx_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n) 66 * converts the wide character wc to the character set xxx, and stores the 67 * result beginning at r. Up to n bytes may be written at r. n is >= 1. 68 * Result is number of bytes written, or -1 if invalid, or -2 if n too small. 69 */ 70 int (*xxx_reset) (conv_t conv, unsigned char *r, int n); 71 /* 72 * int xxx_reset (conv_t conv, unsigned char *r, int n) 73 * stores a shift sequences returning to the initial state beginning at r. 74 * Up to n bytes may be written at r. n is >= 0. 75 * Result is number of bytes written, or -2 if n too small. 76 */ 77}; 78 79/* Return code if invalid. (xxx_wctomb) */ 80#define RET_ILUNI -1 81/* Return code if output buffer is too small. (xxx_wctomb, xxx_reset) */ 82#define RET_TOOSMALL -2 83 84/* 85 * Contents of a conversion descriptor. 86 */ 87struct conv_struct { 88 struct loop_funcs lfuncs; 89 /* Input (conversion multibyte -> unicode) */ 90 int iindex; 91 struct mbtowc_funcs ifuncs; 92 state_t istate; 93 /* Output (conversion unicode -> multibyte) */ 94 int oindex; 95 struct wctomb_funcs ofuncs; 96 int oflags; 97 state_t ostate; 98 /* Operation flags */ 99 int transliterate; 100 int discard_ilseq; 101 #ifndef LIBICONV_PLUG 102 struct iconv_fallbacks fallbacks; 103 struct iconv_hooks hooks; 104 #endif 105}; 106 107/* 108 * Include all the converters. 109 */ 110 111#include "ascii.h" 112 113/* General multi-byte encodings */ 114#include "utf8.h" 115#include "ucs2.h" 116#include "ucs2be.h" 117#include "ucs2le.h" 118#include "ucs4.h" 119#include "ucs4be.h" 120#include "ucs4le.h" 121#include "utf16.h" 122#include "utf16be.h" 123#include "utf16le.h" 124#include "utf32.h" 125#include "utf32be.h" 126#include "utf32le.h" 127#include "utf7.h" 128#include "ucs2internal.h" 129#include "ucs2swapped.h" 130#include "ucs4internal.h" 131#include "ucs4swapped.h" 132 133/* 8-bit encodings */ 134#include "iso8859_1.h" 135#include "iso8859_2.h" 136#include "iso8859_15.h" 137#include "koi8_r.h" 138#include "cp1250.h" 139#include "cp850.h" 140 141#ifdef USE_DOS 142#include "cp437.h" 143#endif 144