aboutsummaryrefslogtreecommitdiffstats
path: root/camel/gmime-content-field.c
diff options
context:
space:
mode:
authorBertrand Guiheneuf <bertrand@src.gnome.org>1999-06-22 00:46:58 +0800
committerBertrand Guiheneuf <bertrand@src.gnome.org>1999-06-22 00:46:58 +0800
commit4f689d0fb8e33e91fec8b8e0471d48f1e6993622 (patch)
treeb7f6adc3bdf3df1e76dc832d3e56e2f0c098a840 /camel/gmime-content-field.c
parent1703ec52d776954d5da61413b09a82f81b46dd02 (diff)
downloadgsoc2013-evolution-4f689d0fb8e33e91fec8b8e0471d48f1e6993622.tar.gz
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.c63
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;
+}