Mercurial > dovecot > original-hg > dovecot-1.2
changeset 7916:8f3115354d14 HEAD
Added imap_dquote_append().
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sat, 21 Jun 2008 09:21:51 +0300 |
parents | 1789ac4637b0 |
children | ca2ff54ee9b4 |
files | src/lib-imap/imap-quote.c src/lib-imap/imap-quote.h |
diffstat | 2 files changed, 26 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-imap/imap-quote.c Sat Jun 21 09:21:38 2008 +0300 +++ b/src/lib-imap/imap-quote.c Sat Jun 21 09:21:51 2008 +0300 @@ -108,3 +108,26 @@ t_pop(); return ret; } + +void imap_dquote_append(string_t *dest, const char *src) +{ + str_append_c(dest, '"'); + for (; *src != '\0'; src++) { + switch (*src) { + case '"': + case '\\': + str_append_c(dest, '\\'); + str_append_c(dest, *src); + break; + default: + if ((unsigned char)*src >= 0x80) { + /* 8bit input not allowed in dquotes */ + break; + } + + str_append_c(dest, *src); + break; + } + } + str_append_c(dest, '"'); +}
--- a/src/lib-imap/imap-quote.h Sat Jun 21 09:21:38 2008 +0300 +++ b/src/lib-imap/imap-quote.h Sat Jun 21 09:21:51 2008 +0300 @@ -15,4 +15,7 @@ imap_quote_append(str, (const unsigned char *)(value), \ (size_t)-1, compress_lwsp) +/* Append data to destination string quoted using "". */ +void imap_dquote_append(string_t *dest, const char *src); + #endif