]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Added imap_utf7 tool for mUTF-7 <-> UTF-8 conversion.
authorTimo Sirainen <tss@iki.fi>
Sat, 1 Nov 2008 20:32:04 +0000 (22:32 +0200)
committerTimo Sirainen <tss@iki.fi>
Sat, 1 Nov 2008 20:32:04 +0000 (22:32 +0200)
--HG--
branch : HEAD

.hgignore
src/util/Makefile.am
src/util/imap-utf7.c [new file with mode: 0644]

index 3dd73572e77e3c00996a89bfdbed0258504fd786..e9299c2ec75f0af2cdffc2778071d897f6d1bef8 100644 (file)
--- 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
index eecd991f2d6826c44cd5ba105aa39caddee303ee..aa43d45f0a7d6a63c61908d63d14b09e105d5ad1 100644 (file)
@@ -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 (file)
index 0000000..cbf7dfb
--- /dev/null
@@ -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 <stdio.h>
+
+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] <string>", 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;
+}