From: Timo Sirainen Date: Sat, 1 Nov 2008 20:32:04 +0000 (+0200) Subject: Added imap_utf7 tool for mUTF-7 <-> UTF-8 conversion. X-Git-Tag: 1.2.alpha4~106 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=24c39d5d2112888914ac1189ce5e07c5ac2b0c0a;p=thirdparty%2Fdovecot%2Fcore.git Added imap_utf7 tool for mUTF-7 <-> UTF-8 conversion. --HG-- branch : HEAD --- diff --git a/.hgignore b/.hgignore index 3dd73572e7..e9299c2ec7 100644 --- a/.hgignore +++ b/.hgignore @@ -74,6 +74,7 @@ src/tests/test-imap src/util/dovecotpw src/util/gdbhelper src/util/idxview +src/util/imap_utf7 src/util/listview src/util/logview src/util/maildirlock diff --git a/src/util/Makefile.am b/src/util/Makefile.am index eecd991f2d..aa43d45f0a 100644 --- a/src/util/Makefile.am +++ b/src/util/Makefile.am @@ -4,6 +4,7 @@ pkglibexec_PROGRAMS = \ rawlog \ gdbhelper \ idxview \ + imap_utf7 \ listview \ logview \ maildirlock \ @@ -14,6 +15,7 @@ sbin_PROGRAMS = dovecotpw AM_CPPFLAGS = \ -I$(top_srcdir)/src/lib \ -I$(top_srcdir)/src/lib-mail \ + -I$(top_srcdir)/src/lib-imap \ -I$(top_srcdir)/src/lib-index \ -I$(top_srcdir)/src/lib-storage/index/maildir \ -I$(top_srcdir)/src/auth @@ -34,6 +36,12 @@ idxview_LDADD = \ idxview_SOURCES = \ idxview.c +imap_utf7_LDADD = \ + ../lib-imap/imap-utf7.o \ + ../lib/liblib.a +imap_utf7_SOURCES = \ + imap-utf7.c + listview_LDADD = \ ../lib/liblib.a listview_SOURCES = \ diff --git a/src/util/imap-utf7.c b/src/util/imap-utf7.c new file mode 100644 index 0000000000..cbf7dfb0ac --- /dev/null +++ b/src/util/imap-utf7.c @@ -0,0 +1,37 @@ +/* Copyright (c) 2008 Dovecot authors, see the included COPYING file */ + +#include "lib.h" +#include "str.h" +#include "imap-utf7.h" + +#include + +int main(int argc ATTR_UNUSED, const char *argv[]) +{ + string_t *dest; + bool reverse = FALSE; + int ret; + + lib_init(); + + if (argv[1] != NULL && strcmp(argv[1], "-r") == 0) { + reverse = TRUE; + argv++; + } + + if (argv[1] == NULL) { + fprintf(stderr, "Usage: %s [-r] ", argv[0]); + return 1; + } + + dest = t_str_new(256); + ret = reverse ? + imap_utf8_to_utf7(argv[1], dest) : + imap_utf7_to_utf8(argv[1], dest); + if (ret < 0) { + fprintf(stderr, "Invalid input\n"); + return 1; + } + printf("%s\n", str_c(dest)); + return 0; +}