2005-09-30 [colin] 1.9.14cvs62
[claws.git] / src / pop.c
index 9daf02b597e841296aa04c25d531d6837bd9695a..a72f037edc1813129b80440aa3c7381503818d69 100644 (file)
--- a/src/pop.c
+++ b/src/pop.c
@@ -14,7 +14,7 @@
  *
  * 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.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
 #ifdef HAVE_CONFIG_H
@@ -271,7 +271,8 @@ static gint pop3_getrange_uidl_recv(Pop3Session *session, const gchar *data,
                        session->msg[num].received = 
                                (partial_recv != POP3_MUST_COMPLETE_RECV);
                        session->msg[num].partial_recv = partial_recv;
-
+                       if (partial_recv == POP3_MUST_COMPLETE_RECV)
+                               session->new_msg_exist = TRUE;
                }
                if (!session->new_msg_exist &&
                    (session->ac_prefs->getall || recv_time == RECV_TIME_NONE ||
@@ -575,13 +576,13 @@ void pop3_get_uidl_table(PrefsAccount *ac_prefs, Pop3Session *session)
                           "-", sanitized_uid, NULL);
                           
        g_free(sanitized_uid);
-       if ((fp = fopen(path, "rb")) == NULL) {
+       if ((fp = g_fopen(path, "rb")) == NULL) {
                if (ENOENT != errno) FILE_OP_ERROR(path, "fopen");
                g_free(path);
                path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
                                   "uidl-", ac_prefs->recv_server,
                                   "-", ac_prefs->userid, NULL);
-               if ((fp = fopen(path, "rb")) == NULL) {
+               if ((fp = g_fopen(path, "rb")) == NULL) {
                        if (ENOENT != errno) FILE_OP_ERROR(path, "fopen");
                        g_free(path);
                        session->uidl_table = table;
@@ -599,8 +600,8 @@ void pop3_get_uidl_table(PrefsAccount *ac_prefs, Pop3Session *session)
                recv_time = RECV_TIME_NONE;
                partial_recv = POP3_TOTALLY_RECEIVED;
                
-               if (sscanf(buf, "%s\t%ld\t%s", uidl, &recv_time, tmp) < 3) {
-                       if (sscanf(buf, "%s\t%ld", uidl, &recv_time) != 2) {
+               if (sscanf(buf, "%s\t%ld\t%s", uidl, (long int *) &recv_time, tmp) < 3) {
+                       if (sscanf(buf, "%s\t%ld", uidl, (long int *) &recv_time) != 2) {
                                if (sscanf(buf, "%s", uidl) != 1)
                                        continue;
                                else {
@@ -652,7 +653,7 @@ gint pop3_write_uidl_list(Pop3Session *session)
        
        g_free(sanitized_uid);
 
-       if ((fp = fopen(path, "wb")) == NULL) {
+       if ((fp = g_fopen(path, "wb")) == NULL) {
                FILE_OP_ERROR(path, "fopen");
                g_free(path);
                return -1;
@@ -663,7 +664,7 @@ gint pop3_write_uidl_list(Pop3Session *session)
                if (msg->uidl && msg->received &&
                    (!msg->deleted || session->state != POP3_DONE))
                        fprintf(fp, "%s\t%ld\t%d\n", 
-                               msg->uidl, msg->recv_time, msg->partial_recv);
+                               msg->uidl, (long int) msg->recv_time, msg->partial_recv);
        }
 
        if (fclose(fp) == EOF) FILE_OP_ERROR(path, "fclose");
@@ -680,7 +681,7 @@ static gint pop3_write_msg_to_file(const gchar *file, const gchar *data,
 
        g_return_val_if_fail(file != NULL, -1);
 
-       if ((fp = fopen(file, "wb")) == NULL) {
+       if ((fp = g_fopen(file, "wb")) == NULL) {
                FILE_OP_ERROR(file, "fopen");
                return -1;
        }
@@ -699,12 +700,12 @@ static gint pop3_write_msg_to_file(const gchar *file, const gchar *data,
        prev = data;
        while ((cur = (gchar *)my_memmem(prev, len - (prev - data), "\r\n", 2))
               != NULL) {
-               if ((cur > prev && fwrite(prev, cur - prev, 1, fp) < 1) ||
+               if ((cur > prev && fwrite(prev, 1, cur - prev, fp) < 1) ||
                    fputc('\n', fp) == EOF) {
                        FILE_OP_ERROR(file, "fwrite");
                        g_warning("can't write to file: %s\n", file);
                        fclose(fp);
-                       unlink(file);
+                       g_unlink(file);
                        return -1;
                }
 
@@ -726,11 +727,11 @@ static gint pop3_write_msg_to_file(const gchar *file, const gchar *data,
        }
 
        if (prev - data < len &&
-           fwrite(prev, len - (prev - data), 1, fp) < 1) {
+           fwrite(prev, 1, len - (prev - data), fp) < 1) {
                FILE_OP_ERROR(file, "fwrite");
                g_warning("can't write to file: %s\n", file);
                fclose(fp);
-               unlink(file);
+               g_unlink(file);
                return -1;
        }
        if (data[len - 1] != '\r' && data[len - 1] != '\n') {
@@ -738,14 +739,14 @@ static gint pop3_write_msg_to_file(const gchar *file, const gchar *data,
                        FILE_OP_ERROR(file, "fputc");
                        g_warning("can't write to file: %s\n", file);
                        fclose(fp);
-                       unlink(file);
+                       g_unlink(file);
                        return -1;
                }
        }
 
        if (fclose(fp) == EOF) {
                FILE_OP_ERROR(file, "fclose");
-               unlink(file);
+               g_unlink(file);
                return -1;
        }
 
@@ -867,7 +868,7 @@ static gint pop3_session_recv_msg(Session *session, const gchar *msg)
 {
        Pop3Session *pop3_session = POP3_SESSION(session);
        Pop3ErrorValue val = PS_SUCCESS;
-       const guchar *body;
+       const gchar *body;
 
        body = msg;
        if (pop3_session->state != POP3_GETRANGE_UIDL_RECV &&
@@ -882,9 +883,9 @@ static gint pop3_session_recv_msg(Session *session, const gchar *msg)
 
                if (*body == '+' || *body == '-')
                        body++;
-               while (isalpha(*body))
+               while (g_ascii_isalpha(*body))
                        body++;
-               while (isspace(*body))
+               while (g_ascii_isspace(*body))
                        body++;
        }