Implemented base64 encoder based on CamelStreams. Should the
authorMiguel de Icaza <miguel@gnu.org>
Thu, 15 Jul 1999 00:11:56 +0000 (00:11 +0000)
committerArturo Espinosa <unammx@src.gnome.org>
Thu, 15 Jul 1999 00:11:56 +0000 (00:11 +0000)
1999-07-13  Miguel de Icaza  <miguel@gnu.org>

* camel/gmime-base64.c (gmime_encode_base64): Implemented base64
encoder based on CamelStreams.  Should the encoder/decoder be a
Stream itself?

* camel/gmime-utils.c: include config.h here.
* camel/url-util.c: ditto.
* camel/gstring-util.c: ditto.
* camel/gmime-content-field.c: ditto.
* camel/camel-stream.c: ditto.
* camel/camel-stream-fs.c: ditto.
* camel/camel-store.c: ditto.
* camel/camel-simple-data-wrapper.c: ditto.
* camel/camel-session.c: ditto.
* camel/camel-service.c: ditto.
* camel/camel-mime-part.c: ditto.
* camel/camel-mime-message.c: ditto.
* camel/camel-log.c: ditto.
* camel/camel-data-wrapper.c: ditto
* camel/camel-folder.c: ditto.

* camel/camel-stream.c (camel_stream_write): Moved api
documentation to the places that they document.
(camel_stream_class_init): Virtual classes do not need to have a
default implementation.  So null them all.
(camel_stream_write): Return value from write.
(camel_stream_available): implement.
(camel_stream_write_strings): documented.

* devel-docs/query/virtual-folder-in-depth.sgml: Small
reformatting

1999-06-28  bertrand  <Bertrand.Guiheneuf@inria.fr>

* tests/test2.c (main): now use
CamelDataWrapper::contruct_form_stream to test

20 files changed:
camel/camel-data-wrapper.c
camel/camel-folder.c
camel/camel-log.c
camel/camel-mime-message.c
camel/camel-mime-message.h
camel/camel-mime-part.c
camel/camel-mime-part.h
camel/camel-service.c
camel/camel-session.c
camel/camel-simple-data-wrapper.c
camel/camel-store.c
camel/camel-stream-fs.c
camel/camel-stream-fs.h
camel/camel-stream.c
camel/camel-stream.h
camel/gmime-content-field.c
camel/gmime-utils.c
camel/gstring-util.c
camel/gstring-util.h
camel/url-util.c

index 05d97d4..b4ef2f9 100644 (file)
@@ -23,7 +23,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  * USA
  */
-
+#include <config.h>
 #include "camel-data-wrapper.h"
 
 static GtkObjectClass *parent_class=NULL;
index d7b5407..63881d1 100644 (file)
@@ -20,7 +20,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  * USA
  */
-
+#include <config.h>
 #include "camel-folder.h"
 #include "gstring-util.h"
 
@@ -362,12 +362,17 @@ _create(CamelFolder *folder)
        g_assert(folder->parent_store);
        g_assert(folder->name);
 
-       if ( CF_CLASS(folder)->exists(folder) ) return TRUE;
+       if (CF_CLASS(folder)->exists(folder))
+               return TRUE;
+
        sep = camel_store_get_separator(folder->parent_store);  
