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  *
15  * When distributing Covered Code, include this CDDL HEADER in each
16  * file and include the License file CDDL.Schily.txt from this distribution.
17  */
18 
19 #ifndef _SCHILY_SICONV_H
20 #define	_SCHILY_SICONV_H
21 
22 #ifndef _SCHILY_MCONFIG_H
23 #include <schily/mconfig.h>
24 #endif
25 #ifndef _SCHILY_UTYPES_H
26 #include <schily/utypes.h>
27 #endif
28 #ifndef _SCHILY_ICONV_H
29 #include <schily/iconv.h>
30 #endif
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 
37 typedef struct siconv_table	siconvt_t;
38 struct siconv_table {
39 	char		*sic_name;		/* SICONV charset name	*/
40 	UInt16_t	*sic_cs2uni;		/* Charset -> Unicode	*/
41 	UInt8_t		**sic_uni2cs;		/* Unicode -> Charset	*/
42 	iconv_t		sic_cd2uni;		/* iconv Charset -> Unicode */
43 	iconv_t		sic_uni2cd;		/* iconv Unicode -> Charset */
44 	siconvt_t	*sic_alt;		/* alternate iconv tab	*/
45 	siconvt_t	*sic_next;		/* Next table		*/
46 	int		sic_refcnt;		/* Reference count	*/
47 };
48 
49 #define	use_iconv(t)	((t)->sic_cd2uni != NULL)
50 
51 #define	sic_c2uni(t, c)	((t)->sic_cs2uni[c])
52 #define	sic_uni2c(t, c)	((t)->sic_uni2cs[((c) >> 8) & 0xFF][(c) & 0xFF])
53 
54 extern int		sic_list		__PR((FILE *));
55 extern siconvt_t	*sic_open		__PR((char *));
56 extern const char	*sic_base		__PR((void));
57 extern int 		sic_close		__PR((siconvt_t *));
58 
59 #ifdef	__cplusplus
60 }
61 #endif
62 
63 #endif	/* _SCHILY_SICONV_H */
64