2 * This file has been modified for the cdrkit suite.
4 * The behaviour and appearence of the program code below can differ to a major
5 * extent from the version distributed by the original author(s).
7 * For details, see Changelog file distributed with the cdrkit package. If you
8 * received this file from another source then ask the distributing person for
9 * a log of modifications.
13 /* @(#)nls_iconv.c 1.0 02/04/20 2002 J. Schilling */
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2, or (at your option)
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this program; see the file COPYING. If not, write to
27 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
30 * Modifications to make the code portable Copyright (c) 2000 J. Schilling
32 * nls_iconv: create a pseudo-charset table to use iconv() provided by C
33 * library or libiconv by Bruno Haible
34 * The Unicode to charset table has only exact mappings.
37 * Jungshik Shin (jshin@mailaps.org) 04-Feb-2002
48 static void inc_use_count(void);
49 static void dec_use_count(void);
65 init_nls_iconv(char *charset)
67 iconv_t iconv_d; /* iconv conversion descriptor */
68 struct unls_table *table;
70 /* give up if no charset is given */
74 /* see if we already have a table with this name - built in tables
75 have precedence over iconv() - i.e. can't have the name of an
76 existing table. Also, we may have already registered this file
78 if (find_unls(charset) != NULL)
81 if ((iconv_d = iconv_open("UCS-2BE", charset)) == (iconv_t) -1)
85 /* set up the table */
86 if ((table = (struct unls_table *)malloc(sizeof (struct unls_table)))
91 /* give the table the file name, so we can find it again if needed */
92 table->unls_name = strdup(charset);
93 table->unls_uni2cs = NULL;
94 table->unls_cs2uni = NULL;
95 table->unls_next = NULL;
96 table->iconv_d = iconv_d;
98 /* register the table */
99 return register_unls(table);