1219019Sgabor/* $FreeBSD$ */
2219019Sgabor/* $NetBSD: citrus_mapper_local.h,v 1.2 2008/02/09 14:56:20 junyoung Exp $ */
3219019Sgabor
4219019Sgabor/*-
5219019Sgabor * Copyright (c)2003 Citrus Project,
6219019Sgabor * All rights reserved.
7219019Sgabor *
8219019Sgabor * Redistribution and use in source and binary forms, with or without
9219019Sgabor * modification, are permitted provided that the following conditions
10219019Sgabor * are met:
11219019Sgabor * 1. Redistributions of source code must retain the above copyright
12219019Sgabor *    notice, this list of conditions and the following disclaimer.
13219019Sgabor * 2. Redistributions in binary form must reproduce the above copyright
14219019Sgabor *    notice, this list of conditions and the following disclaimer in the
15219019Sgabor *    documentation and/or other materials provided with the distribution.
16219019Sgabor *
17219019Sgabor * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18219019Sgabor * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19219019Sgabor * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20219019Sgabor * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21219019Sgabor * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22219019Sgabor * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23219019Sgabor * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24219019Sgabor * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25219019Sgabor * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26219019Sgabor * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27219019Sgabor * SUCH DAMAGE.
28219019Sgabor */
29219019Sgabor
30219019Sgabor#ifndef _CITRUS_MAPPER_LOCAL_H_
31219019Sgabor#define _CITRUS_MAPPER_LOCAL_H_
32219019Sgabor
33219019Sgabor#define _CITRUS_MAPPER_GETOPS_FUNC_BASE(_n_)				\
34219019Sgaborint _n_(struct _citrus_mapper_ops *)
35219019Sgabor#define _CITRUS_MAPPER_GETOPS_FUNC(_n_)					\
36219019Sgabor_CITRUS_MAPPER_GETOPS_FUNC_BASE(_citrus_##_n_##_mapper_getops)
37219019Sgabor
38219019Sgabor#define _CITRUS_MAPPER_DECLS(_m_)					\
39219019Sgaborstatic int	 _citrus_##_m_##_mapper_init				\
40219019Sgabor		    (struct _citrus_mapper_area *__restrict,		\
41219019Sgabor		    struct _citrus_mapper * __restrict,			\
42219019Sgabor		    const char * __restrict, const void * __restrict,	\
43219019Sgabor		    size_t, struct _citrus_mapper_traits * __restrict,	\
44219019Sgabor		    size_t);						\
45219019Sgaborstatic void	 _citrus_##_m_##_mapper_uninit(				\
46219019Sgabor		    struct _citrus_mapper *);				\
47219019Sgaborstatic int	 _citrus_##_m_##_mapper_convert				\
48219019Sgabor		    (struct _citrus_mapper * __restrict,		\
49219019Sgabor		    _citrus_index_t * __restrict, _citrus_index_t,	\
50219019Sgabor		    void * __restrict);					\
51219019Sgaborstatic void	 _citrus_##_m_##_mapper_init_state			\
52219019Sgabor		    (void);
53219019Sgabor
54219019Sgabor#define _CITRUS_MAPPER_DEF_OPS(_m_)					\
55219019Sgaborstruct _citrus_mapper_ops _citrus_##_m_##_mapper_ops = {		\
56219019Sgabor	/* mo_init */		&_citrus_##_m_##_mapper_init,		\
57219019Sgabor	/* mo_uninit */		&_citrus_##_m_##_mapper_uninit,		\
58219019Sgabor	/* mo_convert */	&_citrus_##_m_##_mapper_convert,	\
59219019Sgabor	/* mo_init_state */	&_citrus_##_m_##_mapper_init_state	\
60219019Sgabor}
61219019Sgabor
62219019Sgabortypedef _CITRUS_MAPPER_GETOPS_FUNC_BASE((*_citrus_mapper_getops_t));
63219019Sgabortypedef	int (*_citrus_mapper_init_t)(
64219019Sgabor    struct _citrus_mapper_area *__restrict,
65219019Sgabor    struct _citrus_mapper *__restrict, const char *__restrict,
66219019Sgabor    const void *__restrict, size_t,
67219019Sgabor    struct _citrus_mapper_traits * __restrict, size_t);
68219019Sgabortypedef void (*_citrus_mapper_uninit_t)(struct _citrus_mapper *);
69219019Sgabortypedef int (*_citrus_mapper_convert_t)(struct _citrus_mapper * __restrict,
70219019Sgabor    _citrus_index_t * __restrict, _citrus_index_t, void * __restrict);
71219019Sgabortypedef void (*_citrus_mapper_init_state_t)(void);
72219019Sgabor
73219019Sgaborstruct _citrus_mapper_ops {
74219019Sgabor	_citrus_mapper_init_t			 mo_init;
75219019Sgabor	_citrus_mapper_uninit_t			 mo_uninit;
76219019Sgabor	_citrus_mapper_convert_t		 mo_convert;
77219019Sgabor	_citrus_mapper_init_state_t		 mo_init_state;
78219019Sgabor};
79219019Sgabor
80219019Sgaborstruct _citrus_mapper_traits {
81219019Sgabor	/* version 0x00000001 */
82219019Sgabor	size_t					 mt_state_size;
83219019Sgabor	size_t					 mt_src_max;
84219019Sgabor	size_t					 mt_dst_max;
85219019Sgabor};
86219019Sgabor
87219019Sgaborstruct _citrus_mapper {
88219019Sgabor	struct _citrus_mapper_ops		*cm_ops;
89219019Sgabor	void					*cm_closure;
90219019Sgabor	_citrus_module_t			 cm_module;
91219019Sgabor	struct _citrus_mapper_traits		*cm_traits;
92219019Sgabor	_CITRUS_HASH_ENTRY(_citrus_mapper)	 cm_entry;
93219019Sgabor	int					 cm_refcount;
94219019Sgabor	char					*cm_key;
95219019Sgabor};
96219019Sgabor#endif
97