From 44575d972d94ce00b0e7c5d46bbb59761d5c840d Mon Sep 17 00:00:00 2001 From: Michael Zucci Date: Tue, 2 May 2000 20:37:06 +0000 Subject: > * gmime-utils.[ch]: What the hell, remove it. This will break the > nntp provider (but its broken anyway). The mime parser can be > used instead though. > Removed from all code including it (but none were using it). > > * gmime-utils.c (_store_header_pair_from_string): Removed bizarre > string_dichotomy version of this. This code is somewhat redundant > now, and is headed for death anyway. > > * gstring-util.c (g_string_dichotomy): Same with this one. > (g_string_clone): Removed a memory leak, g_string_new() allocates > its own memory. > (g_string_append_g_string): Allow to append an empty gstring onto > another gstring, dont abort()! > > * string-utils.c (string_dichotomy): Removed this incredibly weird > function. > > * camel-folder.c (_create): Replaced the rather obtuse use of > "string_dichotomy" function with a simple strrchr(). Still not > sure it'll work. > > * camel-folder-summary.c: cvs removed a long-removed file. svn path=/trunk/; revision=2753 --- camel/ChangeLog | 23 +++ camel/Makefile.am | 2 - camel/camel-folder-summary.c | 177 --------------------- camel/camel-folder.c | 37 ++--- camel/camel-medium.c | 1 - camel/camel-mime-message.c | 1 - camel/camel-mime-part-utils.c | 5 +- camel/camel-mime-part.c | 1 - camel/camel-multipart.c | 1 - camel/gmime-utils.c | 257 ------------------------------- camel/gmime-utils.h | 70 --------- camel/gstring-util.c | 119 +------------- camel/gstring-util.h | 11 -- camel/providers/mbox/camel-mbox-folder.c | 1 - camel/string-utils.c | 107 ------------- camel/string-utils.h | 14 -- 16 files changed, 41 insertions(+), 786 deletions(-) delete mode 100644 camel/camel-folder-summary.c delete mode 100644 camel/gmime-utils.c delete mode 100644 camel/gmime-utils.h diff --git a/camel/ChangeLog b/camel/ChangeLog index 8f0281b0e2..cedc8e4b9d 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,5 +1,28 @@ 2000-05-02 NotZed + * gmime-utils.[ch]: What the hell, remove it. This will break the + nntp provider. The mime parser can be used instead though. + Removed from all code including it (but none were using it). + + * gmime-utils.c (_store_header_pair_from_string): Removed bizarre + string_dichotomy version of this. This code is somewhat redundant + now, and is headed for death anyway. + + * gstring-util.c (g_string_dichotomy): Same with this one. + (g_string_clone): Removed a memory leak, g_string_new() allocates + its own memory. + (g_string_append_g_string): Allow to append an empty gstring onto + another gstring, dont abort()! + + * string-utils.c (string_dichotomy): Removed this incredibly weird + function. + + * camel-folder.c (_create): Replaced the rather obtuse use of + "string_dichotomy" function with a simple strrchr(). Still not + sure it'll work. + + * camel-folder-summary.c: cvs removed a long-removed file. + * camel-mime-parser.c (folder_scan_header): Fix the previous overflow problem properly (can happen in 2 places). (header_append): A new macro to include the code changed above, so diff --git a/camel/Makefile.am b/camel/Makefile.am index 288eb72023..a53e3fd564 100644 --- a/camel/Makefile.am +++ b/camel/Makefile.am @@ -57,7 +57,6 @@ libcamel_la_SOURCES = \ camel-transport.c \ camel-url.c \ gmime-content-field.c \ - gmime-utils.c \ gstring-util.c \ hash-table-utils.c \ md5-utils.c \ @@ -100,7 +99,6 @@ libcamelinclude_HEADERS = \ camel-transport.h \ camel-url.h \ gmime-content-field.h \ - gmime-utils.h \ gstring-util.h \ hash-table-utils.h \ md5-utils.h \ diff --git a/camel/camel-folder-summary.c b/camel/camel-folder-summary.c deleted file mode 100644 index a04b12a51d..0000000000 --- a/camel/camel-folder-summary.c +++ /dev/null @@ -1,177 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camelFolderSummary.c : Abstract class for a folder_summary */ - - -/* - * - * Author : - * Bertrand Guiheneuf - * - * Copyright 1999, 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 Place, Suite 330, Boston, MA 02111-1307 - * USA - */ -#include -#include "camel-folder-summary.h" - -static GtkObjectClass *parent_class = NULL; - -/* Returns the class for a CamelFolderSummary */ -#define CFS_CLASS(so) CAMEL_FOLDER_SUMMARY_CLASS (GTK_OBJECT(so)->klass) - - -static int count_messages (CamelFolderSummary *summary); -static int count_subfolders (CamelFolderSummary *summary); -static GPtrArray *get_subfolder_info (CamelFolderSummary *summary, - int first, int count); -static GPtrArray *get_message_info (CamelFolderSummary *summary, - int first, int count); - -static void -camel_folder_summary_class_init (CamelFolderSummaryClass *camel_folder_summary_class) -{ - parent_class = gtk_type_class (gtk_object_get_type ()); - - /* virtual method definition */ - camel_folder_summary_class->count_messages = count_messages; - camel_folder_summary_class->count_subfolders = count_subfolders; - camel_folder_summary_class->get_subfolder_info = get_subfolder_info; - camel_folder_summary_class->get_message_info = get_message_info; -} - - - -GtkType -camel_folder_summary_get_type (void) -{ - static GtkType camel_folder_summary_type = 0; - - if (!camel_folder_summary_type) { - GtkTypeInfo camel_folder_summary_info = - { - "CamelFolderSummary", - sizeof (CamelFolderSummary), - sizeof (CamelFolderSummaryClass), - (GtkClassInitFunc) camel_folder_summary_class_init, - (GtkObjectInitFunc) NULL, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_folder_summary_type = gtk_type_unique (gtk_object_get_type (), &camel_folder_summary_info); - } - - return camel_folder_summary_type; -} - - -static int -count_messages (CamelFolderSummary *summary) -{ - g_warning ("CamelFolderSummary::count_messages not implemented for `%s'", gtk_type_name (GTK_OBJECT_TYPE (summary))); - return 0; -} - -/** - * camel_folder_summary_count_messages: return the number of messages - * in the folder. - * @summary: the summary - * - * Return value: the number of messages in the folder. - **/ -int -camel_folder_summary_count_messages (CamelFolderSummary *summary) -{ - return CFS_CLASS (summary)->count_messages (summary); -} - - -static int -count_subfolders (CamelFolderSummary *summary) -{ - g_warning ("CamelFolderSummary::count_subfolders not implemented for `%s'", gtk_type_name (GTK_OBJECT_TYPE (summary))); - return 0; -} - -/** - * camel_folder_summary_count_subfolders: return the number of subfolders - * in the folder. - * @summary: the summary - * - * Return value: the number of subfolders in the folder. - **/ -int -camel_folder_summary_count_subfolders (CamelFolderSummary *summary) -{ - return CFS_CLASS (summary)->count_subfolders (summary); -} - - -static GPtrArray * -get_subfolder_info (CamelFolderSummary *summary, int first, int count) -{ - g_warning ("CamelFolderSummary::get_subfolder_info not implemented for `%s'", gtk_type_name (GTK_OBJECT_TYPE (summary))); - return NULL; -} - -/** - * camel_folder_summary_get_subfolder_info: return an array of subfolders - * @summary: a summary - * @first: the index of the first subfolder to return information for - * (starting from 0) - * @count: the number of subfolders to return information for - * - * Returns an array of pointers to CamelFolderInfo objects. The caller - * must free the array when it is done with it, but should not modify - * the elements. - * - * Return value: an array containing information about the subfolders. - **/ -GPtrArray * -camel_folder_summary_get_subfolder_info (CamelFolderSummary *summary, - int first, int count) -{ - return CFS_CLASS (summary)->get_subfolder_info (summary, first, count); -} - - -static GPtrArray * -get_message_info (CamelFolderSummary *summary, int first, int count) -{ - g_warning ("CamelFolderSummary::get_message_info not implemented for `%s'", gtk_type_name (GTK_OBJECT_TYPE (summary))); - return NULL; -} - -/** - * camel_folder_summary_get_message_info: return an array of messages - * @summary: a summary - * @first: the index of the first message to return information for - * (starting from 0) - * @count: the number of messages to return information for - * - * Returns an array of pointers to CamelMessageInfo objects. The caller - * must free the array when it is done with it, but should not modify - * the elements. - * - * Return value: an array containing information about the messages. - **/ -GPtrArray * -camel_folder_summary_get_message_info (CamelFolderSummary *summary, - int first, int count) -{ - return CFS_CLASS (summary)->get_message_info (summary, first, count); -} diff --git a/camel/camel-folder.c b/camel/camel-folder.c index c979c3278b..6455fbf77b 100644 --- a/camel/camel-folder.c +++ b/camel/camel-folder.c @@ -679,40 +679,29 @@ camel_folder_get_subfolder (CamelFolder *folder, gchar *folder_name, CamelExcept static gboolean _create (CamelFolder *folder, CamelException *ex) { - gchar *prefix; - gchar dich_result; CamelFolder *parent; g_assert (folder->parent_store != NULL); g_assert (folder->name != NULL); - /* if the folder already exists on the - store, do nothing and return true */ + /* if the folder already exists on the store, do nothing and return true */ if (CF_CLASS (folder)->exists (folder, ex)) return TRUE; - if (folder->parent_folder) { camel_folder_create (folder->parent_folder, ex); - if (camel_exception_get_id (ex)) return FALSE; - } - else { - if (folder->full_name) { - dich_result = string_dichotomy ( - folder->full_name, - folder->separator, - &prefix, NULL, - STRING_DICHOTOMY_STRIP_TRAILING | STRING_DICHOTOMY_RIGHT_DIR); - if (dich_result!='o') { - if (prefix == NULL) { - /* separator is the first caracter, no folder above */ - return TRUE; - } - } else { - parent = camel_store_get_folder (folder->parent_store, prefix, ex); - camel_folder_create (parent, ex); - if (camel_exception_get_id (ex)) return FALSE; - } + if (camel_exception_get_id (ex)) + return FALSE; + } else if (folder->full_name) { + char *slash, *prefix; + + slash = strrchr(folder->full_name, folder->separator); + if (slash && slash != folder->full_name) { + prefix = g_strndup(folder->full_name, slash-folder->full_name); + parent = camel_store_get_folder (folder->parent_store, prefix, ex); + camel_folder_create (parent, ex); + if (camel_exception_get_id (ex)) + return FALSE; } } return TRUE; diff --git a/camel/camel-medium.c b/camel/camel-medium.c index 7a2ed1a6c8..68463eca40 100644 --- a/camel/camel-medium.c +++ b/camel/camel-medium.c @@ -28,7 +28,6 @@ #include "camel-medium.h" #include "gmime-content-field.h" #include "string-utils.h" -#include "gmime-utils.h" #include "hash-table-utils.h" #define d(x) diff --git a/camel/camel-mime-message.c b/camel/camel-mime-message.c index c1cf13403a..db42a3e599 100644 --- a/camel/camel-mime-message.c +++ b/camel/camel-mime-message.c @@ -28,7 +28,6 @@ #include #include "gmime-content-field.h" #include "string-utils.h" -#include "gmime-utils.h" #include "hash-table-utils.h" #define d(x) diff --git a/camel/camel-mime-part-utils.c b/camel/camel-mime-part-utils.c index 972081cb65..adbc62d305 100644 --- a/camel/camel-mime-part-utils.c +++ b/camel/camel-mime-part-utils.c @@ -25,7 +25,6 @@ #include #include "gmime-content-field.h" #include "string-utils.h" -#include "gmime-utils.h" #include "camel-mime-part-utils.h" #include "camel-mime-message.h" #include "camel-multipart.h" @@ -44,12 +43,12 @@ simple_data_wrapper_construct_from_parser(CamelDataWrapper *dw, CamelMimeParser GByteArray *buffer; char *buf; int len; - off_t start, end; + off_t start, end; /* ignore the start may be used unitialised warning */ CamelMimeFilter *fdec = NULL, *fch = NULL; struct _header_content_type *ct; int decid=-1, chrid=-1, cache=TRUE; CamelStream *source; - CamelSeekableStream *seekable_source; + CamelSeekableStream *seekable_source; /* and ignore the warning about this one too. */ char *encoding; d(printf("constructing data-wrapper\n")); diff --git a/camel/camel-mime-part.c b/camel/camel-mime-part.c index 1d885991b8..e2a6a731f9 100644 --- a/camel/camel-mime-part.c +++ b/camel/camel-mime-part.c @@ -29,7 +29,6 @@ #include #include "gmime-content-field.h" #include "string-utils.h" -#include "gmime-utils.h" #include "hash-table-utils.h" #include "camel-mime-part-utils.h" #include diff --git a/camel/camel-multipart.c b/camel/camel-multipart.c index 797d7b20e8..c0f50eb331 100644 --- a/camel/camel-multipart.c +++ b/camel/camel-multipart.c @@ -28,7 +28,6 @@ #include #include "gmime-content-field.h" -#include "gmime-utils.h" #include "camel-stream-mem.h" #include "camel-multipart.h" #include "camel-mime-part.h" diff --git a/camel/gmime-utils.c b/camel/gmime-utils.c deleted file mode 100644 index 19292d8918..0000000000 --- a/camel/gmime-utils.c +++ /dev/null @@ -1,257 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* mime-utils.c : misc utilities for mime */ - -/* - * - * Author : - * Bertrand Guiheneuf - * - * Copyright 1999, 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 Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#include -#include -#include "gmime-utils.h" -#include "string-utils.h" -#include "camel-stream.h" - -void -gmime_write_header_pair_to_stream (CamelStream *stream, const gchar* name, const gchar *value) -{ - - gchar *strtmp; - - g_assert(name); - - if (!value) return; - strtmp = g_strdup_printf ("%s: %s\n", name, value); - - camel_stream_write_string (stream, strtmp); - - g_free (strtmp); -} - - -static void -_write_one_header_to_stream (gpointer key, gpointer value, gpointer user_data) -{ - gchar *header_name = (gchar *)key; - gchar *header_value = (gchar *)value; - CamelStream *stream = (CamelStream *)user_data; - - if ((header_name) && (header_value)) - gmime_write_header_pair_to_stream (stream, header_name, header_value); -} - -void -gmime_write_header_table_to_stream (CamelStream *stream, GHashTable *header_table) -{ - g_hash_table_foreach (header_table, - _write_one_header_to_stream, - (gpointer)stream); -} - - -void -gmime_write_header_with_glist_to_stream (CamelStream *stream, - const gchar *header_name, - GList *header_values, - const gchar *separator) -{ - - gchar *current; - - if ( (header_name) && (header_values) ) - { - gboolean first; - - camel_stream_write (stream, header_name, strlen (header_name) ); - camel_stream_write (stream, ": ", 2); - first = TRUE; - while (header_values) { - current = (gchar *)header_values->data; - if (current) { - if (!first) camel_stream_write_string (stream, separator); - else first = FALSE; - camel_stream_write (stream, current, strlen (current)); - } - header_values = g_list_next (header_values); - } - camel_stream_write (stream, "\n", 1); - } -} - - - - - -/* * * * * * * * * * * */ -/* scanning functions */ - -static void -_store_header_pair_from_string (GArray *header_array, gchar *header_line) -{ - Rfc822Header header; - - g_assert (header_array); - g_return_if_fail (header_line); - - - if (header_line) { - char *p = strchr(header_line, ':'); - if (p) { - header.name = g_strndup(header_line, p-header_line); - header.value = g_strdup(p+1); - string_trim (header.value, " \t", - STRING_TRIM_STRIP_LEADING | STRING_TRIM_STRIP_TRAILING); - g_array_append_val (header_array, header); - } - } -} - - - -/* - this is a blocking version of the - header parsing. Need to change when - fs streams are non blocking -*/ -GArray * -get_header_array_from_stream (CamelStream *stream) -{ -#warning Correct Lazy Implementation - /* should not use GString. */ - /* should read the header line by line */ - /* and not char by char */ - gchar next_char; - gint nb_char_read; - - gboolean crlf = FALSE; - gboolean end_of_header_line = FALSE; - gboolean end_of_headers = FALSE; - gboolean end_of_file = FALSE; - - GString *header_line=NULL; - GArray *header_array; - - - header_array = g_array_new (FALSE, FALSE, sizeof (Rfc822Header)); - - nb_char_read = camel_stream_read (stream, &next_char, 1); - do { - header_line = g_string_new (""); - end_of_header_line = FALSE; - crlf = FALSE; - - /* read a whole header line */ - do { - if (nb_char_read>0) { - switch (next_char) { - - case '\r': - case '\n': /* a blank line means end of headers */ - if (crlf) { - end_of_headers=TRUE; - end_of_header_line = TRUE; - } - else crlf = TRUE; - break; - case ' ': - case '\t': - if (crlf) { - crlf = FALSE; - next_char = ' '; - } - - default: - if (!crlf) header_line = g_string_append_c (header_line, next_char); - else end_of_header_line = TRUE; - - } - } else { - - if (camel_stream_eos (stream)) { - - end_of_file=TRUE; - end_of_header_line = TRUE; - - } - } - - /* if we have read a whole header line, we have also read - the first character of the next line to be sure the - crlf was not followed by a space or a tab char */ - if (!end_of_header_line) nb_char_read = camel_stream_read (stream, &next_char, 1); - - } while ( !end_of_header_line ); - if ( strlen(header_line->str) ) { - /* str_header_line = g_strdup (header_line->str); */ - /*printf("got header line: %s\n", header_line->str);*/ - _store_header_pair_from_string (header_array, header_line->str); - } - g_string_free (header_line, TRUE); - - } while ( (!end_of_headers) && (!end_of_file) ); - - return header_array; -} - - - -gchar * -gmime_read_line_from_stream (CamelStream *stream) -{ - GString *new_line; - gchar *result; - gchar next_char; - gboolean end_of_line = FALSE; - gboolean end_of_stream = FALSE; - gint nb_char_read; - - new_line = g_string_new (""); - do { - nb_char_read = camel_stream_read (stream, &next_char, 1); - - if (nb_char_read>0) { - - switch (next_char) { - case '\n': - end_of_line = TRUE; - /* g_string_append_c (new_line, next_char); */ - break; - default: - g_string_append_c (new_line, next_char); - - } - } else { - - if (camel_stream_eos (stream)) - end_of_stream = TRUE; - - } - } while (!end_of_line && !end_of_stream); - - - if (!end_of_stream) - result = g_strdup (new_line->str); - else result=NULL; - - g_string_free (new_line, TRUE); - - return result; -} diff --git a/camel/gmime-utils.h b/camel/gmime-utils.h deleted file mode 100644 index 99f240bebc..0000000000 --- a/camel/gmime-utils.h +++ /dev/null @@ -1,70 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* mime-utils.h : misc utilities for mime */ - -/* - * - * Author : - * Bertrand Guiheneuf - * - * Copyright 1999, 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 Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -#ifndef GMIME_UTILS_H -#define GMIME_UTILS_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include -#include -#include - -typedef struct -{ - gchar *name; - gchar *value; - -} Rfc822Header; - - -void gmime_write_header_pair_to_stream (CamelStream *stream, - const gchar* name, - const gchar *value); - -void gmime_write_header_table_to_stream (CamelStream *stream, - GHashTable *header_table); - -void gmime_write_header_with_glist_to_stream (CamelStream *stream, - const gchar *header_name, - GList *header_values, - const gchar *separator); - -GArray *get_header_array_from_stream (CamelStream *stream); -gchar *gmime_read_line_from_stream (CamelStream *stream); - - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* GMIME_UTILS_H */ diff --git a/camel/gstring-util.c b/camel/gstring-util.c index ebfd569e8e..a0c1345b71 100644 --- a/camel/gstring-util.c +++ b/camel/gstring-util.c @@ -59,120 +59,9 @@ g_string_equals (GString *string1, GString *string2) GString * g_string_clone (GString *string) { - return g_string_new (g_strdup (string->str) ); + return g_string_new (string->str); } - - - -/** - * g_string_dichotomy: - * @sep : separator - * @prefix: pointer to be field by the prefix object - * the prefix is not returned when the given pointer is NULL - * @suffix: pointer to be field by the suffix object - * the suffix is not returned when the given pointer is NULL - * - * Return the strings before and/or after - * the last occurence of the specified separator - * - * This routine returns the string before and/or after - * a character given as an argument. - * if the separator is the last character, prefix and/or - * suffix is set to NULL and result is set to 'l' - * if the separator is not in the list, prefix and/or - * suffix is set to NULL and result is set to 'n' - * When the operation succedeed, the return value is 'o' - * - * @Return Value : result of the operation ('o', 'l' or 'n') - * - **/ -gchar -g_string_dichotomy (GString *string, gchar sep, GString **prefix, GString **suffix, - GStringDichotomyOption options) -{ - gchar *str, *tmp; - gint pos, len, first; - - g_assert (tmp=string->str); - len = strlen (tmp); - if (!len) { - if (prefix) - *prefix=NULL; - if (suffix) - *suffix=NULL; - return 'n'; - } - first = 0; - - if ((options & GSTRING_DICHOTOMY_STRIP_LEADING ) && (tmp[first] == sep) ) - do {first++;} while ( (first=first) && (tmp[pos]!=sep)); - } else { - pos = first; - do { - pos++; - } while ((pos=len) ) - { - if (suffix) *suffix=NULL; - if (prefix) *prefix=NULL; - return 'n'; - } - - /* if we have stripped trailing separators, we should */ - /* never enter here */ - if (pos==len-1) - { - if (suffix) *suffix=NULL; - if (prefix) *prefix=NULL; - return 'l'; - } - /* if we have stripped leading separators, we should */ - /* never enter here */ - if (pos==first) - { - if (suffix) *suffix=NULL; - if (prefix) *prefix=NULL; - return 'l'; - } - - if (prefix) /* return the prefix */ - { - str = g_strndup(tmp,pos); - *prefix = g_string_new(str); - g_free(str); - } - if (suffix) /* return the suffix */ - { - str = g_strdup(tmp+pos+1); - *suffix = g_string_new(str); - g_free(str); - } - - return 'o'; -} - - /** * g_string_append_g_string : append a GString to another GString * @@ -185,13 +74,11 @@ g_string_append_g_string(GString *dest_string, GString *other_string) { g_assert(other_string); g_assert(dest_string); - g_assert(other_string->str); - g_string_append(dest_string, other_string->str); + if (other_string->len) + g_string_append(dest_string, other_string->str); } - - /** * g_string_equal_for_hash: test equality of two GStrings for hash tables * @v: string 1 diff --git a/camel/gstring-util.h b/camel/gstring-util.h index 01cdeffd76..487bbc8a3b 100644 --- a/camel/gstring-util.h +++ b/camel/gstring-util.h @@ -37,14 +37,6 @@ extern "C" { #include -typedef enum { - GSTRING_DICHOTOMY_NONE = 0, - GSTRING_DICHOTOMY_RIGHT_DIR = 1, - GSTRING_DICHOTOMY_STRIP_TRAILING = 2, - GSTRING_DICHOTOMY_STRIP_LEADING = 4 - -} GStringDichotomyOption; - typedef enum { GSTRING_TRIM_NONE = 0, GSTRING_TRIM_STRIP_TRAILING = 1, @@ -54,9 +46,6 @@ typedef enum { gboolean g_string_equals (GString *string1, GString *string2); GString *g_string_clone (GString *string); -gchar g_string_dichotomy (GString *string, gchar sep, - GString **prefix, GString **suffix, - GStringDichotomyOption options); void g_string_append_g_string (GString *dest_string, GString *other_string); diff --git a/camel/providers/mbox/camel-mbox-folder.c b/camel/providers/mbox/camel-mbox-folder.c index 8c45d64fd7..0b776db81c 100644 --- a/camel/providers/mbox/camel-mbox-folder.c +++ b/camel/providers/mbox/camel-mbox-folder.c @@ -40,7 +40,6 @@ #include "string-utils.h" #include "camel-stream-fs.h" #include "camel-mbox-summary.h" -#include "gmime-utils.h" #include "camel-mbox-search.h" #include "camel-data-wrapper.h" #include "camel-mime-message.h" diff --git a/camel/string-utils.c b/camel/string-utils.c index 039aafe2b8..42fb93538a 100644 --- a/camel/string-utils.c +++ b/camel/string-utils.c @@ -24,122 +24,16 @@ * USA */ - - #include #include "string-utils.h" #include "string.h" - - gboolean string_equal_for_glist (gconstpointer v, gconstpointer v2) { return (!strcmp ( ((const gchar *)v), ((const gchar*)v2))) == 0; } -/** - * string_dichotomy: - * @sep : separator - * @prefix: pointer to be field by the prefix object - * the prefix is not returned when the given pointer is NULL - * @suffix: pointer to be field by the suffix object - * the suffix is not returned when the given pointer is NULL - * - * Return the strings before and/or after - * the last occurence of the specified separator - * - * This routine returns the string before and/or after - * a character given as an argument. - * if the separator is the last character, prefix and/or - * suffix is set to NULL and result is set to 'l' - * if the separator is not in the list, prefix and/or - * suffix is set to NULL and result is set to 'n' - * When the operation succedeed, the return value is 'o' - * - * @Return Value : result of the operation ('o', 'l' or 'n') - * - **/ -gchar -string_dichotomy (const gchar *string, gchar sep, gchar **prefix, gchar **suffix, - StringDichotomyOption options) -{ - gint sep_pos, first, last, len; - - g_assert (string); - len = strlen (string); - if (!len) { - if (prefix) - *prefix=NULL; - if (suffix) - *suffix=NULL; - return 'n'; - } - first = 0; - last = len-1; - - if ( (options & STRING_DICHOTOMY_STRIP_LEADING ) && (string[first] == sep) ) - do {first++;} while ( (firstfirst)) - last--; - - if (first==last) { - if (prefix) *prefix=NULL; - if (suffix) *suffix=NULL; - return 'n'; - } - - if (options & STRING_DICHOTOMY_RIGHT_DIR) { - sep_pos = last; - while ((sep_pos>=first) && (string[sep_pos]!=sep)) { - sep_pos--; - } - } else { - sep_pos = first; - while ((sep_pos<=last) && (string[sep_pos]!=sep)) { - sep_pos++; - } - - } - - if ( (sep_poslast) ) - { - if (suffix) *suffix=NULL; - if (prefix) *prefix=NULL; - return 'n'; - } - - /* if we have stripped trailing separators, we should */ - /* never enter here */ - if (sep_pos==last) - { - if (suffix) *suffix=NULL; - if (prefix) *prefix=NULL; - return 'l'; - } - /* if we have stripped leading separators, we should */ - /* never enter here */ - if (sep_pos==first) - { - if (suffix) *suffix=NULL; - if (prefix) *prefix=NULL; - return 'l'; - } - if (prefix) - *prefix = g_strndup (string+first,sep_pos-first); - if (suffix) - *suffix = g_strndup (string+sep_pos+1, last-sep_pos); - - return 'o'; -} - - - - - - /* utility func : frees a gchar element in a GList */ static void __string_list_free_string (gpointer data, gpointer user_data) @@ -148,7 +42,6 @@ __string_list_free_string (gpointer data, gpointer user_data) g_free (string); } - void string_list_free (GList *string_list) { diff --git a/camel/string-utils.h b/camel/string-utils.h index e63c332897..665aafc01e 100644 --- a/camel/string-utils.h +++ b/camel/string-utils.h @@ -37,17 +37,6 @@ extern "C" { #include - - -typedef enum { - STRING_DICHOTOMY_NONE = 0, - STRING_DICHOTOMY_RIGHT_DIR = 1, - STRING_DICHOTOMY_STRIP_TRAILING = 2, - STRING_DICHOTOMY_STRIP_LEADING = 4 - -} StringDichotomyOption; - - typedef enum { STRING_TRIM_NONE = 0, STRING_TRIM_STRIP_TRAILING = 1, @@ -58,9 +47,6 @@ typedef enum { gboolean string_equal_for_glist (gconstpointer v, gconstpointer v2); -gchar string_dichotomy (const gchar *string, gchar sep, - gchar **prefix, gchar **suffix, - StringDichotomyOption options); void string_list_free (GList *string_list); GList *string_split (const gchar *string, char sep, -- cgit v1.2.3