diff options
author | Alexander Bokovoy <ab@samba.org> | 2003-12-10 15:59:28 +0000 |
---|---|---|
committer | Alexander Bokovoy <ab@samba.org> | 2003-12-10 15:59:28 +0000 |
commit | 57607049187fc735d16050cb6f5d1aa41cf44747 (patch) | |
tree | 303496cc3b40407be4f2c3bf3d97a18c52a2f1d6 /source3/lib | |
parent | d73f554a3594d18d9f85a3a694eb9689d056f2a6 (diff) | |
download | samba-57607049187fc735d16050cb6f5d1aa41cf44747.tar.gz samba-57607049187fc735d16050cb6f5d1aa41cf44747.tar.bz2 samba-57607049187fc735d16050cb6f5d1aa41cf44747.zip |
Fix #558 -- support ISO-8859-1 internally. Makes Solaris users a bit happier
(This used to be commit ba95fe56d2db8243191d5dd6b75c6b65e0f5fbe9)
Diffstat (limited to 'source3/lib')
-rw-r--r-- | source3/lib/iconv.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/source3/lib/iconv.c b/source3/lib/iconv.c index 9f6db79ee2..b0c13a5ee6 100644 --- a/source3/lib/iconv.c +++ b/source3/lib/iconv.c @@ -53,6 +53,7 @@ static size_t ascii_pull(void *,char **, size_t *, char **, size_t *); static size_t ascii_push(void *,char **, size_t *, char **, size_t *); +static size_t latin1_push(void *,char **, size_t *, char **, size_t *); static size_t utf8_pull(void *,char **, size_t *, char **, size_t *); static size_t utf8_push(void *,char **, size_t *, char **, size_t *); static size_t ucs2hex_pull(void *,char **, size_t *, char **, size_t *); @@ -64,6 +65,7 @@ static struct charset_functions builtin_functions[] = { {"UTF8", utf8_pull, utf8_push}, {"ASCII", ascii_pull, ascii_push}, {"646", ascii_pull, ascii_push}, + {"ISO-8859-1", ascii_pull, latin1_push}, {"UCS2-HEX", ucs2hex_pull, ucs2hex_push}, {NULL, NULL, NULL} }; @@ -354,6 +356,32 @@ static size_t ascii_push(void *cd, char **inbuf, size_t *inbytesleft, return ir_count; } +static size_t latin1_push(void *cd, char **inbuf, size_t *inbytesleft, + char **outbuf, size_t *outbytesleft) +{ + int ir_count=0; + + while (*inbytesleft >= 2 && *outbytesleft >= 1) { + (*outbuf)[0] = (*inbuf)[0]; + if ((*inbuf)[1]) ir_count++; + (*inbytesleft) -= 2; + (*outbytesleft) -= 1; + (*inbuf) += 2; + (*outbuf) += 1; + } + + if (*inbytesleft == 1) { + errno = EINVAL; + return -1; + } + + if (*inbytesleft > 1) { + errno = E2BIG; + return -1; + } + + return ir_count; +} static size_t ucs2hex_pull(void *cd, char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft) |