#include <glib.h>
#include <glib/gi18n.h>
#include <gtk/gtk.h>
+
+#ifdef YTNEF_H_SUBDIR
+#include <libytnef/tnef-types.h>
+#include <libytnef/ytnef.h>
+#include <libytnef/mapi.h>
+#include <libytnef/mapidefs.h>
+#else
+#include <tnef-types.h>
+#include <ytnef.h>
+#include <mapi.h>
+#include <mapidefs.h>
+#endif
+
#include "common/claws.h"
#include "common/version.h"
#include "main.h"
#include "plugin.h"
#include "procmime.h"
#include "utils.h"
-
-#include <tnef-types.h>
-#include <ytnef.h>
-#include <mapi.h>
-#include <mapidefs.h>
+#include "file-utils.h"
#include "tnef_dump.h"
"Claws Mail TNEF parser:\n\n"
"%s\n"), reason?reason:_("Unknown error"));
- fclose(fp);
+ claws_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;
}
}
}
- if (fwrite(data, 1, size, fp) < size) {
- FILE_OP_ERROR(tmpfilename, "fwrite");
- fclose(fp);
+ if (claws_fwrite(data, 1, size, fp) < size) {
+ FILE_OP_ERROR(tmpfilename, "claws_fwrite");
+ claws_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);
+ claws_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;
result = SaveVCalendar(fp, tnef);
- fclose(fp);
+ claws_fclose(fp);
if (g_stat(tmpfilename, &statbuf) < 0) {
result = FALSE;
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;
result = SaveVTask(fp, tnef);
- fclose(fp);
+ claws_fclose(fp);
if (g_stat(tmpfilename, &statbuf) < 0) {
result = FALSE;
}
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;
FILE *fp = get_tmpfile_in_dir(get_mime_tmp_dir(), &tmpfilename);
GStatBuf statbuf;
gboolean result = FALSE;
+ gint ret;
if (!fp) {
g_free(tmpfilename);
return NULL;
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) {
+ claws_fclose(fp);
+
+ 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;
}
if (mimeinfo->content == MIMECONTENT_FILE)
debug_print("content: %s\n", mimeinfo->data.filename);
else
- debug_print("contents in memory (len %zd)\n",
+ debug_print("contents in memory (len %"G_GSIZE_FORMAT")\n",
strlen(mimeinfo->data.mem));
tnef = g_new0(TNEFStruct, 1);