dovecot-1.2: Added imap_utf7 tool for mUTF-7 <-> UTF-8 conversion.

dovecot at dovecot.org dovecot at dovecot.org
Sat Nov 1 22:32:09 EET 2008


details:   http://hg.dovecot.org/dovecot-1.2/rev/8815fc1099c8
changeset: 8383:8815fc1099c8
user:      Timo Sirainen <tss at iki.fi>
date:      Sat Nov 01 22:32:04 2008 +0200
description:
Added imap_utf7 tool for mUTF-7 <-> UTF-8 conversion.

diffstat:

3 files changed, 46 insertions(+)
.hgignore            |    1 +
src/util/Makefile.am |    8 ++++++++
src/util/imap-utf7.c |   37 +++++++++++++++++++++++++++++++++++++

diffs (84 lines):

diff -r bcf3a185bfc1 -r 8815fc1099c8 .hgignore
--- a/.hgignore	Sat Nov 01 21:16:38 2008 +0200
+++ b/.hgignore	Sat Nov 01 22:32:04 2008 +0200
@@ -74,6 +74,7 @@ src/util/dovecotpw
 src/util/dovecotpw
 src/util/gdbhelper
 src/util/idxview
+src/util/imap_utf7
 src/util/listview
 src/util/logview
 src/util/maildirlock
diff -r bcf3a185bfc1 -r 8815fc1099c8 src/util/Makefile.am
--- a/src/util/Makefile.am	Sat Nov 01 21:16:38 2008 +0200
+++ b/src/util/Makefile.am	Sat Nov 01 22:32:04 2008 +0200
@@ -4,6 +4,7 @@ pkglibexec_PROGRAMS = \
 	rawlog \
 	gdbhelper \
 	idxview \
+	imap_utf7 \
 	listview \
 	logview \
 	maildirlock \
@@ -14,6 +15,7 @@ AM_CPPFLAGS = \
 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
@@ -33,6 +35,12 @@ idxview_LDADD = \
 	../lib/liblib.a
 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
diff -r bcf3a185bfc1 -r 8815fc1099c8 src/util/imap-utf7.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/util/imap-utf7.c	Sat Nov 01 22:32:04 2008 +0200
@@ -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;
+}


More information about the dovecot-cvs mailing list