1*0d5acd74SJohn Marino /* $FreeBSD: head/lib/libiconv_modules/mapper_none/citrus_mapper_none.c 219019 2011-02-25 00:04:39Z gabor $ */
2*0d5acd74SJohn Marino /*	$NetBSD: citrus_mapper_none.c,v 1.2 2003/06/27 17:53:31 tshiozak Exp $	*/
3*0d5acd74SJohn Marino 
4*0d5acd74SJohn Marino /*-
5*0d5acd74SJohn Marino  * Copyright (c)2003 Citrus Project,
6*0d5acd74SJohn Marino  * All rights reserved.
7*0d5acd74SJohn Marino  *
8*0d5acd74SJohn Marino  * Redistribution and use in source and binary forms, with or without
9*0d5acd74SJohn Marino  * modification, are permitted provided that the following conditions
10*0d5acd74SJohn Marino  * are met:
11*0d5acd74SJohn Marino  * 1. Redistributions of source code must retain the above copyright
12*0d5acd74SJohn Marino  *    notice, this list of conditions and the following disclaimer.
13*0d5acd74SJohn Marino  * 2. Redistributions in binary form must reproduce the above copyright
14*0d5acd74SJohn Marino  *    notice, this list of conditions and the following disclaimer in the
15*0d5acd74SJohn Marino  *    documentation and/or other materials provided with the distribution.
16*0d5acd74SJohn Marino  *
17*0d5acd74SJohn Marino  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18*0d5acd74SJohn Marino  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19*0d5acd74SJohn Marino  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20*0d5acd74SJohn Marino  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21*0d5acd74SJohn Marino  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22*0d5acd74SJohn Marino  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23*0d5acd74SJohn Marino  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24*0d5acd74SJohn Marino  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25*0d5acd74SJohn Marino  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26*0d5acd74SJohn Marino  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27*0d5acd74SJohn Marino  * SUCH DAMAGE.
28*0d5acd74SJohn Marino  */
29*0d5acd74SJohn Marino 
30*0d5acd74SJohn Marino #include <sys/cdefs.h>
31*0d5acd74SJohn Marino #include <sys/queue.h>
32*0d5acd74SJohn Marino 
33*0d5acd74SJohn Marino #include <assert.h>
34*0d5acd74SJohn Marino #include <errno.h>
35*0d5acd74SJohn Marino #include <stdlib.h>
36*0d5acd74SJohn Marino #include <string.h>
37*0d5acd74SJohn Marino 
38*0d5acd74SJohn Marino #include "citrus_namespace.h"
39*0d5acd74SJohn Marino #include "citrus_types.h"
40*0d5acd74SJohn Marino #include "citrus_module.h"
41*0d5acd74SJohn Marino #include "citrus_hash.h"
42*0d5acd74SJohn Marino #include "citrus_mapper.h"
43*0d5acd74SJohn Marino #include "citrus_mapper_none.h"
44*0d5acd74SJohn Marino 
45*0d5acd74SJohn Marino /* ---------------------------------------------------------------------- */
46*0d5acd74SJohn Marino 
47*0d5acd74SJohn Marino _CITRUS_MAPPER_DECLS(mapper_none);
48*0d5acd74SJohn Marino _CITRUS_MAPPER_DEF_OPS(mapper_none);
49*0d5acd74SJohn Marino 
50*0d5acd74SJohn Marino 
51*0d5acd74SJohn Marino /* ---------------------------------------------------------------------- */
52*0d5acd74SJohn Marino 
53*0d5acd74SJohn Marino int
_citrus_mapper_none_mapper_getops(struct _citrus_mapper_ops * ops)54*0d5acd74SJohn Marino _citrus_mapper_none_mapper_getops(struct _citrus_mapper_ops *ops)
55*0d5acd74SJohn Marino {
56*0d5acd74SJohn Marino 
57*0d5acd74SJohn Marino 	memcpy(ops, &_citrus_mapper_none_mapper_ops,
58*0d5acd74SJohn Marino 	    sizeof(_citrus_mapper_none_mapper_ops));
59*0d5acd74SJohn Marino 
60*0d5acd74SJohn Marino 	return (0);
61*0d5acd74SJohn Marino }
62*0d5acd74SJohn Marino 
63*0d5acd74SJohn Marino static int
64*0d5acd74SJohn Marino /*ARGSUSED*/
_citrus_mapper_none_mapper_init(struct _citrus_mapper_area * __restrict ma __unused,struct _citrus_mapper * __restrict cm,const char * __restrict dir __unused,const void * __restrict var __unused,size_t lenvar __unused,struct _citrus_mapper_traits * __restrict mt,size_t lenmt)65*0d5acd74SJohn Marino _citrus_mapper_none_mapper_init(struct _citrus_mapper_area *__restrict ma __unused,
66*0d5acd74SJohn Marino     struct _citrus_mapper * __restrict cm, const char * __restrict dir __unused,
67*0d5acd74SJohn Marino     const void * __restrict var __unused, size_t lenvar __unused,
68*0d5acd74SJohn Marino     struct _citrus_mapper_traits * __restrict mt, size_t lenmt)
69*0d5acd74SJohn Marino {
70*0d5acd74SJohn Marino 
71*0d5acd74SJohn Marino 	if (lenmt < sizeof(*mt))
72*0d5acd74SJohn Marino 		return (EINVAL);
73*0d5acd74SJohn Marino 
74*0d5acd74SJohn Marino 	cm->cm_closure = NULL;
75*0d5acd74SJohn Marino 	mt->mt_src_max = mt->mt_dst_max = 1;	/* 1:1 converter */
76*0d5acd74SJohn Marino 	mt->mt_state_size = 0;			/* stateless */
77*0d5acd74SJohn Marino 
78*0d5acd74SJohn Marino 	return (0);
79*0d5acd74SJohn Marino }
80*0d5acd74SJohn Marino 
81*0d5acd74SJohn Marino static void
82*0d5acd74SJohn Marino /*ARGSUSED*/
_citrus_mapper_none_mapper_uninit(struct _citrus_mapper * cm __unused)83*0d5acd74SJohn Marino _citrus_mapper_none_mapper_uninit(struct _citrus_mapper *cm __unused)
84*0d5acd74SJohn Marino {
85*0d5acd74SJohn Marino 
86*0d5acd74SJohn Marino }
87*0d5acd74SJohn Marino 
88*0d5acd74SJohn Marino static int
89*0d5acd74SJohn Marino /*ARGSUSED*/
_citrus_mapper_none_mapper_convert(struct _citrus_mapper * __restrict cm __unused,_citrus_index_t * __restrict dst,_citrus_index_t src,void * __restrict ps __unused)90*0d5acd74SJohn Marino _citrus_mapper_none_mapper_convert(struct _citrus_mapper * __restrict cm __unused,
91*0d5acd74SJohn Marino     _citrus_index_t * __restrict dst, _citrus_index_t src,
92*0d5acd74SJohn Marino     void * __restrict ps __unused)
93*0d5acd74SJohn Marino {
94*0d5acd74SJohn Marino 
95*0d5acd74SJohn Marino 	*dst = src;
96*0d5acd74SJohn Marino 	return (_CITRUS_MAPPER_CONVERT_SUCCESS);
97*0d5acd74SJohn Marino }
98*0d5acd74SJohn Marino 
99*0d5acd74SJohn Marino static void
100*0d5acd74SJohn Marino /*ARGSUSED*/
_citrus_mapper_none_mapper_init_state(void)101*0d5acd74SJohn Marino _citrus_mapper_none_mapper_init_state(void)
102*0d5acd74SJohn Marino {
103*0d5acd74SJohn Marino 
104*0d5acd74SJohn Marino }
105