-       if (folder->parent_folder) camel_folder_create(folder->parent_folder);
+       if (folder->parent_folder)
+               camel_folder_create(folder->parent_folder);
        else {   
                if (folder->full_name) {
-                       dich_result = g_string_dichotomy(folder->full_name, sep, &prefix, NULL, DICHOTOMY_STRIP_TRAILING | DICHOTOMY_RIGHT_DIR);
+                       dich_result = g_string_dichotomy(
+                               folder->full_name, sep, &prefix, NULL,
+                               GSTRING_DICHOTOMY_STRIP_TRAILING | GSTRING_DICHOTOMY_RIGHT_DIR);
                        if (dich_result!='o') {
                                g_warning("I have to handle the case where the path is not OK\n"); 
                                return FALSE;
index 59ce557..a0dd800 100644 (file)
@@ -20,7 +20,7 @@
  * USA
  */
 
-
+#include <config.h>
 #include "camel-log.h"
 
 int camel_debug_level = 10;
index df65c12..61a4ca4 100644 (file)
@@ -21,7 +21,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  * USA
  */
-
+#include <config.h>
 #include "camel-mime-message.h"
 #include <stdio.h>
 #include "gmime-content-field.h"
@@ -564,7 +564,9 @@ _set_recipient_list_from_string (CamelMimeMessage *message, GString *recipient_t
 {
        GList *recipients_list;
        CAMEL_LOG (FULL_DEBUG,"CamelMimeMessage::_set_recipient_list_from_string parsing ##%s##\n", recipients_string->str);
-       recipients_list = g_string_split (recipients_string, ',', "\t ", TRIM_STRIP_TRAILING | TRIM_STRIP_LEADING);
+       recipients_list = g_string_split (
+               recipients_string, ',', "\t ",
+               GSTRING_TRIM_STRIP_TRAILING | GSTRING_TRIM_STRIP_LEADING);
        g_hash_table_insert (message->recipients, recipient_type, recipients_list);
 
 }
index 73d1cb9..321f3fd 100644 (file)
@@ -81,24 +81,35 @@ typedef struct {
        CamelMimePartClass parent_class;
        
        /* Virtual methods */   
-       void  (*set_received_date) (CamelMimeMessage *mime_message, GString *received_date);
+       void      (*set_received_date) (CamelMimeMessage *mime_message,
+                                       GString *received_date);
        GString * (*get_received_date) (CamelMimeMessage *mime_message);
-       GString * (*get_sent_date) (CamelMimeMessage *mime_message);
-       void  (*set_reply_to) (CamelMimeMessage *mime_message, GString *reply_to);
-       GString * (*get_reply_to) (CamelMimeMessage *mime_message);
-       void  (*set_subject) (CamelMimeMessage *mime_message, GString *subject);
-       GString * (*get_subject) (CamelMimeMessage *mime_message);
-       void  (*set_from) (CamelMimeMessage *mime_message, GString *from);
-       GString * (*get_from) (CamelMimeMessage *mime_message);
-       void (*add_recipient) (CamelMimeMessage *mime_message, GString *recipient_type, GString *recipient); 
-       void (*remove_recipient) (CamelMimeMessage *mime_message, GString *recipient_type, GString *recipient);
-       GList * (*get_recipients) (CamelMimeMessage *mime_message, GString *recipient_type);
-       void  (*set_flag) (CamelMimeMessage *mime_message, GString *flag, gboolean value);
-       gboolean  (*get_flag) (CamelMimeMessage *mime_message, GString *flag);
-
-       void  (*set_message_number) (CamelMimeMessage *mime_message, guint number);
-       guint  (*get_message_number) (CamelMimeMessage *mime_message);
-
+       GString * (*get_sent_date)     (CamelMimeMessage *mime_message);
+       void      (*set_reply_to)      (CamelMimeMessage *mime_message,
+                                       GString *reply_to);
+       GString * (*get_reply_to)      (CamelMimeMessage *mime_message);
+       void      (*set_subject)       (CamelMimeMessage *mime_message,
+                                       GString *subject);
+       GString * (*get_subject)       (CamelMimeMessage *mime_message);
+       void      (*set_from)          (CamelMimeMessage *mime_message,
+                                       GString *from);
+       GString * (*get_from)          (CamelMimeMessage *mime_message);
+       void      (*add_recipient)     (CamelMimeMessage *mime_message,
+                                       GString *recipient_type,
+                                       GString *recipient); 
+       void      (*remove_recipient)  (CamelMimeMessage *mime_message,
+                                       GString *recipient_type,
+                                       GString *recipient);
+       GList   * (*get_recipients)    (CamelMimeMessage *mime_message,
+                                       GString *recipient_type);
+       void      (*set_flag)          (CamelMimeMessage *mime_message,
+                                       GString *flag, gboolean value);
+       gboolean  (*get_flag)          (CamelMimeMessage *mime_message,
+                                       GString *flag);
+
+       void      (*set_message_number)(CamelMimeMessage *mime_message,
+                                       guint number);
+       guint     (*get_message_number)(CamelMimeMessage *mime_message);
 } CamelMimeMessageClass;
 
 
@@ -111,24 +122,34 @@ GtkType camel_mime_message_get_type (void);
 CamelMimeMessage *camel_mime_message_new_with_session (CamelSession *session);
 
 
-void camel_mime_message_set_received_date (CamelMimeMessage *mime_message, GString *received_date);
-GString *camel_mime_message_get_received_date (CamelMimeMessage *mime_message);
-GString *camel_mime_message_get_sent_date (CamelMimeMessage *mime_message);
-void camel_mime_message_set_reply_to (CamelMimeMessage *mime_message, GString *reply_to);
-GString *camel_mime_message_get_reply_to (CamelMimeMessage *mime_message);
-void camel_mime_message_set_subject (CamelMimeMessage *mime_message, GString *subject);
-GString *camel_mime_message_get_subject (CamelMimeMessage *mime_message);
-void camel_mime_message_set_from (CamelMimeMessage *mime_message, GString *from);
-GString *camel_mime_message_get_from (CamelMimeMessage *mime_message);
-
-void camel_mime_message_add_recipient (CamelMimeMessage *mime_message, GString *recipient_type, GString *recipient);
-void camel_mime_message_remove_recipient (CamelMimeMessage *mime_message, GString *recipient_type, GString *recipient);
-GList *camel_mime_message_get_recipients (CamelMimeMessage *mime_message, GString *recipient_type);
-
-void camel_mime_message_set_flag (CamelMimeMessage *mime_message, GString *flag, gboolean value);
-gboolean camel_mime_message_get_flag (CamelMimeMessage *mime_message, GString *flag);
-
-guint camel_mime_message_get_message_number (CamelMimeMessage *mime_message);
+void      camel_mime_message_set_received_date (CamelMimeMessage *mime_message,
+                                               GString *received_date);
+GString  *camel_mime_message_get_received_date (CamelMimeMessage *mime_message);
+GString  *camel_mime_message_get_sent_date     (CamelMimeMessage *mime_message);
+void      camel_mime_message_set_reply_to      (CamelMimeMessage *mime_message,
+                                               GString *reply_to);
+GString  *camel_mime_message_get_reply_to      (CamelMimeMessage *mime_message);
+void      camel_mime_message_set_subject       (CamelMimeMessage *mime_message,
+                                               GString *subject);
+GString  *camel_mime_message_get_subject       (CamelMimeMessage *mime_message);
+void      camel_mime_message_set_from         (CamelMimeMessage *mime_message, GString *from);
+GString  *camel_mime_message_get_from         (CamelMimeMessage *mime_message);
+
+void      camel_mime_message_add_recipient     (CamelMimeMessage *mime_message,
+                                               GString *recipient_type,
+                                               GString *recipient);
+void      camel_mime_message_remove_recipient  (CamelMimeMessage *mime_message,
+                                               GString *recipient_type,
+                                               GString *recipient);
+GList    *camel_mime_message_get_recipients    (CamelMimeMessage *mime_message,
+                                               GString *recipient_type);
+
+void     camel_mime_message_set_flag           (CamelMimeMessage *mime_message,
+                                               GString *flag, gboolean value);
+gboolean camel_mime_message_get_flag           (CamelMimeMessage *mime_message,
+                                               GString *flag);
+
+guint    camel_mime_message_get_message_number (CamelMimeMessage *mime_message);
 
 #ifdef __cplusplus
 }
index 0fdf749..aa40144 100644 (file)
@@ -21,7 +21,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  * USA
  */
-
+#include <config.h>
 #include "camel-mime-part.h"
 #include <stdio.h>
 #include "gmime-content-field.h"
index ad3ce17..9f364c4 100644 (file)
@@ -104,23 +104,33 @@ GtkType camel_mime_part_get_type (void);
 
 
 /* public methods */
-void camel_mime_part_add_header (CamelMimePart *mime_part, GString *header_name, GString *header_value);
-void camel_mime_part_remove_header (CamelMimePart *mime_part, GString *header_name);
-GString *camel_mime_part_get_header (CamelMimePart *mime_part, GString *header_name);
-void camel_mime_part_set_description (CamelMimePart *mime_part, GString *description);
-GString *camel_mime_part_get_description (CamelMimePart *mime_part);
-void camel_mime_part_set_disposition (CamelMimePart *mime_part, GString *disposition);
-GString *camel_mime_part_get_disposition (CamelMimePart *mime_part);
-void camel_mime_part_set_filename (CamelMimePart *mime_part, GString *filename);
-GString *camel_mime_part_get_filename (CamelMimePart *mime_part);
-GString *camel_mime_part_get_content_id (CamelMimePart *mime_part);
-GString *camel_mime_part_get_content_MD5 (CamelMimePart *mime_part);
-void camel_mime_part_set_encoding (CamelMimePart *mime_part, GString *encoding);
-GString *camel_mime_part_get_encoding (CamelMimePart *mime_part);
-void camel_mime_part_set_content_languages (CamelMimePart *mime_part, GList *content_languages);
-GList *camel_mime_part_get_content_languages (CamelMimePart *mime_part);
-void camel_mime_part_set_header_lines (CamelMimePart *mime_part, GList *header_lines);
-GList *camel_mime_part_get_header_lines (CamelMimePart *mime_part);
+void     camel_mime_part_add_header            (CamelMimePart *mime_part,
+                                               GString *header_name,
+                                               GString *header_value);
+void     camel_mime_part_remove_header         (CamelMimePart *mime_part,
+                                               GString *header_name);
+GString *camel_mime_part_get_header            (CamelMimePart *mime_part,
+                                               GString *header_name);
+void     camel_mime_part_set_description       (CamelMimePart *mime_part,
+                                               GString *description);
+GString *camel_mime_part_get_description       (CamelMimePart *mime_part);
+void     camel_mime_part_set_disposition       (CamelMimePart *mime_part,
+                                               GString *disposition);
+GString *camel_mime_part_get_disposition       (CamelMimePart *mime_part);
+void     camel_mime_part_set_filename          (CamelMimePart *mime_part,
+                                               GString *filename);
+GString *camel_mime_part_get_filename          (CamelMimePart *mime_part);
+GString *camel_mime_part_get_content_id        (CamelMimePart *mime_part);
+GString *camel_mime_part_get_content_MD5       (CamelMimePart *mime_part);
+void     camel_mime_part_set_encoding          (CamelMimePart *mime_part,
+                                               GString *encoding);
+GString *camel_mime_part_get_encoding          (CamelMimePart *mime_part);
+void     camel_mime_part_set_content_languages (CamelMimePart *mime_part,
+                                               GList *content_languages);
+GList   *camel_mime_part_get_content_languages (CamelMimePart *mime_part);
+void     camel_mime_part_set_header_lines      (CamelMimePart *mime_part,
+                                               GList *header_lines);
+GList   *camel_mime_part_get_header_lines      (CamelMimePart *mime_part);
 
 #ifdef __cplusplus
 }
index 2ca3d6f..645eaf3 100644 (file)
@@ -20,7 +20,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  * USA
  */
-
+#include <config.h>
 #include "camel-service.h"
 
 static GtkObjectClass *parent_class=NULL;
index 42f681f..5238b8d 100644 (file)
@@ -20,7 +20,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  * USA
  */
-
+#include <config.h>
 #include "camel-session.h"
 #include "gstring-util.h"
 
index 2d81fa6..775cf5c 100644 (file)
@@ -21,7 +21,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  * USA
  */
-
+#include <config.h>
 #include "camel-simple-data-wrapper.h"
 
 static  CamelDataWrapperClass *parent_class=NULL;
index 61c5216..cedd452 100644 (file)
@@ -20,7 +20,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  * USA
  */
-
+#include <config.h>
 #include "camel-store.h"
 
 static GtkObjectClass *parent_class=NULL;
index 09b193b..0b70802 100644 (file)
@@ -21,7 +21,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  * USA
  */
-
+#include <config.h>
 #include "camel-stream-fs.h"
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -32,7 +32,7 @@
 static CamelStreamClass *parent_class=NULL;
 
 
-/* Returns the class for a CamelMimeMessage */
+/* Returns the class for a CamelStreamFS */
 #define CS_CLASS(so) CAMEL_STREAM_FS_CLASS (GTK_OBJECT(so)->klass)
 
 static gint _read (CamelStream *stream, gchar *buffer, gint n);
@@ -101,13 +101,17 @@ camel_stream_fs_new_with_name (GString *name, CamelStreamFsMode mode)
        CAMEL_LOG (FULL_DEBUG, "Entering CamelStream::new_with_name, name=\"%s\", mode=%d\n", name->str, mode); 
        v = stat (name->str, &s);
        
-       if (mode & CAMEL_STREAM_FS_READ)
-               if (mode & CAMEL_STREAM_FS_WRITE) flags = O_RDWR | O_CREAT;
-               else flags = O_RDONLY;
-       else 
-               if (mode & CAMEL_STREAM_FS_WRITE) flags = O_WRONLY | O_CREAT;
-               else return NULL;
-
+       if (mode & CAMEL_STREAM_FS_READ){
+               if (mode & CAMEL_STREAM_FS_WRITE)
+                       flags = O_RDWR | O_CREAT;
+               else
+                       flags = O_RDONLY;
+       } else {
+               if (mode & CAMEL_STREAM_FS_WRITE)
+                       flags = O_WRONLY | O_CREAT;
+               else
+                       return NULL;
+       }
        if ( (mode & CAMEL_STREAM_FS_READ) && !(mode & CAMEL_STREAM_FS_WRITE) )
                if (v == -1) return NULL;
 
index 046e90d..3570e8a 100644 (file)
@@ -52,7 +52,6 @@ typedef struct
        CamelStream parent_object;
        GString *name;
        int fd;
-
 } CamelStreamFs;
 
 
index 9f9e912..5554b8f 100644 (file)
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  * USA
  */
-
+#include <config.h>
 #include "camel-stream.h"
 
-static CamelStreamClass *parent_class=NULL;
+static CamelStreamClass *parent_class = NULL;
 
 
 /* Returns the class for a CamelMimeMessage */
 #define CS_CLASS(so) CAMEL_STREAM_CLASS (GTK_OBJECT(so)->klass)
 
-static gint _read (CamelStream *stream, gchar *buffer, gint n);
-static gint _write (CamelStream *stream, gchar *buffer, gint n);
-static void _flush (CamelStream *stream);
-static gint _available (CamelStream *stream);
-static gboolean _eos (CamelStream *stream);
-static void _close (CamelStream *stream);
+static void
+default_camel_flush (CamelStream *stream)
+{
+       /* nothing */
+}
 
+static void
+default_camel_close (CamelStream *stream)
+{
+       /* nothing */
+}
 
 static void
 camel_stream_class_init (CamelStreamClass *camel_stream_class)
@@ -45,19 +49,16 @@ camel_stream_class_init (CamelStreamClass *camel_stream_class)
        parent_class = gtk_type_class (gtk_object_get_type ());
 
        /* virtual method definition */
-       camel_stream_class->read = _read;
-       camel_stream_class->write = _write;
-       camel_stream_class->flush = _flush;
-       camel_stream_class->available = _available;
-       camel_stream_class->eos = _eos;
-       camel_stream_class->close = _close;
+       camel_stream_class->read = NULL;
+       camel_stream_class->write = NULL;
+       camel_stream_class->flush = default_camel_flush;
+       camel_stream_class->available = NULL;
+       camel_stream_class->eos = NULL; 
+       camel_stream_class->close = default_camel_close;
 
        /* virtual method overload */
-
 }
 
