aboutsummaryrefslogtreecommitdiffstats
path: root/camel/camel-file-utils.c
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2004-02-16 17:38:24 +0800
committerMichael Zucci <zucchi@src.gnome.org>2004-02-16 17:38:24 +0800
commit1ceb4cd764fbdd89a3b67903251dc89ad3e7d723 (patch)
treea551592e442ee3404caa5d05a8362d7dd1d553b0 /camel/camel-file-utils.c
parent22fdff59a00dbbdcc6c6a59f452cfa7141bc7aad (diff)
downloadgsoc2013-evolution-1ceb4cd764fbdd89a3b67903251dc89ad3e7d723.tar.gz
gsoc2013-evolution-1ceb4cd764fbdd89a3b67903251dc89ad3e7d723.tar.zst
gsoc2013-evolution-1ceb4cd764fbdd89a3b67903251dc89ad3e7d723.zip
** See bug #51045.
2004-02-16 Not Zed <NotZed@Ximian.com> ** See bug #51045. * providers/imap/camel-imap-store.c (fill_fi): similar to mbox version. (get_folder_counts): use fill_fi to try and get folder counts if we're not doing the hard slog. (get_one_folder_offline): use fill_fi to try to get folder counts from open folders or summaries. * providers/local/camel-maildir-store.c (fill_fi): similar to mbox version. (scan_dir): use fill_fi to get the unread count now. * providers/local/camel-mbox-store.c (fill_fi): helper to lookup unread count either from active folder or from summary file, if it's available. (scan_dir, get_folder_info): use helper above to get folder info. * devel-docs/camel-folder-summary.txt: New document describing the format/conventions in the CamelFolderSummary file. * providers/nntp/camel-nntp-summary.c (summary_header_load/save): * providers/imapp/camel-imapp-summary.c (summary_header_load/save): * providers/imap/camel-imap-summary.c (summary_header_load/save): Handle versions, per-class version number (1). * providers/local/camel-mbox-summary.c (summary_header_load/save): Handle versions properly, add a per-class version (1). Write out the folder size as a size_t rather than 32 bit int. * providers/local/camel-local-summary.c (summary_header_load/save): read/write the per-class version number (1). * camel-folder-summary.c (summary_header_load): do version checking differently, allow the version to be bumped without aborting the load. Added unread/deleted/junk counts to base header. (summary_header_save): Save out the new-format header. Version bumped to 13. * camel.c (camel_init): return 0 rather than spit a compiler warning. * camel-file-utils.c (camel_file_util_encode_*_t): macro-ise the type encoder/decoders. Also add size_t encoder/decoder. svn path=/trunk/; revision=24744
Diffstat (limited to 'camel/camel-file-utils.c')
-rw-r--r--camel/camel-file-utils.c112
1 files changed, 57 insertions, 55 deletions
diff --git a/camel/camel-file-utils.c b/camel/camel-file-utils.c
index f4ed4cd22c..0d51795e32 100644
--- a/camel/camel-file-utils.c
+++ b/camel/camel-file-utils.c
@@ -144,6 +144,37 @@ camel_file_util_decode_fixed_int32 (FILE *in, gint32 *dest)
}
}
+#define CFU_ENCODE_T(type) \
+int \
+camel_file_util_encode_##type(FILE *out, type value) \
+{ \
+ int i; \
+ \
+ for (i = sizeof (type) - 1; i >= 0; i--) { \
+ if (fputc((value >> (i * 8)) & 0xff, out) == -1) \
+ return -1; \
+ } \
+ return 0; \
+}
+
+#define CFU_DECODE_T(type) \
+int \
+camel_file_util_decode_##type(FILE *in, type *dest) \
+{ \
+ type save = 0; \
+ int i = sizeof(type) - 1; \
+ int v = EOF; \
+ \
+ while (i >= 0 && (v = fgetc (in)) != EOF) { \
+ save |= ((type)v) << (i * 8); \
+ i--; \
+ } \
+ *dest = save; \
+ if (v == EOF) \
+ return -1; \
+ return 0; \
+}
+
/**
* camel_file_util_encode_time_t:
@@ -154,18 +185,7 @@ camel_file_util_decode_fixed_int32 (FILE *in, gint32 *dest)
*
* 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;
-}
-
+CFU_ENCODE_T(time_t)
/**
* camel_file_util_decode_time_t:
@@ -176,23 +196,7 @@ camel_file_util_encode_time_t(FILE *out, 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 i = sizeof (time_t) - 1;
- int v = EOF;
-
- while (i >= 0 && (v = fgetc (in)) != EOF) {
- save |= ((time_t)v) << (i * 8);
- i--;
- }
- *dest = save;
- if (v == EOF)
- return -1;
- return 0;
-}
-
+CFU_DECODE_T(time_t)
/**
* camel_file_util_encode_off_t:
@@ -203,17 +207,7 @@ camel_file_util_decode_time_t (FILE *in, time_t *dest)
*
* 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;
-}
+CFU_ENCODE_T(off_t)
/**
@@ -225,22 +219,30 @@ camel_file_util_encode_off_t (FILE *out, off_t value)
*
* 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 i = sizeof(off_t) - 1;
- int v = EOF;
+CFU_DECODE_T(off_t)
- 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_size_t:
+ * @out: file to output to
+ * @value: value to output
+ *
+ * Encode an size_t type.
+ *
+ * Return value: 0 on success, -1 on error.
+ **/
+CFU_ENCODE_T(size_t)
+
+
+/**
+ * camel_file_util_decode_size_t:
+ * @in: file to read from
+ * @dest: pointer to a variable to put the value in
+ *
+ * Decode an size_t type.
+ *
+ * Return value: 0 on success, -1 on failure.
+ **/
+CFU_DECODE_T(size_t)
/**