<commit_before> 
/*--------------------------------*-C-*---------------------------------*
 *
 * Author :
 *  <NAME> <<EMAIL>>
 *
 *  Copyright 2000, Helix Code, Inc. (http://www.helixcode.com) .
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program 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 General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
 *
 *----------------------------------------------------------------------*/

#include <config.h>
#include "camel-formatter.h"

#include "camel-log.h"
#include <libgnome/libgnome.h>
#include <ctype.h> // for isprint
#include <string.h> // for strstr

/*
 * The CamelFormatter takes a mime message, and produces html from it,
 * through the single function camel_formatter_mime_message_to_html().
 * The flow of execution goes something like this:
 *
 *     camel_formatter_mime_message_to_html()
 *                 |
 *                 V
 *         handle_mime_message()
 *                 |
 *                 V
 *        call_handler_function()
 *
 * Then, 'call_handler_function' acts as a dispatcher, using a
 * hashtable to match a mime type to one of the following functions;
 * note that the below functions sometimes then use
 * 'call_handler_function()' to continue the process recursively.
 */

static void handle_text_plain         (CamelFormatter *formatter,
			               CamelDataWrapper *wrapper);
static void handle_text_html          (CamelFormatter *formatter,
			               CamelDataWrapper *wrapper);
static void handle_image              (CamelFormatter *formatter,
				       CamelDataWrapper *wrapper);
static void handle_vcard              (CamelFormatter *formatter,
				       CamelDataWrapper *wrapper);
static void handle_mime_message       (CamelFormatter *formatter,
			               CamelDataWrapper *wrapper);
static void handle_multipart_mixed    (CamelFormatter *formatter,
				       CamelDataWrapper *wrapper);
static void handle_multipart_related  (CamelFormatter *formatter,
				       CamelDataWrapper *wrapper);
static void handle_multipart_alternate(CamelFormatter *formatter,
				       CamelDataWrapper *wrapper);
static void handle_unknown_type       (CamelFormatter *formatter,
				       CamelDataWrapper *wrapper);

/* encodes some characters into their 'escaped' version;
 * so '<' turns into '&lt;', and '"' turns into '&quot;' */
static gchar* text_to_html (const guchar *input,
			       guint len,
			       guint *encoded_len_return);

/* compares strings case-insensitively */
static gint strcase_equal (gconstpointer v, gconstpointer v2);

/* writes the header info for a mime message into a stream */
static void write_header_info_to_stream (CamelMimeMessage* mime_message,
					 CamelStream* stream);

static GtkObjectClass *parent_class = NULL;

struct _CamelFormatterPrivate {
	CamelMimeMessage *current_root;<commit_msg>+	* tests/test-formatter.c (convert_to_html_and_print): Fixed call +	to 'camel_formatter_mime_message_to_html' to contain correct +	params.<commit_after> 
/*--------------------------------*-C-*---------------------------------*
 *
 * Author :
 *  <NAME> <<EMAIL>>
 *
 *  Copyright 2000, Helix Code, Inc. (http://www.helixcode.com) .
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program 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 General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
 *
 *----------------------------------------------------------------------*/

#include <config.h>
#include "camel-formatter.h"

#include "camel-log.h"
#include <libgnome/libgnome.h>
#include <ctype.h> // for isprint
#include <string.h> // for strstr

/*
 * The CamelFormatter takes a mime message, and produces html from it,
 * through the single function camel_formatter_mime_message_to_html().
 * The flow of execution goes something like this:
 *
 *     camel_formatter_mime_message_to_html()
 *                 |
 *                 V
 *         handle_mime_message()
 *                 |
 *                 V
 *        call_handler_function()
 *
 * Then, 'call_handler_function' acts as a dispatcher, using a
 * hashtable to match a mime type to one of the following functions;
 * note that the below functions sometimes then use
 * 'call_handler_function()' to continue the process recursively.
 */

static void handle_text_plain         (CamelFormatter *formatter,
			               CamelDataWrapper *wrapper);
static void handle_text_html          (CamelFormatter *formatter,
			               CamelDataWrapper *wrapper);
static void handle_image              (CamelFormatter *formatter,
				       CamelDataWrapper *wrapper);
static void handle_vcard              (CamelFormatter *formatter,
				       CamelDataWrapper *wrapper);
static void handle_mime_message       (CamelFormatter *formatter,
			               CamelDataWrapper *wrapper);
static void handle_multipart_mixed    (CamelFormatter *formatter,
				       CamelDataWrapper *wrapper);
static void handle_multipart_related  (CamelFormatter *formatter,
				       CamelDataWrapper *wrapper);
static void handle_multipart_alternate(CamelFormatter *formatter,
				       CamelDataWrapper *wrapper);
static void handle_unknown_type       (CamelFormatter *formatter,
				       CamelDataWrapper *wrapper);

/* encodes some characters into their 'escaped' version;
 * so '<' turns into '&lt;', and '"' turns into '&quot;' */
static gchar* text_to_html (const guchar *input,
			    guint len,
			    guint *encoded_len_return);

/* compares strings case-insensitively */
static gint strcase_equal (gconstpointer v, gconstpointer v2);

/* writes the header info for a mime message into a stream */
static void write_header_info_to_stream (CamelMimeMessage* mime_message,
					 CamelStream* stream);

static GtkObjectClass *parent_class = NULL;

struct _CamelFormatterPrivate {
	CamelMimeMessage *current_root;
{'fraction_non_alphanumeric': 0.11519607843137254, 'fraction_numerical': 0.0057670126874279125, 'mean_word_length': 2.7948577680525166, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '625221', 'n_tokens_mistral': 1998, 'n_tokens_neox': 1822, 'n_words': 659}