[gmime] Introduced the beginnings of GMimeParserOptions



commit cf0ec8b67396fa0edd21b859757333c6f0d5ba63
Author: Jeffrey Stedfast <jestedfa microsoft com>
Date:   Mon Feb 6 13:30:53 2017 -0500

    Introduced the beginnings of GMimeParserOptions

 gmime/Makefile.am            |    2 +
 gmime/gmime-parser-options.c |  267 ++++++++++++++++++++++++++++++++++++++++++
 gmime/gmime-parser-options.h |   74 ++++++++++++
 gmime/gmime-parser.c         |   80 ++++++++++---
 gmime/gmime-parser.h         |    3 +
 gmime/gmime.h                |    1 +
 6 files changed, 407 insertions(+), 20 deletions(-)
---
diff --git a/gmime/Makefile.am b/gmime/Makefile.am
index b4433f4..42d5127 100644
--- a/gmime/Makefile.am
+++ b/gmime/Makefile.am
@@ -57,6 +57,7 @@ libgmime_3_0_la_SOURCES =             \
        gmime-param.c                   \
        gmime-parse-utils.c             \
        gmime-parser.c                  \
+       gmime-parser-options.c          \
        gmime-part.c                    \
        gmime-part-iter.c               \
        gmime-pkcs7-context.c           \
@@ -111,6 +112,7 @@ gmimeinclude_HEADERS =                      \
        gmime-object.h                  \
        gmime-param.h                   \
        gmime-parser.h                  \
+       gmime-parser-options.h          \
        gmime-part.h                    \
        gmime-part-iter.h               \
        gmime-pkcs7-context.h           \
