25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-20 16:15:59 +01:00

* src/mod_irc/iconv_erl.c: Bugfix (thanks to Tomas Janousek)

SVN Revision: 470
This commit is contained in:
Alexey Shchepin 2005-12-14 01:32:48 +00:00
parent 689842edf8
commit 5f2de53f01
2 changed files with 22 additions and 10 deletions

View File

@ -1,3 +1,7 @@
2005-12-14 Alexey Shchepin <alexey@sevcom.net>
* src/mod_irc/iconv_erl.c: Bugfix (thanks to Tomas Janousek)
2005-12-13 Alexey Shchepin <alexey@sevcom.net>
* src/win32/ejabberd.nsi: Updated (thanks to Maxim Ryazanov)

View File

@ -55,27 +55,35 @@ static int iconv_erl_control(ErlDrvData drv_data,
ei_get_type(buf, &index, &i, &size);
stmp = string = malloc(size + 1);
ei_decode_string(buf, &index, string);
cd = iconv_open(to, from);
if(cd == (iconv_t) -1)
{
if (cd == (iconv_t) -1) {
cd = iconv_open("ascii", "ascii");
if(cd == (iconv_t) -1)
{
cd = iconv_open("ascii", "ascii");
}
if (cd == (iconv_t) -1) {
*rbuf = (char*)(b = driver_alloc_binary(size));
memcpy(b->orig_bytes, string, size);
free(from);
free(to);
free(string);
return size;
}
}
outleft = avail = 4*size;
inleft = size;
rtmp = rstring = malloc(avail);
iconv(cd, &stmp, &inleft, &rtmp, &outleft);
while (inleft > 0) {
if (iconv(cd, &stmp, &inleft, &rtmp, &outleft) == (size_t) -1) {
stmp++;
inleft--;
}
}
size = rtmp - rstring;
//printf("size=%d, res=%s\r\n", size, rstring);
*rbuf = (char*)(b = driver_alloc_binary(size));
memcpy(b->orig_bytes, rstring, size);