-dnl ./aclocal.m4 generated automatically by aclocal 1.4-p5
+dnl aclocal.m4 generated automatically by aclocal 1.4-p5
dnl Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
AC_INIT(configure.in)
AM_CONFIG_HEADER(config.h)
-AM_INIT_AUTOMAKE(libi2ncommon, 0.1)
+AM_INIT_AUTOMAKE(libi2ncommon, 0.2)
AC_LANG_CPLUSPLUS
AC_PROG_CXX
AC_SUBST(LIBGETTEXT_CFLAGS)
AC_SUBST(LIBGETTEXT_LIBS)
+PKG_CHECK_MODULES(LIBICONV, libiconv >= 0.0.0)
+AC_SUBST(LIBICONV_CFLAGS)
+AC_SUBST(LIBICONV_LIBS)
+
AM_PATH_CPPUNIT(1.8.0)
AC_OUTPUT(Makefile src/Makefile libi2ncommon.pc test/Makefile)
# set the include path found by configure
-INCLUDES = -I$(top_srcdir)/src @LIBGETTEXT_CFLAGS@ $(all_includes)
+INCLUDES = -I$(top_srcdir)/src @LIBGETTEXT_CFLAGS@ @LIBICONV_CFLAGS@ $(all_includes)
# the library search path.
lib_LTLIBRARIES = libi2ncommon.la
# the library that is made has version (a-c).c.b. In this
# example, the version is 2.1.2. (3:2:1)
-libi2ncommon_la_LIBADD = @LIBGETTEXT_LIBS@
+libi2ncommon_la_LIBADD = @LIBGETTEXT_LIBS@ @LIBICONV_LIBS@
return result;
}
+std::string utf7imap_to_iso(const std::string& utf7imapstring)
+{
+ string result;
+
+ iconv_t utf7imap2iso = iconv_open ("ISO-8859-1","UTF-7-IMAP");
+
+ if (utf7imap2iso == (iconv_t)-1)
+ throw runtime_error("iconv can't convert from UTF-7-IMAP to ISO-8859-1");
+
+ size_t in_size=utf7imapstring.size();
+ size_t out_size=in_size;
+
+ char *buf = (char *)malloc(out_size+1);
+ if (buf == NULL)
+ throw runtime_error("out of memory for iconv buffer");
+
+ const char *in = utf7imapstring.c_str();
+ char *out = buf;
+ iconv (utf7imap2iso, &in, &in_size, &out, &out_size);
+
+ buf[utf7imapstring.size()-out_size]=0;
+
+ result=buf;
+
+ free(buf);
+ iconv_close (utf7imap2iso);
+
+ return result;
+}
+
bool replace_all(string &base, const char *ist, const char *soll)
{
string i=ist;
std::string utf8_to_iso(const std::string& utf8string);
std::string iso_to_html(const std::string& isostring, bool showerr_bug=false);
+std::string utf7imap_to_iso(const std::string &utf7imapstring);
+
std::string escape(const std::string &s);
std::string descape(const std::string &s, int startpos, int &endpos);