diff --git a/gmime/gmime-parser-options.c b/gmime/gmime-parser-options.c
new file mode 100644
index 0000000..786f78d
--- /dev/null
+++ b/gmime/gmime-parser-options.c
@@ -0,0 +1,267 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*  GMime
+ *  Copyright (C) 2000-2014 Jeffrey Stedfast
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public License
+ *  as published by the Free Software Foundation; either version 2.1
+ *  of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free
+ *  Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
+ *  02110-1301, USA.
+ */
+
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <string.h>
+
+#include "gmime-parser-options.h"
+
+static char *default_charsets[3] = { "utf-8", "iso-8859-1", NULL };
+
+
+GMimeParserOptions g_mime_parser_options_default = {
+       GMIME_RFC_COMPLIANCE_LOOSE,
+       GMIME_RFC_COMPLIANCE_LOOSE,
+       GMIME_RFC_COMPLIANCE_LOOSE,
+       default_charsets
+};
+
+
+/**
+ * @g_mime_parser_options_new:
+ *
+ * Creates a new set of #GMimeParserOptions.
+ *
+ * Returns: a newly allocated set of #GMimeParserOptions with the default values.
+ **/
+GMimeParserOptions *
+g_mime_parser_options_new (void)
+{
+       GMimeParserOptions *options;
+       
+       options = g_slice_new (GMimeParserOptions);
+       options->addresses = GMIME_RFC_COMPLIANCE_LOOSE;
+       options->parameters = GMIME_RFC_COMPLIANCE_LOOSE;
+       options->rfc2047 = GMIME_RFC_COMPLIANCE_LOOSE;
+       
+       options->charsets = g_malloc (sizeof (char *) * 3);
+       options->charsets[0] = g_strdup ("utf-8");
+       options->charsets[1] = g_strdup ("iso-8859-1");
+       options->charsets[2] = NULL;
+       
+       return options;
+}
+
+
+/**
+ * g_mime_parser_options_free:
+ * @options: a #GMimeParserOptions
+ *
+ * Frees a set of #GMimeParserOptions.
+ **/
+void
+g_mime_parser_options_free (GMimeParserOptions *options)
+{
+       g_return_if_fail (options != NULL);
+       
+       g_str_freev (options->charsets);
+       g_slice_free (GMimeParserOptions, options);
+}
+
+
+/**
+ * g_mime_parser_options_get_address_parser_compliance_mode:
+ * @options: a #GMimeParserOptions
+ *
+ * Gets the compliance mode that should be used when parsing rfc822 addresses.
+ *
+ * Note: Even in #GMIME_RFC_COMPLIANCE_STRICT mode, the address parser is fairly liberal in
+ * what it accepts. Setting it to #GMIME_RFC_COMPLIANCE_LOOSE just makes it try harder to
+ * deal with garbage input.
+ *
+ * Returns: the compliance mode that is currently set.
+ **/
+GMimeRfcComplianceMode
+g_mime_parser_options_get_address_parser_compliance_mode (GMimeParserOptions *options)
+{
+       g_return_val_if_fail (options != NULL, GMIME_RFC_COMPLIANCE_LOOSE);
+       
+       return options->addresses;
+}
+
+
+/**
+ * g_mime_parser_options_set_address_parser_compliance_mode:
+ * @options: a #GMimeParserOptions
+ * @mode: a #GMimeRfcComplianceMode
+ *
+ * Sets the compliance mode that should be used when parsing rfc822 addresses.
+ *
+ * In general, you'll probably want this value to be #GMIME_RFC_COMPLIANCE_LOOSE
+ * (the default) as it allows maximum interoperability with existing (broken) mail clients
+ * and other mail software such as sloppily written perl scripts (aka spambots).
+ *
+ * Note: Even in #GMIME_RFC_COMPLIANCE_STRICT mode, the address parser is fairly liberal in
+ * what it accepts. Setting it to #GMIME_RFC_COMPLIANCE_LOOSE just makes it try harder to
+ * deal with garbage input.
+ **/
+void
+g_mime_parser_options_set_address_parser_compliance_mode (GMimeParserOptions *options, 
GMimeRfcComplianceMode mode)
+{
+       g_return_if_fail (options != NULL);
+       
+       options->addresses = mode;
+}
+
+
+/**
+ * g_mime_parser_options_get_parameter_compliance_mode:
+ * @options: a #GMimeParserOptions
+ *
+ * Gets the compliance mode that should be used when parsing Content-Type and
+ * Content-Disposition parameters.
+ *
+ * Note: Even in #GMIME_RFC_COMPLIANCE_STRICT mode, the parameter parser is fairly liberal
+ * in what it accepts. Setting it to #GMIME_RFC_COMPLIANCE_LOOSE just makes it try harder
+ * to deal with garbage input.
+ *
+ * Returns: the compliance mode that is currently set.
+ **/
+GMimeRfcComplianceMode
+g_mime_parser_options_get_parameter_compliance_mode (GMimeParserOptions *options)
+{
+       g_return_val_if_fail (options != NULL, GMIME_RFC_COMPLIANCE_LOOSE);
+       
+       return options->parameters;
+}
+
+
+/**
+ * g_mime_parser_options_set_parameter_compliance_mode:
+ * @options: a #GMimeParserOptions
+ * @mode: a #GMimeRfcComplianceMode
+ *
+ * Sets the compliance mode that should be used when parsing Content-Type and
+ * Content-Disposition parameters.
+ *
+ * In general, you'll probably want this value to be #GMIME_RFC_COMPLIANCE_LOOSE
+ * (the default) as it allows maximum interoperability with existing (broken) mail clients
+ * and other mail software such as sloppily written perl scripts (aka spambots).
+ *
+ * Note: Even in #GMIME_RFC_COMPLIANCE_STRICT mode, the parameter parser is fairly liberal
+ * in what it accepts. Setting it to #GMIME_RFC_COMPLIANCE_LOOSE just makes it try harder
+ * to deal with garbage input.
+ **/
+void
+g_mime_parser_options_set_parameter_compliance_mode (GMimeParserOptions *options, GMimeRfcComplianceMode 
mode)
+{
+       g_return_if_fail (options != NULL);
+       
+       options->parameters = mode;
+}
+
+
+/**
+ * g_mime_parser_options_get_rfc2047_compliance_mode:
+ * @options: a #GMimeParserOptions
+ *
+ * Gets the compliance mode that should be used when parsing rfc2047 encoded words.
+ *
+ * Note: Even in #GMIME_RFC_COMPLIANCE_STRICT mode, the rfc2047 parser is fairly liberal
+ * in what it accepts. Setting it to #GMIME_RFC_COMPLIANCE_LOOSE just makes it try harder
+ * to deal with garbage input.
+ *
+ * Returns: the compliance mode that is currently set.
+ **/
+GMimeRfcComplianceMode
+g_mime_parser_options_get_rfc2047_compliance_mode (GMimeParserOptions *options)
+{
+       g_return_val_if_fail (options != NULL, GMIME_RFC_COMPLIANCE_LOOSE);
+       
+       return options->rfc2047;
+}
+
+
+/**
+ * g_mime_parser_options_set_rfc2047_compliance_mode:
+ * @options: a #GMimeParserOptions
+ * @mode: a #GMimeRfcComplianceMode
+ *
+ * Sets the compliance mode that should be used when parsing rfc2047 encoded words.
+ *
+ * In general, you'll probably want this value to be #GMIME_RFC_COMPLIANCE_LOOSE
+ * (the default) as it allows maximum interoperability with existing (broken) mail clients
+ * and other mail software such as sloppily written perl scripts (aka spambots).
+ *
+ * Note: Even in #GMIME_RFC_COMPLIANCE_STRICT mode, the parameter parser is fairly liberal
+ * in what it accepts. Setting it to #GMIME_RFC_COMPLIANCE_LOOSE just makes it try harder
+ * to deal with garbage input.
+ **/
+void
+g_mime_parser_options_set_rfc2047_compliance_mode (GMimeParserOptions *options, GMimeRfcComplianceMode mode)
+{
+       g_return_if_fail (options != NULL);
+       
+       options->rfc2047 = mode;
+}
+
+
+/**
+ * g_mime_parser_options_get_fallback_charsets:
+ * @options: a #GMimeParserOptions
+ *
+ * Gets the fallback charsets to try when decoding 8-bit headers.
+ *
+ * Returns: a %NULL-terminated list of charsets to try when decoding
+ * 8-bit headers.
+ **/
+const char **
+g_mime_parser_options_get_fallback_charsets (GMimeParserOptions *options)
+{
+       g_return_val_if_fail (options != NULL, default_charsets);
+       
+       return options->charsets;
+}
+
+
+/**
+ * g_mime_parser_options_set_fallback_charsets:
+ * @options: a #GMimeParserOptions
+ * @charsets: a %NULL-terminated list of charsets or %NULL for the default list
+ *
+ * Sets the fallback charsets to try when decoding 8-bit headers.
+ *
+ * Note: It is recommended that the list of charsets start with utf-8
+ * and end with iso-8859-1.
+ **/
+void
+g_mime_parser_options_set_fallback_charsets (GMimeParserOptions *options, const char **charsets)
+{
+       guint i, n = 0;
+       
+       g_return_if_fail (options != NULL);
+       
+       g_str_freev (options->charsets);
+       
+       if (charsets == NULL || *charsets == NULL)
+               charsets = default_charsets;
+       
+       while (charsets[n] != NULL)
+               n++;
+       
+       options->charsets = g_malloc (sizeof (char *) * (n + 1));
+       for (i = 0; i < n; i++)
+               options->charsets[i] = g_strdup (charsets[i]);
+       options->charsets[n] = NULL;
+}
diff --git a/gmime/gmime-parser-options.h b/gmime/gmime-parser-options.h
new file mode 100644
index 0000000..6beb8ed
--- /dev/null
+++ b/gmime/gmime-parser-options.h
@@ -0,0 +1,74 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*  GMime
+ *  Copyright (C) 2000-2014 Jeffrey Stedfast
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public License
+ *  as published by the Free Software Foundation; either version 2.1
+ *  of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free
+ *  Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
+ *  02110-1301, USA.
+ */
+
+
+#ifndef __GMIME_PARSER_OPTIONS_H__
+#define __GMIME_PARSER_OPTIONS_H__
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+/**
+ * GMimeRfcComplianceMode:
+ * @GMIME_RFC_COMPLIANCE_LOOSE: Attempt to be much more liberal accepting broken and/or invalid formatting.
+ * @GMIME_RFC_COMPLIANCE_STRICT: Do not attempt to be overly liberal in accepting broken and/or invalid 
formatting.
+ *
+ * An RFC compliance mode.
+ **/
+typedef enum {
+       GMIME_RFC_COMPLIANCE_LOOSE,
+       GMIME_RFC_COMPLIANCE_STRICT
+} GMimeRfcComplianceMode;
+
+/**
+ * GMimeParserOptions:
+ * @addresses: The compliance mode that should be used when parsing rfc822 addresses.
+ * @parameters: The compliance mode that should be used when parsing Content-Type and Content-Disposition 
parameters.
+ * @rfc2047: The compliance mode that should be used when decoding rfc2047 encoded words.
+ * @charsets: The fallback charsets to try when decoding 8-bit headers.
+ *
+ * A set of parser options used by #GMimeParser and various other parsing functions.
+ **/
+typedef struct {
+       GMimeRfcComplianceMode addresses;
+       GMimeRfcComplianceMode parameters;
+       GMimeRfcComplianceMode rfc2047;
+       char **charsets;
+} GMimeParserOptions;
+
+GMimeParserOptions *g_mime_parser_options_new (void);
+void g_mime_parser_options_free (GMimeParserOptions *options);
+
+GMimeRfcComplianceMode g_mime_parser_options_get_address_parser_compliance_mode (GMimeParserOptions 
*options);
+void g_mime_parser_options_set_address_parser_compliance_mode (GMimeParserOptions *options, 
GMimeRfcComplianceMode mode);
+
+GMimeRfcComplianceMode g_mime_parser_options_get_parameter_compliance_mode (GMimeParserOptions *options);
+void g_mime_parser_options_set_parameter_compliance_mode (GMimeParserOptions *options, 
GMimeRfcComplianceMode mode);
+
+GMimeRfcComplianceMode g_mime_parser_options_get_rfc2047_compliance_mode (GMimeParserOptions *options);
+void g_mime_parser_options_set_rfc2047_compliance_mode (GMimeParserOptions *options, GMimeRfcComplianceMode 
mode);
+
+const char **g_mime_parser_options_get_fallback_charsets (GMimeParserOptions *options);
+void g_mime_parser_options_set_fallback_charsets (GMimeParserOptions *options, const char **charsets);
+
+G_END_DECLS
+
+#endif /* __GMIME_PARSER_OPTIONS_H__ */
diff --git a/gmime/gmime-parser.c b/gmime/gmime-parser.c
index 4755331..daaeb4f 100644
--- a/gmime/gmime-parser.c
+++ b/gmime/gmime-parser.c
@@ -83,6 +83,8 @@ typedef struct _content_type {
        gboolean exists;
 } ContentType;
 
