dovecot-2.2: lib-imap: Added imap_append_astring()

dovecot at dovecot.org dovecot at dovecot.org
Wed Oct 24 10:14:29 EEST 2012


details:   http://hg.dovecot.org/dovecot-2.2/rev/d9c44aafd163
changeset: 15246:d9c44aafd163
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Oct 24 10:08:06 2012 +0300
description:
lib-imap: Added imap_append_astring()

diffstat:

 src/lib-imap/imap-quote.c |  19 +++++++++++++++++++
 src/lib-imap/imap-quote.h |   2 ++
 2 files changed, 21 insertions(+), 0 deletions(-)

diffs (48 lines):

diff -r 42f99a4fc763 -r d9c44aafd163 src/lib-imap/imap-quote.c
--- a/src/lib-imap/imap-quote.c	Wed Oct 24 10:05:37 2012 +0300
+++ b/src/lib-imap/imap-quote.c	Wed Oct 24 10:08:06 2012 +0300
@@ -2,6 +2,7 @@
 
 #include "lib.h"
 #include "str.h"
+#include "imap-arg.h"
 #include "imap-quote.h"
 
 void imap_quote_append(string_t *str, const unsigned char *value,
@@ -130,6 +131,24 @@
 	imap_append_nstring(dest, src);
 }
 
+void imap_append_astring(string_t *dest, const char *src)
+{
+	unsigned int i;
+
+	i_assert(src != NULL);
+
+	for (i = 0; src[i] != '\0'; i++) {
+		if (!IS_ASTRING_CHAR(src[i])) {
+			imap_append_string(dest, src);
+			return;
+		}
+	}
+	if (i == 0)
+		imap_append_string(dest, src);
+	else
+		str_append(dest, src);
+}
+
 void imap_append_nstring(string_t *dest, const char *src)
 {
 	imap_quote_append_string(dest, src, FALSE);
diff -r 42f99a4fc763 -r d9c44aafd163 src/lib-imap/imap-quote.h
--- a/src/lib-imap/imap-quote.h	Wed Oct 24 10:05:37 2012 +0300
+++ b/src/lib-imap/imap-quote.h	Wed Oct 24 10:08:06 2012 +0300
@@ -17,6 +17,8 @@
 
 /* Append "quoted" or literal. */
 void imap_append_string(string_t *dest, const char *src);
+/* Append atom, "quoted" or literal. */
+void imap_append_astring(string_t *dest, const char *src);
 /* Append NIL, "quoted" or literal. */
 void imap_append_nstring(string_t *dest, const char *src);
 /* Append "quoted". If src has 8bit chars, skip over them. */


More information about the dovecot-cvs mailing list