Expand PMF_FN_* macros.
[netbsd-mini2440.git] / sys / netsmb / iconv.h
blobde49c4ae5afad204167fd9b940ebb036c9e3823c
1 /* $NetBSD: iconv.h,v 1.8 2005/12/11 06:25:32 christos Exp $ */
3 /*
4 * Copyright (c) 2000-2001, Boris Popov
5 * All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
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
32 * SUCH DAMAGE.
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 {
49 int cs_version;
50 int cs_id;
51 int cs_base;
52 int cs_refcount;
53 char cs_to[ICONV_CSNMAXLEN];
54 char cs_from[ICONV_CSNMAXLEN];
58 * Parameters for 'add' sysctl
60 #define ICONV_ADD_VER 1
62 struct iconv_add_in {
63 int ia_version;
64 char ia_converter[ICONV_CNVNMAXLEN];
65 char ia_to[ICONV_CSNMAXLEN];
66 char ia_from[ICONV_CSNMAXLEN];
67 int ia_datalen;
68 const void *ia_data;
71 struct iconv_add_out {
72 int ia_csid;
75 #ifndef _KERNEL
77 __BEGIN_DECLS
79 int kiconv_add_xlat_table(const char *, const char *, const u_char *);
81 __END_DECLS
83 #else /* !_KERNEL */
85 #ifndef __NetBSD__
86 #include <sys/kobj.h>
87 #include <sys/queue.h> /* can't avoid that */
88 #include <sys/sysctl.h> /* can't avoid that */
90 struct iconv_cspair;
91 struct iconv_cspairdata;
94 * iconv converter class definition
96 struct iconv_converter_class {
97 KOBJ_CLASS_FIELDS;
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;
105 const char * cp_to;
106 void * cp_data;
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 \
117 }; \
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 \
125 }; \
126 DECLARE_MODULE(iconv_ces_ ## name, iconv_ces_ ## name ## _mod, SI_SUB_DRIVERS, SI_ORDER_ANY);
127 #endif /* !NetBSD */
129 #ifdef MALLOC_DECLARE
130 MALLOC_DECLARE(M_ICONV);
131 #endif
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);
143 * Internal functions
145 int iconv_lookupcp(const char **, const char *);
147 #ifndef __NetBSD__
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 *);
151 #endif /* !NetBSD */
153 #ifdef ICONV_DEBUG
154 #define ICDEBUG(x) aprint_debug x
155 #else
156 #define ICDEBUG(x) /* nothing */
157 #endif
159 #endif /* !_KERNEL */
161 #endif /* !_NETSMB_ICONV_H_ */