diff options
author | Bertrand Guiheneuf <bertrand@src.gnome.org> | 1999-06-22 00:46:58 +0800 |
---|---|---|
committer | Bertrand Guiheneuf <bertrand@src.gnome.org> | 1999-06-22 00:46:58 +0800 |
commit | 4f689d0fb8e33e91fec8b8e0471d48f1e6993622 (patch) | |
tree | b7f6adc3bdf3df1e76dc832d3e56e2f0c098a840 /camel/gmime-content-field.c | |
parent | 1703ec52d776954d5da61413b09a82f81b46dd02 (diff) | |
download | gsoc2013-evolution-4f689d0fb8e33e91fec8b8e0471d48f1e6993622.tar gsoc2013-evolution-4f689d0fb8e33e91fec8b8e0471d48f1e6993622.tar.gz gsoc2013-evolution-4f689d0fb8e33e91fec8b8e0471d48f1e6993622.tar.bz2 gsoc2013-evolution-4f689d0fb8e33e91fec8b8e0471d48f1e6993622.tar.lz gsoc2013-evolution-4f689d0fb8e33e91fec8b8e0471d48f1e6993622.tar.xz gsoc2013-evolution-4f689d0fb8e33e91fec8b8e0471d48f1e6993622.tar.zst gsoc2013-evolution-4f689d0fb8e33e91fec8b8e0471d48f1e6993622.zip |
sync
svn path=/trunk/; revision=983
Diffstat (limited to 'camel/gmime-content-field.c')
-rw-r--r-- | camel/gmime-content-field.c | 63 |
1 files changed, 62 insertions, 1 deletions
diff --git a/camel/gmime-content-field.c b/camel/gmime-content-field.c index 87ceaf39f0..6cd368664e 100644 --- a/camel/gmime-content-field.c +++ b/camel/gmime-content-field.c @@ -90,7 +90,7 @@ gmime_content_field_write_to_stream (GMimeContentField *content_field, CamelStre camel_stream_write_strings (stream, "Content-Type: ", content_field->type->str, NULL); if ((content_field->subtype) && ((content_field->subtype)->str)) { //fprintf (file, "/%s", content_field->subtype->str); - camel_stream_write_strings (stream, "/", content_field->type->str, NULL); + camel_stream_write_strings (stream, "/", content_field->subtype->str, NULL); } /* print all parameters */ g_hash_table_foreach (content_field->parameters, _print_parameter, stream); @@ -99,3 +99,64 @@ gmime_content_field_write_to_stream (GMimeContentField *content_field, CamelStre } } +GMimeContentField * +gmime_content_field_construct_from_string (GString *string) +{ + GMimeContentField *cf; + gint first, len; + gchar *str; + gint i=0; + GString *type, *subtype; + GString *param_name, *param_value; + gboolean param_end; + + g_assert (string); + g_assert (string->str); + + cf = g_new (GMimeContentField,1); + str = string->str; + first = 0; + len = string->len; + if (!len) return NULL; + + /* find the type */ + while ( (i<len) && (!strchr ("/;", str[i])) ) i++; + + if (i == 0) return NULL; + + type = g_string_new (strndup (str, i)); + if (i == len) return (gmime_content_field_new (type, NULL)); + + first = i+1; + /* find the subtype, if any */ + if (str[i++] == '/') { + while ( (i<len) && (str[i] != ';') ) i++; + if (i != first) { + subtype = g_string_new (strndup (str+first, i-first)); + if (first == len) return (gmime_content_field_new (type, subtype)); + } + } + first = i+1; + cf = gmime_content_field_new (type, subtype); + + /* parse parameters list */ + param_end = FALSE; + do { + while ( (i<len) && (str[i] != '=') ) i++; + if ((i == len) || (i==first)) param_end = TRUE; + else { + /* we have found parameter name */ + param_name = g_string_new (strndup (str+first, i-first)); + i++; + first = i; + while ( (i<len) && (str[i] != ';') ) i++; + if (i != first) { + /** ****/ + } else { + + } + } + } while ((!param_end) && (first < len)); + + return cf; +} |