aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2002-11-01 05:41:26 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2002-11-01 05:41:26 +0800
commitf48db35928c31854f828f04d52b5ee9df858e4e5 (patch)
tree8af24d75b2810e5b8f44a7c7bc4109ff8926a733
parent613453b1095e325149b8d37e5731d415e1d5f9bd (diff)
downloadgsoc2013-evolution-f48db35928c31854f828f04d52b5ee9df858e4e5.tar
gsoc2013-evolution-f48db35928c31854f828f04d52b5ee9df858e4e5.tar.gz
gsoc2013-evolution-f48db35928c31854f828f04d52b5ee9df858e4e5.tar.bz2
gsoc2013-evolution-f48db35928c31854f828f04d52b5ee9df858e4e5.tar.lz
gsoc2013-evolution-f48db35928c31854f828f04d52b5ee9df858e4e5.tar.xz
gsoc2013-evolution-f48db35928c31854f828f04d52b5ee9df858e4e5.tar.zst
gsoc2013-evolution-f48db35928c31854f828f04d52b5ee9df858e4e5.zip
Remove a ton of useless snot.
2002-10-31 Jeffrey Stedfast <fejj@ximian.com> Remove a ton of useless snot. * Makefile.am: Remove gstring-util.[c,h] from the build. * gstring-util.[c,h]: Removed. * string-utils.c (string_equal_for_glist): Removed. (string_split): Removed. (string_trim): Removed. (string_prefix): Removed. (string_unquote): Removed. (strip): Removed. * hash-table-utils.c (g_hash_table_generic_free): Removed. g_str[n]casecmp functions are deprecated in glib2. * string-utils.c (strstrcase): Use strncasecmp instead of g_strncasecmp. * hash-table-utils.c (g_strcase_equal): Use strcasecmp instead of g_strcasecmp. * camel-smime-utils.c (camel_smime_is_smime_v3_signed): Same. (camel_smime_is_smime_v3_encrypted): Here too. * camel-sasl-digest-md5.c (decode_data_type): And here. (parse_server_challenge): Again here. * camel-pgp-mime.c (camel_pgp_mime_is_rfc2015_signed): Same. (camel_pgp_mime_is_rfc2015_encrypted): Same * camel-mime-part-utils.c (check_html_charset): Here too. * camel-folder-summary.c (camel_system_flag): Same. svn path=/trunk/; revision=18472
-rw-r--r--camel/ChangeLog38
-rw-r--r--camel/Makefile.am2
-rw-r--r--camel/camel-folder-summary.c2
-rw-r--r--camel/camel-mime-part-utils.c4
-rw-r--r--camel/camel-pgp-mime.c4
-rw-r--r--camel/camel-sasl-digest-md5.c4
-rw-r--r--camel/camel-smime-utils.c6
-rw-r--r--camel/gstring-util.c216
-rw-r--r--camel/gstring-util.h65
-rw-r--r--camel/hash-table-utils.c37
-rw-r--r--camel/hash-table-utils.h2
-rw-r--r--camel/string-utils.c209
-rw-r--r--camel/string-utils.h61
13 files changed, 100 insertions, 550 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index bf98740615..c504171765 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,3 +1,41 @@
+2002-10-31 Jeffrey Stedfast <fejj@ximian.com>
+
+ Remove a ton of useless snot.
+
+ * Makefile.am: Remove gstring-util.[c,h] from the build.
+
+ * gstring-util.[c,h]: Removed.
+
+ * string-utils.c (string_equal_for_glist): Removed.
+ (string_split): Removed.
+ (string_trim): Removed.
+ (string_prefix): Removed.
+ (string_unquote): Removed.
+ (strip): Removed.
+
+ * hash-table-utils.c (g_hash_table_generic_free): Removed.
+
+ g_str[n]casecmp functions are deprecated in glib2.
+
+ * string-utils.c (strstrcase): Use strncasecmp instead of
+ g_strncasecmp.
+
+ * hash-table-utils.c (g_strcase_equal): Use strcasecmp
+ instead of g_strcasecmp.
+
+ * camel-smime-utils.c (camel_smime_is_smime_v3_signed): Same.
+ (camel_smime_is_smime_v3_encrypted): Here too.
+
+ * camel-sasl-digest-md5.c (decode_data_type): And here.
+ (parse_server_challenge): Again here.
+
+ * camel-pgp-mime.c (camel_pgp_mime_is_rfc2015_signed): Same.
+ (camel_pgp_mime_is_rfc2015_encrypted): Same
+
+ * camel-mime-part-utils.c (check_html_charset): Here too.
+
+ * camel-folder-summary.c (camel_system_flag): Same.
+
2002-10-25 Jeffrey Stedfast <fejj@ximian.com>
* camel-gpg-context.c (gpg_ctx_parse_status): Don't prematurely
diff --git a/camel/Makefile.am b/camel/Makefile.am
index 4bb0ddeba6..ab2160375b 100644
--- a/camel/Makefile.am
+++ b/camel/Makefile.am
@@ -114,7 +114,6 @@ libcamel_la_SOURCES = \
camel-vee-store.c \
camel-vtrash-folder.c \
camel.c \
- gstring-util.c \
hash-table-utils.c \
string-utils.c
@@ -214,7 +213,6 @@ libcamelinclude_HEADERS = \
camel-vee-store.h \
camel-vtrash-folder.h \
camel.h \
- gstring-util.h \
hash-table-utils.h \
string-utils.h
diff --git a/camel/camel-folder-summary.c b/camel/camel-folder-summary.c
index 09e75b10a5..b66b57753e 100644
--- a/camel/camel-folder-summary.c
+++ b/camel/camel-folder-summary.c
@@ -2482,7 +2482,7 @@ camel_system_flag (const char *name)
g_return_val_if_fail (name != NULL, 0);
for (flag = flag_names; *flag->name; flag++)
- if (!g_strcasecmp (name, flag->name))
+ if (!strcasecmp (name, flag->name))
return flag->value;
return 0;
diff --git a/camel/camel-mime-part-utils.c b/camel/camel-mime-part-utils.c
index bf4d434b34..42460b07da 100644
--- a/camel/camel-mime-part-utils.c
+++ b/camel/camel-mime-part-utils.c
@@ -81,9 +81,9 @@ check_html_charset(char *buffer, int length)
case CAMEL_HTML_PARSER_ELEMENT:
val = camel_html_parser_tag(hp);
d(printf("Got tag: %s\n", val));
- if (g_strcasecmp(val, "meta") == 0
+ if (strcasecmp(val, "meta") == 0
&& (val = camel_html_parser_attr(hp, "http-equiv"))
- && g_strcasecmp(val, "content-type") == 0
+ && strcasecmp(val, "content-type") == 0
&& (val = camel_html_parser_attr(hp, "content"))
&& (ct = header_content_type_decode(val))) {
charset = header_content_type_param(ct, "charset");
diff --git a/camel/camel-pgp-mime.c b/camel/camel-pgp-mime.c
index f9d0ea80a9..43562495d0 100644
--- a/camel/camel-pgp-mime.c
+++ b/camel/camel-pgp-mime.c
@@ -63,7 +63,7 @@ camel_pgp_mime_is_rfc2015_signed (CamelMimePart *mime_part)
#ifdef ENABLE_PEDANTIC_PGPMIME
/* check that we have a protocol param with the value: "application/pgp-signature" */
param = header_content_type_param (type, "protocol");
- if (!param || g_strcasecmp (param, "application/pgp-signature"))
+ if (!param || strcasecmp (param, "application/pgp-signature"))
return FALSE;
/* check that we have a micalg parameter */
@@ -126,7 +126,7 @@ camel_pgp_mime_is_rfc2015_encrypted (CamelMimePart *mime_part)
#ifdef ENABLE_PEDANTIC_PGPMIME
/* check that we have a protocol param with the value: "application/pgp-encrypted" */
param = header_content_type_param (type, "protocol");
- if (!param || g_strcasecmp (param, "application/pgp-encrypted"))
+ if (!param || strcasecmp (param, "application/pgp-encrypted"))
return FALSE;
#endif /* ENABLE_PEDANTIC_PGPMIME */
diff --git a/camel/camel-sasl-digest-md5.c b/camel/camel-sasl-digest-md5.c
index a88612de7b..d7219f6779 100644
--- a/camel/camel-sasl-digest-md5.c
+++ b/camel/camel-sasl-digest-md5.c
@@ -360,7 +360,7 @@ decode_data_type (DataType *dtype, const char *name)
int i;
for (i = 0; dtype[i].name; i++) {
- if (!g_strcasecmp (dtype[i].name, name))
+ if (!strcasecmp (dtype[i].name, name))
break;
}
@@ -467,7 +467,7 @@ parse_server_challenge (const char *tokens, gboolean *abort)
break;
case DIGEST_STALE:
PARANOID (digest_abort (&got_stale, abort));
- if (!g_strcasecmp (param->value, "true"))
+ if (!strcasecmp (param->value, "true"))
challenge->stale = TRUE;
else
challenge->stale = FALSE;
diff --git a/camel/camel-smime-utils.c b/camel/camel-smime-utils.c
index 188ed8a17f..0aa41c2efe 100644
--- a/camel/camel-smime-utils.c
+++ b/camel/camel-smime-utils.c
@@ -53,7 +53,7 @@ camel_smime_is_smime_v3_signed (CamelMimePart *mime_part)
/* check that we have a protocol param with the value: "application/pkcs7-signature" */
param = header_content_type_param (type, "protocol");
- if (!param || g_strcasecmp (param, "application/pkcs7-signature"))
+ if (!param || strcasecmp (param, "application/pkcs7-signature"))
return FALSE;
/* check that we have a micalg parameter */
@@ -109,7 +109,7 @@ camel_smime_is_smime_v3_encrypted (CamelMimePart *mime_part)
param = header_content_type_param (type, "name");
if (param && *param && strlen (param) > 4) {
for (i = 0; types[i]; i++)
- if (!g_strcasecmp (param + strlen (param)-4, types[i]))
+ if (!strcasecmp (param + strlen (param)-4, types[i]))
return TRUE;
}
@@ -117,7 +117,7 @@ camel_smime_is_smime_v3_encrypted (CamelMimePart *mime_part)
filename = camel_mime_part_get_filename (mime_part);
if (filename && *filename && strlen (filename) > 4) {
for (i = 0; types[i]; i++)
- if (!g_strcasecmp (filename + strlen (filename)-4, types[i]))
+ if (!strcasecmp (filename + strlen (filename)-4, types[i]))
return TRUE;
}
}
diff --git a/camel/gstring-util.c b/camel/gstring-util.c
deleted file mode 100644
index e0d404aede..0000000000
--- a/camel/gstring-util.c
+++ /dev/null
@@ -1,216 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* gstring-util : utilities for gstring object */
-
-/*
- *
- * Author :
- * Bertrand Guiheneuf <bertrand@helixcode.com>
- *
- * Copyright 1999, 2000 Ximian, Inc. (www.ximian.com)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * 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
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <string.h>
-#include "gstring-util.h"
-
-/**
- * g_string_equals : test if two string are equal
- *
- * @string1 : first string
- * @string2 : second string
- *
- * @Return Value : true if the strings equal, false otherwise
- **/
-gboolean
-g_string_equals (GString *string1, GString *string2)
-{
- g_assert (string1);
- g_assert (string2);
- return !strcmp (string1->str, string2->str);
-}
-
-
-
-
-/**
- * g_string_clone : clone a GString
- *
- * @string : the string to clone
- *
- * @Return Value : the clone ...
- **/
-GString *
-g_string_clone (GString *string)
-{
- return g_string_new (string->str);
-}
-
-/**
- * g_string_append_g_string : append a GString to another GString
- *
- * @dest_string : string which will be appended
- * @other_string : string to append
- *
- **/
-void
-g_string_append_g_string(GString *dest_string, GString *other_string)
-{
- g_assert(other_string);
- g_assert(dest_string);
-
- 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
- * @v2: string 2
- *
- *
- *
- * Return value:
- **/
-gint
-g_string_equal_for_hash (gconstpointer v, gconstpointer v2)
-{
- return strcmp ( ((const GString*)v)->str, ((const GString*)v2)->str) == 0;
-}
-
-gint
-g_string_equal_for_glist (gconstpointer v, gconstpointer v2)
-{
- return !strcmp ( ((const GString*)v)->str, ((const GString*)v2)->str) == 0;
-}
-
-
-/**
- * g_string_hash: computes a hash value for a Gstring
- * @v: Gstring object
- *
- *
- *
- * Return value:
- **/
-guint
-g_string_hash (gconstpointer v)
-{
- return g_str_hash(((const GString*)v)->str);
-}
-
-
-
-
-/* utility func : frees a GString element in a GList */
-static void
-__g_string_list_free_string (gpointer data, gpointer user_data)
-{
- GString *string = (GString *)data;
- g_string_free(string, TRUE);
-}
-
-
-void
-g_string_list_free (GList *string_list)
-{
- g_list_foreach(string_list, __g_string_list_free_string, NULL);
- g_list_free(string_list);
-}
-
-
-
-
-
-
-GList *
-g_string_split (GString *string, char sep, gchar *trim_chars, GStringTrimOption trim_options)
-{
- GList *result = NULL;
- gint first, last, pos;
- gchar *str;
- gchar *new_str;
- GString *new_gstring;
-
- g_assert (string);
- str = string->str;
- if (!str) return NULL;
-
- first = 0;
- last = strlen(str) - 1;
-
- /* strip leading and trailing separators */
- while ( (first<=last) && (str[first]==sep) )
- first++;
- while ( (first<=last) && (str[last]==sep) )
- last--;
-
-
- while (first<=last) {
- pos = first;
- /* find next separator */
- while ((pos<=last) && (str[pos]!=sep)) pos++;
- if (first != pos) {
- new_str = g_strndup (str+first, pos-first);
- new_gstring = g_string_new (new_str);
- g_free (new_str);
- /* could do trimming in line to speed up this code */
- if (trim_chars) g_string_trim (new_gstring, trim_chars, trim_options);
- result = g_list_append (result, new_gstring);
- }
- first = pos + 1;
- }
-
- return result;
-}
-
-
-void
-g_string_trim (GString *string, gchar *chars, GStringTrimOption options)
-{
- gint first_ok;
- gint last_ok;
- guint length;
- gchar *str;
-
- if ((!string) || (!string->str))
- return;
- str = string->str;
- length = strlen (str);
- if (!length)
- return;
-
- first_ok = 0;
- last_ok = length - 1;
-
- if (options & GSTRING_TRIM_STRIP_LEADING)
- while ( (first_ok <= last_ok) && (strchr (chars, str[first_ok])) )
- first_ok++;
-
- if (options & GSTRING_TRIM_STRIP_TRAILING)
- while ( (first_ok <= last_ok) && (strchr (chars, str[last_ok])) )
- last_ok++;
-
- if (first_ok > 0)
- g_string_erase (string, 0, first_ok);
-
- if (last_ok < length-1)
- g_string_truncate (string, last_ok - first_ok +1);
-
-}
diff --git a/camel/gstring-util.h b/camel/gstring-util.h
deleted file mode 100644
index 39fdf32fd1..0000000000
--- a/camel/gstring-util.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* gstring-util : utilities for gstring object */
-
-/*
- *
- * Author :
- * Bertrand Guiheneuf <bertrand@helixcode.com>
- *
- * Copyright 1999, 2000 Ximian, Inc. (www.ximian.com)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * 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 GSTRING_UTIL_H
-#define GSTRING_UTIL_H 1
-
-
-#ifdef __cplusplus
-extern "C" {
-#pragma }
-#endif /* __cplusplus }*/
-
-#include <glib.h>
-
-typedef enum {
- GSTRING_TRIM_NONE = 0,
- GSTRING_TRIM_STRIP_TRAILING = 1,
- GSTRING_TRIM_STRIP_LEADING = 2
-} GStringTrimOption;
-
-
-gboolean g_string_equals (GString *string1, GString *string2);
-GString *g_string_clone (GString *string);
-void g_string_append_g_string (GString *dest_string,
- GString *other_string);
-
-gboolean g_string_equal_for_hash (gconstpointer v, gconstpointer v2);
-gboolean g_string_equal_for_glist (gconstpointer v, gconstpointer v2);
-guint g_string_hash (gconstpointer v);
-void g_string_list_free (GList *string_list);
-
-GList *g_string_split (GString *string, char sep,
- gchar *trim_chars, GStringTrimOption trim_options);
-void g_string_trim (GString *string, gchar *chars,
- GStringTrimOption options);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* GSTRING_UTIL_H */
diff --git a/camel/hash-table-utils.c b/camel/hash-table-utils.c
index f17f6ce5d5..195afbee2d 100644
--- a/camel/hash-table-utils.c
+++ b/camel/hash-table-utils.c
@@ -23,22 +23,11 @@
* USA
*/
-#include <ctype.h>
-#include "hash-table-utils.h"
+#include <string.h>
+#include <ctype.h>
-/*
- * free a (key/value) hash table pair.
- * to be called in a g_hash_table_foreach()
- * before g_hash_table_destroy().
- */
-void
-g_hash_table_generic_free (gpointer key, gpointer value, gpointer user_data)
-{
- g_free (key);
- g_free (value);
-}
-
+#include "hash-table-utils.h"
/***/
@@ -47,7 +36,7 @@ g_hash_table_generic_free (gpointer key, gpointer value, gpointer user_data)
gint
g_strcase_equal (gconstpointer a, gconstpointer b)
{
- return (g_strcasecmp ((gchar *)a, (gchar *)b) == 0);
+ return (strcasecmp ((char *) a, (char *) b) == 0);
}
@@ -60,19 +49,15 @@ g_strcase_hash (gconstpointer v)
{
const char *s = (char*)v;
const char *p;
- guint h=0, g;
+ guint h = 0, g;
- for(p = s; *p != '\0'; p += 1) {
- h = ( h << 4 ) + toupper(*p);
- if ( ( g = h & 0xf0000000 ) ) {
+ for (p = s; *p != '\0'; p += 1) {
+ h = (h << 4) + toupper (*p);
+ if ((g = h & 0xf0000000)) {
h = h ^ (g >> 24);
h = h ^ g;
}
- }
-
- return h /* % M */;
+ }
+
+ return h;
}
-
-
-
-/***/
diff --git a/camel/hash-table-utils.h b/camel/hash-table-utils.h
index 80e9a6057c..0d3ab7dce6 100644
--- a/camel/hash-table-utils.h
+++ b/camel/hash-table-utils.h
@@ -35,8 +35,6 @@ extern "C" {
#include <glib.h>
-void g_hash_table_generic_free (gpointer key, gpointer value, gpointer user_data);
-
gint g_strcase_equal (gconstpointer a, gconstpointer b);
guint g_strcase_hash (gconstpointer v);
diff --git a/camel/string-utils.c b/camel/string-utils.c
index 1e2fa103ef..02cfded80c 100644
--- a/camel/string-utils.c
+++ b/camel/string-utils.c
@@ -1,210 +1,49 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* string-util : utilities for gchar* strings */
-
-/*
+/*
+ * Authors: Jeffrey Stedfast <fejj@ximian.com>
*
- * Authors: Bertrand Guiheneuf <bertrand@helixcode.com>
- * Jeffrey Stedfast <fejj@ximian.com>
+ * Copyright 2002 Ximian, Inc. (www.ximian.com)
*
- * Copyright 1999, 2000 Ximian, Inc. (www.ximian.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 free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
+ * 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.
*
- * 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.
*
- * 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
*/
+
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
+#include <string.h>
+
#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;
-}
-/* utility func : frees a gchar element in a GList */
-static void
-__string_list_free_string (gpointer data, gpointer user_data)
+static void
+free_string (gpointer string, gpointer user_data)
{
- gchar *string = (gchar *)data;
g_free (string);
}
void
string_list_free (GList *string_list)
{
- if (string_list == NULL) return;
-
- g_list_foreach (string_list, __string_list_free_string, NULL);
- g_list_free (string_list);
-}
-
-GList *
-string_split (const gchar *string, char sep, const gchar *trim_chars, StringTrimOption trim_options)
-{
- GList *result = NULL;
- gint first, last, pos;
- gchar *new_string;
-
- g_assert (string);
-
- first = 0;
- last = strlen(string) - 1;
-
- /* strip leading and trailing separators */
- while ( (first<=last) && (string[first]==sep) )
- first++;
- while ( (first<=last) && (string[last]==sep) )
- last--;
-
-
- while (first<=last) {
- pos = first;
- /* find next separator */
- while ((pos<=last) && (string[pos]!=sep)) pos++;
- if (first != pos) {
- new_string = g_strndup (string+first, pos-first);
- /* could do trimming in line to speed up this code */
- if (trim_chars) string_trim (new_string, trim_chars, trim_options);
- result = g_list_append (result, new_string);
- }
- first = pos + 1;
- }
-
- return result;
-}
-
-void
-string_trim (gchar *string, const gchar *trim_chars, StringTrimOption options)
-{
- gint first_ok;
- gint last_ok;
- guint length;
-
- g_return_if_fail (string);
- length = strlen (string);
- if (length==0)
- return;
-
- first_ok = 0;
- last_ok = length - 1;
-
- if (options & STRING_TRIM_STRIP_LEADING)
- while ( (first_ok <= last_ok) && (strchr (trim_chars, string[first_ok])!=NULL) )
- first_ok++;
+ if (string_list == NULL)
+ return;
- if (options & STRING_TRIM_STRIP_TRAILING)
- while ( (first_ok <= last_ok) && (strchr (trim_chars, string[last_ok])!=NULL) )
- last_ok--;
-
- if (first_ok > 0)
- memmove (string, string+first_ok, last_ok - first_ok + 1);
- string[last_ok - first_ok +1] = '\0';
-
-}
-
-
-/**
- * remove_suffix: remove a suffix from a string
- * @s: the string to remove the suffix from.
- * @suffix: the suffix to remove
- * @suffix_found : suffix found flag
- *
- * Remove a suffix from a string. If the
- * string ends with the full suffix, a copy
- * of the string without the suffix is returned and
- * @suffix_found is set to %TRUE.
- * Otherwise, NULL is returned and
- * @suffix_found is set to %FALSE.
- *
- * Return value: an allocated copy of the string without the suffix or NULL if the suffix was not found.
- **/
-gchar *
-string_prefix (const gchar *s, const gchar *suffix, gboolean *suffix_found)
-{
- guint s_len, suf_len;
- guint suffix_pos;
- char *result_string;
-
- g_assert (s);
- g_assert (suffix);
- g_assert (suffix_found);
-
- s_len = strlen (s);
- suf_len = strlen (suffix);
-
- /* if the string is shorter than the suffix, do nothing */
- if (s_len < suf_len) {
- *suffix_found = FALSE;
- return NULL;
- }
-
- /* theoretical position of the prefix */
- suffix_pos = s_len - suf_len;
-
- /* compare the right hand side of the string with the suffix */
- if (!strncmp (s+suffix_pos, suffix, suf_len)) {
-
- /* if the suffix matches, check that there are
- characters before */
- if (suffix_pos == 0) {
- result_string = NULL;
- *suffix_found = TRUE;
- } else {
- result_string = g_strndup (s, suffix_pos);
- *suffix_found = TRUE;
- }
-
- } else {
- result_string = NULL;
- *suffix_found = FALSE;
- }
-
- return result_string;
-}
-
-void
-string_unquote (gchar *string)
-{
- /* if the string is quoted, unquote it */
-
- g_return_if_fail (string != NULL);
-
- if (*string == '"' && *(string + strlen (string) - 1) == '"') {
- *(string + strlen (string) - 1) = '\0';
- if (*string)
- memmove (string, string+1, strlen (string));
- }
-}
-
-gchar *
-strip (gchar *string, gchar c)
-{
- /* strip all occurances of c from the string */
- gchar *src, *dst;
-
- g_return_val_if_fail (string != NULL, NULL);
-
- for (src = dst = string; *src; src++)
- if (*src != c)
- *dst++ = *src;
- *dst = '\0';
-
- return string;
+ g_list_foreach (string_list, free_string, NULL);
+ g_list_free (string_list);
}
char *
@@ -225,7 +64,7 @@ strstrcase (const char *haystack, const char *needle)
return (char *) haystack;
for (ptr = haystack; *(ptr + len - 1) != '\0'; ptr++)
- if (!g_strncasecmp (ptr, needle, len))
+ if (!strncasecmp (ptr, needle, len))
return (char *) ptr;
return NULL;
diff --git a/camel/string-utils.h b/camel/string-utils.h
index 0402eb15ad..76004f03a4 100644
--- a/camel/string-utils.h
+++ b/camel/string-utils.h
@@ -1,66 +1,39 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* string-util : utilities for normal gchar * strings */
-
-/*
+/*
+ * Authors: Jeffrey Stedfast <fejj@ximian.com>
*
- * Authors: Bertrand Guiheneuf <bertrand@helixcode.com>
- * Jeffrey Stedfast <fejj@ximian.com>
+ * Copyright 2002 Ximian, Inc. (www.ximian.com)
*
- * Copyright 1999, 2000 Ximian, Inc. (www.ximian.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 free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
+ * 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.
*
- * 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.
*
- * 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 STRING_UTIL_H
#define STRING_UTIL_H 1
-
#ifdef __cplusplus
extern "C" {
#pragma }
-#endif /* __cplusplus }*/
+#endif /* __cplusplus */
#include <glib.h>
-typedef enum {
- STRING_TRIM_NONE = 0,
- STRING_TRIM_STRIP_TRAILING = 1,
- STRING_TRIM_STRIP_LEADING = 2
-} StringTrimOption;
-
-
-
-gboolean string_equal_for_glist (gconstpointer v, gconstpointer v2);
-
-void string_list_free (GList *string_list);
-
-GList *string_split (const gchar *string, char sep,
- const gchar *trim_chars, StringTrimOption trim_options);
-void string_trim (gchar *string, const gchar *chars,
- StringTrimOption options);
-
-gchar *string_prefix (const gchar *s, const gchar *suffix,
- gboolean *suffix_found);
-
-void string_unquote (gchar *string);
-
-gchar *strip (gchar *string, gchar c);
+void string_list_free (GList *string_list);
-char *strstrcase (const char *haystack, const char *needle);
+char *strstrcase (const char *haystack, const char *needle);
#ifdef __cplusplus
}