commit 3813adcf59bc4e4578f9e75535a7296b459626f5
parent 79df8adbfee87e42bd4ca6071537619289de85b5
Author: Andrej Kacian <ticho@claws-mail.org>
Date: Fri, 1 Mar 2019 14:27:17 +0100
Remove pgpcore's fp_read_noconv() in favour of file_read_stream_to_str_no_recode() from file-utils.c
Diffstat:
7 files changed, 6 insertions(+), 39 deletions(-)
diff --git a/src/plugins/pgpcore/pgp_utils.c b/src/plugins/pgpcore/pgp_utils.c
@@ -32,37 +32,6 @@
#include "codeconv.h"
#include "file-utils.h"
-gchar *fp_read_noconv(FILE *fp)
-{
- GByteArray *array;
- guchar buf[BUFSIZ];
- gint n_read;
- gchar *result = NULL;
-
- if (!fp)
- return NULL;
- array = g_byte_array_new();
-
- while ((n_read = claws_fread(buf, sizeof(gchar), sizeof(buf), fp)) > 0) {
- if (n_read < sizeof(buf) && claws_ferror(fp))
- break;
- g_byte_array_append(array, buf, n_read);
- }
-
- if (claws_ferror(fp)) {
- FILE_OP_ERROR("file stream", "claws_fread");
- g_byte_array_free(array, TRUE);
- return NULL;
- }
-
- buf[0] = '\0';
- g_byte_array_append(array, buf, 1);
- result = (gchar *)array->data;
- g_byte_array_free(array, FALSE);
-
- return result;
-}
-
gchar *get_part_as_string(MimeInfo *mimeinfo)
{
gchar *textdata = NULL;
@@ -84,10 +53,12 @@ gchar *get_part_as_string(MimeInfo *mimeinfo)
fp = claws_fopen(filename,"rb");
if (!fp) {
g_warning("error opening temporary file '%s'", filename);
+
g_free(filename);
return NULL;
}
- textdata = fp_read_noconv(fp);
+ textdata = file_read_stream_to_str_no_recode(fp);
+
claws_fclose(fp);
g_unlink(filename);
g_free(filename);
diff --git a/src/plugins/pgpcore/pgp_utils.h b/src/plugins/pgpcore/pgp_utils.h
@@ -27,7 +27,6 @@
#include "procmime.h"
-gchar *fp_read_noconv(FILE *fp);
gchar *get_part_as_string(MimeInfo *mimeinfo);
gchar *pgp_locate_armor_header(gchar *textdata, const gchar *armor_header);
diff --git a/src/plugins/pgpcore/plugin.def b/src/plugins/pgpcore/plugin.def
@@ -28,6 +28,5 @@ EXPORTS
cm_gpgme_data_rewind
get_part_as_string
- fp_read_noconv
pgp_locate_armor_header
prefs_gpg_auto_check_signatures
diff --git a/src/plugins/pgpinline/mypgpcore.def b/src/plugins/pgpinline/mypgpcore.def
@@ -17,4 +17,3 @@ sgpgme_verify_signature
get_part_as_string
pgp_locate_armor_header
prefs_gpg_auto_check_signatures
-fp_read_noconv
diff --git a/src/plugins/pgpinline/pgpinline.c b/src/plugins/pgpinline/pgpinline.c
@@ -508,7 +508,7 @@ static gboolean pgpinline_sign(MimeInfo *mimeinfo, PrefsAccount *account, const
rewind(fp);
/* read temporary file into memory */
- textstr = fp_read_noconv(fp);
+ textstr = file_read_stream_to_str_no_recode(fp);
claws_fclose(fp);
@@ -702,7 +702,7 @@ static gboolean pgpinline_encrypt(MimeInfo *mimeinfo, const gchar *encrypt_data)
rewind(fp);
/* read temporary file into memory */
- textstr = fp_read_noconv(fp);
+ textstr = file_read_stream_to_str_no_recode(fp);
claws_fclose(fp);
diff --git a/src/plugins/smime/mypgpcore.def b/src/plugins/smime/mypgpcore.def
@@ -17,4 +17,3 @@ sgpgme_sigstat_info_short
sgpgme_verify_signature
cm_gpgme_data_rewind
prefs_gpg_auto_check_signatures
-fp_read_noconv
diff --git a/src/plugins/smime/smime.c b/src/plugins/smime/smime.c
@@ -816,7 +816,7 @@ gboolean smime_encrypt(MimeInfo *mimeinfo, const gchar *encrypt_data)
g_free(tmpfile);
/* read temporary file into memory */
- textstr = fp_read_noconv(fp);
+ textstr = file_read_stream_to_str_no_recode(fp);
claws_fclose(fp);