1 /* $NetBSD: iconv.c,v 1.11 2006/10/12 01:32:46 christos Exp $ */
6 __KERNEL_RCSID(0, "$NetBSD: iconv.c,v 1.11 2006/10/12 01:32:46 christos Exp $");
9 #include <sys/kernel.h>
10 #include <sys/systm.h>
11 #include <sys/errno.h>
12 #include <sys/malloc.h>
14 #include <netsmb/iconv.h>
17 iconv_open(const char *to
, const char *from
,
24 iconv_close(void *handle
)
30 iconv_conv(void *handle
, const char **inbuf
,
31 size_t *inbytesleft
, char **outbuf
, size_t *outbytesleft
)
33 if (*inbytesleft
> *outbytesleft
)
37 return(0); /* initial shift state */
39 (void)memcpy(*outbuf
, *inbuf
, *inbytesleft
);
41 *outbytesleft
-= *inbytesleft
;
43 *inbuf
+= *inbytesleft
;
44 *outbuf
+= *inbytesleft
;
52 iconv_convstr(void *handle
, char *dst
, const char *src
, size_t l
)
62 inlen
= outlen
= strlen(src
);
63 error
= iconv_conv(handle
, NULL
, NULL
, &p
, &outlen
);
66 error
= iconv_conv(handle
, &src
, &inlen
, &p
, &outlen
);
74 iconv_convmem(void *handle
, void *dst
, const void *src
, int size
)
84 memcpy(dst
, src
, size
);
87 inlen
= outlen
= size
;
88 error
= iconv_conv(handle
, NULL
, NULL
, &d
, &outlen
);
91 error
= iconv_conv(handle
, &s
, &inlen
, &d
, &outlen
);
98 iconv_lookupcp(const char **cpp
, const char *s
)
101 if (strcmp(*cpp
, s
) == 0)