aboutsummaryrefslogtreecommitdiffstats
path: root/camel/gstring-util.c
diff options
context:
space:
mode:
authorMiguel de Icaza <miguel@gnu.org>1999-07-15 08:11:56 +0800
committerArturo Espinosa <unammx@src.gnome.org>1999-07-15 08:11:56 +0800
commitfce26238c489db149f63164f13adf4bdb83d6062 (patch)
treef05ffd69d069044bcdb28e6d0d768239bc489e03 /camel/gstring-util.c
parent68f3afb7a29764be0389cb5a7b9960357e957412 (diff)
downloadgsoc2013-evolution-fce26238c489db149f63164f13adf4bdb83d6062.tar
gsoc2013-evolution-fce26238c489db149f63164f13adf4bdb83d6062.tar.gz
gsoc2013-evolution-fce26238c489db149f63164f13adf4bdb83d6062.tar.bz2
gsoc2013-evolution-fce26238c489db149f63164f13adf4bdb83d6062.tar.lz
gsoc2013-evolution-fce26238c489db149f63164f13adf4bdb83d6062.tar.xz
gsoc2013-evolution-fce26238c489db149f63164f13adf4bdb83d6062.tar.zst
gsoc2013-evolution-fce26238c489db149f63164f13adf4bdb83d6062.zip
Implemented base64 encoder based on CamelStreams. Should the
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 svn path=/trunk/; revision=1024
Diffstat (limited to 'camel/gstring-util.c')
-rw-r--r--camel/gstring-util.c59
1 files changed, 34 insertions, 25 deletions
diff --git a/camel/gstring-util.c b/camel/gstring-util.c
index c48a98d410..89cd263e85 100644
--- a/camel/gstring-util.c
+++ b/camel/gstring-util.c
@@ -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);
}