aboutsummaryrefslogtreecommitdiffstats
path: root/camel
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2001-04-27 03:44:50 +0800
committerDan Winship <danw@src.gnome.org>2001-04-27 03:44:50 +0800
commit84e075645b9013f6c0f8200ebddee10b1904936a (patch)
tree74f643de637d9d67844a018ac34354a6872184a0 /camel
parent8605f534604aea28d0ebe6385f0f04c7df2a34c7 (diff)
downloadgsoc2013-evolution-84e075645b9013f6c0f8200ebddee10b1904936a.tar
gsoc2013-evolution-84e075645b9013f6c0f8200ebddee10b1904936a.tar.gz
gsoc2013-evolution-84e075645b9013f6c0f8200ebddee10b1904936a.tar.bz2
gsoc2013-evolution-84e075645b9013f6c0f8200ebddee10b1904936a.tar.lz
gsoc2013-evolution-84e075645b9013f6c0f8200ebddee10b1904936a.tar.xz
gsoc2013-evolution-84e075645b9013f6c0f8200ebddee10b1904936a.tar.zst
gsoc2013-evolution-84e075645b9013f6c0f8200ebddee10b1904936a.zip
New file, with the int, string, time_t, and off_t encode/decode routines
* camel-file-utils.c: New file, with the int, string, time_t, and off_t encode/decode routines from camel-folder-summary.c moved here and renamed, for the enjoyment of non-CamelFolderSummary subclasses. * Makefile.am (libcamel_la_SOURCES): Add camel-file-utils.c (libcamelinclude_HEADERS): and camel-file-utils.h * camel-folder-summary.c: Remove functions that were moved to camel-file-utils.c, update uses of them for the new names. (camel_folder_summary_{en,de}code_token are still here.) * providers/local/camel-mbox-summary.c: Use camel_file_util_* names * providers/imap/camel-imap-summary.c: Use camel_file_util_* names * providers/imap/camel-imap-store.c (imap_store_setup_online, imap_store_setup_offline): Use camel_file_util_* names, which makes much more sense since this isn't folder summary stuff. svn path=/trunk/; revision=9590
Diffstat (limited to 'camel')
-rw-r--r--camel/ChangeLog23
-rw-r--r--camel/Makefile.am2
-rw-r--r--camel/camel-file-utils.c283
-rw-r--r--camel/camel-file-utils.h54
-rw-r--r--camel/camel-folder-summary.c395
-rw-r--r--camel/camel-folder-summary.h12
-rw-r--r--camel/providers/imap/camel-imap-store.c21
-rw-r--r--camel/providers/imap/camel-imap-summary.c11
-rw-r--r--camel/providers/local/camel-mbox-summary.c9
9 files changed, 447 insertions, 363 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index a65bb55a07..b45e43bb2b 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,5 +1,28 @@
2001-04-26 Dan Winship <danw@ximian.com>
+ * camel-file-utils.c: New file, with the int, string, time_t, and
+ off_t encode/decode routines from camel-folder-summary.c moved
+ here and renamed, for the enjoyment of non-CamelFolderSummary
+ subclasses.
+
+ * Makefile.am (libcamel_la_SOURCES): Add camel-file-utils.c
+ (libcamelinclude_HEADERS): and camel-file-utils.h
+
+ * camel-folder-summary.c: Remove functions that were moved to
+ camel-file-utils.c, update uses of them for the new names.
+ (camel_folder_summary_{en,de}code_token are still here.)
+
+ * providers/local/camel-mbox-summary.c: Use camel_file_util_*
+ names
+
+ * providers/imap/camel-imap-summary.c: Use camel_file_util_* names
+
+ * providers/imap/camel-imap-store.c (imap_store_setup_online,
+ imap_store_setup_offline): Use camel_file_util_* names, which
+ makes much more sense since this isn't folder summary stuff.
+
+2001-04-26 Dan Winship <danw@ximian.com>
+
* Makefile.am (INCLUDES): Remove UNICODE_CFLAGS (and some other
stuff that's redundant with EXTRA_GNOME_CFLAGS)
(libcamel_la_LIBADD): Replace UNICODE_LIBS with GAL_LIBS.
diff --git a/camel/Makefile.am b/camel/Makefile.am
index 5c24cd06df..53f7befbfe 100644
--- a/camel/Makefile.am
+++ b/camel/Makefile.am
@@ -25,6 +25,7 @@ libcamel_la_SOURCES = \
camel-data-wrapper.c \
camel-digest-folder.c \
camel-exception.c \
+ camel-file-utils.c \
camel-filter-driver.c \
camel-filter-search.c \
camel-folder-search.c \
@@ -101,6 +102,7 @@ libcamelinclude_HEADERS = \
camel-digest-folder.h \
camel-exception-list.def \
camel-exception.h \
+ camel-file-utils.h \
camel-filter-driver.h \
camel-filter-search.h \
camel-folder-search.h \
diff --git a/camel/camel-file-utils.c b/camel/camel-file-utils.c
new file mode 100644
index 0000000000..1b0fe65dbb
--- /dev/null
+++ b/camel/camel-file-utils.c
@@ -0,0 +1,283 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/*
+ * Authors:
+ * Michael Zucchi <notzed@ximian.com>
+ * Dan Winship <danw@ximian.com>
+ *
+ * Copyright (C) 2000, 2001 Ximian, Inc.
+ *
+ * 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-file-utils.h"
+
+#include <netinet/in.h>
+
+/**
+ * camel_file_util_encode_uint32:
+ * @out: file to output to
+ * @value: value to output
+ *
+ * Utility function to save an uint32 to a file.
+ *
+ * Return value: 0 on success, -1 on error.
+ **/
+int
+camel_file_util_encode_uint32 (FILE *out, guint32 value)
+{
+ int i;
+
+ for (i = 28; i > 0; i -= 7) {
+ if (value >= (1 << i)) {
+ unsigned int c = (value >> i) & 0x7f;
+ if (fputc (c, out) == -1)
+ return -1;
+ }
+ }
+ return fputc (value | 0x80, out);
+}
+
+/**
+ * camel_file_util_decode_uint32:
+ * @in: file to read from
+ * @dest: pointer to a variable to store the value in
+ *
+ * Retrieve an encoded uint32 from a file.
+ *
+ * Return value: 0 on success, -1 on error. @*dest will contain the
+ * decoded value.
+ **/
+int
+camel_file_util_decode_uint32 (FILE *in, guint32 *dest)
+{
+ guint32 value = 0;
+ int v;
+
+ /* until we get the last byte, keep decoding 7 bits at a time */
+ while ( ((v = fgetc (in)) & 0x80) == 0 && v!=EOF) {
+ value |= v;
+ value <<= 7;
+ }
+ if (v == EOF) {
+ *dest = value >> 7;
+ return -1;
+ }
+ *dest = value | (v & 0x7f);
+
+ return 0;
+}
+
+/**
+ * camel_file_util_encode_fixed_int32:
+ * @out: file to output to
+ * @value: value to output
+ *
+ * Encode a gint32, performing no compression, but converting
+ * to network order.
+ *
+ * Return value: 0 on success, -1 on error.
+ **/
+int
+camel_file_util_encode_fixed_int32 (FILE *out, gint32 value)
+{
+ guint32 save;
+
+ save = htonl (value);
+ if (fwrite (&save, sizeof (save), 1, out) != 1)
+ return -1;
+ return 0;
+}
+
+/**
+ * camel_file_util_decode_fixed_int32:
+ * @in: file to read from
+ * @dest: pointer to a variable to store the value in
+ *
+ * Retrieve a gint32.
+ *
+ * Return value: 0 on success, -1 on error.
+ **/
+int
+camel_file_util_decode_fixed_int32 (FILE *in, gint32 *dest)
+{
+ guint32 save;
+
+ if (fread (&save, sizeof (save), 1, in) == 1) {
+ *dest = ntohl (save);
+ return 0;
+ } else {
+ return -1;
+ }
+}
+
+/**
+ * camel_file_util_encode_time_t:
+ * @out: file to output to
+ * @value: value to output
+ *
+ * Encode a time_t value to the file.
+ *
+ * Return value: 0 on success, -1 on error.
+ **/
+int
+camel_file_util_encode_time_t(FILE *out, time_t value)
+{
+ int i;
+
+ for (i = sizeof (time_t) - 1; i >= 0; i--) {
+ if (fputc((value >> (i * 8)) & 0xff, out) == -1)
+ return -1;
+ }
+ return 0;
+}
+
+/**
+ * camel_file_util_decode_time_t:
+ * @in: file to read from
+ * @dest: pointer to a variable to store the value in
+ *
+ * Decode a time_t value.
+ *
+ * Return value: 0 on success, -1 on error.
+ **/
+int
+camel_file_util_decode_time_t (FILE *in, time_t *dest)
+{
+ time_t save = 0;
+ int v, i = sizeof (time_t) - 1;
+
+ while (i >= 0 && (v = fgetc (in)) != EOF) {
+ save |= ((time_t)v) << (i * 8);
+ i--;
+ }
+ *dest = save;
+ if (v == EOF)
+ return -1;
+ return 0;
+}
+
+/**
+ * camel_file_util_encode_off_t:
+ * @out: file to output to
+ * @value: value to output
+ *
+ * Encode an off_t type.
+ *
+ * Return value: 0 on success, -1 on error.
+ **/
+int
+camel_file_util_encode_off_t (FILE *out, off_t value)
+{
+ int i;
+
+ for (i = sizeof (off_t) - 1; i >= 0; i--) {
+ if (fputc ((value >> (i * 8)) & 0xff, out) == -1)
+ return -1;
+ }
+ return 0;
+}
+
+/**
+ * camel_file_util_decode_off_t:
+ * @in: file to read from
+ * @dest: pointer to a variable to put the value in
+ *
+ * Decode an off_t type.
+ *
+ * Return value: 0 on success, -1 on failure.
+ **/
+int
+camel_file_util_decode_off_t (FILE *in, off_t *dest)
+{
+ off_t save = 0;
+ int v, i = sizeof(off_t) - 1;
+
+ while (i >= 0 && (v = fgetc (in)) != EOF) {
+ save |= ((off_t)v) << (i * 8);
+ i--;
+ }
+ *dest = save;
+ if (v == EOF)
+ return -1;
+ return 0;
+}
+
+/**
+ * camel_file_util_encode_string:
+ * @out: file to output to
+ * @str: value to output
+ *
+ * Encode a normal string and save it in the output file.
+ *
+ * Return value: 0 on success, -1 on error.
+ **/
+int
+camel_file_util_encode_string (FILE *out, const char *str)
+{
+ register int len;
+
+ if (str == NULL)
+ return camel_file_util_encode_uint32 (out, 0);
+
+ len = strlen (str);
+ if (camel_file_util_encode_uint32 (out, len+1) == -1)
+ return -1;
+ if (fwrite (str, len, 1, out) == 1)
+ return 0;
+ return -1;
+}
+
+/**
+ * camel_file_util_decode_string:
+ * @in: file to read from
+ * @str: pointer to a variable to store the value in
+ *
+ * Decode a normal string from the input file.
+ *
+ * Return value: 0 on success, -1 on error.
+ **/
+int
+camel_file_util_decode_string (FILE *in, char **str)
+{
+ guint32 len;
+ register char *ret;
+
+ if (camel_file_util_decode_uint32 (in, &len) == -1) {
+ *str = NULL;
+ return -1;
+ }
+
+ len--;
+ if (len > 65536) {
+ *str = NULL;
+ return -1;
+ }
+
+ ret = g_malloc (len+1);
+ if (fread (ret, len, 1, in) != 1) {
+ g_free (ret);
+ *str = NULL;
+ return -1;
+ }
+
+ ret[len] = 0;
+ *str = ret;
+ return 0;
+}
+
+
diff --git a/camel/camel-file-utils.h b/camel/camel-file-utils.h
new file mode 100644
index 0000000000..e0972583bd
--- /dev/null
+++ b/camel/camel-file-utils.h
@@ -0,0 +1,54 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/*
+ * Authors:
+ * Michael Zucchi <notzed@ximian.com>
+ * Dan Winship <danw@ximian.com>
+ *
+ * Copyright (C) 2000, 2001 Ximian, Inc.
+ *
+ * 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_FILE_UTILS_H
+#define CAMEL_FILE_UTILS_H 1
+
+#ifdef __cplusplus
+extern "C" {
+#pragma }
+#endif /* __cplusplus }*/
+
+#include <glib.h>
+#include <stdio.h>
+#include <time.h>
+
+int camel_file_util_encode_fixed_int32 (FILE *out, gint32);
+int camel_file_util_decode_fixed_int32 (FILE *in, gint32 *);
+int camel_file_util_encode_uint32 (FILE *out, guint32);
+int camel_file_util_decode_uint32 (FILE *in, guint32 *);
+int camel_file_util_encode_time_t (FILE *out, time_t);
+int camel_file_util_decode_time_t (FILE *in, time_t *);
+int camel_file_util_encode_off_t (FILE *out, off_t);
+int camel_file_util_decode_off_t (FILE *in, off_t *);
+int camel_file_util_encode_string (FILE *out, const char *);
+int camel_file_util_decode_string (FILE *in, char **);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* CAMEL_FILE_UTILS_H */
diff --git a/camel/camel-folder-summary.c b/camel/camel-folder-summary.c
index 2627007294..e9b60cebc2 100644
--- a/camel/camel-folder-summary.c
+++ b/camel/camel-folder-summary.c
@@ -24,7 +24,6 @@
#endif
#include <unistd.h>
-#include <netinet/in.h>
#include <ctype.h>
#include <string.h>
#include <errno.h>
@@ -32,9 +31,7 @@
#include "camel-folder-summary.h"
-#include <camel/camel-mime-message.h>
-#include <camel/camel-multipart.h>
-
+#include <camel/camel-file-utils.h>
#include <camel/camel-mime-filter.h>
#include <camel/camel-mime-filter-index.h>
#include <camel/camel-mime-filter-charset.h>
@@ -42,6 +39,7 @@
#include <camel/camel-mime-filter-basic.h>
#include <camel/camel-mime-filter-html.h>
#include <camel/camel-mime-message.h>
+#include <camel/camel-multipart.h>
#include <camel/camel-stream-mem.h>
#include "hash-table-utils.h"
@@ -508,7 +506,7 @@ perform_content_info_load(CamelFolderSummary *s, FILE *in)
if (ci == NULL)
return NULL;
- if (camel_folder_summary_decode_uint32(in, &count) == -1 || count > 500) {
+ if (camel_file_util_decode_uint32(in, &count) == -1 || count > 500) {
camel_folder_summary_content_info_free(s, ci);
return NULL;
}
@@ -587,7 +585,7 @@ perform_content_info_save(CamelFolderSummary *s, FILE *out, CamelMessageContentI
CamelMessageContentInfo *part;
((CamelFolderSummaryClass *)(CAMEL_OBJECT_GET_CLASS(s)))->content_info_save(s, out, ci);
- camel_folder_summary_encode_uint32(out, my_list_size((struct _node **)&ci->childs));
+ camel_file_util_encode_uint32(out, my_list_size((struct _node **)&ci->childs));
part = ci->childs;
while (part) {
perform_content_info_save(s, out, part);
@@ -1067,200 +1065,6 @@ void camel_folder_summary_remove_index(CamelFolderSummary *s, int index)
}
}
-/**
- * camel_folder_summary_encode_uint32:
- * @out:
- * @value:
- *
- * Utility function to save an uint32 to a file.
- *
- * Return value: -1 on error.
- **/
-int
-camel_folder_summary_encode_uint32(FILE *out, guint32 value)
-{
- int i;
-
- io(printf("Encoding int %u\n", value));
-
- for (i=28;i>0;i-=7) {
- if (value >= (1<<i)) {
- unsigned int c = (value>>i) & 0x7f;
- if (fputc(c, out) == -1)
- return -1;
- }
- }
- return fputc(value | 0x80, out);
-}
-
-/**
- * camel_folder_summary_decode_uint32:
- * @in:
- * @dest:
- *
- * Retrieve an encoded uint32 from a file.
- *
- * Return value: -1 on error. @*dest will contain the
- * decoded value.
- **/
-int
-camel_folder_summary_decode_uint32(FILE *in, guint32 *dest)
-{
- guint32 value=0, v;
-
- /* until we get the last byte, keep decoding 7 bits at a time */
- while ( ((v = fgetc(in)) & 0x80) == 0 && v!=EOF) {
- value |= v;
- value <<= 7;
- }
- if (v == EOF) {
- *dest = value>>7;
- return -1;
- }
- *dest = value | (v&0x7f);
-
- io(printf("Decoding int %u\n", *dest));
-
- return 0;
-}
-
-/**
- * camel_folder_summary_encode_fixed_int32:
- * @out:
- * @value:
- *
- * Encode a gint32, performing no compression, but converting
- * to network order.
- *
- * Return value: -1 on error.
- **/
-int
-camel_folder_summary_encode_fixed_int32(FILE *out, gint32 value)
-{
- guint32 save;
-
- save = htonl(value);
- if (fwrite(&save, sizeof(save), 1, out) != 1)
- return -1;
- return 0;
-}
-
-/**
- * camel_folder_summary_decode_fixed_int32:
- * @in:
- * @dest:
- *
- * Retrieve a gint32.
- *
- * Return value: -1 on error.
- **/
-int
-camel_folder_summary_decode_fixed_int32(FILE *in, gint32 *dest)
-{
- guint32 save;
-
- if (fread(&save, sizeof(save), 1, in) == 1) {
- *dest = ntohl(save);
- return 0;
- } else {
- return -1;
- }
-}
-
-/**
- * camel_folder_summary_encode_time_t:
- * @out:
- * @value:
- *
- * Encode a time_t value to the file.
- *
- * Return value: -1 on error.
- **/
-int
-camel_folder_summary_encode_time_t(FILE *out, time_t value)
-{
- int i;
-
- for (i=sizeof(time_t)-1;i>=0;i--) {
- if (fputc((value >> (i*8)) & 0xff, out) == -1)
- return -1;
- }
- return 0;
-}
-
-/**
- * camel_folder_summary_decode_time_t:
- * @in:
- * @dest:
- *
- * Decode a time_t value.
- *
- * Return value: -1 on error.
- **/
-int
-camel_folder_summary_decode_time_t(FILE *in, time_t *dest)
-{
- time_t save = 0;
- unsigned int v;
- int i = sizeof(time_t) - 1;
-
- while ( i>=0 && (v = fgetc(in)) != EOF) {
- save |= v << (i*8);
- i--;
- }
- *dest = save;
- if (v == EOF)
- return -1;
- return 0;
-}
-
-/**
- * camel_folder_summary_encode_off_t:
- * @out:
- * @value:
- *
- * Encode an off_t type.
- *
- * Return value:
- **/
-int
-camel_folder_summary_encode_off_t(FILE *out, off_t value)
-{
- int i;
-
- for (i=sizeof(off_t)-1;i>=0;i--) {
- if (fputc((value >> (i*8)) & 0xff, out) == -1)
- return -1;
- }
- return 0;
-}
-
-/**
- * camel_folder_summary_decode_off_t:
- * @in:
- * @dest:
- *
- * Decode an off_t type.
- *
- * Return value:
- **/
-int
-camel_folder_summary_decode_off_t(FILE *in, off_t *dest)
-{
- off_t save = 0;
- unsigned int v;
- int i = sizeof(off_t) - 1;
-
- while ( i>=0 && (v = fgetc(in)) != EOF) {
- save |= v << (i*8);
- i--;
- }
- *dest = save;
- if (v == EOF)
- return -1;
- return 0;
-}
-
/* should be sorted, for binary search */
/* This is a tokenisation mechanism for strings written to the
summary - to save space.
@@ -1327,7 +1131,7 @@ camel_folder_summary_encode_token(FILE *out, const char *str)
io(printf("Encoding token: '%s'\n", str));
if (str == NULL) {
- return camel_folder_summary_encode_uint32(out, 0);
+ return camel_file_util_encode_uint32(out, 0);
} else {
int len = strlen(str);
int i, token=-1;
@@ -1353,9 +1157,9 @@ camel_folder_summary_encode_token(FILE *out, const char *str)
#endif
}
if (token != -1) {
- return camel_folder_summary_encode_uint32(out, token+1);
+ return camel_file_util_encode_uint32(out, token+1);
} else {
- if (camel_folder_summary_encode_uint32(out, len+32) == -1)
+ if (camel_file_util_encode_uint32(out, len+32) == -1)
return -1;
if (fwrite(str, len, 1, out) != 1)
return -1;
@@ -1381,7 +1185,7 @@ camel_folder_summary_decode_token(FILE *in, char **str)
io(printf("Decode token ...\n"));
- if (camel_folder_summary_decode_uint32(in, &len) == -1) {
+ if (camel_file_util_decode_uint32(in, &len) == -1) {
g_warning("Could not decode token from file");
*str = NULL;
return -1;
@@ -1418,77 +1222,6 @@ camel_folder_summary_decode_token(FILE *in, char **str)
return 0;
}
-/**
- * camel_folder_summary_encode_string:
- * @out:
- * @str:
- *
- * Encode a normal string and save it in the output file.
- *
- * Return value: -1 on error.
- **/
-int
-camel_folder_summary_encode_string(FILE *out, const char *str)
-{
- register int len;
-
- io(printf("Encoding string: '%s'\n", str));
-
- if (str == NULL)
- return camel_folder_summary_encode_uint32(out, 0);
-
- len = strlen(str);
- if (camel_folder_summary_encode_uint32(out, len+1) == -1)
- return -1;
- if (fwrite(str, len, 1, out) == 1)
- return 0;
- return -1;
-}
-
-
-/**
- * camel_folder_summary_decode_string:
- * @in:
- * @str:
- *
- * Decode a normal string from the input file.
- *
- * Return value: -1 on error.
- **/
-int
-camel_folder_summary_decode_string(FILE *in, char **str)
-{
- guint32 len;
- register char *ret;
-
- io(printf("Decode string ...\n", str));
-
- if (camel_folder_summary_decode_uint32(in, &len) == -1) {
- *str = NULL;
- return -1;
- }
-
- len--;
- if (len > 65536) {
- *str = NULL;
- io(printf("String = '%s'\n", *str));
- return -1;
- }
-
- ret = g_malloc(len+1);
- if (fread(ret, len, 1, in) != 1) {
- g_free(ret);
- *str = NULL;
- return -1;
- }
-
- io(printf("String = '%s'\n", ret));
-
- ret[len] = 0;
- *str = ret;
- return 0;
-}
-
static struct _node *
my_list_append(struct _node **list, struct _node *n)
{
@@ -1522,11 +1255,11 @@ summary_header_load(CamelFolderSummary *s, FILE *in)
io(printf("Loading header\n"));
- if (camel_folder_summary_decode_fixed_int32(in, &version) == -1
- || camel_folder_summary_decode_fixed_int32(in, &flags) == -1
- || camel_folder_summary_decode_fixed_int32(in, &nextuid) == -1
- || camel_folder_summary_decode_time_t(in, &time) == -1
- || camel_folder_summary_decode_fixed_int32(in, &count) == -1) {
+ if (camel_file_util_decode_fixed_int32(in, &version) == -1
+ || camel_file_util_decode_fixed_int32(in, &flags) == -1
+ || camel_file_util_decode_fixed_int32(in, &nextuid) == -1
+ || camel_file_util_decode_time_t(in, &time) == -1
+ || camel_file_util_decode_fixed_int32(in, &count) == -1) {
return -1;
}
@@ -1548,11 +1281,11 @@ summary_header_save(CamelFolderSummary *s, FILE *out)
io(printf("Savining header\n"));
- camel_folder_summary_encode_fixed_int32(out, s->version);
- camel_folder_summary_encode_fixed_int32(out, s->flags);
- camel_folder_summary_encode_fixed_int32(out, s->nextuid);
- camel_folder_summary_encode_time_t(out, s->time);
- return camel_folder_summary_encode_fixed_int32(out, camel_folder_summary_count(s));
+ camel_file_util_encode_fixed_int32(out, s->version);
+ camel_file_util_encode_fixed_int32(out, s->flags);
+ camel_file_util_encode_fixed_int32(out, s->nextuid);
+ camel_file_util_encode_time_t(out, s->time);
+ return camel_file_util_encode_fixed_int32(out, camel_folder_summary_count(s));
}
/* are these even useful for anything??? */
@@ -1799,16 +1532,16 @@ message_info_load(CamelFolderSummary *s, FILE *in)
io(printf("Loading message info\n"));
- camel_folder_summary_decode_string(in, &uid);
- camel_folder_summary_decode_uint32(in, &mi->flags);
- camel_folder_summary_decode_uint32(in, &mi->size);
- camel_folder_summary_decode_time_t(in, &mi->date_sent);
- camel_folder_summary_decode_time_t(in, &mi->date_received);
- camel_folder_summary_decode_string(in, &subject);
- camel_folder_summary_decode_string(in, &from);
- camel_folder_summary_decode_string(in, &to);
- camel_folder_summary_decode_string(in, &cc);
- camel_folder_summary_decode_string(in, &mlist);
+ camel_file_util_decode_string(in, &uid);
+ camel_file_util_decode_uint32(in, &mi->flags);
+ camel_file_util_decode_uint32(in, &mi->size);
+ camel_file_util_decode_time_t(in, &mi->date_sent);
+ camel_file_util_decode_time_t(in, &mi->date_received);
+ camel_file_util_decode_string(in, &subject);
+ camel_file_util_decode_string(in, &from);
+ camel_file_util_decode_string(in, &to);
+ camel_file_util_decode_string(in, &cc);
+ camel_file_util_decode_string(in, &mlist);
#ifdef DOEPOOLV
e_poolv_set(mi->strings, CAMEL_MESSAGE_INFO_UID, uid, TRUE);
@@ -1835,38 +1568,38 @@ message_info_load(CamelFolderSummary *s, FILE *in)
mi->content = NULL;
- camel_folder_summary_decode_fixed_int32(in, &mi->message_id.id.part.hi);
- camel_folder_summary_decode_fixed_int32(in, &mi->message_id.id.part.lo);
+ camel_file_util_decode_fixed_int32(in, &mi->message_id.id.part.hi);
+ camel_file_util_decode_fixed_int32(in, &mi->message_id.id.part.lo);
- if (camel_folder_summary_decode_uint32(in, &count) == -1 || count > 500)
+ if (camel_file_util_decode_uint32(in, &count) == -1 || count > 500)
goto error;
if (count > 0) {
mi->references = g_malloc(sizeof(*mi->references) + ((count-1) * sizeof(mi->references->references[0])));
mi->references->size = count;
for (i=0;i<count;i++) {
- camel_folder_summary_decode_fixed_int32(in, &mi->references->references[i].id.part.hi);
- camel_folder_summary_decode_fixed_int32(in, &mi->references->references[i].id.part.lo);
+ camel_file_util_decode_fixed_int32(in, &mi->references->references[i].id.part.hi);
+ camel_file_util_decode_fixed_int32(in, &mi->references->references[i].id.part.lo);
}
}
- if (camel_folder_summary_decode_uint32(in, &count) == -1 || count > 500)
+ if (camel_file_util_decode_uint32(in, &count) == -1 || count > 500)
goto error;
for (i=0;i<count;i++) {
char *name;
- camel_folder_summary_decode_string(in, &name);
+ camel_file_util_decode_string(in, &name);
camel_flag_set(&mi->user_flags, name, TRUE);
g_free(name);
}
- if (camel_folder_summary_decode_uint32(in, &count) == -1 || count > 500)
+ if (camel_file_util_decode_uint32(in, &count) == -1 || count > 500)
goto error;
for (i=0;i<count;i++) {
char *name, *value;
- camel_folder_summary_decode_string(in, &name);
- camel_folder_summary_decode_string(in, &value);
+ camel_file_util_decode_string(in, &name);
+ camel_file_util_decode_string(in, &value);
camel_tag_set(&mi->user_tags, name, value);
g_free(name);
g_free(value);
@@ -1891,44 +1624,44 @@ message_info_save(CamelFolderSummary *s, FILE *out, CamelMessageInfo *mi)
io(printf("Saving message info\n"));
- camel_folder_summary_encode_string(out, camel_message_info_uid(mi));
- camel_folder_summary_encode_uint32(out, mi->flags);
- camel_folder_summary_encode_uint32(out, mi->size);
- camel_folder_summary_encode_time_t(out, mi->date_sent);
- camel_folder_summary_encode_time_t(out, mi->date_received);
- camel_folder_summary_encode_string(out, camel_message_info_subject(mi));
- camel_folder_summary_encode_string(out, camel_message_info_from(mi));
- camel_folder_summary_encode_string(out, camel_message_info_to(mi));
- camel_folder_summary_encode_string(out, camel_message_info_cc(mi));
- camel_folder_summary_encode_string(out, camel_message_info_mlist(mi));
+ camel_file_util_encode_string(out, camel_message_info_uid(mi));
+ camel_file_util_encode_uint32(out, mi->flags);
+ camel_file_util_encode_uint32(out, mi->size);
+ camel_file_util_encode_time_t(out, mi->date_sent);
+ camel_file_util_encode_time_t(out, mi->date_received);
+ camel_file_util_encode_string(out, camel_message_info_subject(mi));
+ camel_file_util_encode_string(out, camel_message_info_from(mi));
+ camel_file_util_encode_string(out, camel_message_info_to(mi));
+ camel_file_util_encode_string(out, camel_message_info_cc(mi));
+ camel_file_util_encode_string(out, camel_message_info_mlist(mi));
- camel_folder_summary_encode_fixed_int32(out, mi->message_id.id.part.hi);
- camel_folder_summary_encode_fixed_int32(out, mi->message_id.id.part.lo);
+ camel_file_util_encode_fixed_int32(out, mi->message_id.id.part.hi);
+ camel_file_util_encode_fixed_int32(out, mi->message_id.id.part.lo);
if (mi->references) {
- camel_folder_summary_encode_uint32(out, mi->references->size);
+ camel_file_util_encode_uint32(out, mi->references->size);
for (i=0;i<mi->references->size;i++) {
- camel_folder_summary_encode_fixed_int32(out, mi->references->references[i].id.part.hi);
- camel_folder_summary_encode_fixed_int32(out, mi->references->references[i].id.part.lo);
+ camel_file_util_encode_fixed_int32(out, mi->references->references[i].id.part.hi);
+ camel_file_util_encode_fixed_int32(out, mi->references->references[i].id.part.lo);
}
} else {
- camel_folder_summary_encode_uint32(out, 0);
+ camel_file_util_encode_uint32(out, 0);
}
count = camel_flag_list_size(&mi->user_flags);
- camel_folder_summary_encode_uint32(out, count);
+ camel_file_util_encode_uint32(out, count);
flag = mi->user_flags;
while (flag) {
- camel_folder_summary_encode_string(out, flag->name);
+ camel_file_util_encode_string(out, flag->name);
flag = flag->next;
}
count = camel_tag_list_size(&mi->user_tags);
- camel_folder_summary_encode_uint32(out, count);
+ camel_file_util_encode_uint32(out, count);
tag = mi->user_tags;
while (tag) {
- camel_folder_summary_encode_string(out, tag->name);
- camel_folder_summary_encode_string(out, tag->value);
+ camel_file_util_encode_string(out, tag->name);
+ camel_file_util_encode_string(out, tag->value);
tag = tag->next;
}
@@ -1987,7 +1720,7 @@ content_info_load(CamelFolderSummary *s, FILE *in)
ct = header_content_type_new(type, subtype);
g_free(type); /* can this be removed? */
g_free(subtype);
- if (camel_folder_summary_decode_uint32(in, &count) == -1 || count > 500)
+ if (camel_file_util_decode_uint32(in, &count) == -1 || count > 500)
goto error;
for (i=0;i<count;i++) {
@@ -2005,7 +1738,7 @@ content_info_load(CamelFolderSummary *s, FILE *in)
camel_folder_summary_decode_token(in, &ci->description);
camel_folder_summary_decode_token(in, &ci->encoding);
- camel_folder_summary_decode_uint32(in, &ci->size);
+ camel_file_util_decode_uint32(in, &ci->size);
ci->childs = NULL;
@@ -2029,7 +1762,7 @@ content_info_save(CamelFolderSummary *s, FILE *out, CamelMessageContentInfo *ci)
if (ct) {
camel_folder_summary_encode_token(out, ct->type);
camel_folder_summary_encode_token(out, ct->subtype);
- camel_folder_summary_encode_uint32(out, my_list_size((struct _node **)&ct->params));
+ camel_file_util_encode_uint32(out, my_list_size((struct _node **)&ct->params));
hp = ct->params;
while (hp) {
camel_folder_summary_encode_token(out, hp->name);
@@ -2039,12 +1772,12 @@ content_info_save(CamelFolderSummary *s, FILE *out, CamelMessageContentInfo *ci)
} else {
camel_folder_summary_encode_token(out, NULL);
camel_folder_summary_encode_token(out, NULL);
- camel_folder_summary_encode_uint32(out, 0);
+ camel_file_util_encode_uint32(out, 0);
}
camel_folder_summary_encode_token(out, ci->id);
camel_folder_summary_encode_token(out, ci->description);
camel_folder_summary_encode_token(out, ci->encoding);
- return camel_folder_summary_encode_uint32(out, ci->size);
+ return camel_file_util_encode_uint32(out, ci->size);
}
static void
diff --git a/camel/camel-folder-summary.h b/camel/camel-folder-summary.h
index eb1a527a47..6c59915194 100644
--- a/camel/camel-folder-summary.h
+++ b/camel/camel-folder-summary.h
@@ -261,18 +261,6 @@ void camel_folder_summary_array_free(CamelFolderSummary *s, GPtrArray *array);
char *camel_folder_summary_format_address(struct _header_raw *h, const char *name);
char *camel_folder_summary_format_string(struct _header_raw *h, const char *name);
-/* summary file loading/saving helper functions */
-int camel_folder_summary_encode_fixed_int32(FILE *, gint32);
-int camel_folder_summary_decode_fixed_int32(FILE *, gint32 *);
-int camel_folder_summary_encode_uint32(FILE *, guint32);
-int camel_folder_summary_decode_uint32(FILE *, guint32 *);
-int camel_folder_summary_encode_time_t(FILE *out, time_t value);
-int camel_folder_summary_decode_time_t(FILE *in, time_t *dest);
-int camel_folder_summary_encode_off_t(FILE *out, off_t value);
-int camel_folder_summary_decode_off_t(FILE *in, off_t *dest);
-int camel_folder_summary_encode_string(FILE *out, const char *str);
-int camel_folder_summary_decode_string(FILE *in, char **);
-
/* basically like strings, but certain keywords can be compressed and de-cased */
int camel_folder_summary_encode_token(FILE *, const char *);
int camel_folder_summary_decode_token(FILE *, char **);
diff --git a/camel/providers/imap/camel-imap-store.c b/camel/providers/imap/camel-imap-store.c
index 37eb99623c..38f585d6e7 100644
--- a/camel/providers/imap/camel-imap-store.c
+++ b/camel/providers/imap/camel-imap-store.c
@@ -38,6 +38,7 @@
#include "camel-imap-folder.h"
#include "camel-imap-utils.h"
#include "camel-imap-command.h"
+#include "camel-file-utils.h"
#include "camel-folder.h"
#include "camel-exception.h"
#include "camel-session.h"
@@ -568,8 +569,8 @@ imap_store_setup_online (CamelImapStore *store, CamelException *ex)
g_free (path);
/* Write header and capabilities */
- camel_folder_summary_encode_uint32 (storeinfo, IMAP_STOREINFO_VERSION);
- camel_folder_summary_encode_uint32 (storeinfo, store->capabilities);
+ camel_file_util_encode_uint32 (storeinfo, IMAP_STOREINFO_VERSION);
+ camel_file_util_encode_uint32 (storeinfo, store->capabilities);
/* Get namespace and hierarchy separator */
if ((store->capabilities & IMAP_CAPABILITY_NAMESPACE) &&
@@ -636,8 +637,8 @@ imap_store_setup_online (CamelImapStore *store, CamelException *ex)
}
/* Write namespace/separator out */
- camel_folder_summary_encode_string (storeinfo, store->namespace);
- camel_folder_summary_encode_uint32 (storeinfo, store->dir_sep);
+ camel_file_util_encode_string (storeinfo, store->namespace);
+ camel_file_util_encode_uint32 (storeinfo, store->dir_sep);
if (CAMEL_STORE (store)->flags & CAMEL_STORE_SUBSCRIPTIONS) {
/* Get subscribed folders */
@@ -659,7 +660,7 @@ imap_store_setup_online (CamelImapStore *store, CamelException *ex)
}
g_hash_table_insert (store->subscribed_folders, name,
GINT_TO_POINTER (1));
- camel_folder_summary_encode_string (storeinfo, result);
+ camel_file_util_encode_string (storeinfo, result);
}
camel_imap_response_free (response);
}
@@ -680,20 +681,20 @@ imap_store_setup_offline (CamelImapStore *store, CamelException *ex)
g_free (path);
tmp = 0;
if (storeinfo)
- camel_folder_summary_decode_uint32 (storeinfo, &tmp);
+ camel_file_util_decode_uint32 (storeinfo, &tmp);
if (tmp != IMAP_STOREINFO_VERSION) {
/* This must set ex and return FALSE if we're here... */
return camel_imap_store_check_online (store, ex);
}
- camel_folder_summary_decode_uint32 (storeinfo, &store->capabilities);
- camel_folder_summary_decode_string (storeinfo, &store->namespace);
- camel_folder_summary_decode_uint32 (storeinfo, &tmp);
+ camel_file_util_decode_uint32 (storeinfo, &store->capabilities);
+ camel_file_util_decode_string (storeinfo, &store->namespace);
+ camel_file_util_decode_uint32 (storeinfo, &tmp);
store->dir_sep = tmp;
/* Get subscribed folders */
store->subscribed_folders = g_hash_table_new (g_str_hash, g_str_equal);
- while (camel_folder_summary_decode_string (storeinfo, &buf) == 0) {
+ while (camel_file_util_decode_string (storeinfo, &buf) == 0) {
if (!imap_parse_list_response (buf, NULL, NULL, &name)) {
g_free (buf);
continue;
diff --git a/camel/providers/imap/camel-imap-summary.c b/camel/providers/imap/camel-imap-summary.c
index ca7a2ab737..cd7444559e 100644
--- a/camel/providers/imap/camel-imap-summary.c
+++ b/camel/providers/imap/camel-imap-summary.c
@@ -30,7 +30,7 @@
#include <stdlib.h>
#include "camel-imap-summary.h"
-#include <camel/camel-mime-message.h>
+#include "camel-file-utils.h"
#define CAMEL_IMAP_SUMMARY_VERSION (0x300)
@@ -110,7 +110,6 @@ camel_imap_summary_new (const char *filename)
{
CamelFolderSummary *summary = CAMEL_FOLDER_SUMMARY (
camel_object_new (camel_imap_summary_get_type ()));
- CamelImapSummary *imap_summary = (CamelImapSummary *)summary;
camel_folder_summary_set_build_content (summary, TRUE);
camel_folder_summary_set_filename (summary, filename);
@@ -132,7 +131,7 @@ summary_header_load (CamelFolderSummary *s, FILE *in)
if (camel_imap_summary_parent->summary_header_load (s, in) == -1)
return -1;
- return camel_folder_summary_decode_uint32 (in, &ims->validity);
+ return camel_file_util_decode_uint32 (in, &ims->validity);
}
static int
@@ -143,7 +142,7 @@ summary_header_save (CamelFolderSummary *s, FILE *out)
if (camel_imap_summary_parent->summary_header_save (s, out) == -1)
return -1;
- return camel_folder_summary_encode_uint32 (out, ims->validity);
+ return camel_file_util_encode_uint32 (out, ims->validity);
}
@@ -157,7 +156,7 @@ message_info_load (CamelFolderSummary *s, FILE *in)
if (info) {
iinfo = (CamelImapMessageInfo *)info;
- if (camel_folder_summary_decode_uint32 (in, &iinfo->server_flags) == -1)
+ if (camel_file_util_decode_uint32 (in, &iinfo->server_flags) == -1)
goto error;
}
@@ -175,7 +174,7 @@ message_info_save (CamelFolderSummary *s, FILE *out, CamelMessageInfo *info)
if (camel_imap_summary_parent->message_info_save (s, out, info) == -1)
return -1;
- return camel_folder_summary_encode_uint32 (out, iinfo->server_flags);
+ return camel_file_util_encode_uint32 (out, iinfo->server_flags);
}
diff --git a/camel/providers/local/camel-mbox-summary.c b/camel/providers/local/camel-mbox-summary.c
index 5f3691834f..3f0dd100dd 100644
--- a/camel/providers/local/camel-mbox-summary.c
+++ b/camel/providers/local/camel-mbox-summary.c
@@ -36,6 +36,7 @@
#include <stdlib.h>
#include "camel-mbox-summary.h"
+#include "camel/camel-file-utils.h"
#include "camel/camel-mime-message.h"
#include "camel/camel-operation.h"
@@ -152,7 +153,7 @@ summary_header_load(CamelFolderSummary *s, FILE *in)
if (((CamelFolderSummaryClass *)camel_mbox_summary_parent)->summary_header_load(s, in) == -1)
return -1;
- return camel_folder_summary_decode_uint32(in, &mbs->folder_size);
+ return camel_file_util_decode_uint32(in, &mbs->folder_size);
}
static int
@@ -163,7 +164,7 @@ summary_header_save(CamelFolderSummary *s, FILE *out)
if (((CamelFolderSummaryClass *)camel_mbox_summary_parent)->summary_header_save(s, out) == -1)
return -1;
- return camel_folder_summary_encode_uint32(out, mbs->folder_size);
+ return camel_file_util_encode_uint32(out, mbs->folder_size);
}
static CamelMessageInfo *
@@ -207,7 +208,7 @@ message_info_load(CamelFolderSummary *s, FILE *in)
if (mi) {
CamelMboxMessageInfo *mbi = (CamelMboxMessageInfo *)mi;
- if (camel_folder_summary_decode_off_t(in, &mbi->frompos) == -1)
+ if (camel_file_util_decode_off_t(in, &mbi->frompos) == -1)
goto error;
}
@@ -225,7 +226,7 @@ message_info_save(CamelFolderSummary *s, FILE *out, CamelMessageInfo *mi)
io(printf("saving mbox message info\n"));
if (((CamelFolderSummaryClass *)camel_mbox_summary_parent)->message_info_save(s, out, mi) == -1
- || camel_folder_summary_encode_off_t(out, mbi->frompos) == -1)
+ || camel_file_util_encode_off_t(out, mbi->frompos) == -1)
return -1;
return 0;