-
-
 GtkType
 camel_stream_get_type (void)
 {
@@ -82,24 +83,17 @@ camel_stream_get_type (void)
        return camel_stream_type;
 }
 
-
-
 /**
- * _read: read bytes from a stream
- * @stream: stream
- * @buffer: buffer where bytes are stored
- * @n: max number of bytes to read
- * 
+ * camel_stream_read: 
+ * @stream: a CamelStream.
+ * @buffer: buffer where bytes pulled from the stream are stored.
+ * @n: max number of bytes to read.
  * 
+ * Read at most @n bytes from the @stream object and stores them
+ * in the buffer pointed at by @buffer.
  * 
  * Return value: number of bytes actually read.
  **/
-static gint
-_read (CamelStream *stream, gchar *buffer, gint n)
-{
-       
-}
-
 gint 
 camel_stream_read (CamelStream *stream, gchar *buffer, gint n)
 {
@@ -107,98 +101,84 @@ camel_stream_read (CamelStream *stream, gchar *buffer, gint n)
 }
 
 /**
- * _write: read bytes to a stream
- * @stream: the stream
- * @buffer: byte buffer
+ * camel_stream_write: 
+ * @stream: a CamelStream object.
+ * @buffer: buffer to write.
  * @n: number of bytes to write
- * 
- * 
- * 
+ *
+ * Write @n bytes from the buffer pointed at by @buffer into @stream.
+ *
  * Return value: the number of bytes actually written
  *  in the stream.
  **/
