From: Pierre Habouzit Date: Sun, 12 Nov 2006 00:35:27 +0000 (+0100) Subject: move mutt_strsysexit into lib-sys/exit.[hc] X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=commitdiff_plain;h=06797b065bbd5d88bf473c4b9f8525dcb9990bb7;ds=sidebyside move mutt_strsysexit into lib-sys/exit.[hc] Signed-off-by: Pierre Habouzit --- diff --git a/commands.c b/commands.c index 3ad59c8..6a0dc10 100644 --- a/commands.c +++ b/commands.c @@ -29,6 +29,8 @@ #include +#include + #include #include #include diff --git a/lib-sys/Makefile.am b/lib-sys/Makefile.am index de7194f..5e896e5 100644 --- a/lib-sys/Makefile.am +++ b/lib-sys/Makefile.am @@ -1,7 +1,10 @@ noinst_LIBRARIES = libsys.a -libsys_a_SOURCES = mutt_socket.h mutt_tunnel.c mutt_ssl.h \ - mutt_socket.c mutt_tunnel.h mutt_ssl.c mutt_ssl_gnutls.c +libsys_a_SOURCES = exit.h \ + exit.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 noinst_HEADERS = mutt_socket.h mutt_tunnel.c mutt_ssl.h diff --git a/lib-sys/exit.c b/lib-sys/exit.c new file mode 100644 index 0000000..0b4e499 --- /dev/null +++ b/lib-sys/exit.c @@ -0,0 +1,106 @@ +/* + * 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 + */ +/* + * Copyright notice from original mutt: + * Copyright (C) 1996-2000 Michael R. Elkins + * Copyright (C) 1999-2000 Thomas Roessler + * + * This file is part of mutt-ng, see http://www.muttng.org/. + * It's licensed under the GNU General Public License, + * please see the file GPL in the top level source directory. + */ + +#if HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#ifdef HAVE_SYSEXITS_H +#include +#else /* Make sure EX_OK is defined */ +#define EX_OK 0 +#endif + +#include + +#include "exit.h" + +static const struct { + int v; + const char *str; +} sysexits_h[] = { +#ifdef EX_USAGE + { 0xff & EX_USAGE, "Bad usage." }, +#endif +#ifdef EX_DATAERR + { 0xff & EX_DATAERR, "Data format error." }, +#endif +#ifdef EX_NOINPUT + { 0xff & EX_NOINPUT, "Cannot open input." }, +#endif +#ifdef EX_NOUSER + { 0xff & EX_NOUSER, "User unknown." }, +#endif +#ifdef EX_NOHOST + { 0xff & EX_NOHOST, "Host unknown." }, +#endif +#ifdef EX_UNAVAILABLE + { 0xff & EX_UNAVAILABLE, "Service unavailable." }, +#endif +#ifdef EX_SOFTWARE + { 0xff & EX_SOFTWARE, "Internal error." }, +#endif +#ifdef EX_OSERR + { 0xff & EX_OSERR, "Operating system error." }, +#endif +#ifdef EX_OSFILE + { 0xff & EX_OSFILE, "System file missing." }, +#endif +#ifdef EX_CANTCREAT + { 0xff & EX_CANTCREAT, "Can't create output." }, +#endif +#ifdef EX_IOERR + { 0xff & EX_IOERR, "I/O error." }, +#endif +#ifdef EX_TEMPFAIL + { 0xff & EX_TEMPFAIL, "Deferred." }, +#endif +#ifdef EX_PROTOCOL + { 0xff & EX_PROTOCOL, "Remote protocol error." }, +#endif +#ifdef EX_NOPERM + { 0xff & EX_NOPERM, "Insufficient permission." }, +#endif +#ifdef EX_CONFIG + { 0xff & EX_NOPERM, "Local configuration error." }, +#endif + { S_ERR, "Exec error." }, +}; + +const char *m_strsysexit(int e) +{ + int i; + + for (i = 0; countof(sysexits_h); i++) { + if (e == sysexits_h[i].v) + return sysexits_h[i].str; + } + + return ""; +} diff --git a/lib-sys/exit.h b/lib-sys/exit.h new file mode 100644 index 0000000..2602ebd --- /dev/null +++ b/lib-sys/exit.h @@ -0,0 +1,38 @@ +/* + * 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 + */ +/* + * Copyright notice from original mutt: + * Copyright (C) 1996-2000 Michael R. Elkins + * Copyright (C) 1999-2000 Thomas Roessler + * + * This file is part of mutt-ng, see http://www.muttng.org/. + * It's licensed under the GNU General Public License, + * please see the file GPL in the top level source directory. + */ + +#ifndef MUTT_LIB_SYS_EXIT_H +#define MUTT_LIB_SYS_EXIT_H + +/* Exit values used in send_msg() */ +#define S_ERR 127 +#define S_BKG 126 + +const char *m_strsysexit(int e); + +#endif /* MUTT_LIB_SYS_EXIT_H */ diff --git a/lib-sys/mutt_tunnel.c b/lib-sys/mutt_tunnel.c index a37fa11..d82ec63 100644 --- a/lib-sys/mutt_tunnel.c +++ b/lib-sys/mutt_tunnel.c @@ -127,7 +127,7 @@ static int tunnel_socket_close (CONNECTION * conn) if (!WIFEXITED(status) || WEXITSTATUS(status)) { mutt_error(_("Tunnel to %s returned error %d (%s)"), conn->account.host, WEXITSTATUS(status), - NONULL(mutt_strsysexit(WEXITSTATUS(status)))); + m_strsysexit(WEXITSTATUS(status))); mutt_sleep (2); } p_delete(&conn->sockdata); diff --git a/lib.c b/lib.c index d07878a..39676a5 100644 --- a/lib.c +++ b/lib.c @@ -28,12 +28,6 @@ #include #include -#ifdef HAVE_SYSEXITS_H -#include -#else /* Make sure EX_OK is defined */ -#define EX_OK 0 -#endif - #include #include #include @@ -41,63 +35,6 @@ #include "lib.h" - -static struct sysexits -{ - int v; - const char *str; -} -sysexits_h[] = -{ -#ifdef EX_USAGE - { 0xff & EX_USAGE, "Bad usage." }, -#endif -#ifdef EX_DATAERR - { 0xff & EX_DATAERR, "Data format error." }, -#endif -#ifdef EX_NOINPUT - { 0xff & EX_NOINPUT, "Cannot open input." }, -#endif -#ifdef EX_NOUSER - { 0xff & EX_NOUSER, "User unknown." }, -#endif -#ifdef EX_NOHOST - { 0xff & EX_NOHOST, "Host unknown." }, -#endif -#ifdef EX_UNAVAILABLE - { 0xff & EX_UNAVAILABLE, "Service unavailable." }, -#endif -#ifdef EX_SOFTWARE - { 0xff & EX_SOFTWARE, "Internal error." }, -#endif -#ifdef EX_OSERR - { 0xff & EX_OSERR, "Operating system error." }, -#endif -#ifdef EX_OSFILE - { 0xff & EX_OSFILE, "System file missing." }, -#endif -#ifdef EX_CANTCREAT - { 0xff & EX_CANTCREAT, "Can't create output." }, -#endif -#ifdef EX_IOERR - { 0xff & EX_IOERR, "I/O error." }, -#endif -#ifdef EX_TEMPFAIL - { 0xff & EX_TEMPFAIL, "Deferred." }, -#endif -#ifdef EX_PROTOCOL - { 0xff & EX_PROTOCOL, "Remote protocol error." }, -#endif -#ifdef EX_NOPERM - { 0xff & EX_NOPERM, "Insufficient permission." }, -#endif -#ifdef EX_CONFIG - { 0xff & EX_NOPERM, "Local configuration error." }, -#endif - { S_ERR, "Exec error." }, - { -1, NULL} -}; - void mutt_nocurses_error (const char *fmt, ...) { va_list ap; @@ -108,17 +45,3 @@ void mutt_nocurses_error (const char *fmt, ...) fputc ('\n', stderr); } - -const char * -mutt_strsysexit(int e) -{ - int i; - - for(i = 0; sysexits_h[i].str; i++) - { - if(e == sysexits_h[i].v) - break; - } - - return sysexits_h[i].str; -} diff --git a/lib.h b/lib.h index 44a793a..3985310 100644 --- a/lib.h +++ b/lib.h @@ -31,14 +31,8 @@ void mutt_exit (int); -/* Exit values used in send_msg() */ -#define S_ERR 127 -#define S_BKG 126 - /* The actual library functions. */ void mutt_nocurses_error (const char *, ...); -const char *mutt_strsysexit(int e); - #endif diff --git a/sendlib.c b/sendlib.c index 2afe601..e6c0359 100644 --- a/sendlib.c +++ b/sendlib.c @@ -31,6 +31,8 @@ #include #include +#include + #include #include @@ -2024,11 +2026,8 @@ static int mutt_invoke_sendmail (address_t * from, /* the sender */ if ((i = send_msg (path, args, msg, &childout)) != (EX_OK & 0xff)) { if (i != S_BKG) { - const char *e = mutt_strsysexit (i); - - e = mutt_strsysexit (i); mutt_error (_("Error sending message, child exited %d (%s)."), i, - NONULL (e)); + m_strsysexit(i)); if (childout) { struct stat st;