diff options
Diffstat (limited to 'source3/modules/CP850.c')
-rw-r--r-- | source3/modules/CP850.c | 76 |
1 files changed, 3 insertions, 73 deletions
diff --git a/source3/modules/CP850.c b/source3/modules/CP850.c index 1805a1e11b5..0adfd24defd 100644 --- a/source3/modules/CP850.c +++ b/source3/modules/CP850.c @@ -2,8 +2,9 @@ * Conversion table for CP850 charset also known as IBM850. * * Copyright (C) Alexander Bokovoy 2003 + * * Conversion tables are generated using GNU libc 2.2.5's - * localedata/charmaps/IBM850 table and iconvdata/gen-8bit-gap.sh script + * localedata/charmaps/IBM850 table and source/script/gen-8bit-gap.sh script * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,13 +23,6 @@ #include "includes.h" -struct gap -{ - uint16 start; - uint16 end; - int32 idx; -}; - static const uint16 to_ucs2[256] = { [0x01] = 0x0001, [0x02] = 0x0002, @@ -347,69 +341,5 @@ static const unsigned char from_ucs2[] = { '\xdb', '\xb0', '\xb1', '\xb2', '\xfe', }; +SMB_GENERATE_CHARSET_MODULE_8_BIT_GAP(CP850) -static size_t CP850_push(void *cd, char **inbuf, size_t *inbytesleft, - char **outbuf, size_t *outbytesleft) -{ - while (*inbytesleft >= 2 && *outbytesleft >= 1) { - int i; - int done = 0; - - uint16 ch = SVAL(*inbuf,0); - - for (i=0; from_idx[i].start != 0xffff; i++) { - if ((from_idx[i].start <= ch) && (from_idx[i].end >= ch)) { - ((unsigned char*)(*outbuf))[0] = from_ucs2[from_idx[i].idx+ch]; - (*inbytesleft) -= 2; - (*outbytesleft) -= 1; - (*inbuf) += 2; - (*outbuf) += 1; - done = 1; - break; - } - } - if (!done) { - errno = EINVAL; - return -1; - } - - } - - if (*inbytesleft == 1) { - errno = EINVAL; - return -1; - } - - if (*inbytesleft > 1) { - errno = E2BIG; - return -1; - } - - return 0; -} - -static size_t CP850_pull(void *cd, char **inbuf, size_t *inbytesleft, - char **outbuf, size_t *outbytesleft) -{ - while (*inbytesleft >= 1 && *outbytesleft >= 2) { - *(uint16*)(*outbuf) = to_ucs2[((unsigned char*)(*inbuf))[0]]; - (*inbytesleft) -= 1; - (*outbytesleft) -= 2; - (*inbuf) += 1; - (*outbuf) += 2; - } - - if (*inbytesleft > 0) { - errno = E2BIG; - return -1; - } - - return 0; -} - -struct charset_functions CP850_functions = {"CP850", CP850_pull, CP850_push}; - -NTSTATUS charset_CP850_init(void) -{ - return smb_register_charset(&CP850_functions); -} |