-static gint
-_write (CamelStream *stream, gchar *buffer, gint n)
-{
-
-}
-
 gint
 camel_stream_write (CamelStream *stream, gchar *buffer, gint n)
 {
-       CS_CLASS (stream)->write (stream, buffer, n);
+       return CS_CLASS (stream)->write (stream, buffer, n);
 }
 
-
-
 /**
- * _flush: flush pending changes 
- * @stream: the stream
- * 
+ * camel_stream_flush:
+ * @stream: a CamelStream object
  * 
+ * Flushes the contents of the stream to its backing store.
  **/
-static void
-_flush (CamelStream *stream)
+void
+camel_stream_flush (CamelStream *stream)
 {
-
+       return CS_CLASS (stream)->flush (stream);
 }
 
-
-
 /**
- * _available: return the number of bytes available for reading
- * @stream: the stream
- * 
- * Return the number of bytes available without blocking.
+ * camel_stream_available: 
+ * @stream: a CamelStream object
  * 
- * Return value: the number of bytes available
+ * Return value: the number of bytes available.
  **/
 static gint 
-_available (CamelStream *stream)
+camel_stream_available (CamelStream *stream)
 {
-
+       return CS_CLASS (stream)->available (stream);
 }
 
-
 /**
- * _eos: test if there are bytes left to read
- * @stream: the stream
- * 
+ * camle_stream_eos: 
+ * @stream: a CamelStream object
  * 
+ * Test if there are bytes left to read on the @stream object.
  * 
- * Return value: true if all stream has been read
+ * Return value: %TRUE if all the contents on the stream has been read, or
+ * %FALSE if information is still available.
  **/
 static gboolean
