/* * Conversion table for ISO8859-1 charset * * 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 * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "includes.h" static size_t latin1_pull(void *cd, char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft) { while (*inbytesleft >= 1 && *outbytesleft >= 2) { *(uint16*)(*outbuf) = **inbuf; (*inbytesleft) -= 1; (*outbytesleft) -= 2; (*inbuf) += 1; (*outbuf) += 2; } if (*inbytesleft > 0) { errno = E2BIG; return -1; } return 0; } static size_t latin1_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); (*outbuf)[0] = ch; (*inbytesleft) -= 2; (*outbytesleft) -= 1; (*inbuf) += 2; (*outbuf) += 1; } if (*inbytesleft == 1) { errno = EINVAL; return -1; } if (*inbytesleft > 1) { errno = E2BIG; return -1; } return 0; } struct charset_functions latin1_functions = {"ISO8859-1", latin1_pull, latin1_push}; NTSTATUS charset_latin1_init(void) { return smb_register_charset(&latin1_functions); }