more sync with sylpheed 0.7.0cvs15
authorPaul Mangan <paul@claws-mail.org>
Thu, 24 Jan 2002 10:11:51 +0000 (10:11 +0000)
committerPaul Mangan <paul@claws-mail.org>
Thu, 24 Jan 2002 10:11:51 +0000 (10:11 +0000)
ChangeLog
ChangeLog.claws
ChangeLog.jp
configure.in
src/imap.c
src/utils.c
src/utils.h

index 8642ac1..fc48a22 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,8 @@
        * src/compose.c
          src/gtkstext.[ch]: removed the hardcoded shortcuts in GtkSText,
          and made them customizable.
+       * src/utils.[ch]: added get_file_size_as_crlf() which returns
+         the file size when converting LF to CR+LF.
 
 2002-01-22
 
index aaa1a20..bb8b872 100644 (file)
@@ -1,3 +1,8 @@
+2002-01-24 [paul]      0.7.0claws24
+
+       * more sync with sylpheed 0.7.0cvs15
+               get_file_size_as_clrf(), see ChangeLog entry 2002-01-23
+
 2002-01-23 [sergey]    0.7.0claws23
 
        * src/importldif.c
index 2bf02fe..0de66e2 100644 (file)
@@ -3,6 +3,8 @@
        * src/compose.c
          src/gtkstext.[ch]: GtkSText Ãæ¤Î¥Ï¡¼¥É¥³¡¼¥É¤µ¤ì¤Æ¤¤¤ë¥·¥ç¡¼¥È
          ¥«¥Ã¥È¤òºï½ü¤·¡¢¥«¥¹¥¿¥Þ¥¤¥º²Äǽ¤Ë¤·¤¿¡£
+       * src/utils.[ch]: LF ¤ò CR+LF ¤ËÊÑ´¹¤·¤¿¤È¤­¤Î¥Õ¥¡¥¤¥ë¥µ¥¤¥º¤ò
+         ÊÖ¤¹ get_file_size_as_crlf() ¤òÄɲá£
 
 2002-01-22
 
index bb3babb..0a3d4d9 100644 (file)
@@ -8,7 +8,7 @@ MINOR_VERSION=7
 MICRO_VERSION=0
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws23
+EXTRA_VERSION=claws24
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index 5e4c0f5..fba1032 100644 (file)
@@ -2289,7 +2289,7 @@ static gint imap_cmd_append(SockInfo *sock, const gchar *destfolder,
 
        g_return_val_if_fail(file != NULL, IMAP_ERROR);
 
-       size = get_file_size(file);
+       size = get_file_size_as_crlf(file);
        QUOTE_IF_REQUIRED(destfolder_, destfolder);
        imap_cmd_gen_send(sock, "APPEND %s {%d}", destfolder_, size);
        ok = imap_cmd_ok(sock, NULL);
index 173900b..74843a3 100644 (file)
@@ -1299,6 +1299,53 @@ off_t get_file_size(const gchar *file)
        return s.st_size;
 }
 
+off_t get_file_size_as_crlf(const gchar *file)
+{
+       FILE *fp;
+       off_t size = 0;
+       gint left;
+       gint line_len;
+       gchar buf[BUFSIZ];
+       gchar *p, *prev;
+
+       if ((fp = fopen(file, "r")) == NULL) {
+               FILE_OP_ERROR(file, "fopen");
+               return -1;
+       }
+
+       while ((left = fread(buf, sizeof(gchar), sizeof(buf), fp)) > 0) {
+               prev = buf;
+
+               if (left < sizeof(buf) && ferror(fp))
+                       break;
+
+               do {
+                       p = memchr(prev, '\n', left);
+                       if (p != NULL) {
+                               line_len = p - prev;
+                               if (p > buf && *(p - 1) == '\r')
+                                       size += line_len + 1;
+                               else
+                                       size += line_len + 2;
+                               left -= line_len + 1;
+                               prev = p + 1;
+                       } else {
+                               size += left;
+                               break;
+                       }
+               } while (left > 0);
+       }
+
+       if (ferror(fp)) {
+               FILE_OP_ERROR(file, "fread");
+               size = -1;
+       }
+
+       fclose(fp);
+
+       return size;
+}
+
 off_t get_left_file_size(FILE *fp)
 {
        glong pos;
index e41939d..04802f3 100644 (file)
@@ -293,6 +293,7 @@ gchar *get_domain_name              (void);
 
 /* file / directory handling */
 off_t get_file_size            (const gchar    *file);
+off_t get_file_size_as_crlf    (const gchar    *file);
 off_t get_left_file_size       (FILE           *fp);
 gboolean file_exist            (const gchar    *file,
                                 gboolean        allow_fifo);