1 /* $NetBSD: iconv.h,v 1.8 2005/12/11 06:25:32 christos Exp $ */
4 * Copyright (c) 2000-2001, Boris Popov
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by Boris Popov.
18 * 4. Neither the name of the author nor the names of any co-contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * $FreeBSD: src/sys/sys/iconv.h,v 1.5 2002/07/15 13:34:50 markm Exp $
36 #ifndef _NETSMB_ICONV_H_
37 #define _NETSMB_ICONV_H_
39 #define ICONV_CSNMAXLEN 31 /* maximum length of charset name */
40 #define ICONV_CNVNMAXLEN 31 /* maximum length of converter name */
41 #define ICONV_CSMAXDATALEN 1024 /* maximum size of data associated with cs pair */
44 * Entry for cslist sysctl
46 #define ICONV_CSPAIR_INFO_VER 1
48 struct iconv_cspair_info
{
53 char cs_to
[ICONV_CSNMAXLEN
];
54 char cs_from
[ICONV_CSNMAXLEN
];
58 * Parameters for 'add' sysctl
60 #define ICONV_ADD_VER 1
64 char ia_converter
[ICONV_CNVNMAXLEN
];
65 char ia_to
[ICONV_CSNMAXLEN
];
66 char ia_from
[ICONV_CSNMAXLEN
];
71 struct iconv_add_out
{
79 int kiconv_add_xlat_table(const char *, const char *, const u_char
*);
87 #include <sys/queue.h> /* can't avoid that */
88 #include <sys/sysctl.h> /* can't avoid that */
91 struct iconv_cspairdata
;
94 * iconv converter class definition
96 struct iconv_converter_class
{
98 TAILQ_ENTRY(iconv_converter_class
) cc_link
;
101 struct iconv_cspair
{
102 int cp_id
; /* unique id of charset pair */
103 int cp_refcount
; /* number of references from other pairs */
104 const char * cp_from
;
107 struct iconv_converter_class
* cp_dcp
;
108 struct iconv_cspair
*cp_base
;
109 TAILQ_ENTRY(iconv_cspair
) cp_link
;
112 #define KICONV_CONVERTER(name,size) \
113 static DEFINE_CLASS(iconv_ ## name, iconv_ ## name ## _methods, (size)); \
114 static moduledata_t iconv_ ## name ## _mod = { \
115 "iconv_"#name, iconv_converter_handler, \
116 (void*)&iconv_ ## name ## _class \
118 DECLARE_MODULE(iconv_ ## name, iconv_ ## name ## _mod, SI_SUB_DRIVERS, SI_ORDER_ANY);
120 #define KICONV_CES(name,size) \
121 static DEFINE_CLASS(iconv_ces_ ## name, iconv_ces_ ## name ## _methods, (size)); \
122 static moduledata_t iconv_ces_ ## name ## _mod = { \
123 "iconv_ces_"#name, iconv_cesmod_handler, \
124 (void*)&iconv_ces_ ## name ## _class \
126 DECLARE_MODULE(iconv_ces_ ## name, iconv_ces_ ## name ## _mod, SI_SUB_DRIVERS, SI_ORDER_ANY);
129 #ifdef MALLOC_DECLARE
130 MALLOC_DECLARE(M_ICONV
);
134 * Basic conversion functions
136 int iconv_open(const char *, const char *, void **);
137 int iconv_close(void *);
138 int iconv_conv(void *, const char **, size_t *, char **, size_t *);
139 char *iconv_convstr(void *, char *, const char *, size_t);
140 void *iconv_convmem(void *, void *, const void *, int);
145 int iconv_lookupcp(const char **, const char *);
148 int iconv_converter_initstub(struct iconv_converter_class
*);
149 int iconv_converter_donestub(struct iconv_converter_class
*);
150 int iconv_converter_handler(module_t
, int, void *);
154 #define ICDEBUG(x) aprint_debug x
156 #define ICDEBUG(x) /* nothing */
159 #endif /* !_KERNEL */
161 #endif /* !_NETSMB_ICONV_H_ */