-_eos (CamelStream *stream)
+camel_stream_eos (CamelStream *stream)
 {
-
+       return CS_CLASS (stream)->eos (stream);
 }
 
 
 /**
- * _close: close a stream
- * @stream: the stream
- * 
+ * camel_stram_close: 
+ * @stream: a CamelStream object.
  * 
+ * Close the @stream object.
  **/
-static void
-_close (CamelStream *stream)
-{
-
-}
-
 void
 camel_stream_close (CamelStream *stream)
 {
        CS_CLASS (stream)->close (stream);
 }
 
-
-
-
-
 /***************** Utility functions ********************/
 
+/**
+ * came_stream_write_strings:
+ * @stream: a CamelStream object.
+ * @...: A %NULL terminated list of strings.
+ *
+ * This is a utility function that writes the list of
+ * strings into the @stream object.
+ */
 void
 camel_stream_write_strings (CamelStream *stream, ... )
 {
@@ -209,7 +189,7 @@ camel_stream_write_strings (CamelStream *stream, ... )
        string = va_arg (args, char *);
        
        while (string) {
-               camel_stream_write_string(stream, string);
+               camel_stream_write_string (stream, string);
                string = va_arg (args, char *);
        }
        va_end (args);
index 5fff22a..8434002 100644 (file)
@@ -52,13 +52,12 @@ typedef struct {
        GtkObjectClass parent_class;
        
        /* Virtual methods */   
-gint  (*read) (CamelStream *stream, gchar *buffer, gint n);
-gint  (*write) (CamelStream *stream, gchar *buffer, gint n);
-void  (*flush) (CamelStream *stream);
-gint  (*available) (CamelStream *stream);
-gboolean  (*eos) (CamelStream *stream);
-void  (*close) (CamelStream *stream);
-
+       gint  (*read)      (CamelStream *stream, gchar *buffer, gint n);
+       gint  (*write)     (CamelStream *stream, gchar *buffer, gint n);
+       void  (*flush)     (CamelStream *stream);
+       gint  (*available) (CamelStream *stream);
+       gboolean  (*eos)   (CamelStream *stream);
+       void  (*close)     (CamelStream *stream);
 } CamelStreamClass;
 
 
@@ -68,9 +67,12 @@ GtkType camel_stream_get_type (void);
 
 
 /* public methods */
-gint camel_stream_read (CamelStream *stream, gchar *buffer, gint n);
-gint camel_stream_write (CamelStream *stream, gchar *buffer, gint n);
-void camel_stream_close (CamelStream *stream);
+gint     camel_stream_read      (CamelStream *stream, gchar *buffer, gint n);
+gint     camel_stream_write     (CamelStream *stream, gchar *buffer, gint n);
+void     camel_stream_flush     (CamelStream *stream);
+gint     camel_stream_available (CamelStream *stream);
+gboolean camel_stream_eos       (CamelStream *stream);
+void     camel_stream_close     (CamelStream *stream);
 
 /* utility macros and funcs */
 #define camel_stream_write_string(stream, string) camel_stream_write ((stream), (string), strlen (string))
index 06e4384..a86c704 100644 (file)
@@ -21,9 +21,7 @@
  * USA
  */
 
-
-
-
+#include <config.h>
 #include "gmime-content-field.h"
 #include "gstring-util.h"
 #include "camel-log.h"
index 1555d27..8c3db96 100644 (file)
@@ -21,8 +21,7 @@
  * USA
  */
 
-
-
+#include <config.h>
 #include "gmime-utils.h"
 #include "gstring-util.h"
 #include "camel-log.h"
@@ -112,14 +111,18 @@ _store_header_pair_from_gstring (GHashTable *header_table, GString *header_line)
        
        g_assert (header_table);
        if ( (header_line) && (header_line->str) ) {
-               dich_result = g_string_dichotomy(header_line, ':', &header_name, &header_value, DICHOTOMY_NONE);
+               dich_result = g_string_dichotomy (
+                       header_line, ':', &header_name, &header_value,
+                       GSTRING_DICHOTOMY_NONE);
                if (dich_result != 'o')
                        camel_log(WARNING, 
                                  "store_header_pair_from_gstring : dichotomy result is %c"
                                  "header line is :\n--\n%s\n--\n");
                
                else {
-                       g_string_trim (header_value, " \t", TRIM_STRIP_LEADING | TRIM_STRIP_TRAILING);
+                       g_string_trim (
+                               header_value, " \t",
+                               GSTRING_TRIM_STRIP_LEADING | GSTRING_TRIM_STRIP_TRAILING);
                        g_hash_table_insert (header_table, header_name, header_value);
                }
        }
index c48a98d..89cd263 100644 (file)
@@ -23,7 +23,7 @@
 
 
 
-
+#include <config.h>
 #include "gstring-util.h"
 #include "camel-log.h"
 
@@ -64,7 +64,14 @@ g_string_clone(GString *string)
 
 
 /**
- * g_string_dichotomy : return the strings before and/or after 
+ * 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
@@ -75,17 +82,12 @@ g_string_clone(GString *string)
  * 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_dichotomy (GString *string, gchar sep, GString **prefix, GString **suffix, DichotomyOption options)
+g_string_dichotomy (GString *string, gchar sep, GString **prefix, GString **suffix,
+                   GStringDichotomyOption options)
 {
        gchar *str, *tmp;
        gint pos, len, first;
@@ -96,17 +98,19 @@ g_string_dichotomy (GString *string, gchar sep, GString **prefix, GString **suff
        g_assert( tmp=string->str );
        len = strlen(tmp);
        if (!len) {
-               if (prefix) *prefix=NULL;
-               if (suffix) *suffix=NULL;
+               if (prefix)
+                       *prefix=NULL;
+               if (suffix)
+                       *suffix=NULL;
                CAMEL_LOG(FULL_DEBUG,"string_dichotomy: string is empty\n");
                return 'n';
        }
        first = 0;
        
-       if ( (options & DICHOTOMY_STRIP_LEADING ) && (tmp[first] == sep) )
+       if ( (options & GSTRING_DICHOTOMY_STRIP_LEADING ) && (tmp[first] == sep) )
            do {first++;} while ( (first<len) && (tmp[first] == sep) );
        
-       if (options & DICHOTOMY_STRIP_TRAILING )
+       if (options & GSTRING_DICHOTOMY_STRIP_TRAILING )
                while (tmp[len-1] == sep)
                        len--;
        
@@ -117,7 +121,7 @@ g_string_dichotomy (GString *string, gchar sep, GString **prefix, GString **suff
                return 'n';
        }
        
-       if (options & DICHOTOMY_RIGHT_DIR) {
+       if (options & GSTRING_DICHOTOMY_RIGHT_DIR) {
                pos = len;
                
                do {
@@ -253,7 +257,7 @@ g_string_list_free (GList *string_list)
 
 
 GList *
-g_string_split (GString *string, char sep, gchar *trim_chars, TrimOption trim_options)
+g_string_split (GString *string, char sep, gchar *trim_chars, GStringTrimOption trim_options)
 {
        GList *result = NULL;
        gint first, last, pos;
@@ -296,10 +300,8 @@ g_string_split (GString *string, char sep, gchar *trim_chars, TrimOption trim_op
 }
 
 
-
-
 void 
-g_string_trim (GString *string, gchar *chars, TrimOption options)
+g_string_trim (GString *string, gchar *chars, GStringTrimOption options)
 {
        gint first_ok;
        gint last_ok;
@@ -308,24 +310,31 @@ g_string_trim (GString *string, gchar *chars, TrimOption options)
 
        CAMEL_LOG(FULL_DEBUG,"**\nentering g_string_trim::\n");
 
-       if ((!string) || (!string->str)) return; 
+       if ((!string) || (!string->str))
+               return; 
        str = string->str;
        length = strlen (str);
-       if (!length) return;
+       if (!length)
+               return;
 
        first_ok = 0;
        last_ok = length - 1;
        
        CAMEL_LOG (FULL_DEBUG,"g_string_trim:: trim_options:%d\n", options);
-       if (options & TRIM_STRIP_LEADING)
+       if (options & GSTRING_TRIM_STRIP_LEADING)
                while  ( (first_ok <= last_ok) && (strchr (chars, str[first_ok])) )
                        first_ok++;
 
-       if (options & TRIM_STRIP_TRAILING)
+       if (options & GSTRING_TRIM_STRIP_TRAILING)
                while  ( (first_ok <= last_ok) && (strchr (chars, str[last_ok])) )
                        last_ok++;
-       CAMEL_LOG (FULL_DEBUG,"g_string_trim::\n\t\"%s\":first ok:%d last_ok:%d\n", string->str, first_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);
+       CAMEL_LOG (FULL_DEBUG,"g_string_trim::\n\t\"%s\":first ok:%d last_ok:%d\n",
+                  string->str, first_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);
        
 }
index 4198958..7a82f9a 100644 (file)
@@ -35,33 +35,37 @@ extern "C" {
 #include <glib.h>
 
 typedef enum {
-    DICHOTOMY_NONE            =     0,
-    DICHOTOMY_RIGHT_DIR       =     1,
-    DICHOTOMY_STRIP_TRAILING  =     2,
-    DICHOTOMY_STRIP_LEADING   =     4,
+    GSTRING_DICHOTOMY_NONE            =     0,
+    GSTRING_DICHOTOMY_RIGHT_DIR       =     1,
+    GSTRING_DICHOTOMY_STRIP_TRAILING  =     2,
+    GSTRING_DICHOTOMY_STRIP_LEADING   =     4,
     
-} DichotomyOption;
+} GStringDichotomyOption;
 
 typedef enum {
-    TRIM_NONE            =     0,
-    TRIM_STRIP_TRAILING  =     1,
-    TRIM_STRIP_LEADING   =     2,
-    
-} TrimOption;
+    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);
-gchar g_string_dichotomy( GString *string, gchar sep, GString **prefix, GString **suffix, DichotomyOption options);
-void g_string_append_g_string(GString *dest_string, GString *other_string);
+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);
 
-gboolean g_string_equal_for_hash (gconstpointer v, gconstpointer v2);
+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);
+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, TrimOption trim_options);
-void g_string_trim (GString *string, gchar *chars, TrimOption options);
+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
 }
index 1b78438..b9ee4c6 100644 (file)
@@ -34,7 +34,7 @@
 /*
   XXX TODO: recover  the words between #'s or ?'s after the path */
 
-
+#include <config.h>
 #include "url-util.h"
 
 /* general item finder */