diff options
author | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2006-09-19 07:53:00 +0000 |
---|---|---|
committer | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2006-09-19 07:53:00 +0000 |
commit | 7b5e56388e5628766db68f4b3a1ff6e3bf34dc93 (patch) | |
tree | a55777af459b5d6f7b3a41632c71175b5924ca67 /libsylph/utils.c | |
parent | 487442dbe87c703bfe85a4cda8ec483429cdda06 (diff) |
improved PGP/MIME compatibility.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@1169 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'libsylph/utils.c')
-rw-r--r-- | libsylph/utils.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/libsylph/utils.c b/libsylph/utils.c index 525c9a1b..9992de51 100644 --- a/libsylph/utils.c +++ b/libsylph/utils.c @@ -2920,6 +2920,45 @@ gchar *normalize_newlines(const gchar *str) return out; } +gchar *strchomp_all(const gchar *str) +{ + const gchar *p = str; + const gchar *newline, *last; + gchar *out, *outp; + + out = outp = g_malloc(strlen(str) + 1); + while (*p != '\0') { + newline = strchr(p, '\n'); + if (newline) { + for (last = newline; + p < last && g_ascii_isspace(*(last - 1)); --last) + ; + strncpy(outp, p, last - p); + outp += last - p; + + if (p < newline && *(newline - 1) == '\r') { + strncpy(outp, newline - 1, 2); + outp += 2; + } else { + *outp++ = *newline; + } + + p = newline + 1; + } else { + for (last = p + strlen(p); + p < last && g_ascii_isspace(*(last - 1)); --last) + ; + strncpy(outp, p, last - p); + outp += last - p; + break; + } + } + + *outp = '\0'; + + return out; +} + FILE *get_outgoing_rfc2822_file(FILE *fp) { gchar buf[BUFFSIZE]; |