fix typo
[claws.git] / src / plugins / tnef_parse / tnef_parse.c
index 0ce9c6b9c4b529da048eda40941a0595619e3cc0..a9f926f3b6778f0184d30c231e9d4875f24f76a4 100644 (file)
@@ -50,7 +50,7 @@ static MimeInfo *tnef_broken_mimeinfo(const gchar *reason)
        MimeInfo *sub_info = NULL;
        gchar *tmpfilename = NULL;
        FILE *fp = get_tmpfile_in_dir(get_mime_tmp_dir(), &tmpfilename);
-       struct stat statbuf;
+       GStatBuf statbuf;
 
        if (!fp) {
                g_free(tmpfilename);
@@ -69,7 +69,7 @@ static MimeInfo *tnef_broken_mimeinfo(const gchar *reason)
        fclose(fp);
        if (g_stat(tmpfilename, &statbuf) < 0) {
                claws_unlink(tmpfilename);
-               procmime_mimeinfo_free_all(sub_info);
+               procmime_mimeinfo_free_all(&sub_info);
                return NULL;
 
        }
@@ -87,7 +87,7 @@ static MimeInfo *tnef_dump_file(const gchar *filename, char *data, size_t size)
        MimeInfo *sub_info = NULL;
        gchar *tmpfilename = NULL;
        FILE *fp = get_tmpfile_in_dir(get_mime_tmp_dir(), &tmpfilename);
-       struct stat statbuf;
+       GStatBuf statbuf;
        gchar *content_type = NULL;
        if (!fp) {
                g_free(tmpfilename);
@@ -118,14 +118,14 @@ static MimeInfo *tnef_dump_file(const gchar *filename, char *data, size_t size)
                FILE_OP_ERROR(tmpfilename, "fwrite");
                fclose(fp);
                claws_unlink(tmpfilename);
-               procmime_mimeinfo_free_all(sub_info);
+               procmime_mimeinfo_free_all(&sub_info);
                return tnef_broken_mimeinfo(_("Failed to write the part data."));
        }
        fclose(fp);
 
        if (g_stat(tmpfilename, &statbuf) < 0) {
                claws_unlink(tmpfilename);
-               procmime_mimeinfo_free_all(sub_info);
+               procmime_mimeinfo_free_all(&sub_info);
                return tnef_broken_mimeinfo(_("Failed to write the part data."));
        } else {
                sub_info->tmp = TRUE;
@@ -141,7 +141,7 @@ MimeInfo *tnef_parse_vcal(TNEFStruct *tnef)
        MimeInfo *sub_info = NULL;
        gchar *tmpfilename = NULL;
        FILE *fp = get_tmpfile_in_dir(get_mime_tmp_dir(), &tmpfilename);
-       struct stat statbuf;
+       GStatBuf statbuf;
        gboolean result = FALSE;
        if (!fp) {
                g_free(tmpfilename);
@@ -170,7 +170,7 @@ MimeInfo *tnef_parse_vcal(TNEFStruct *tnef)
 
        if (!result) {
                claws_unlink(tmpfilename);
-               procmime_mimeinfo_free_all(sub_info);
+               procmime_mimeinfo_free_all(&sub_info);
                return tnef_broken_mimeinfo(_("Failed to parse VCalendar data."));
        }
        return sub_info;
@@ -181,7 +181,7 @@ MimeInfo *tnef_parse_vtask(TNEFStruct *tnef)
        MimeInfo *sub_info = NULL;
        gchar *tmpfilename = NULL;
        FILE *fp = get_tmpfile_in_dir(get_mime_tmp_dir(), &tmpfilename);
-       struct stat statbuf;
+       GStatBuf statbuf;
        gboolean result = FALSE;
        if (!fp) {
                g_free(tmpfilename);
@@ -209,7 +209,7 @@ MimeInfo *tnef_parse_vtask(TNEFStruct *tnef)
        }
        if (!result) {
                claws_unlink(tmpfilename);
-               procmime_mimeinfo_free_all(sub_info);
+               procmime_mimeinfo_free_all(&sub_info);
                return tnef_broken_mimeinfo(_("Failed to parse VTask data."));
        }
        return sub_info;
@@ -234,8 +234,9 @@ MimeInfo *tnef_parse_vcard(TNEFStruct *tnef)
        MimeInfo *sub_info = NULL;
        gchar *tmpfilename = NULL;
        FILE *fp = get_tmpfile_in_dir(get_mime_tmp_dir(), &tmpfilename);
-       struct stat statbuf;
+       GStatBuf statbuf;
        gboolean result = FALSE;
+       gint ret;
        if (!fp) {
                g_free(tmpfilename);
                return NULL;
@@ -252,16 +253,21 @@ MimeInfo *tnef_parse_vcard(TNEFStruct *tnef)
        result = SaveVCard(fp, tnef);
        
        fclose(fp);
-       g_stat(tmpfilename, &statbuf);
-       sub_info->tmp = TRUE;
-       sub_info->length = statbuf.st_size;
-       sub_info->encoding_type = ENC_BINARY;
-       
-       if (!result) {
+
+       ret = g_stat(tmpfilename, &statbuf);
+       if (ret == -1) {
+               debug_print("couldn't stat tmpfilename '%s'\n", tmpfilename);
+       }
+
+       if ((ret == -1) || !result) {
                claws_unlink(tmpfilename);
-               procmime_mimeinfo_free_all(sub_info);
+               procmime_mimeinfo_free_all(&sub_info);
                return tnef_broken_mimeinfo(_("Failed to parse VCard data."));
        }
+
+       sub_info->tmp = TRUE;
+       sub_info->length = statbuf.st_size;
+       sub_info->encoding_type = ENC_BINARY;
        return sub_info;
 }