charset-iconv.c revision 2e37d45867d081db150ab78dad303b9077aea24f
/* Copyright (c) 2002-2011 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "buffer.h"
#include "unichar.h"
#include "charset-utf8.h"
#ifdef HAVE_ICONV
#include <iconv.h>
#include <ctype.h>
struct charset_translation {
enum charset_flags flags;
};
struct charset_translation **t_r)
{
struct charset_translation *t;
if (charset_is_utf8(charset))
else {
return -1;
}
*t_r = t;
return 0;
}
{
struct charset_translation *t = *_t;
iconv_close(t->cd);
i_free(t);
}
void charset_to_utf8_reset(struct charset_translation *t)
{
}
static bool
charset_to_utf8_try(struct charset_translation *t,
enum charset_result *result)
{
ICONV_CONST char *ic_srcbuf;
/* no translation needed - just copy it to outbuf uppercased */
*result = CHARSET_RET_OK;
if (!dtcase) {
return TRUE;
}
return TRUE;
}
if (!dtcase) {
/* The buffer is most likely too small to hold the
output, so increase it at least to the input size. */
}
} else {
ic_destbuf = tmpbuf;
}
*result = CHARSET_RET_OK;
/* set result just to avoid compiler warning */
else {
/* should be EILSEQ */
if (!dtcase)
return TRUE;
}
if (!dtcase) {
/* give back the memory we didn't use */
} else {
/* we just converted data to UTF-8. it shouldn't be invalid,
but Solaris iconv appears to pass invalid data through
sometimes (e.g. 8 bit characters with UTF-7) */
}
return ret;
}
enum charset_result
charset_to_utf8(struct charset_translation *t,
{
enum charset_result result;
bool ret;
for (pos = 0;;) {
if (ret) {
return result;
}
if (!dtcase) {
/* force buffer to grow */
} else {
}
}
}
#endif