commit - dab376b8b67c043a8a5e937abc4452cdd533eaac
commit + 30d1a28ae115c9aa91c308768e9e392fd71b481c
blob - fef764efd2e28a97e0d71869a8065f397116552b
blob + a0c9137c6fb86eac769c6cfc9fe43b9d5377c5a4
--- README.md
+++ README.md
## Goals
Many features of Claws Mail have been removed to make it easier to maintain by a single person.
+As of the end of 2025, Talons is less than half the size of Claws Mail; 120KLOC. versus Claws Mail 4.3.1 at around 295KLOC.
To be honest I can't even remember how many or which features have been removed.
Off the top of my head:
- no localisation (sorry)
- no actions
- no client-side mail filtering
+- no LDAP, Palm Pilot address books
[Zig]: https://ziglang.org
[Claws Mail]: https://claws-mail.org
blob - b92cddf2a4f4ab23b4128a75ae9eb73afa3ab9e2
blob + ad2cea13b4e15ca1b56cb44e4ed26af80929e902
--- src/addrbook.c
+++ src/addrbook.c
book->retVal = MGU_SUCCESS;
#ifdef DEV_STANDALONE
- safe_fclose(fp);
+ fclose(fp);
#else
if (prefs_file_close( pfile ) < 0)
book->retVal = MGU_ERROR_WRITE;
blob - d8a6047e6068a06e30f7de04444c00d4e4fa0eea
blob + 45696c111fc8bd8b0e7013a82bfd6a681838d355
--- src/addrindex.c
+++ src/addrindex.c
goto fail;
addrIndex->retVal = MGU_SUCCESS;
-#ifdef DEV_STANDALONE
- safe_fclose( fp );
-#else
- if( prefs_file_close( pfile ) < 0 ) {
+ if (prefs_file_close(pfile) < 0)
addrIndex->retVal = MGU_ERROR_WRITE;
- }
-#endif
}
fileSpec = NULL;
blob - ec93821554b472b10cf6ac6579de6fd7ae9afdaa
blob + 1c51fec62c0b194f3e19a2e15eed3d7d52edb132
--- src/common/file-utils.c
+++ src/common/file-utils.c
#include <sys/wait.h>
+#include <err.h>
#include <errno.h>
#include <stdio.h>
#include <unistd.h>
#include "utils.h"
#include "file-utils.h"
-int safe_fclose(FILE *fp)
-{
- if (fflush(fp) != 0) {
- return EOF;
- }
- if (fsync(fileno(fp)) != 0) {
- return EOF;
- }
- return fclose(fp);
-}
-
gint file_strip_crs(const gchar *file)
{
FILE *fp = NULL, *outfp = NULL;
}
fclose(fp);
- if (safe_fclose(outfp) == EOF) {
+ if (fclose(outfp) == EOF) {
goto unlinkout;
}
err = TRUE;
}
fclose(src_fp);
- if (safe_fclose(dest_fp) == EOF) {
+ if (fclose(dest_fp) == EOF) {
FILE_OP_ERROR(dest, "fclose");
err = TRUE;
}
if (copy_file_part_to_fp(fp, offset, length, dest_fp) < 0)
err = TRUE;
- if (safe_fclose(dest_fp) == EOF) {
+ if (fclose(dest_fp) == EOF) {
FILE_OP_ERROR(dest, "fclose");
err = TRUE;
}
err = TRUE;
}
fclose(src_fp);
- if (safe_fclose(dest_fp) == EOF) {
+ if (fclose(dest_fp) == EOF) {
FILE_OP_ERROR(dest, "fclose");
err = TRUE;
}
}
-gint str_write_to_file(const gchar *str, const gchar *file, gboolean safe)
+gint str_write_to_file(const gchar *str, char *file)
{
- FILE *fp;
- size_t len;
- int r;
-
- cm_return_val_if_fail(str != NULL, -1);
- cm_return_val_if_fail(file != NULL, -1);
-
- if ((fp = g_fopen(file, "wb")) == NULL) {
- FILE_OP_ERROR(file, "g_fopen");
- return -1;
- }
-
- len = strlen(str);
- if (len == 0) {
- fclose(fp);
+ if (strlen(str) == 0)
return 0;
+
+ FILE *fp = fopen(file, "wb");
+ if (fp == NULL) {
+ warn("open %s", file);
+ return -1;
}
- if (fwrite(str, 1, len, fp) != len) {
- FILE_OP_ERROR(file, "fwrite");
+ size_t len = strlen(str);
+ size_t n = fwrite(str, 1, strlen(str), fp);
+ if (n != len) {
+ warn("short write to %s: expected %d bytes but wrote %d", file, len, n);
fclose(fp);
- unlink(file);
+ remove(file);
return -1;
}
- if (safe) {
- r = safe_fclose(fp);
- } else {
- r = fclose(fp);
- }
-
- if (r == EOF) {
- FILE_OP_ERROR(file, "fclose");
- unlink(file);
+ if (fclose(fp) == EOF) {
+ warn("close %s", file);
+ remove(file);
return -1;
}
-
return 0;
}
blob - a1a180d3ecd0de5c14dd386047970f9142a7fbf4
blob + 7415f849ff040114ad012afab9c343361d9c84f7
--- src/common/file-utils.h
+++ src/common/file-utils.h
#include <stdio.h>
#include <glib.h>
-int safe_fclose(FILE *fp);
-
gint file_strip_crs (const gchar *file);
gint append_file (const gchar *src,
const gchar *dest,
FILE *get_tmpfile_in_dir (const gchar *dir,
gchar **filename);
FILE *str_open_as_stream (const gchar *str);
-gint str_write_to_file (const gchar *str,
- const gchar *file,
- gboolean safe);
+gint str_write_to_file (const gchar *str, char *file);
gint prefs_chmod_mode (gchar *chmod_pref);
blob - a9693e2fd6d59568343ab983d0102efcc3ae2788
blob + 06f3b712bcdb551dc96c7c9529b95d5662710531
--- src/common/prefs.c
+++ src/common/prefs.c
tmppath = g_strconcat(path, ".tmp", NULL);
- if (safe_fclose(fp) == EOF) {
+ if (fclose(fp) == EOF) {
FILE_OP_ERROR(tmppath, "fclose");
unlink(tmppath);
g_free(path);
blob - 3daf7a4df9e4e454658eeda47e8c341a3d6a0bdf
blob + a74762ffa52c911c0e5863f74aca8758d7a4f31b
--- src/common/ssl_certificate.c
+++ src/common/ssl_certificate.c
gnutls_export_X509_fp(fp, cert->x509_cert, GNUTLS_X509_FMT_DER);
g_free(file);
- safe_fclose(fp);
+ fclose(fp);
}
}
if (fp)
- safe_fclose(fp);
+ fclose(fp);
}
gboolean ssl_certificate_check (gnutls_x509_crt_t x509_cert, guint status,
blob - faad4fd71fab6822cc953363bf01d27ac70781f6
blob + de62e33401dca583a41b80309db4b0ddc94d6b4c
--- src/common/utils.c
+++ src/common/utils.c
if (fp)
fclose(fp);
- if (safe_fclose(outfp) == EOF)
+ if (fclose(outfp) == EOF)
err = TRUE;
if (!err)
blob - 28567290bd0264bd4f8fdb8535f84e460ef3c403
blob + 676a1274f89652e6fe4190634cd4eb15f65b9e4b
--- src/compose.c
+++ src/compose.c
rewind(fp);
content = file_read_stream_to_str(fp);
- str_write_to_file(content, tmp_enc_file, TRUE);
+ str_write_to_file(content, tmp_enc_file);
g_free(content);
/* Now write the unencrypted body. */
g_free(chars);
- if (safe_fclose(fp) == EOF) {
+ if (fclose(fp) == EOF) {
FILE_OP_ERROR(file, "fclose");
unlink(file);
return -1;
g_free(tmp);
return COMPOSE_QUEUE_ERROR_WITH_ERRNO;
}
- if (safe_fclose(fp) == EOF) {
+ if (fclose(fp) == EOF) {
FILE_OP_ERROR(tmp, "fclose");
unlink(tmp);
g_free(tmp);
fclose(fp);
goto warn_err;
}
- if (safe_fclose(fp) == EOF) {
+ if (fclose(fp) == EOF) {
goto warn_err;
}
return -1;
}
- r = safe_fclose(fp);
+ r = fclose(fp);
if (r == EOF) {
FILE_OP_ERROR(file, "fclose");
/* Assume a list of no files, and data has ://, is a remote link */
gchar *tmpdata = g_strstrip(g_strdup(ddata));
gchar *tmpfile = get_tmp_file();
- str_write_to_file(tmpdata, tmpfile, TRUE);
+ str_write_to_file(tmpdata, tmpfile);
g_free(tmpdata);
compose_insert_file(compose, tmpfile);
unlink(tmpfile);
blob - a6f33bc49d03910d5620491f6df35516239cace8
blob + da387a52a94ecd67501dec829bbe66c4fe653012
--- src/etpan/imap-thread.c
+++ src/etpan/imap-thread.c
goto do_fclose;
}
- if (safe_fclose(f) == EOF) {
+ if (fclose(f) == EOF) {
result->error = MAILIMAP_ERROR_FETCH;
goto unlink;
}
blob - 806f21a382a843585323ca334db8999eeee6ad72
blob + 7c68ad3202506f2f71f94a739a644262aad6cf40
--- src/mbox.c
+++ src/mbox.c
return -1;
}
- if (safe_fclose(tmp_fp) == EOF) {
+ if (fclose(tmp_fp) == EOF) {
FILE_OP_ERROR(tmp_file, "fclose");
g_warning("can't write to temporary file");
fclose(mbox_fp);
err = TRUE;
}
- if (safe_fclose(dest_fp) == EOF) {
+ if (fclose(dest_fp) == EOF) {
FILE_OP_ERROR(dest, "fclose");
err = TRUE;
}
goto out;
}
- safe_fclose(msg_fp);
+ fclose(msg_fp);
statusbar_progress_all(msgs++,total, 500);
if (msgs%500 == 0)
GTK_EVENTS_FLUSH();
statusbar_progress_all(0,0,0);
statusbar_pop_all();
- safe_fclose(mbox_fp);
+ fclose(mbox_fp);
return err;
}
blob - 79982edc69e887df01ea7f2d70c29039b5edadc7
blob + f9651f836508fa3073f32715e70cbc9834c6322d
--- src/msgcache.c
+++ src/msgcache.c
/* close files */
if (write_fps.cache_fp)
- write_fps.error |= (safe_fclose(write_fps.cache_fp) != 0);
+ write_fps.error |= (fclose(write_fps.cache_fp) != 0);
if (write_fps.mark_fp)
- write_fps.error |= (safe_fclose(write_fps.mark_fp) != 0);
+ write_fps.error |= (fclose(write_fps.mark_fp) != 0);
if (write_fps.error != 0) {
/* in case of error, forget all */
blob - 2361a57f7dafb1d85d3f648f0349441697f72cab
blob + 0a7786e1812fed0b88c24e683e9f81f5a97ba438
--- src/pop.c
+++ src/pop.c
> 0);
}
- if (safe_fclose(fp) == EOF) {
+ if (fclose(fp) == EOF) {
FILE_OP_ERROR(tmp_path, "fclose");
fp = NULL;
goto err_write;
}
}
- if (safe_fclose(fp) == EOF) {
+ if (fclose(fp) == EOF) {
FILE_OP_ERROR(file, "fclose");
unlink(file);
return -1;
blob - 152f0f4c9a009d3f22c7425a1d68751eb6e533e4
blob + 2378da0af60415b9fb279cf6bdede0697d0db9a6
--- src/prefs_account.c
+++ src/prefs_account.c
{
const gchar *sigpath = gtk_entry_get_text(GTK_ENTRY(data));
if (!is_file_exist(sigpath))
- str_write_to_file(sigpath, "", TRUE);
+ str_write_to_file(sigpath, "");
open_txt_editor(sigpath, prefs_common_get_ext_editor_cmd());
}
blob - c4df5b30783b4811f3fe4fe70b8d0471199343a2
blob + b77bbd6d5366a3aa6554739e6b20f0265aba62e2
--- src/prefs_common.c
+++ src/prefs_common.c
fputc('\n', fp) != EOF);
}
- if (safe_fclose(fp) == EOF) {
+ if (fclose(fp) == EOF) {
FILE_OP_ERROR(tmp_path, "fclose");
fp = NULL;
goto out;
out:
if (fp)
- safe_fclose(fp);
+ fclose(fp);
g_free(tmp_path);
g_free(path);
}
blob - 40cb0d741828c3de2c95021b26669e0743ee0c05
blob + 663f1dd2a2fb3fbaef5a67588f74bea5734ad191
--- src/procmsg.c
+++ src/procmsg.c
}
if (fp && procmime_write_mimeinfo(mimeinfo, fp) >= 0) {
- safe_fclose(fp);
+ fclose(fp);
fp = NULL;
tmp_msginfo = procheader_parse_file(
tmpfile, flags,
TRUE, FALSE);
}
if (fp)
- safe_fclose(fp);
+ fclose(fp);
if (tmp_msginfo != NULL) {
if (src_msginfo)