--- gvpe/src/slog.C 2003/03/01 15:53:03 1.1 +++ gvpe/src/slog.C 2011/02/08 23:11:36 1.7 @@ -1,20 +1,32 @@ /* slog.C -- logging - Copyright (C) 2003 Marc Lehmannn + Copyright (C) 2003-2008 Marc Lehmann - 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. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + This file is part of GVPE. + + GVPE 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 3 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, see . + + Additional permission under GNU GPL version 3 section 7 + + If you modify this Program, or any covered work, by linking or + combining it with the OpenSSL project's OpenSSL library (or a modified + version of that library), containing parts covered by the terms of the + OpenSSL or SSLeay licenses, the licensors of this Program grant you + additional permission to convey the resulting work. Corresponding + Source for a non-source form of such a combination shall include the + source code for the parts of OpenSSL used as well as that of the + covered work. */ #include @@ -31,7 +43,8 @@ const char *log_identity = ""; static int logto = LOGTO_STDERR; -loglevel string_to_loglevel (const char *s) +loglevel +string_to_loglevel (const char *s) { if (!strcmp (s, "noise")) return L_NOISE; if (!strcmp (s, "trace")) return L_TRACE; @@ -45,7 +58,8 @@ return L_NONE; } -void log_to (int mask) +void +log_to (int mask) { if (logto & LOGTO_SYSLOG) closelog (); @@ -56,7 +70,8 @@ openlog (log_identity, LOG_CONS | LOG_PID, LOG_DAEMON); } -void slog_ (const loglevel l, const char *m, ...) +void +slog_ (const loglevel l, const char *m, ...) { if (l >= log_level) { @@ -89,9 +104,23 @@ } } -void fatal (const char *m) +void +fatal (const char *m) { slog (L_CRIT, m); - exit (1); + exit (EXIT_FAILURE); +} + +void +require_failed (const char *file, int line, const char *info) +{ + slog (L_CRIT, "FATAL: This program encountered a SHOULD NOT HAPPEN condition and will exit:"); + slog (L_CRIT, "FATAL+ %s:%d '%s' is false", file, line, info); + slog (L_CRIT, "FATAL+ This might indicates a bug in this program, a bug in your libraries,"); + slog (L_CRIT, "FATAL+ your system setup or operating system. Or it might indicate a very"); + slog (L_CRIT, "FATAL+ unusual, unanticipated operating condition, library version mismatch"); + slog (L_CRIT, "FATAL+ or similar problem. If it's not obvious to you what was causing it,"); + slog (L_CRIT, "FATAL+ then please report this to the program author(s)."); + exit (126); }