Home | History | Annotate | Line # | Download | only in citrus
citrus_iconv_local.h revision 1.1
      1 /*	$NetBSD: citrus_iconv_local.h,v 1.1 2003/06/25 09:51:34 tshiozak Exp $	*/
      2 
      3 /*-
      4  * Copyright (c)2003 Citrus Project,
      5  * All rights reserved.
      6  *
      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  *
     16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     19  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
     20  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     22  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     26  * SUCH DAMAGE.
     27  */
     28 
     29 #ifndef _CITRUS_ICONV_LOCAL_H_
     30 #define _CITRUS_ICONV_LOCAL_H_
     31 
     32 #define _CITRUS_ICONV_GETOPS_FUNC_BASE(_n_)				\
     33 int _n_(struct _citrus_iconv_ops *, size_t, u_int32_t)
     34 #define _CITRUS_ICONV_GETOPS_FUNC(_n_)					\
     35 _CITRUS_ICONV_GETOPS_FUNC_BASE(_citrus_##_n_##_iconv_getops)
     36 
     37 #define _CITRUS_ICONV_DECLS(_m_)					\
     38 static int	_citrus_##_m_##_iconv_init				\
     39 	(struct _citrus_iconv * __restrict,				\
     40 	 const char * __restrict,					\
     41 	 const char * __restrict, const char * __restrict,		\
     42 	 const void * __restrict, size_t);				\
     43 static void	_citrus_##_m_##_iconv_uninit(struct _citrus_iconv *);	\
     44 static int	_citrus_##_m_##_iconv_convert				\
     45 	(struct _citrus_iconv * __restrict,				\
     46 	 const char * __restrict * __restrict, size_t * __restrict,	\
     47 	 char * __restrict * __restrict, size_t * __restrict outbytes,	\
     48 	 u_int32_t, size_t * __restrict)
     49 
     50 
     51 #define _CITRUS_ICONV_DEF_OPS(_m_)					\
     52 struct _citrus_iconv_ops _citrus_##_m_##_iconv_ops = {			\
     53 	/* io_abi_version */	_CITRUS_ICONV_ABI_VERSION,		\
     54 	/* io_init */		&_citrus_##_m_##_iconv_init,		\
     55 	/* io_uninit */		&_citrus_##_m_##_iconv_uninit,		\
     56 	/* io_convert */	&_citrus_##_m_##_iconv_convert		\
     57 }
     58 
     59 __BEGIN_DECLS
     60 typedef _CITRUS_ICONV_GETOPS_FUNC_BASE((*_citrus_iconv_getops_t));
     61 typedef	int	(*_citrus_iconv_init_t)(struct _citrus_iconv * __restrict,
     62 					const char * __restrict,
     63 					const char * __restrict,
     64 					const char * __restrict,
     65 					const void * __restrict, size_t);
     66 typedef void	(*_citrus_iconv_uninit_t)(struct _citrus_iconv *);
     67 typedef int	(*_citrus_iconv_convert_t)(struct _citrus_iconv * __restrict,
     68 					   const char *__restrict* __restrict,
     69 					   size_t * __restrict,
     70 					   char * __restrict * __restrict,
     71 					   size_t * __restrict, u_int32_t,
     72 					   size_t * __restrict);
     73 __END_DECLS
     74 
     75 struct _citrus_iconv_ops {
     76 	u_int32_t		io_abi_version;
     77 	_citrus_iconv_init_t	io_init;
     78 	_citrus_iconv_uninit_t	io_uninit;
     79 	_citrus_iconv_convert_t	io_convert;
     80 };
     81 #define _CITRUS_ICONV_ABI_VERSION	1
     82 
     83 struct _citrus_iconv {
     84 	struct _citrus_iconv_ops	*ci_ops;
     85 	void				*ci_closure;
     86 	_citrus_module_t		ci_module;
     87 };
     88 
     89 #endif
     90