]> granicus.if.org Git - neomutt/commitdiff
standardise the naming of the signal functions
authorRichard Russon <rich@flatcap.org>
Thu, 23 Nov 2017 16:06:13 +0000 (16:06 +0000)
committerRichard Russon <rich@flatcap.org>
Mon, 27 Nov 2017 00:04:29 +0000 (00:04 +0000)
13 files changed:
compress.c
conn/socket.c
conn/tunnel.c
curs_lib.c
filter.c
imap/command.c
imap/util.c
mbox.c
mutt/signal.c
mutt/signal2.h
protos.h
sendlib.c
system.c

index bd806bb1baaded35daa5a2964eca895701badf19..407ee0d20d008bf105d401b7d74bac4bc9c29a52 100644 (file)
@@ -422,7 +422,7 @@ static int execute_command(struct Context *ctx, const char *command, const char
   if (!ctx->quiet)
     mutt_message(progress, ctx->realpath);
 
-  mutt_block_signals();
+  mutt_sig_block();
   endwin();
   fflush(stdout);
 
@@ -435,7 +435,7 @@ static int execute_command(struct Context *ctx, const char *command, const char
     mutt_error(_("Error running \"%s\"!"), sys_cmd);
   }
 
-  mutt_unblock_signals();
+  mutt_sig_unblock();
 
   return rc;
 }
index bf3916962b0cbdb13524e7b625e709355965cc52..c8f358ff4662e4b5b9e8edffc2e5a8095e540db5 100644 (file)
@@ -129,7 +129,7 @@ static int socket_connect(int fd, struct sockaddr *sa)
   if (ConnectTimeout > 0)
     alarm(ConnectTimeout);
 
-  mutt_allow_interrupt(1);
+  mutt_sig_allow_interrupt(1);
 
   /* FreeBSD's connect() does not respect SA_RESTART, meaning
    * a SIGWINCH will cause the connect to fail. */
@@ -148,7 +148,7 @@ static int socket_connect(int fd, struct sockaddr *sa)
 
   if (ConnectTimeout > 0)
     alarm(0);
-  mutt_allow_interrupt(0);
+  mutt_sig_allow_interrupt(0);
   sigprocmask(SIG_UNBLOCK, &set, NULL);
 
   return save_errno;
