From dbacadf0ce81052365d7a43373ac7d4ac67ff91e Mon Sep 17 00:00:00 2001 From: Pierre Habouzit Date: Sun, 12 Nov 2006 14:45:21 +0100 Subject: [PATCH] move signal.c into lib/sys Signed-off-by: Pierre Habouzit --- Makefile.am | 7 +++---- compress.c | 2 ++ filter.c | 6 ++++-- init.c | 2 ++ lib-lib/mapping.c | 1 + lib-sys/Makefile.am | 4 ++-- signal.c => lib-sys/mutt_signal.c | 22 ++++++++++----------- lib-sys/mutt_signal.h | 32 +++++++++++++++++++++++++++++++ lib-sys/mutt_socket.c | 27 +++++++++++++------------- lib-sys/mutt_tunnel.c | 1 + lib-ui/curs_lib.c | 2 ++ main.c | 9 ++++----- mbox.c | 2 ++ protos.h | 6 ------ sendlib.c | 1 + system.c | 8 +++++--- 16 files changed, 85 insertions(+), 47 deletions(-) rename signal.c => lib-sys/mutt_signal.c (96%) create mode 100644 lib-sys/mutt_signal.h diff --git a/Makefile.am b/Makefile.am index 6e18b90..ed8d667 100644 --- a/Makefile.am +++ b/Makefile.am @@ -18,15 +18,14 @@ BUILT_SOURCES = keymap_defs.h version.h bin_PROGRAMS = madmutt madmutt_dotlock pgpringng pgpewrapng smime_keysng madmutt_SOURCES = $(BUILT_SOURCES) \ alias.c attach.c base64.c browser.c buffy.c \ - charset.c compress.c commands.c complete.c \ - compose.c copy.c editmsg.c \ + charset.c compress.c commands.c complete.c \ + compose.c copy.c editmsg.c init.c keymap.c lib.c \ flags.c filter.c from.c getdomain.c \ handler.c hcache.c hdrline.c headers.c help.c history.c hook.c \ - init.c keymap.c lib.c \ main.c mbox.c mbyte.c mh.c muttlib.c mutt_idna.c mx.c \ pager.c pattern.c postpone.c query.c \ recvattach.c recvcmd.c rfc1524.c rfc3676.c \ - score.c send.c sendlib.c sidebar.c signal.c sort.c state.c status.c system.c \ + score.c send.c sendlib.c sidebar.c sort.c state.c status.c system.c \ thread.c url.c utf8.c wcwidth.c account.c madmutt_LDADD = @MUTT_LIB_OBJECTS@ @LIBOBJS@ \ diff --git a/compress.c b/compress.c index fd8b97d..456719a 100644 --- a/compress.c +++ b/compress.c @@ -18,6 +18,8 @@ #include #include +#include + #include #include "mutt.h" diff --git a/filter.c b/filter.c index 530f16f..ef052b5 100644 --- a/filter.c +++ b/filter.c @@ -11,12 +11,14 @@ # include "config.h" #endif -#include "mutt.h" - #include #include #include +#include + +#include "mutt.h" + /* Invokes a commmand on a pipe and optionally connects its stdin and stdout * to the specified handles. */ diff --git a/init.c b/init.c index 5151f5a..a9b318e 100644 --- a/init.c +++ b/init.c @@ -24,6 +24,8 @@ #include #include +#include + #include #include "mutt.h" diff --git a/lib-lib/mapping.c b/lib-lib/mapping.c index c3065ba..d8d8200 100644 --- a/lib-lib/mapping.c +++ b/lib-lib/mapping.c @@ -32,6 +32,7 @@ #include #include "mapping.h" +#include "ascii.h" const char *mutt_getnamebyvalue(int val, const struct mapping_t *map) { diff --git a/lib-sys/Makefile.am b/lib-sys/Makefile.am index 18d56c7..e73c14f 100644 --- a/lib-sys/Makefile.am +++ b/lib-sys/Makefile.am @@ -1,7 +1,7 @@ noinst_LIBRARIES = libsys.a -libsys_a_SOURCES = exit.h unix.h \ - exit.c unix.c \ +libsys_a_SOURCES = exit.h unix.h mutt_signal.h \ + exit.c unix.c mutt_signal.c \ $(___networking_part____) \ mutt_socket.h mutt_tunnel.c mutt_ssl.h \ mutt_socket.c mutt_tunnel.h mutt_ssl.c mutt_ssl_gnutls.c diff --git a/signal.c b/lib-sys/mutt_signal.c similarity index 96% rename from signal.c rename to lib-sys/mutt_signal.c index 6600a82..159612b 100644 --- a/signal.c +++ b/lib-sys/mutt_signal.c @@ -11,17 +11,17 @@ # include "config.h" #endif -#include - -#include - -#include "mutt.h" - #include #include #include #include +#include + +#include + +#include "mutt_signal.h" + static sigset_t Sigset; static sigset_t SigsetSys; static struct sigaction SysOldInt; @@ -33,13 +33,13 @@ RETSIGTYPE exit_handler (int sig) { curs_set (1); endwin (); /* just to be safe */ -#if SYS_SIGLIST_DECLARED +#ifdef SYS_SIGLIST_DECLARED printf (_("%s... Exiting.\n"), sys_siglist[sig]); #else -#if (__sun__ && __svr4__) +#if defined(__sun__) && defined(__svr4__) printf (_("Caught %s... Exiting.\n"), _sys_siglist[sig]); #else -#if (__alpha && __osf__) +#if defined(__alpha) && defined(__osf__) printf (_("Caught %s... Exiting.\n"), __sys_siglist[sig]); #else printf (_("Caught signal %d... Exiting.\n"), sig); @@ -49,7 +49,7 @@ RETSIGTYPE exit_handler (int sig) exit (0); } -RETSIGTYPE chld_handler (int sig) +RETSIGTYPE chld_handler(int sig __attribute__((unused))) { /* empty */ } @@ -100,7 +100,7 @@ int mutt_intr_hook (void) } #endif /* USE_SLANG_CURSES */ -void mutt_signal_init (void) +void mutt_signal_initialize (void) { struct sigaction act; diff --git a/lib-sys/mutt_signal.h b/lib-sys/mutt_signal.h new file mode 100644 index 0000000..36a34a8 --- /dev/null +++ b/lib-sys/mutt_signal.h @@ -0,0 +1,32 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * Copyright © 2006 Pierre Habouzit + */ + +#ifndef MUTT_LIB_SYS_SIGNAL_H +#define MUTT_LIB_SYS_SIGNAL_H + +void mutt_signal_initialize(void); + +void mutt_block_signals(void); +void mutt_unblock_signals(void); +void mutt_block_signals_system(void); +void mutt_unblock_signals_system(int); + +void mutt_allow_interrupt(int); + +#endif diff --git a/lib-sys/mutt_socket.c b/lib-sys/mutt_socket.c index e3874d1..e3cd00d 100644 --- a/lib-sys/mutt_socket.c +++ b/lib-sys/mutt_socket.c @@ -13,6 +13,16 @@ # include "config.h" #endif +#include +#include +#include +#include +#include +#include +#include +#include +#include + #include #include #include @@ -20,25 +30,14 @@ #include "mutt.h" #include "globals.h" + #include "mutt_socket.h" #include "mutt_tunnel.h" -#if defined(USE_SSL) || defined(USE_GNUTLS) -# include "mutt_ssl.h" -#endif +#include "mutt_signal.h" +#include "mutt_ssl.h" #include "mutt_idna.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - /* support for multiple socket connections */ static CONNECTION *Connections = NULL; diff --git a/lib-sys/mutt_tunnel.c b/lib-sys/mutt_tunnel.c index b74c5c5..d94f4a0 100644 --- a/lib-sys/mutt_tunnel.c +++ b/lib-sys/mutt_tunnel.c @@ -28,6 +28,7 @@ #include "exit.h" #include "mutt_socket.h" #include "mutt_tunnel.h" +#include "mutt_signal.h" /* -- data types -- */ typedef struct { diff --git a/lib-ui/curs_lib.c b/lib-ui/curs_lib.c index 318ee85..56e796b 100644 --- a/lib-ui/curs_lib.c +++ b/lib-ui/curs_lib.c @@ -35,6 +35,8 @@ #include #include +#include + #include "curses.h" #include "menu.h" #include "enter.h" diff --git a/main.c b/main.c index ab893ca..4a735ef 100644 --- a/main.c +++ b/main.c @@ -33,6 +33,8 @@ #include #include +#include + #include #include "mutt.h" @@ -465,17 +467,14 @@ static void start_curses (void) #else /* should come before initscr() so that ncurses 4.2 doesn't try to install its own SIGWINCH handler */ - mutt_signal_init (); + mutt_signal_initialize (); #endif if (initscr () == NULL) { puts _("Error initializing terminal."); exit (1); } -#if 1 /* USE_SLANG_CURSES - commenting out suggested in #455. */ - /* slang requires the signal handlers to be set after initializing */ - mutt_signal_init (); -#endif + mutt_signal_initialize (); ci_start_color (); keypad (stdscr, TRUE); cbreak (); diff --git a/mbox.c b/mbox.c index d4d3a08..5f76334 100644 --- a/mbox.c +++ b/mbox.c @@ -28,6 +28,8 @@ #include #include +#include + #include "mutt.h" #include "mx.h" #include "buffy.h" diff --git a/protos.h b/protos.h index d72450d..ee8527d 100644 --- a/protos.h +++ b/protos.h @@ -98,9 +98,6 @@ void mutt_account_hook (const char *url); void mutt_add_to_reference_headers (ENVELOPE * env, ENVELOPE * curenv, LIST *** pp, LIST *** qq); void mutt_adv_mktemp (const char*, char*, size_t); -void mutt_allow_interrupt (int); -void mutt_block_signals (void); -void mutt_block_signals_system (void); int mutt_bounce_message (FILE * fp, HEADER *, address_t *); void mutt_canonical_charset (char *, size_t, const char *); void mutt_check_rescore (CONTEXT *); @@ -168,12 +165,9 @@ void _mutt_set_flag (CONTEXT *, HEADER *, int, int, int); void mutt_set_followup_to (ENVELOPE *); void mutt_shell_escape (void); void mutt_show_error (void); -void mutt_signal_init (void); void mutt_stamp_attachment (BODY * a); void mutt_tabs_to_spaces (char *); void mutt_tag_set_flag (int, int); -void mutt_unblock_signals (void); -void mutt_unblock_signals_system (int); void mutt_update_encoding (BODY * a); void mutt_version (void); void mutt_write_references (LIST *, FILE *); diff --git a/sendlib.c b/sendlib.c index e6c0359..e911fed 100644 --- a/sendlib.c +++ b/sendlib.c @@ -32,6 +32,7 @@ #include #include +#include #include diff --git a/system.c b/system.c index 2d96430..384b7e7 100644 --- a/system.c +++ b/system.c @@ -11,9 +11,6 @@ # include "config.h" #endif -#include "mutt.h" -#include - #include #include #include @@ -21,6 +18,11 @@ #include #include +#include + +#include "mutt.h" +#include + int _mutt_system (const char *cmd, int flags) { int rc = -1; -- 2.20.1