]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-charset: Move non-iconv UTF-8 only translation code to its own file
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 9 Nov 2017 13:12:05 +0000 (15:12 +0200)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 19 Feb 2018 10:06:42 +0000 (12:06 +0200)
src/lib-charset/Makefile.am
src/lib-charset/charset-utf8-only.c [new file with mode: 0644]
src/lib-charset/charset-utf8.c

index 122d1dff1b858736d632a25b4c12cc396e493027..cb711909a42017ec2b21725372ee977a5c352975 100644 (file)
@@ -7,7 +7,8 @@ AM_CPPFLAGS = \
 libcharset_la_LIBADD = $(LTLIBICONV)
 libcharset_la_SOURCES = \
        charset-iconv.c \
-       charset-utf8.c
+       charset-utf8.c \
+       charset-utf8-only.c
 
 headers = \
        charset-utf8.h
diff --git a/src/lib-charset/charset-utf8-only.c b/src/lib-charset/charset-utf8-only.c
new file mode 100644 (file)
index 0000000..1b2d940
--- /dev/null
@@ -0,0 +1,47 @@
+/* Copyright (c) 2002-2017 Dovecot authors, see the included COPYING file */
+
+#include "lib.h"
+#include "charset-utf8.h"
+
+#ifndef HAVE_ICONV
+
+struct charset_translation {
+       normalizer_func_t *normalizer;
+};
+
+int charset_to_utf8_begin(const char *charset, normalizer_func_t *normalizer,
+                         struct charset_translation **t_r)
+{
+       struct charset_translation *t;
+
+       if (!charset_is_utf8(charset)) {
+               /* no support for charsets that need translation */
+               return -1;
+       }
+
+       t = i_new(struct charset_translation, 1);
+       t->normalizer = normalizer;
+       *t_r = t;
+       return 0;
+}
+
+void charset_to_utf8_end(struct charset_translation **_t)
+{
+       struct charset_translation *t = *_t;
+
+       *_t = NULL;
+       i_free(t);
+}
+
+void charset_to_utf8_reset(struct charset_translation *t ATTR_UNUSED)
+{
+}
+
+enum charset_result
+charset_to_utf8(struct charset_translation *t,
+               const unsigned char *src, size_t *src_size, buffer_t *dest)
+{
+       return charset_utf8_to_utf8(t->normalizer, src, src_size, dest);
+}
+
+#endif
index 668bb45ac5a949714059e96ffb0104f52341eef5..8a25eddcd52b75f692dd469745e5fe8a6ccb5116 100644 (file)
@@ -42,49 +42,6 @@ charset_utf8_to_utf8_begin(normalizer_func_t *normalizer)
        return trans;
 }
 
-#ifndef HAVE_ICONV
-
-struct charset_translation {
-       normalizer_func_t *normalizer;
-};
-
-int charset_to_utf8_begin(const char *charset, normalizer_func_t *normalizer,
-                         struct charset_translation **t_r)
-{
-       struct charset_translation *t;
-
-       if (!charset_is_utf8(charset)) {
-               /* no support for charsets that need translation */
-               return -1;
-       }
-
-       t = i_new(struct charset_translation, 1);
-       t->normalizer = normalizer;
-       *t_r = t;
-       return 0;
-}
-
-void charset_to_utf8_end(struct charset_translation **_t)
-{
-       struct charset_translation *t = *_t;
-
-       *_t = NULL;
-       i_free(t);
-}
-
-void charset_to_utf8_reset(struct charset_translation *t ATTR_UNUSED)
-{
-}
-
-enum charset_result
-charset_to_utf8(struct charset_translation *t,
-               const unsigned char *src, size_t *src_size, buffer_t *dest)
-{
-       return charset_utf8_to_utf8(t->normalizer, src, src_size, dest);
-}
-
-#endif
-
 enum charset_result
 charset_utf8_to_utf8(normalizer_func_t *normalizer,
                     const unsigned char *src, size_t *src_size, buffer_t *dest)