1 /* @(#)siconv.h	1.5 10/12/20 Copyright 2007-2010 J. Schilling */
2 /*
3  *	Definitions fur users of libsiconv
4  *
5  *	Copyright (c) 2007-2010 J. Schilling
6  */
7 /*
8  * The contents of this file are subject to the terms of the
9  * Common Development and Distribution License, Version 1.0 only
10  * (the "License").  You may not use this file except in compliance
11  * with the License.
12  *
13  * See the file CDDL.Schily.txt in this distribution for details.
14  * A copy of the CDDL is also available via the Internet at
15  * http://www.opensource.org/licenses/cddl1.txt
16  *
17  * When distributing Covered Code, include this CDDL HEADER in each
18  * file and include the License file CDDL.Schily.txt from this distribution.
19  */
20 
21 #ifndef _SCHILY_SICONV_H
22 #define	_SCHILY_SICONV_H
23 
24 #ifndef _SCHILY_MCONFIG_H
25 #include <schily/mconfig.h>
26 #endif
27 #ifndef _SCHILY_UTYPES_H
28 #include <schily/utypes.h>
29 #endif
30 #ifndef _SCHILY_ICONV_H
31 #include <schily/iconv.h>
32 #endif
33 
34 #ifdef	__cplusplus
35 extern "C" {
36 #endif
37 
38 
39 typedef struct siconv_table	siconvt_t;
40 struct siconv_table {
41 	char		*sic_name;		/* SICONV charset name	*/
42 	UInt16_t	*sic_cs2uni;		/* Charset -> Unicode	*/
43 	UInt8_t		**sic_uni2cs;		/* Unicode -> Charset	*/
44 	iconv_t		sic_cd2uni;		/* iconv Charset -> Unicode */
45 	iconv_t		sic_uni2cd;		/* iconv Unicode -> Charset */
46 	siconvt_t	*sic_alt;		/* alternate iconv tab	*/
47 	siconvt_t	*sic_next;		/* Next table		*/
48 	int		sic_refcnt;		/* Reference count	*/
49 };
50 
51 #define	use_iconv(t)	((t)->sic_cd2uni != NULL)
52 
53 #define	sic_c2uni(t, c)	((t)->sic_cs2uni[c])
54 #define	sic_uni2c(t, c)	((t)->sic_uni2cs[((c) >> 8) & 0xFF][(c) & 0xFF])
55 
56 extern int		sic_list		__PR((FILE *));
57 extern siconvt_t	*sic_open		__PR((char *));
58 extern const char	*sic_base		__PR((void));
59 extern int 		sic_close		__PR((siconvt_t *));
60 
61 #ifdef	__cplusplus
62 }
63 #endif
64 
65 #endif	/* _SCHILY_SICONV_H */
66