Example #1
0
static int
smb_copy_iconv(struct mbchain *mbp, c_caddr_t src, caddr_t dst, int len)
{
	int outlen = len;

	return iconv_conv((struct iconv_drv*)mbp->mb_udata, &src, &len, &dst, &outlen);
}
Example #2
0
static int
smb_copy_iconv(struct mbchain *mbp, const char *src, char *dst, size_t len)
{
	size_t outlen = len;

	return iconv_conv((struct iconv_drv*)mbp->mb_udata, &src, &len, &dst, &outlen);
}
Example #3
0
char *
iconv_convstr(void *handle, char *dst, const char *src, size_t l)
{
    char *p = dst;
    size_t inlen, outlen;
    int error;

    if (handle == NULL) {
        strlcpy(dst, src, l);
        return dst;
    }
    inlen = outlen = strlen(src);
    error = iconv_conv(handle, NULL, NULL, &p, &outlen);
    if (error)
        return NULL;
    error = iconv_conv(handle, &src, &inlen, &p, &outlen);
    if (error)
        return NULL;
    *p = 0;
    return dst;
}
Example #4
0
void *
iconv_convmem(void *handle, void *dst, const void *src, int size)
{
    const char *s = src;
    char *d = dst;
    size_t inlen, outlen;
    int error;

    if (size == 0)
        return dst;
    if (handle == NULL) {
        memcpy(dst, src, size);
        return dst;
    }
    inlen = outlen = size;
    error = iconv_conv(handle, NULL, NULL, &d, &outlen);
    if (error)
        return NULL;
    error = iconv_conv(handle, &s, &inlen, &d, &outlen);
    if (error)
        return NULL;
    return dst;
}
Example #5
0
static int
smb_copy_iconv(struct mbchain *mbp, c_caddr_t src, caddr_t dst,
    size_t *srclen, size_t *dstlen)
{
	int error;
	size_t inlen = *srclen, outlen = *dstlen;

	error = iconv_conv((struct iconv_drv*)mbp->mb_udata, &src, &inlen,
	    &dst, &outlen);
	if (inlen != *srclen || outlen != *dstlen) {
		*srclen -= inlen;
		*dstlen -= outlen;
		return 0;
	} else
		return error;
}