aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbertrand <Bertrand.Guiheneuf@aful.org>2000-01-04 06:40:54 +0800
committerBertrand Guiheneuf <bertrand@src.gnome.org>2000-01-04 06:40:54 +0800
commitc1d59fcb62563f31b5f753fa90b5c7bd2baa5fed (patch)
tree57a35f02b38b600eab3a706152d294072e170451
parent01c8e48720676af9576b5eee0c3081432d61b133 (diff)
downloadgsoc2013-evolution-c1d59fcb62563f31b5f753fa90b5c7bd2baa5fed.tar.gz
gsoc2013-evolution-c1d59fcb62563f31b5f753fa90b5c7bd2baa5fed.tar.zst
gsoc2013-evolution-c1d59fcb62563f31b5f753fa90b5c7bd2baa5fed.zip
detects netscape ".sdb" folders as well as simple non-suffixed folders (as
2000-01-03 bertrand <Bertrand.Guiheneuf@aful.org> * camel/providers/mbox/camel-mbox-folder.c (_list_subfolders): detects netscape ".sdb" folders as well as simple non-suffixed folders (as the ones used in pine). * camel/string-utils.c (string_prefix): finished implementation. (string_prefix): added a boolean flag to indicate if the suffix has been found. When the suffix does not match, return NULL. svn path=/trunk/; revision=1531
-rw-r--r--ChangeLog15
-rw-r--r--camel/providers/mbox/camel-mbox-folder.c16
-rw-r--r--camel/string-utils.c50
-rw-r--r--camel/string-utils.h8
4 files changed, 80 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index 5029bb02c2..ae834596c9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,17 @@
-1999-12-26 Bertrand Guiheneuf <guiheneu@localhost.localdomain>
+2000-01-03 bertrand <Bertrand.Guiheneuf@aful.org>
+
+ * camel/providers/mbox/camel-mbox-folder.c (_list_subfolders):
+ detects netscape ".sdb" folders as well as simple
+ non-suffixed folders (as the ones used in pine).
+
+
+ * camel/string-utils.c (string_prefix):
+ finished implementation.
+ (string_prefix): added a boolean flag to indicate if the
+ suffix has been found. When the suffix does not match,
+ return NULL.
+
+1999-12-26 bertrand <Bertrand.Guiheneuf@aful.org>
* camel/camel-exception.c (camel_exception_setv):
new function. Allow printf-like description
diff --git a/camel/providers/mbox/camel-mbox-folder.c b/camel/providers/mbox/camel-mbox-folder.c
index 90d9399833..44d2ec8913 100644
--- a/camel/providers/mbox/camel-mbox-folder.c
+++ b/camel/providers/mbox/camel-mbox-folder.c
@@ -34,7 +34,7 @@
#include "camel-mbox-folder.h"
#include "camel-mbox-store.h"
-#include "gstring-util.h"
+#include "string-utils.h"
#include "camel-log.h"
#include "camel-stream-buffered-fs.h"
#include "camel-folder-summary.h"
@@ -641,10 +641,13 @@ _list_subfolders (CamelFolder *folder, CamelException *ex)
GList *file_list;
gchar *entry_name;
gchar *full_entry_name;
+ gchar *real_folder_name;
struct dirent *dir_entry;
DIR *dir_handle;
+ gboolean folder_suffix_found;
gchar *io_error_text;
+
/* check if the folder object exists */
@@ -697,8 +700,17 @@ _list_subfolders (CamelFolder *folder, CamelException *ex)
if (entry_name[0] != '.') {
CAMEL_LOG_FULL_DEBUG ("CamelMboxFolder::list_subfolders adding "
"%s\n", entry_name);
+
+ /* if the folder is a netscape folder, remove the
+ ".sdb" from the name */
+ real_folder_name = string_prefix (entry_name, ".sdb", &folder_suffix_found);
+ /* stick here the tests for other folder suffixes if any */
+
+ if (!folder_suffix_found) real_folder_name = g_strdup (entry_name);
+
+ /* add the folder name to the list */
subfolder_name_list = g_list_append (subfolder_name_list,
- g_strdup (entry_name));
+ real_folder_name);
}
}
/* read next entry */
diff --git a/camel/string-utils.c b/camel/string-utils.c
index beddfa8172..df973fc01b 100644
--- a/camel/string-utils.c
+++ b/camel/string-utils.c
@@ -253,23 +253,61 @@ string_trim (gchar *string, const gchar *trim_chars, StringTrimOption options)
+/**
+ * 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)
+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 (s_len < suf_len)
- return null;
-
+ /* 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;
- if (!strncmp (s+suffix_pos, suffix, 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;
}
diff --git a/camel/string-utils.h b/camel/string-utils.h
index f67d3434d4..fcc3a6c2d1 100644
--- a/camel/string-utils.h
+++ b/camel/string-utils.h
@@ -37,6 +37,8 @@ extern "C" {
#include <glib.h>
+
+
typedef enum {
STRING_DICHOTOMY_NONE = 0,
STRING_DICHOTOMY_RIGHT_DIR = 1,
@@ -45,12 +47,15 @@ typedef enum {
} StringDichotomyOption;
+
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);
gchar string_dichotomy (const gchar *string, gchar sep,
@@ -63,6 +68,9 @@ GList *string_split (const gchar *string, char sep,
void string_trim (gchar *string, const gchar *chars,
StringTrimOption options);
+gchar *string_prefix (const gchar *s, const gchar *suffix, gboolean *suffix_found);
+
+
#ifdef __cplusplus
}
#endif /* __cplusplus */