summaryrefslogtreecommitdiff
path: root/lib/util
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2009-03-02 04:12:57 +0100
committerJelmer Vernooij <jelmer@samba.org>2009-03-02 04:12:57 +0100
commitc7b9757b8ac3ac6baa478655a4d2f77dff8240a8 (patch)
treeccdbd06a49613d9d8cafd26ea95a829868cf2e0d /lib/util
parent9940c7690e2c1b225111d5d8e09cc735ebe296dd (diff)
downloadsamba-c7b9757b8ac3ac6baa478655a4d2f77dff8240a8.tar.gz
samba-c7b9757b8ac3ac6baa478655a4d2f77dff8240a8.tar.bz2
samba-c7b9757b8ac3ac6baa478655a4d2f77dff8240a8.zip
Import ISO-8859-1, 646 from Samba 3 iconv.
Diffstat (limited to 'lib/util')
-rw-r--r--lib/util/charset/iconv.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/util/charset/iconv.c b/lib/util/charset/iconv.c
index 98284ce9bd..9825e4be01 100644
--- a/lib/util/charset/iconv.c
+++ b/lib/util/charset/iconv.c
@@ -50,6 +50,7 @@
static size_t ascii_pull (void *,const char **, size_t *, char **, size_t *);
static size_t ascii_push (void *,const char **, size_t *, char **, size_t *);
+static size_t latin1_push (void *,const char **, size_t *, char **, size_t *);
static size_t utf8_pull (void *,const char **, size_t *, char **, size_t *);
static size_t utf8_push (void *,const char **, size_t *, char **, size_t *);
static size_t utf16_munged_pull(void *,const char **, size_t *, char **, size_t *);
@@ -73,6 +74,8 @@ static const struct charset_functions builtin_functions[] = {
{"UTF16_MUNGED", utf16_munged_pull, iconv_copy},
{"ASCII", ascii_pull, ascii_push},
+ {"646", ascii_pull, ascii_push},
+ {"ISO-8859-1", ascii_pull, latin1_push},
{"UCS2-HEX", ucs2hex_pull, ucs2hex_push}
};
@@ -341,6 +344,32 @@ static size_t ascii_push(void *cd, const char **inbuf, size_t *inbytesleft,
return ir_count;
}
+static size_t latin1_push(void *cd, const 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, const char **inbuf, size_t *inbytesleft,
char **outbuf, size_t *outbytesleft)