+extern GMimeParserOptions g_mime_parser_options_default;
+
 extern void _g_mime_object_append_header (GMimeObject *object, const char *header, const char *value, const 
char *raw_value, gint64 offset);
 extern void _g_mime_object_set_content_type (GMimeObject *object, GMimeContentType *content_type);
 
@@ -93,9 +95,9 @@ static void g_mime_parser_finalize (GObject *object);
 static void parser_init (GMimeParser *parser, GMimeStream *stream);
 static void parser_close (GMimeParser *parser);
 
-static GMimeObject *parser_construct_leaf_part (GMimeParser *parser, ContentType *content_type,
+static GMimeObject *parser_construct_leaf_part (GMimeParser *parser, GMimeParserOptions *options, 
ContentType *content_type,
                                                gboolean toplevel, int *found);
-static GMimeObject *parser_construct_multipart (GMimeParser *parser, ContentType *content_type,
+static GMimeObject *parser_construct_multipart (GMimeParser *parser, GMimeParserOptions *options, 
ContentType *content_type,
                                                gboolean toplevel, int *found);
 
 static GObjectClass *parent_class = NULL;
@@ -1577,7 +1579,7 @@ parser_scan_mime_part_content (GMimeParser *parser, GMimePart *mime_part, int *f
 }
 
 static void
-parser_scan_message_part (GMimeParser *parser, GMimeMessagePart *mpart, int *found)
+parser_scan_message_part (GMimeParser *parser, GMimeParserOptions *options, GMimeMessagePart *mpart, int 
*found)
 {
        struct _GMimeParserPrivate *priv = parser->priv;
        ContentType *content_type;
@@ -1641,9 +1643,9 @@ parser_scan_message_part (GMimeParser *parser, GMimeMessagePart *mpart, int *fou
        
        content_type = parser_content_type (parser, NULL);
        if (content_type_is_type (content_type, "multipart", "*"))
-               object = parser_construct_multipart (parser, content_type, TRUE, found);
+               object = parser_construct_multipart (parser, options, content_type, TRUE, found);
        else
-               object = parser_construct_leaf_part (parser, content_type, TRUE, found);
+               object = parser_construct_leaf_part (parser, options, content_type, TRUE, found);
        
        content_type_destroy (content_type);
        message->mime_part = object;
@@ -1653,7 +1655,7 @@ parser_scan_message_part (GMimeParser *parser, GMimeMessagePart *mpart, int *fou
 }
 
 static GMimeObject *
-parser_construct_leaf_part (GMimeParser *parser, ContentType *content_type, gboolean toplevel, int *found)
+parser_construct_leaf_part (GMimeParser *parser, GMimeParserOptions *options, ContentType *content_type, 
gboolean toplevel, int *found)
 {
        struct _GMimeParserPrivate *priv = parser->priv;
        GMimeObject *object;
@@ -1689,7 +1691,7 @@ parser_construct_leaf_part (GMimeParser *parser, ContentType *content_type, gboo
        }
        
        if (GMIME_IS_MESSAGE_PART (object))
-               parser_scan_message_part (parser, (GMimeMessagePart *) object, found);
+               parser_scan_message_part (parser, options, (GMimeMessagePart *) object, found);
        else
                parser_scan_mime_part_content (parser, (GMimePart *) object, found);
        
@@ -1754,7 +1756,7 @@ parser_scan_multipart_face (GMimeParser *parser, GMimeMultipart *multipart, gboo
 #define parser_scan_multipart_postface(parser, multipart) parser_scan_multipart_face (parser, multipart, 
FALSE)
 
 static int
-parser_scan_multipart_subparts (GMimeParser *parser, GMimeMultipart *multipart)
+parser_scan_multipart_subparts (GMimeParser *parser, GMimeParserOptions *options, GMimeMultipart *multipart)
 {
        struct _GMimeParserPrivate *priv = parser->priv;
        ContentType *content_type;
@@ -1782,9 +1784,9 @@ parser_scan_multipart_subparts (GMimeParser *parser, GMimeMultipart *multipart)
                
                content_type = parser_content_type (parser, ((GMimeObject *) multipart)->content_type);
                if (content_type_is_type (content_type, "multipart", "*"))
-                       subpart = parser_construct_multipart (parser, content_type, FALSE, &found);
+                       subpart = parser_construct_multipart (parser, options, content_type, FALSE, &found);
                else
-                       subpart = parser_construct_leaf_part (parser, content_type, FALSE, &found);
+                       subpart = parser_construct_leaf_part (parser, options, content_type, FALSE, &found);
                
                g_mime_multipart_add (multipart, subpart);
                content_type_destroy (content_type);
@@ -1795,7 +1797,7 @@ parser_scan_multipart_subparts (GMimeParser *parser, GMimeMultipart *multipart)
 }
 
 static GMimeObject *
-parser_construct_multipart (GMimeParser *parser, ContentType *content_type, gboolean toplevel, int *found)
+parser_construct_multipart (GMimeParser *parser, GMimeParserOptions *options, ContentType *content_type, 
gboolean toplevel, int *found)
 {
        struct _GMimeParserPrivate *priv = parser->priv;
        GMimeMultipart *multipart;
@@ -1834,7 +1836,7 @@ parser_construct_multipart (GMimeParser *parser, ContentType *content_type, gboo
                *found = parser_scan_multipart_preface (parser, multipart);
                
                if (*found == FOUND_BOUNDARY)
-                       *found = parser_scan_multipart_subparts (parser, multipart);
+                       *found = parser_scan_multipart_subparts (parser, options, multipart);
                
                if (*found == FOUND_END_BOUNDARY && found_immediate_boundary (priv, TRUE)) {
                        /* eat end boundary */
@@ -1856,7 +1858,7 @@ parser_construct_multipart (GMimeParser *parser, ContentType *content_type, gboo
 }
 
 static GMimeObject *
-parser_construct_part (GMimeParser *parser)
+parser_construct_part (GMimeParser *parser, GMimeParserOptions *options)
 {
        struct _GMimeParserPrivate *priv = parser->priv;
        ContentType *content_type;
@@ -1872,9 +1874,9 @@ parser_construct_part (GMimeParser *parser)
        
        content_type = parser_content_type (parser, NULL);
        if (content_type_is_type (content_type, "multipart", "*"))
-               object = parser_construct_multipart (parser, content_type, FALSE, &found);
+               object = parser_construct_multipart (parser, options, content_type, FALSE, &found);
        else
-               object = parser_construct_leaf_part (parser, content_type, FALSE, &found);
+               object = parser_construct_leaf_part (parser, options, content_type, FALSE, &found);
        
        content_type_destroy (content_type);
        
@@ -1896,12 +1898,32 @@ g_mime_parser_construct_part (GMimeParser *parser)
 {
        g_return_val_if_fail (GMIME_IS_PARSER (parser), NULL);
        
-       return parser_construct_part (parser);
+       return parser_construct_part (parser, &g_mime_parser_options_default);
+}
+
+
+/**
+ * g_mime_parser_construct_part_with_options:
+ * @parser: a #GMimeParser context
+ * @options: a #GMimeParserOptions
+ *
+ * Constructs a MIME part from @parser.
+ *
+ * Returns: (transfer full): a MIME part based on @parser or %NULL on
+ * fail.
+ **/
+GMimeObject *
+g_mime_parser_construct_part_with_options (GMimeParser *parser, GMimeParserOptions *options)
+{
+       g_return_val_if_fail (GMIME_IS_PARSER (parser), NULL);
+       g_return_val_if_fail (options != NULL, NULL);
+       
+       return parser_construct_part (parser, options);
 }
 
 
 static GMimeMessage *
-parser_construct_message (GMimeParser *parser)
+parser_construct_message (GMimeParser *parser, GMimeParserOptions *options)
 {
        struct _GMimeParserPrivate *priv = parser->priv;
        unsigned long content_length = ULONG_MAX;
@@ -1947,9 +1969,9 @@ parser_construct_message (GMimeParser *parser)
        
        content_type = parser_content_type (parser, NULL);
        if (content_type_is_type (content_type, "multipart", "*"))
-               object = parser_construct_multipart (parser, content_type, TRUE, &found);
+               object = parser_construct_multipart (parser, options, content_type, TRUE, &found);
        else
-               object = parser_construct_leaf_part (parser, content_type, TRUE, &found);
+               object = parser_construct_leaf_part (parser, options, content_type, TRUE, &found);
        
        content_type_destroy (content_type);
        message->mime_part = object;
@@ -1976,7 +1998,25 @@ g_mime_parser_construct_message (GMimeParser *parser)
 {
        g_return_val_if_fail (GMIME_IS_PARSER (parser), NULL);
        
-       return parser_construct_message (parser);
+       return parser_construct_message (parser, &g_mime_parser_options_default);
+}
+
+
+/**
+ * g_mime_parser_construct_message:
+ * @parser: a #GMimeParser context
+ *
+ * Constructs a MIME message from @parser.
+ *
+ * Returns: (transfer full): a MIME message or %NULL on fail.
+ **/
+GMimeMessage *
+g_mime_parser_construct_message_with_options (GMimeParser *parser, GMimeParserOptions *options)
+{
+       g_return_val_if_fail (GMIME_IS_PARSER (parser), NULL);
+       g_return_val_if_fail (options != NULL, NULL);
+       
+       return parser_construct_message (parser, options);
 }
 
 
diff --git a/gmime/gmime-parser.h b/gmime/gmime-parser.h
index 997fad6..2e135c3 100644
--- a/gmime/gmime-parser.h
+++ b/gmime/gmime-parser.h
@@ -29,6 +29,7 @@
 #include <gmime/gmime-object.h>
 #include <gmime/gmime-message.h>
 #include <gmime/gmime-content-type.h>
+#include <gmime/gmime-parser-options.h>
 #include <gmime/gmime-stream.h>
 
 G_BEGIN_DECLS
@@ -100,8 +101,10 @@ void g_mime_parser_set_header_regex (GMimeParser *parser, const char *regex,
                                     gpointer user_data);
 
 GMimeObject *g_mime_parser_construct_part (GMimeParser *parser);
+GMimeObject *g_mime_parser_construct_part_with_options (GMimeParser *parser, GMimeParserOptions *options);
 
 GMimeMessage *g_mime_parser_construct_message (GMimeParser *parser);
+GMimeMessage *g_mime_parser_construct_message_with_options (GMimeParser *parser, GMimeParserOptions 
*options);
 
 gint64 g_mime_parser_tell (GMimeParser *parser);
 
diff --git a/gmime/gmime.h b/gmime/gmime.h
index dc3157f..8b26e30 100644
--- a/gmime/gmime.h
+++ b/gmime/gmime.h
@@ -43,6 +43,7 @@
 #include <gmime/gmime-message-partial.h>
 #include <gmime/internet-address.h>
 #include <gmime/gmime-encodings.h>
+#include <gmime/gmime-parser-options.h>
 #include <gmime/gmime-parser.h>
 #include <gmime/gmime-utils.h>
 #include <gmime/gmime-stream.h>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]