1 /*
2 * This file and its contents are supplied under the terms of the
3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 * You may only use this file in accordance with the terms of version
5 * 1.0 of the CDDL.
6 *
7 * A full copy of the text of the CDDL should have accompanied this
8 * source. A copy of the CDDL is also available via the Internet at
9 * http://www.illumos.org/license/CDDL.
10 */
11
12 /*
13 * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
14 */
15
16
17 #include <sys/types.h>
18 #include <sys/time.h>
19 #include <sys/systm.h>
20 #include <sys/errno.h>
21 #include <sys/kiconv.h>
22
23 #include <errno.h>
24 #include <iconv.h>
25
26
27 kiconv_t
kiconv_open(const char * tocode,const char * fromcode)28 kiconv_open(const char *tocode, const char *fromcode)
29 {
30 return (iconv_open(tocode, fromcode));
31 }
32
33 int
kiconv_close(kiconv_t handle)34 kiconv_close(kiconv_t handle)
35 {
36 if (iconv_close(handle) < 0)
37 return (EBADF);
38
39 return (0);
40 }
41
42 size_t
kiconv(kiconv_t handle,char ** inbuf,size_t * inbytesleft,char ** outbuf,size_t * outbytesleft,int * errno_out)43 kiconv(
44 kiconv_t handle,
45 char **inbuf,
46 size_t *inbytesleft,
47 char **outbuf,
48 size_t *outbytesleft,
49 int *errno_out)
50 {
51 size_t code;
52
53 code = iconv(handle, (const char **)inbuf, inbytesleft,
54 outbuf, outbytesleft);
55 *errno_out = errno;
56 return (code);
57 }
58