aboutsummaryrefslogtreecommitdiffstats
path: root/camel
diff options
context:
space:
mode:
authorbertrand <Bertrand.Guiheneuf@inria.fr>1999-04-18 18:44:38 +0800
committerBertrand Guiheneuf <bertrand@src.gnome.org>1999-04-18 18:44:38 +0800
commit0057293c1cb3f3d001ba3dd262ac3e715378452a (patch)
tree2f7899e813d6a8bf2237c18729889f45020e6632 /camel
parent8fcb90785fb673c5dc14c36b54af45502ae65b83 (diff)
downloadgsoc2013-evolution-0057293c1cb3f3d001ba3dd262ac3e715378452a.tar
gsoc2013-evolution-0057293c1cb3f3d001ba3dd262ac3e715378452a.tar.gz
gsoc2013-evolution-0057293c1cb3f3d001ba3dd262ac3e715378452a.tar.bz2
gsoc2013-evolution-0057293c1cb3f3d001ba3dd262ac3e715378452a.tar.lz
gsoc2013-evolution-0057293c1cb3f3d001ba3dd262ac3e715378452a.tar.xz
gsoc2013-evolution-0057293c1cb3f3d001ba3dd262ac3e715378452a.tar.zst
gsoc2013-evolution-0057293c1cb3f3d001ba3dd262ac3e715378452a.zip
some work log system for camel some utilities for GString objects
1999-04-18 bertrand <Bertrand.Guiheneuf@inria.fr> * camel/camel-folder.c: some work * camel/camel-log.c: log system for camel * camel/gstring-util.c: some utilities for GString objects Work on obmail translation. Bertrand svn path=/trunk/; revision=851
Diffstat (limited to 'camel')
-rw-r--r--camel/Makefile.am8
-rw-r--r--camel/camel-folder.c84
-rw-r--r--camel/camel-folder.h6
-rw-r--r--camel/camel-log.c39
-rw-r--r--camel/camel-log.h43
-rw-r--r--camel/gstring-util.c159
-rw-r--r--camel/gstring-util.h53
7 files changed, 388 insertions, 4 deletions
diff --git a/camel/Makefile.am b/camel/Makefile.am
index 3f51452430..2e8d987404 100644
--- a/camel/Makefile.am
+++ b/camel/Makefile.am
@@ -12,10 +12,14 @@ INCLUDES = -I.. -I$(srcdir)/.. -I$(includedir) \
$(GTK_INCLUDEDIR)
libcamel_la_SOURCES = \
- camel-folder.c
+ camel-log.c \
+ camel-folder.c \
+ gstring-util.c
libcamelinclude_HEADERS = \
- camel-folder.h
+ camel-log.h \
+ camel-folder.h \
+ gstring-util.h
libcamel_la_LDFLAGS = -version-info 0:0:0 -rpath $(libdir)
diff --git a/camel/camel-folder.c b/camel/camel-folder.c
index e7598b0d42..c1af6c7bbe 100644
--- a/camel/camel-folder.c
+++ b/camel/camel-folder.c
@@ -30,6 +30,11 @@ static void camel_folder_open(CamelFolder *folder);
static void camel_folder_close(CamelFolder *folder, gboolean expunge);
static void camel_folder_set_name(CamelFolder *folder, GString *name_string);
static GString *camel_folder_get_name(CamelFolder *folder);
+static gboolean camel_folder_can_hold_folders(CamelFolder *folder);
+static gboolean camel_folder_can_hold_messages(CamelFolder *folder);
+static gboolean camel_folder_exists(CamelFolder *folder);
+static gboolean camel_folder_is_open(CamelFolder *folder);
+static CamelFolder *camel_folder_get_folder(CamelFolder *folder, GString *folderName);
static void
camel_folder_class_init (CamelFolderClass *camel_folder_class)
@@ -41,7 +46,11 @@ camel_folder_class_init (CamelFolderClass *camel_folder_class)
camel_folder_class->close = camel_folder_close;
camel_folder_class->set_name = camel_folder_set_name;
camel_folder_class->get_name = camel_folder_get_name;
-
+ camel_folder_class->can_hold_folders = camel_folder_can_hold_folders;
+ camel_folder_class->can_hold_messages = camel_folder_can_hold_messages;
+ camel_folder_class->exists = camel_folder_exists;
+ camel_folder_class->is_open = camel_folder_is_open;
+ camel_folder_class->get_folder = camel_folder_get_folder;
/* virtual method overload */
}
@@ -125,7 +134,7 @@ camel_folder_set_name(CamelFolder *folder, GString *name_string)
/**
- * getName : get the (short) name of the folder
+ * camel_folder_get_name : get the (short) name of the folder
*
* get the name of the folder. The fully qualified name
* can be obtained with the get_full_ame method (not implemented)
@@ -138,3 +147,74 @@ camel_folder_get_name(CamelFolder *folder)
{
return folder->name;
}
+
+
+/**
+ * camel_folder_can_hold_folders : tests if the folder can contain other folders
+ *
+ **/
+static gboolean
+camel_folder_can_hold_folders(CamelFolder *folder)
+{
+ return folder->can_hold_folders;
+}
+
+
+
+/**
+ * camel_folder_can_hold_messages : tests if the folder can contain messages
+ *
+ **/
+static gboolean
+camel_folder_can_hold_messages(CamelFolder *folder)
+{
+ return folder->can_hold_messages;
+}
+
+
+
+/**
+ * camel_folder_exists : tests if the folder object exists on the store.
+ *
+ **/
+static gboolean
+camel_folder_exists(CamelFolder *folder)
+{
+ return folder->exists_on_store;
+}
+
+
+
+/**
+ * camel_folder_is_open : test if the folder is open
+ *
+ **/
+static gboolean
+camel_folder_is_open(CamelFolder *folder)
+{
+ return (folder->open_state==FOLDER_OPEN);
+}
+
+
+
+
+/**
+ * camel_folder_get_folder: return the (sub)folder object that
+ * is specified.
+ *
+ * This method returns a folder objects. This folder
+ * is necessarily a subfolder of the current folder.
+ * It is an error to ask a folder begining with the
+ * folder separator character.
+ *
+ * @folderName: subfolder path. NULL if the subfolder object
+ * could not be created
+ **/
+static CamelFolder *
+camel_folder_get_folder(CamelFolder *folder, GString *folderName)
+{
+ g_warning("getFolder called on the abstract CamelFolder class\n");
+ return NULL;
+}
+
+
diff --git a/camel/camel-folder.h b/camel/camel-folder.h
index b46d6907ff..e08b0ab618 100644
--- a/camel/camel-folder.h
+++ b/camel/camel-folder.h
@@ -81,6 +81,12 @@ typedef struct {
void (*close) (CamelFolder *folder, gboolean expunge);
void (*set_name) (CamelFolder *folder, GString *name_string);
GString * (*get_name) (CamelFolder *folder);
+ gboolean (*can_hold_folders) (CamelFolder *folder);
+ gboolean (*can_hold_messages) (CamelFolder *folder);
+ gboolean (*exists) (CamelFolder *folder);
+ gboolean (*is_open) (CamelFolder *folder);
+ CamelFolder * (*get_folder) (CamelFolder *folder, GString *folderName);
+
} CamelFolderClass;
diff --git a/camel/camel-log.c b/camel/camel-log.c
new file mode 100644
index 0000000000..fba71e9414
--- /dev/null
+++ b/camel/camel-log.c
@@ -0,0 +1,39 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/*
+ *
+ * Copyright (C) 1999 Bertrand Guiheneuf <Bertrand.Guiheneuf@inria.fr> .
+ *
+ * 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 "camel-log.h"
+
+int camel_debug_level = 10;
+FILE *camel_log_file_descriptor = stderr;
+
+void
+camel_log(CamelLogLevel level, const gchar *format, ... )
+{
+ va_list args;
+ if (level<=camel_debug_level)
+ {
+ va_start(args, format);
+ vfprintf(camel_log_file_descriptor, format, args);
+ va_end (args);
+ }
+}
diff --git a/camel/camel-log.h b/camel/camel-log.h
new file mode 100644
index 0000000000..fd96461258
--- /dev/null
+++ b/camel/camel-log.h
@@ -0,0 +1,43 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/*
+ *
+ * Copyright (C) 1999 Bertrand Guiheneuf <Bertrand.Guiheneuf@inria.fr> .
+ *
+ * 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 CAMEL_LOG_H
+#define CAMEL_LOG_H
+
+
+#include <stdarg.h>
+#include <glib.h>
+#include <stdio.h>
+
+extern int camel_debug_level;
+extern FILE *camel_log_file_descriptor;
+
+typedef enum {
+ NO_LOG = 0,
+ FULL_DEBUG = 10
+} CamelLogLevel;
+
+#define CAMEL_LOG(level, args...) camel_log(level,##args)
+
+extern void camel_log(CamelLogLevel level, const gchar *format, ... );
+
+#endif /* CAMEL_LOG_H */
diff --git a/camel/gstring-util.c b/camel/gstring-util.c
new file mode 100644
index 0000000000..9a1357babd
--- /dev/null
+++ b/camel/gstring-util.c
@@ -0,0 +1,159 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* gstring-util : utilities for gstring object */
+
+/*
+ *
+ * Copyright (C) 1999 Bertrand Guiheneuf <Bertrand.Guiheneuf@inria.fr> .
+ *
+ * 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 "gstring-util.h"
+#include "camel-log.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( g_strdup(string->str) );
+}
+
+
+
+
+/**
+ * right_dichotomy : 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'
+ *
+ * @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 Value : result of the operation ('o', 'l' or 'n')
+ *
+ **/
+gchar
+g_string_right_dichotomy( GString *string, gchar sep, GString **prefix, GString **suffix, DichotomyOption options)
+{
+ gchar *str, *tmp;
+ gint pos, len, first;
+
+ CAMEL_LOG(FULL_DEBUG,\
+ "Entering rightDichotomy: \n\tseparator=%c \n\tprefix=%p \n\tsuffix=%p \n\toptions=%ld\n",\
+ sep, prefix, suffix, options);
+ g_assert( tmp=string->str );
+ len = strlen(tmp);
+ if (!len) {
+ if (prefix) *prefix=NULL;
+ if (suffix) *suffix=NULL;
+ CAMEL_LOG(FULL_DEBUG,"rightDichotomy: string is empty\n");
+ return 'n';
+ }
+ first = 0;
+
+ if ( (options & STRIP_LEADING ) && (tmp[first] == sep) )
+ do {first++;} while ( (first<len) && (tmp[first] == sep) );
+
+ if (options & STRIP_TRAILING )
+ while (tmp[len-1] == sep)
+ len--;
+
+ if (first==len) {
+ if (prefix) *prefix=NULL;
+ if (suffix) *suffix=NULL;
+ CAMEL_LOG(FULL_DEBUG,"rightDichotomy: after stripping, string is empty\n");
+ return 'n';
+ }
+
+ pos = len;
+
+ do {
+ pos--;
+ } while ((pos>=first) && (tmp[pos]!=sep));
+
+
+ if (pos<first)
+ {
+ if (suffix) *suffix=NULL;
+ if (prefix) *prefix=NULL;
+ CAMEL_LOG(FULL_DEBUG,"rightDichotomy: separator not found\n");
+ return 'n';
+ }
+
+ /* if we have stripped trailongs separators, we should */
+ /* never enter here */
+ if (pos==len-1)
+ {
+ if (suffix) *suffix=NULL;
+ if (prefix) *prefix=NULL;
+ CAMEL_LOG(FULL_DEBUG,"rightDichotomy: separator is last character\n");
+ 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';
+}
+
diff --git a/camel/gstring-util.h b/camel/gstring-util.h
new file mode 100644
index 0000000000..6f6adde14f
--- /dev/null
+++ b/camel/gstring-util.h
@@ -0,0 +1,53 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* gstring-util : utilities for gstring object */
+
+/*
+ *
+ * Copyright (C) 1999 Bertrand Guiheneuf <Bertrand.Guiheneuf@inria.fr> .
+ *
+ * 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 GSTRING_UTIL_H
+#define GSTRING_UTIL_H 1
+
+
+#ifdef __cplusplus
+extern "C" {
+#pragma }
+#endif /* __cplusplus }*/
+
+#include <glib.h>
+
+typedef enum {
+ NONE = 0,
+ STRIP_TRAILING = 1,
+ STRIP_LEADING = 2
+
+} DichotomyOption;
+
+
+gboolean g_string_equals(GString *string1, GString *string2);
+GString *g_string_clone(GString *string);
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* GSTRING_UTIL_H */