@@ -370,7 +370,7 @@ int raw_socket_read(struct Connection *conn, char *buf, size_t len)
 {
   int rc;
 
-  mutt_allow_interrupt(1);
+  mutt_sig_allow_interrupt(1);
   rc = read(conn->fd, buf, len);
   if (rc == -1)
   {
@@ -378,7 +378,7 @@ int raw_socket_read(struct Connection *conn, char *buf, size_t len)
     mutt_sleep(2);
     SigInt = 0;
   }
-  mutt_allow_interrupt(0);
+  mutt_sig_allow_interrupt(0);
 
   if (SigInt)
   {
@@ -403,7 +403,7 @@ int raw_socket_write(struct Connection *conn, const char *buf, size_t count)
 {
   int rc;
 
-  mutt_allow_interrupt(1);
+  mutt_sig_allow_interrupt(1);
   rc = write(conn->fd, buf, count);
   if (rc == -1)
   {
@@ -411,7 +411,7 @@ int raw_socket_write(struct Connection *conn, const char *buf, size_t count)
     mutt_sleep(2);
     SigInt = 0;
   }
-  mutt_allow_interrupt(0);
+  mutt_sig_allow_interrupt(0);
 
   if (SigInt)
   {
index 99a2f550a2bcb63d5c5324eaf8da8dd2dcbcfdef..9d58de3317609b3a7c714998fcff469ddeae218c 100644 (file)
@@ -99,11 +99,11 @@ static int tunnel_socket_open(struct Connection *conn)
     return -1;
   }
 
-  mutt_block_signals_system();
+  mutt_sig_block_system();
   pid = fork();
   if (pid == 0)
   {
-    mutt_unblock_signals_system(0);
+    mutt_sig_unblock_system(0);
     devnull = open("/dev/null", O_RDWR);
     if (devnull < 0 || dup2(pout[0], STDIN_FILENO) < 0 ||
         dup2(pin[1], STDOUT_FILENO) < 0 || dup2(devnull, STDERR_FILENO) < 0)
@@ -122,7 +122,7 @@ static int tunnel_socket_open(struct Connection *conn)
     execle(EXECSHELL, "sh", "-c", Tunnel, NULL, mutt_envlist());
     _exit(127);
   }
-  mutt_unblock_signals_system(1);
+  mutt_sig_unblock_system(1);
 
   if (pid == -1)
   {
index 33ddaea91bfd0f063dbf5b477e24f44481cc9234..19b0aa75ff1cb3b9ae89f74377876405b006617c 100644 (file)
@@ -134,14 +134,14 @@ struct Event mutt_getch(void)
 
   SigInt = 0;
 
-  mutt_allow_interrupt(1);
+  mutt_sig_allow_interrupt(1);
 #ifdef KEY_RESIZE
   /* ncurses 4.2 sends this when the screen is resized */
   ch = KEY_RESIZE;
   while (ch == KEY_RESIZE)
 #endif /* KEY_RESIZE */
     ch = getch();
-  mutt_allow_interrupt(0);
+  mutt_sig_allow_interrupt(0);
 
   if (SigInt)
   {
index bef7276e72784f264e8f041f20e3a5e1f151f37d..2775aeb5dbd99ac867a3cfbd7cdc98c4c520323f 100644 (file)
--- a/filter.c
+++ b/filter.c
@@ -98,12 +98,12 @@ pid_t mutt_create_filter_fd(const char *cmd, FILE **in, FILE **out, FILE **err,
     }
   }
 
-  mutt_block_signals_system();
+  mutt_sig_block_system();
 
   thepid = fork();
   if (thepid == 0)
   {
-    mutt_unblock_signals_system(0);
+    mutt_sig_unblock_system(0);
 
     if (in)
     {
@@ -152,7 +152,7 @@ pid_t mutt_create_filter_fd(const char *cmd, FILE **in, FILE **out, FILE **err,
   }
   else if (thepid == -1)
   {
-    mutt_unblock_signals_system(1);
+    mutt_sig_unblock_system(1);
 
     if (in)
     {
@@ -212,7 +212,7 @@ int mutt_wait_filter(pid_t pid)
   int rc;
 
   waitpid(pid, &rc, 0);
-  mutt_unblock_signals_system(1);
+  mutt_sig_unblock_system(1);
   rc = WIFEXITED(rc) ? WEXITSTATUS(rc) : -1;
 
   return rc;
index bb3bc0db6254d820bb6e297b807e631584df512a..eba868e8e52032111a545d7d74a21bfe293d1087 100644 (file)
@@ -1121,11 +1121,11 @@ int imap_exec(struct ImapData *idata, const char *cmdstr, int flags)
   }
 
   /* Allow interruptions, particularly useful if there are network problems. */
-  mutt_allow_interrupt(1);
+  mutt_sig_allow_interrupt(1);
   do
     rc = imap_cmd_step(idata);
   while (rc == IMAP_CMD_CONTINUE);
-  mutt_allow_interrupt(0);
+  mutt_sig_allow_interrupt(0);
 
   if (rc == IMAP_CMD_NO && (flags & IMAP_CMD_FAIL_OK))
     return -2;
index aed0f85c5b570573cd30e2ed2cfa6e98b408369c..ceaafeb3e2859997cc4069d5286b9f6f8e8ea671 100644 (file)
@@ -981,7 +981,7 @@ int imap_wait_keepalive(pid_t pid)
   sigprocmask(SIG_SETMASK, NULL, &oldmask);
 
   sigemptyset(&act.sa_mask);
-  act.sa_handler = empty_signal_handler;
+  act.sa_handler = mutt_sig_empty_handler;
 #ifdef SA_INTERRUPT
   act.sa_flags = SA_INTERRUPT;
 #else
diff --git a/mbox.c b/mbox.c
index 0ad0e8609ffc3182e4e70434a9dab4f29412ae86..456e9606bc4a4deca7f0f27245c20048961c6628 100644 (file)
--- a/mbox.c
+++ b/mbox.c
@@ -446,10 +446,10 @@ static int mbox_open_mailbox(struct Context *ctx)
     mutt_perror(ctx->path);
     return -1;
   }
-  mutt_block_signals();
+  mutt_sig_block();
   if (mbox_lock_mailbox(ctx, 0, 1) == -1)
   {
-    mutt_unblock_signals();
+    mutt_sig_unblock();
     return -1;
   }
 
@@ -462,7 +462,7 @@ static int mbox_open_mailbox(struct Context *ctx)
   mutt_file_touch_atime(fileno(ctx->fp));
 
   mbox_unlock_mailbox(ctx);
-  mutt_unblock_signals();
+  mutt_sig_unblock();
   return rc;
 }
 
@@ -497,7 +497,7 @@ static int mbox_close_mailbox(struct Context *ctx)
   if (ctx->append)
   {
     mutt_file_unlock(ctx->path, fileno(ctx->fp));
-    mutt_unblock_signals();
+    mutt_sig_unblock();
   }
 
   mutt_file_fclose(&ctx->fp);
@@ -876,10 +876,10 @@ static int mbox_check_mailbox(struct Context *ctx, int *index_hint)
       /* lock the file if it isn't already */
       if (!ctx->locked)
       {
-        mutt_block_signals();
+        mutt_sig_block();
         if (mbox_lock_mailbox(ctx, 0, 0) == -1)
         {
-          mutt_unblock_signals();
+          mutt_sig_unblock();
           /* we couldn't lock the mailbox, but nothing serious happened:
            * probably the new mail arrived: no reason to wait till we can
            * parse it: we'll get it on the next pass
@@ -917,7 +917,7 @@ static int mbox_check_mailbox(struct Context *ctx, int *index_hint)
           if (unlock)
           {
             mbox_unlock_mailbox(ctx);
-            mutt_unblock_signals();
+            mutt_sig_unblock();
           }
 
           return MUTT_NEW_MAIL; /* signal that new mail arrived */
@@ -942,7 +942,7 @@ static int mbox_check_mailbox(struct Context *ctx, int *index_hint)
       if (unlock)
       {
         mbox_unlock_mailbox(ctx);
-        mutt_unblock_signals();
+        mutt_sig_unblock();
       }
       return MUTT_REOPENED;
     }
@@ -952,7 +952,7 @@ static int mbox_check_mailbox(struct Context *ctx, int *index_hint)
 
   mbox_unlock_mailbox(ctx);
   mx_fastclose_mailbox(ctx);
-  mutt_unblock_signals();
+  mutt_sig_unblock();
   mutt_error(_("Mailbox was corrupted!"));
   return -1;
 }
@@ -1048,11 +1048,11 @@ static int mbox_sync_mailbox(struct Context *ctx, int *index_hint)
     return -1;
   }
 
-  mutt_block_signals();
+  mutt_sig_block();
 
   if (mbox_lock_mailbox(ctx, 1, 1) == -1)
   {
-    mutt_unblock_signals();
+    mutt_sig_unblock();
     mutt_error(_("Unable to lock mailbox!"));
     goto bail;
   }
@@ -1227,7 +1227,7 @@ static int mbox_sync_mailbox(struct Context *ctx, int *index_hint)
   fp = fopen(tempfile, "r");
   if (!fp)
   {
-    mutt_unblock_signals();
+    mutt_sig_unblock();
     mx_fastclose_mailbox(ctx);
     mutt_debug(1, "unable to reopen temp copy of mailbox!\n");
     mutt_perror(tempfile);
@@ -1292,7 +1292,7 @@ static int mbox_sync_mailbox(struct Context *ctx, int *index_hint)
     snprintf(savefile, sizeof(savefile), "%s/mutt.%s-%s-%u", NONULL(Tmpdir),
              NONULL(Username), NONULL(ShortHostname), (unsigned int) getpid());
     rename(tempfile, savefile);
-    mutt_unblock_signals();
+    mutt_sig_unblock();
     mx_fastclose_mailbox(ctx);
     mutt_pretty_mailbox(savefile, sizeof(savefile));
     mutt_error(_("Write failed!  Saved partial mailbox to %s"), savefile);
@@ -1310,7 +1310,7 @@ static int mbox_sync_mailbox(struct Context *ctx, int *index_hint)
   if (!ctx->fp)
   {
     unlink(tempfile);
-    mutt_unblock_signals();
+    mutt_sig_unblock();
     mx_fastclose_mailbox(ctx);
     mutt_error(_("Fatal error!  Could not reopen mailbox!"));
     FREE(&newOffset);
@@ -1332,7 +1332,7 @@ static int mbox_sync_mailbox(struct Context *ctx, int *index_hint)
   FREE(&newOffset);
   FREE(&oldOffset);
   unlink(tempfile); /* remove partial copy of the mailbox */
-  mutt_unblock_signals();
+  mutt_sig_unblock();
 
   if (option(OPT_CHECK_MBOX_SIZE))
   {
@@ -1363,7 +1363,7 @@ bail: /* Come here in case of disaster */
   /* this is ok to call even if we haven't locked anything */
   mbox_unlock_mailbox(ctx);
 
-  mutt_unblock_signals();
+  mutt_sig_unblock();
   FREE(&newOffset);
   FREE(&oldOffset);
 
index 29cddc230ee8ecd2f63a767798edce1c19e8979b..371192b90f251ed4db56bd0e52f430fa10152cb9 100644 (file)
  *
  * Signal handling
  *
- * | Function                      | Description
- * | :---------------------------- | :---------------------------------------------------------
- * | default_exit_handler          | Notify the user and shutdown gracefully
- * | empty_signal_handler          | Dummy signal handler
- * | mutt_allow_interrupt          | Allow/disallow Ctrl-C (SIGINT)
- * | mutt_block_signals            | Block signals during critical operations
- * | mutt_block_signals_system     | Block signals before calling exec()
- * | mutt_sig_init                 | Initialise the signal handling
- * | mutt_unblock_signals          | Restore previously blocked signals
- * | mutt_unblock_signals_system   | Restore previously blocked signals
+ * | Function                   | Description
+ * | :------------------------- | :---------------------------------------------------------
+ * | mutt_sig_exit_handler()    | Notify the user and shutdown gracefully
+ * | mutt_sig_empty_handler()   | Dummy signal handler
+ * | mutt_sig_allow_interrupt() | Allow/disallow Ctrl-C (SIGINT)
+ * | mutt_sig_block()           | Block signals during critical operations
+ * | mutt_sig_block_system()    | Block signals before calling exec()
+ * | mutt_sig_init()            | Initialise the signal handling
+ * | mutt_sig_unblock()         | Restore previously blocked signals
+ * | mutt_sig_unblock_system()  | Restore previously blocked signals
  */
 
 #include "config.h"
@@ -55,26 +55,26 @@ static struct sigaction SysOldQuit;
 static bool SignalsBlocked;
 static bool SysSignalsBlocked;
 
-static sig_handler_t sig_handler = empty_signal_handler;
-static sig_handler_t exit_handler = default_exit_handler;
+static sig_handler_t sig_handler = mutt_sig_empty_handler;
+static sig_handler_t exit_handler = mutt_sig_exit_handler;
 
 /**
- * empty_signal_handler - Dummy signal handler
+ * mutt_sig_empty_handler - Dummy signal handler
  * @param sig Signal number, e.g. SIGINT
  *
  * Useful for signals that we can't ignore,
  * or don't want to do anything with.
  */
-void empty_signal_handler(int sig)
+void mutt_sig_empty_handler(int sig)
 {
   mutt_debug(2, "Received signal %d\n", sig);
 }
 
 /**
- * default_exit_handler - Notify the user and shutdown gracefully
+ * mutt_sig_exit_handler - Notify the user and shutdown gracefully
  * @param sig Signal number, e.g. SIGINT
  */
-void default_exit_handler(int sig)
+void mutt_sig_exit_handler(int sig)
 {
 #if HAVE_DECL_SYS_SIGLIST
   printf(_("%s...  Exiting.\n"), sys_siglist[sig]);
@@ -140,7 +140,7 @@ void mutt_sig_init(sig_handler_t sig_fn, sig_handler_t exit_fn)
 
   /* POSIX doesn't allow us to ignore SIGCHLD,
    * so we just install a dummy handler for it */
-  act.sa_handler = empty_signal_handler;
+  act.sa_handler = mutt_sig_empty_handler;
   /* don't need to block any other signals here */
   sigemptyset(&act.sa_mask);
   /* we don't want to mess with stopped children */
@@ -149,12 +149,12 @@ void mutt_sig_init(sig_handler_t sig_fn, sig_handler_t exit_fn)
 }
 
 /**
- * mutt_block_signals - Block signals during critical operations
+ * mutt_sig_block - Block signals during critical operations
  *
  * It's important that certain signals don't interfere with critical operations.
- * Call mutt_unblock_signals() to restore the signals' behaviour.
+ * Call mutt_sig_unblock() to restore the signals' behaviour.
  */
-void mutt_block_signals(void)
+void mutt_sig_block(void)
 {
   if (SignalsBlocked)
     return;
@@ -172,9 +172,9 @@ void mutt_block_signals(void)
 }
 
 /**
- * mutt_unblock_signals - Restore previously blocked signals
+ * mutt_sig_unblock - Restore previously blocked signals
  */
-void mutt_unblock_signals(void)
+void mutt_sig_unblock(void)
 {
   if (!SignalsBlocked)
     return;
@@ -184,12 +184,12 @@ void mutt_unblock_signals(void)
 }
 
 /**
- * mutt_block_signals_system - Block signals before calling exec()
+ * mutt_sig_block_system - Block signals before calling exec()
  *
  * It's important that certain signals don't interfere with the child process.
- * Call mutt_unblock_signals_system() to restore the signals' behaviour.
+ * Call mutt_sig_unblock_system() to restore the signals' behaviour.
  */
-void mutt_block_signals_system(void)
+void mutt_sig_block_system(void)
 {
   if (SysSignalsBlocked)
     return;
@@ -210,10 +210,10 @@ void mutt_block_signals_system(void)
 }
 
 /**
- * mutt_unblock_signals_system - Restore previously blocked signals
+ * mutt_sig_unblock_system - Restore previously blocked signals
  * @param catch If true, restore previous SIGINT, SIGQUIT behaviour
  */
-void mutt_unblock_signals_system(int catch)
+void mutt_sig_unblock_system(int catch)
 {
   if (!SysSignalsBlocked)
     return;
@@ -239,12 +239,12 @@ void mutt_unblock_signals_system(int catch)
 }
 
 /**
- * mutt_allow_interrupt - Allow/disallow Ctrl-C (SIGINT)
+ * mutt_sig_allow_interrupt - Allow/disallow Ctrl-C (SIGINT)
  * @param disposition True to allow Ctrl-C to interrupt signals
  *
  * Allow the user to interrupt some long operations.
  */
-void mutt_allow_interrupt(int disposition)
+void mutt_sig_allow_interrupt(int disposition)
 {
   struct sigaction sa;
 
index c368d76ad5a7ffb394f519b0e8bd8ef7e6385256..78e8429341268a76cf2e2d52935d2a18d9905f41 100644 (file)
 
 typedef void (*sig_handler_t)(int sig);
 
-void mutt_block_signals(void);
-void mutt_unblock_signals(void);
-void mutt_block_signals_system(void);
-void mutt_unblock_signals_system(int catch);
-void default_exit_handler(int sig);
-void empty_signal_handler(int sig);
 void mutt_sig_init(sig_handler_t sig_fn, sig_handler_t exit_fn);
-void mutt_allow_interrupt(int disposition);
+void mutt_sig_exit_handler(int sig);
+void mutt_sig_empty_handler(int sig);
+
+void mutt_sig_block(void);
+void mutt_sig_unblock(void);
+void mutt_sig_block_system(void);
+void mutt_sig_unblock_system(int catch);
+void mutt_sig_allow_interrupt(int disposition);
 
 #endif /* _MUTT_SIGNAL_H */
index 39ddfdcc3c640a61384f6b1d3e11c91401cf1e44..cbe806e1825ec287342810f6b56383e38f918e73 100644 (file)
--- a/protos.h
+++ b/protos.h
@@ -147,7 +147,7 @@ void mutt_account_hook(const char *url);
 void mutt_add_to_reference_headers(struct Envelope *env, struct Envelope *curenv);
 void mutt_adv_mktemp(char *s, size_t l);
 void mutt_alias_menu(char *buf, size_t buflen, struct Alias *aliases);
-void mutt_allow_interrupt(int disposition);
+void mutt_sig_allow_interrupt(int disposition);
 int mutt_body_handler(struct Body *b, struct State *s);
 int mutt_bounce_message(FILE *fp, struct Header *h, struct Address *to);
 void mutt_buffy(char *s, size_t slen);
index 70e18a0f5d0c851393e0635172fce5d4ebe39afa..ea69e2c31d15e542a3a97cb5b20cb5b4d39554ca 100644 (file)
--- a/sendlib.c
+++ b/sendlib.c
@@ -481,7 +481,7 @@ int mutt_write_mime_body(struct Body *a, FILE *f)
   else
     fc = fgetconv_open(fpin, 0, 0, 0);
 
-  mutt_allow_interrupt(1);
+  mutt_sig_allow_interrupt(1);
   if (a->encoding == ENCQUOTEDPRINTABLE)
     encode_quoted(fc, f, write_as_text_part(a));
   else if (a->encoding == ENCBASE64)
@@ -490,7 +490,7 @@ int mutt_write_mime_body(struct Body *a, FILE *f)
     encode_8bit(fc, f, write_as_text_part(a));
   else
     mutt_file_copy_stream(fpin, f);
-  mutt_allow_interrupt(0);
+  mutt_sig_allow_interrupt(0);
 
   fgetconv_close(&fc);
   mutt_file_fclose(&fpin);
@@ -2291,7 +2291,7 @@ static int send_msg(const char *path, char **args, const char *msg, char **tempf
   int fd, st;
   pid_t pid, ppid;
 
-  mutt_block_signals_system();
+  mutt_sig_block_system();
 
   sigemptyset(&set);
   /* we also don't want to be stopped right now */
@@ -2441,7 +2441,7 @@ static int send_msg(const char *path, char **args, const char *msg, char **tempf
   else
     st = S_ERR; /* error */
 
-  mutt_unblock_signals_system(1);
+  mutt_sig_unblock_system(1);
 
   return st;
 }
index 1d4ee79b08f78e6185667a34559c0d5f2e6cd259..50b98b7aab56054888bb40ca16d7e566d18893cb 100644 (file)
--- a/system.c
+++ b/system.c
@@ -57,7 +57,7 @@ int mutt_system(const char *cmd)
 
   /* must ignore SIGINT and SIGQUIT */
 
-  mutt_block_signals_system();
+  mutt_sig_block_system();
 
   act.sa_handler = SIG_DFL;
 /* we want to restart the waitpid() below */
@@ -74,7 +74,7 @@ int mutt_system(const char *cmd)
     act.sa_flags = 0;
 
     /* reset signals for the child; not really needed, but... */
-    mutt_unblock_signals_system(0);
+    mutt_sig_unblock_system(0);
     act.sa_handler = SIG_DFL;
     act.sa_flags = 0;
     sigemptyset(&act.sa_mask);
@@ -96,7 +96,7 @@ int mutt_system(const char *cmd)
   sigaction(SIGTSTP, &oldtstp, NULL);
 
   /* reset SIGINT, SIGQUIT and SIGCHLD */
-  mutt_unblock_signals_system(1);
+  mutt_sig_unblock_system(1);
 
   rc = (thepid != -1) ? (WIFEXITED(rc) ? WEXITSTATUS(rc) : -1) : -1;