Skip to content

Commit

Permalink
merge: unify logging/messaging
Browse files Browse the repository at this point in the history
 * refactor cli handling of cc/bcc
 * endwin: separate curses from the message
 * sleep after every error message
 * reorganise startup to return through main()
 * refactor exits in mutt_randbuf()
 * use dedicated set_default() and reset_value()
 * redirect all messages through a log dispatcher
 * update messages (remove newline)
 * add log messages page
 * add comments markers for CLI test cases
 * fix crash with incomplete template
  • Loading branch information
flatcap committed Mar 15, 2018
2 parents 3acb497 + 46569e7 commit 9deaed2
Show file tree
Hide file tree
Showing 103 changed files with 1,732 additions and 1,134 deletions.
8 changes: 4 additions & 4 deletions Makefile.autosetup
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ NEOMUTTOBJS= mutt_account.o addrbook.o alias.o attach.o bcache.o body.o \
compose.o compress.o conststrings.o copy.o curs_lib.o \
curs_main.o edit.o editmsg.o enter.o envelope.o filter.o \
flags.o from.o group.o handler.o hdrline.o \
header.o help.o history.o hook.o init.o keymap.o main.o \
header.o help.o history.o hook.o init.o keymap.o mutt_logging.o main.o \
mbox.o menu.o mh.o muttlib.o \
mutt_socket.o tags.o mx.o \
newsrc.o nntp.o pager.o parse.o pattern.o pop.o \
Expand Down Expand Up @@ -94,10 +94,10 @@ ALLOBJS+= $(NEOMUTTOBJS)
# libmutt
LIBMUTT= libmutt.a
LIBMUTTOBJS= mutt/address.o mutt/base64.o mutt/buffer.o mutt/charset.o \
mutt/date.o mutt/debug.o mutt/exit.o \
mutt/file.o mutt/hash.o mutt/idna.o mutt/list.o \
mutt/date.o mutt/exit.o \
mutt/file.o mutt/hash.o mutt/idna.o mutt/list.o mutt/logging.o \
mutt/mapping.o mutt/mbyte.o mutt/md5.o \
mutt/memory.o mutt/message.o mutt/mime.o mutt/parameter.o \
mutt/memory.o mutt/mime.o mutt/parameter.o \
mutt/regex.o mutt/sha1.o mutt/signal.o mutt/string.o \
mutt/rfc2047.o
CLEANFILES+= $(LIBMUTT) $(LIBMUTTOBJS)
Expand Down
1 change: 0 additions & 1 deletion alias.c
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,6 @@ void mutt_create_alias(struct Envelope *cur, struct Address *iaddr)
if (mutt_addrlist_to_intl(new->addr, &err))
{
mutt_error(_("Error: '%s' is a bad IDN."), err);
mutt_sleep(2);
continue;
}
} while (!new->addr);
Expand Down
15 changes: 6 additions & 9 deletions attach.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ int mutt_compose_attachment(struct Body *a)
{
int r;

mutt_endwin(NULL);
mutt_endwin();
r = mutt_system(command);
if (r == -1)
mutt_error(_("Error running \"%s\"!"), command);
Expand Down Expand Up @@ -266,7 +266,7 @@ int mutt_edit_attachment(struct Body *a)
}
else
{
mutt_endwin(NULL);
mutt_endwin();
if (mutt_system(command) == -1)
{
mutt_error(_("Error running \"%s\"!"), command);
Expand Down Expand Up @@ -474,7 +474,7 @@ int mutt_view_attachment(FILE *fp, struct Body *a, int flag, struct Header *hdr,
int tempfd = -1, pagerfd = -1;

if (!use_pager)
mutt_endwin(NULL);
mutt_endwin();

if (use_pager || use_pipe)
{
Expand Down Expand Up @@ -558,7 +558,6 @@ int mutt_view_attachment(FILE *fp, struct Body *a, int flag, struct Header *hdr,
mutt_debug(1, "mutt_file_fopen(%s) errno=%d %s\n", pagerfile, errno,
strerror(errno));
mutt_perror(pagerfile);
mutt_sleep(1);
goto return_error;
}
decode_state.fpin = fp;
Expand Down Expand Up @@ -659,7 +658,7 @@ int mutt_pipe_attachment(FILE *fp, struct Body *b, const char *path, char *outfi
}
}

mutt_endwin(NULL);
mutt_endwin();

if (fp)
{
Expand Down Expand Up @@ -823,7 +822,6 @@ int mutt_save_attachment(FILE *fp, struct Body *m, char *path, int flags, struct
if (!s.fpout)
{
mutt_perror("fopen");
mutt_sleep(2);
return -1;
}
fseeko((s.fpin = fp), m->offset, SEEK_SET);
Expand All @@ -832,7 +830,6 @@ int mutt_save_attachment(FILE *fp, struct Body *m, char *path, int flags, struct
if (mutt_file_fsync_close(&s.fpout) != 0)
{
mutt_perror("fclose");
mutt_sleep(2);
return -1;
}
}
Expand Down Expand Up @@ -1021,7 +1018,7 @@ int mutt_print_attachment(FILE *fp, struct Body *a)
mutt_str_strfcpy(command, entry->printcommand, sizeof(command));
piped = rfc1524_expand_command(a, newfile, type, command, sizeof(command));

mutt_endwin(NULL);
mutt_endwin();

/* interactive program */
if (piped)
Expand Down Expand Up @@ -1095,7 +1092,7 @@ int mutt_print_attachment(FILE *fp, struct Body *a)

mutt_debug(2, "successfully opened %s read-only\n", newfile);

mutt_endwin(NULL);
mutt_endwin();
thepid = mutt_create_filter(NONULL(PrintCommand), &fpout, NULL, NULL);
if (thepid < 0)
{
Expand Down
12 changes: 5 additions & 7 deletions commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ int mutt_display_message(struct Header *cur)
{
int r;

mutt_endwin(NULL);
mutt_endwin();
snprintf(buf, sizeof(buf), "%s %s", NONULL(Pager), tempfile);
r = mutt_system(buf);
if (r == -1)
Expand Down Expand Up @@ -266,7 +266,6 @@ void ci_bounce_message(struct Header *h)
if (!h->env->from)
{
mutt_error(_("Warning: message contains no From: header"));
mutt_sleep(2);
}
}
else if (Context)
Expand All @@ -276,7 +275,6 @@ void ci_bounce_message(struct Header *h)
if (message_is_tagged(Context, rc) && !Context->hdrs[rc]->env->from)
{
mutt_error(_("Warning: message contains no From: header"));
mutt_sleep(2);
break;
}
}
Expand Down Expand Up @@ -401,7 +399,7 @@ static int pipe_message(struct Header *h, char *cmd, int decode, int print,
if (h->security & ENCRYPT && !crypt_valid_passphrase(h->security))
return 1;
}
mutt_endwin(NULL);
mutt_endwin();

thepid = mutt_create_filter(cmd, &fpout, NULL, NULL);
if (thepid < 0)
Expand Down Expand Up @@ -444,7 +442,7 @@ static int pipe_message(struct Header *h, char *cmd, int decode, int print,
continue;

mutt_message_hook(Context, Context->hdrs[i], MUTT_MESSAGEHOOK);
mutt_endwin(NULL);
mutt_endwin();
thepid = mutt_create_filter(cmd, &fpout, NULL, NULL);
if (thepid < 0)
{
Expand All @@ -464,7 +462,7 @@ static int pipe_message(struct Header *h, char *cmd, int decode, int print,
}
else
{
mutt_endwin(NULL);
mutt_endwin();
thepid = mutt_create_filter(cmd, &fpout, NULL, NULL);
if (thepid < 0)
{
Expand Down Expand Up @@ -613,7 +611,7 @@ void mutt_shell_escape(void)
if (buf[0])
{
mutt_window_clearline(MuttMessageWindow, 0);
mutt_endwin(NULL);
mutt_endwin();
fflush(stdout);
int rc = mutt_system(buf);
if (rc == -1)
Expand Down
4 changes: 2 additions & 2 deletions conn/getdomain.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#include <sys/socket.h>
#include <time.h>
#include <unistd.h>
#include "mutt/debug.h"
#include "mutt/logging.h"
#include "mutt/memory.h"
#include "mutt/string2.h"

Expand Down Expand Up @@ -109,7 +109,7 @@ int getdnsdomainname(char *d, size_t len)
{
mutt_str_strfcpy(d, ++p, len);
rc = 0;
mutt_debug(1, "%s\n", d);
mutt_debug(1, "Hostname: %s\n", d);
freeaddrinfo(h);
}

Expand Down
3 changes: 1 addition & 2 deletions conn/sasl.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
#include <string.h>
#include <sys/socket.h>
#include <time.h>
#include "mutt/debug.h"
#include "mutt/logging.h"
#include "mutt/memory.h"
#include "mutt/message.h"
#include "mutt/string2.h"
Expand Down Expand Up @@ -607,7 +607,6 @@ int mutt_sasl_client_new(struct Connection *conn, sasl_conn_t **saslconn)
if (rc != SASL_OK)
{
mutt_error(_("Error allocating SASL connection"));
mutt_sleep(2);
return -1;
}

Expand Down
8 changes: 0 additions & 8 deletions conn/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ static int socket_preconnect(void)
{
const int save_errno = errno;
mutt_perror(_("Preconnect command failed."));
mutt_sleep(1);

return save_errno;
}
Expand Down Expand Up @@ -274,7 +273,6 @@ int mutt_socket_readchar(struct Connection *conn, char *c)
if (conn->available == 0)
{
mutt_error(_("Connection to %s closed"), conn->account.host);
mutt_sleep(2);
}
if (conn->available <= 0)
{
Expand Down Expand Up @@ -367,15 +365,13 @@ int raw_socket_read(struct Connection *conn, char *buf, size_t len)
if (rc == -1)
{
mutt_error(_("Error talking to %s (%s)"), conn->account.host, strerror(errno));
mutt_sleep(2);
SigInt = 0;
}
mutt_sig_allow_interrupt(0);

if (SigInt)
{
mutt_error(_("Connection to %s has been aborted"), conn->account.host);
mutt_sleep(2);
SigInt = 0;
rc = -1;
}
Expand All @@ -400,15 +396,13 @@ int raw_socket_write(struct Connection *conn, const char *buf, size_t count)
if (rc == -1)
{
mutt_error(_("Error talking to %s (%s)"), conn->account.host, strerror(errno));
mutt_sleep(2);
SigInt = 0;
}
mutt_sig_allow_interrupt(0);

if (SigInt)
{
mutt_error(_("Connection to %s has been aborted"), conn->account.host);
mutt_sleep(2);
SigInt = 0;
rc = -1;
}
Expand Down Expand Up @@ -516,7 +510,6 @@ int raw_socket_open(struct Connection *conn)
if (rc)
{
mutt_error(_("Could not find the host \"%s\""), conn->account.host);
mutt_sleep(2);
return -1;
}

Expand Down Expand Up @@ -607,7 +600,6 @@ int raw_socket_open(struct Connection *conn)
{
mutt_error(_("Could not connect to %s (%s)."), conn->account.host,
(rc > 0) ? strerror(rc) : _("unknown error"));
mutt_sleep(2);
return -1;
}

Expand Down
12 changes: 0 additions & 12 deletions conn/ssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
#include "mutt/debug.h"
#include "mutt/file.h"
#include "mutt/memory.h"
#include "mutt/message.h"
Expand Down Expand Up @@ -226,7 +225,6 @@ static int add_entropy(const char *file)
((st.st_mode & (S_IWOTH | S_IROTH)) != 0))
{
mutt_error(_("%s has insecure permissions!"), file);
mutt_sleep(2);
return -1;
}

Expand Down Expand Up @@ -373,7 +371,6 @@ static int ssl_passwd_cb(char *buf, int size, int rwflag, void *userdata)
static int ssl_socket_open_err(struct Connection *conn)
{
mutt_error(_("SSL disabled due to the lack of entropy"));
mutt_sleep(2);
return -1;
}

Expand Down Expand Up @@ -518,7 +515,6 @@ static bool check_certificate_expiration(X509 *peercert, bool silent)
{
mutt_debug(2, "Server certificate is not yet valid\n");
mutt_error(_("Server certificate is not yet valid"));
mutt_sleep(2);
}
return false;
}
Expand All @@ -528,7 +524,6 @@ static bool check_certificate_expiration(X509 *peercert, bool silent)
{
mutt_debug(2, "Server certificate has expired\n");
mutt_error(_("Server certificate has expired"));
mutt_sleep(2);
}
return false;
}
Expand Down Expand Up @@ -621,7 +616,6 @@ static int ssl_init(void)
if (!HAVE_ENTROPY())
{
mutt_error(_("Failed to find enough entropy on your system"));
mutt_sleep(2);
return -1;
}
}
Expand Down Expand Up @@ -1078,7 +1072,6 @@ static int interactive_check_cert(X509 *cert, int idx, size_t len, SSL *ssl, int
if (!done)
{
mutt_error(_("Warning: Couldn't save certificate"));
mutt_sleep(2);
}
else
{
Expand Down Expand Up @@ -1199,7 +1192,6 @@ static int ssl_verify_callback(int preverify_ok, X509_STORE_CTX *ctx)
if (!check_host(cert, host, buf, sizeof(buf)))
{
mutt_error(_("Certificate host check failed: %s"), buf);
mutt_sleep(2);
/* we disallow (a)ccept always in the prompt, because it will have no effect
* for hostname mismatches. */
return interactive_check_cert(cert, pos, len, ssl, 0);
Expand Down Expand Up @@ -1279,7 +1271,6 @@ static int ssl_negotiate(struct Connection *conn, struct SslSockData *ssldata)
* TLS Server Name Indication (SNI). This allows the server to present
* the correct certificate if it supports multiple hosts. */
mutt_error(_("Warning: unable to set TLS SNI host name"));
mutt_sleep(1);
}

ERR_clear_error();
Expand All @@ -1300,7 +1291,6 @@ static int ssl_negotiate(struct Connection *conn, struct SslSockData *ssldata)
}

mutt_error(_("SSL failed: %s"), errmsg);
mutt_sleep(1);

return -1;
}
Expand Down Expand Up @@ -1389,7 +1379,6 @@ static int ssl_socket_open(struct Connection *conn)
if (ssl_set_verify_partial(data->ctx))
{
mutt_error(_("Warning: error enabling ssl_verify_partial_chains"));
mutt_sleep(2);
}

data->ssl = SSL_new(data->ctx);
Expand Down Expand Up @@ -1490,7 +1479,6 @@ int mutt_ssl_starttls(struct Connection *conn)
if (ssl_set_verify_partial(ssldata->ctx))
{
mutt_error(_("Warning: error enabling ssl_verify_partial_chains"));
mutt_sleep(2);
}

ssldata->ssl = SSL_new(ssldata->ctx);
Expand Down
Loading

0 comments on commit 9deaed2

Please sign in to comment.