2 Unix SMB/CIFS implementation.
3 minimal iconv implementation
4 Copyright (C) Andrew Tridgell 2001
5 Copyright (C) Jelmer Vernooij 2002,2003
6 Copyright (C) Panos Christeas 2006
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 From samba 3.0 beta and GNU libiconv-1.8
23 It's bad but most of the time we can't use libc iconv service:
24 - it doesn't round trip for most encoding
25 - it doesn't know about Apple extension
31 #endif /* HAVE_CONFIG_H */
33 #include <netatalk/endian.h>
34 #include <atalk/unicode.h>
36 #include "mac_greek.h"
37 #include "generic_mb.h"
39 static size_t mac_greek_pull(void *,char **, size_t *, char **, size_t *);
40 static size_t mac_greek_push(void *,char **, size_t *, char **, size_t *);
42 struct charset_functions charset_mac_greek =
48 CHARSET_CLIENT | CHARSET_MULTIBYTE,
52 /* ------------------------ */
54 char_ucs2_to_mac_greek ( unsigned char *r, ucs2_t wc)
61 else if (wc >= 0x00a0 && wc < 0x0100)
62 c = mac_greek_page00[wc-0x00a0];
63 else if (wc == 0x0153)
65 else if (wc >= 0x0380 && wc < 0x03d0)
66 c = mac_greek_page03[wc-0x0380];
67 else if (wc >= 0x2010 && wc < 0x2038)
68 c = mac_greek_page20[wc-0x2010];
69 else if (wc == 0x2122)
71 else if (wc >= 0x2248 && wc < 0x2268)
72 c = mac_greek_page22[wc-0x2248];
80 static size_t mac_greek_push( void *cd, char **inbuf, size_t *inbytesleft,
81 char **outbuf, size_t *outbytesleft)
83 /* No special handling required */
84 return (size_t) mb_generic_push( char_ucs2_to_mac_greek, cd, inbuf, inbytesleft, outbuf, outbytesleft);
87 /* ------------------------ */
89 char_mac_greek_to_ucs2 (ucs2_t *pwc, const unsigned char *s)
97 unsigned short wc = mac_greek_2uni[c-0x80];
106 static size_t mac_greek_pull ( void *cd, char **inbuf, size_t *inbytesleft,
107 char **outbuf, size_t *outbytesleft)
109 return (size_t) mb_generic_pull( char_mac_greek_to_ucs2, cd, inbuf, inbytesleft, outbuf, outbytesleft);