2 * Copyright (C) 1999-2009 Free Software Foundation, Inc.
3 * This file is part of the GNU LIBICONV Library.
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.
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.
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.
21 /* Part 2 of iconv_open.
23 struct conv_struct * cd;
24 unsigned int from_index;
26 unsigned int to_index;
31 Side effects: Fills cd.
34 cd
->iindex
= from_index
;
35 cd
->ifuncs
= all_encodings
[from_index
].ifuncs
;
36 cd
->oindex
= to_index
;
37 cd
->ofuncs
= all_encodings
[to_index
].ofuncs
;
38 cd
->oflags
= all_encodings
[to_index
].oflags
;
39 /* Initialize the loop functions. */
44 cd
->lfuncs
.loop_convert
= wchar_id_loop_convert
;
45 cd
->lfuncs
.loop_reset
= wchar_id_loop_reset
;
49 cd
->lfuncs
.loop_convert
= wchar_to_loop_convert
;
50 cd
->lfuncs
.loop_reset
= wchar_to_loop_reset
;
57 cd
->lfuncs
.loop_convert
= wchar_from_loop_convert
;
58 cd
->lfuncs
.loop_reset
= wchar_from_loop_reset
;
62 cd
->lfuncs
.loop_convert
= unicode_loop_convert
;
63 cd
->lfuncs
.loop_reset
= unicode_loop_reset
;
66 /* Initialize the states. */
67 memset(&cd
->istate
,'\0',sizeof(state_t
));
68 memset(&cd
->ostate
,'\0',sizeof(state_t
));
69 /* Initialize the operation flags. */
70 cd
->transliterate
= transliterate
;
71 cd
->discard_ilseq
= discard_ilseq
;
73 cd
->fallbacks
.mb_to_uc_fallback
= NULL
;
74 cd
->fallbacks
.uc_to_mb_fallback
= NULL
;
75 cd
->fallbacks
.mb_to_wc_fallback
= NULL
;
76 cd
->fallbacks
.wc_to_mb_fallback
= NULL
;
77 cd
->fallbacks
.data
= NULL
;
78 cd
->hooks
.uc_hook
= NULL
;
79 cd
->hooks
.wc_hook
= NULL
;
80 cd
->hooks
.data
= NULL
;
82 /* Initialize additional fields. */
83 if (from_wchar
!= to_wchar
) {
84 struct wchar_conv_struct
* wcd
= (struct wchar_conv_struct
*) cd
;
85 #if HAVE_WCRTOMB || HAVE_MBRTOWC
86 memset(&wcd
->state
,'\0',sizeof(mbstate_t));