4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
33 #include <sys/types.h>
38 * Supported fromcode/tocode values are saved in the following component type
39 * of (name, id) pair. The id values of fromcode and tocode are used to
40 * find out the corresponding code conversions.
48 * Each unique kiconv code conversion identified by tocode and fromcode ids
49 * have corresponding module id and internal function pointers to open(),
50 * kiconv(), close(), and kiconvstr().
53 uint16_t tid
; /* tocode id. */
54 uint16_t fid
; /* fromcode id. */
55 uint16_t mid
; /* module id. */
57 size_t (*kiconv
)(void *, char **, size_t *, char **, size_t *,
60 size_t (*kiconvstr
)(char *, size_t *, char *, size_t *, int,
65 * Each module id has a corresponding module name that is used to load
66 * the module as needed and a reference counter.
74 * The following two data structures are being used to transfer information
75 * on the supported kiconv code conversions from a module to the framework.
77 * Details can be found from kiconv_ops(9S) and kiconv_module_info(9S)
78 * man pages at PSARC/2007/173.
83 void *(*kiconv_open
)(void);
84 size_t (*kiconv
)(void *, char **, size_t *, char **, size_t *,
86 int (*kiconv_close
)(void *);
87 size_t (*kiconvstr
)(char *, size_t *, char *, size_t *, int,
91 typedef struct kiconv_mod_info
{
93 size_t kiconv_num_convs
;
94 kiconv_ops_t
*kiconv_ops_tbl
;
95 size_t kiconv_num_aliases
;
99 } kiconv_module_info_t
;
101 /* The kiconv code conversion descriptor data structure. */
103 void *handle
; /* Handle from the actual open(). */
104 size_t id
; /* Index to the conv_list[]. */
105 } kiconv_data_t
, *kiconv_t
;
107 /* Common conversion state data structure. */
110 uint8_t bom_processed
;
111 } kiconv_state_data_t
, *kiconv_state_t
;
113 /* Common component types for possible code conversion mapping tables. */
116 } kiconv_to_utf8_tbl_comp_t
;
121 } kiconv_to_sb_tbl_comp_t
;
124 * The maximum name length for any given codeset or alias names; the following
125 * should be plenty big enough.
127 #define KICONV_MAX_CODENAME_LEN 63
129 /* The following characters do not exist in the normalized code names. */
130 #define KICONV_SKIPPABLE_CHAR(c) \
131 ((c) == '-' || (c) == '_' || (c) == '.' || (c) == '@')
134 * When we encounter non-identical characters, as like iconv(3C) we have,
135 * map them into either one of the replacement characters based on what is
136 * the current target tocde.
138 * The 0xefbfdb in UTF-8 is U+FFFD in Unicode scalar value.
140 #define KICONV_ASCII_REPLACEMENT_CHAR ('?')
141 #define KICONV_UTF8_REPLACEMENT_CHAR (0xefbfbd)
143 /* Numeric ids for kiconv modules. */
144 #define KICONV_EMBEDDED (0)
145 #define KICONV_MODULE_ID_JA (1)
146 #define KICONV_MODULE_ID_SC (2)
147 #define KICONV_MODULE_ID_KO (3)
148 #define KICONV_MODULE_ID_TC (4)
149 #define KICONV_MODULE_ID_EMEA (5)
151 #define KICONV_MAX_MODULE_ID KICONV_MODULE_ID_EMEA
153 /* Functions used in kiconv conversion and module management. */
154 extern void kiconv_init();
155 extern int kiconv_register_module(kiconv_module_info_t
*);
156 extern int kiconv_unregister_module(kiconv_module_info_t
*);
157 extern size_t kiconv_module_ref_count(size_t);
165 #endif /* _SYS_KICONV_H */