diff options
author | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2010-07-12 09:33:27 +0000 |
---|---|---|
committer | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2010-07-12 09:33:27 +0000 |
commit | ec14e81935047bd2b2182595b76650b5f2fef893 (patch) | |
tree | d87f0c546859b5ef9a8f49a4f9abcdbd75ac63e7 /libsylph/procmime.c | |
parent | af81f08052caa5dd3bf88b31d9eed3cf6158e9df (diff) |
implemented concatenation of partial messages (RFC 2046).
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@2608 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'libsylph/procmime.c')
-rw-r--r-- | libsylph/procmime.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/libsylph/procmime.c b/libsylph/procmime.c index f4f55ede..2789563f 100644 --- a/libsylph/procmime.c +++ b/libsylph/procmime.c @@ -736,6 +736,49 @@ void procmime_scan_content_type_str(const gchar *content_type, procmime_mime_params_free(mparams); } +void procmime_scan_content_type_partial(const gchar *content_type, + gint *total, gchar **part_id, + gint *number) +{ + MimeParams *mparams; + GSList *cur; + gchar *id_str = NULL; + gint t = 0, n = 0; + + *total = 0; + *part_id = NULL; + *number = 0; + + mparams = procmime_parse_mime_parameter(content_type); + + if (!mparams->hvalue || + g_ascii_strcasecmp(mparams->hvalue, "message/partial") != 0) { + procmime_mime_params_free(mparams); + return; + } + + for (cur = mparams->plist; cur != NULL; cur = cur->next) { + MimeParam *param = (MimeParam *)cur->data; + if (!g_ascii_strcasecmp(param->name, "total")) { + t = atoi(param->value); + } else if (!id_str && !g_ascii_strcasecmp(param->name, "id")) { + id_str = g_strdup(param->value); + } else if (!g_ascii_strcasecmp(param->name, "number")) { + n = atoi(param->value); + } + } + + procmime_mime_params_free(mparams); + + if (t > 0 && n > 0 && t >= n && id_str) { + *total = t; + *part_id = id_str; + *number = n; + } else { + g_free(id_str); + } +} + void procmime_scan_content_disposition(MimeInfo *mimeinfo, const gchar *content_disposition) { |