Defuzzied one entry
[midnight-commander.git] / slang / slerr.c
blob14eaf31872cb58fa0efdcb615f66400fe0c2eab6
1 /* error handling common to all routines. */
2 /* Copyright (c) 1992, 1995 John E. Davis
3 * All rights reserved.
4 *
5 * You may distribute under the terms of either the GNU General Public
6 * License or the Perl Artistic License.
7 */
10 #include "config.h"
12 #include <stdio.h>
13 #include <string.h>
14 #include <stdarg.h>
16 #ifdef HAVE_STDLIB_H
17 # include <stdlib.h>
18 #endif
20 #include "slang.h"
21 #include "_slang.h"
23 void (*SLang_Error_Routine)(char *);
24 void (*SLang_Exit_Error_Hook)(char *);
25 volatile int SLang_Error = 0;
26 char *SLang_Error_Message;
27 volatile int SLKeyBoard_Quit = 0;
29 void SLang_doerror (char *error)
31 char err [1024];
32 char *str = NULL;
34 *err = 0;
36 str = "Slang/Midnight Commander unknown error";
38 g_snprintf(err, sizeof (err), "S-Lang Error: %s", str);
40 if (SLang_Error_Routine == NULL)
42 fputs (err, stderr);
43 fputs("\r\n", stderr);
45 else
46 (*SLang_Error_Routine)(err);
51 void SLang_exit_error (char *s)
53 if (SLang_Exit_Error_Hook != NULL)
55 (*SLang_Exit_Error_Hook) (s);
57 if (s != NULL) fprintf (stderr, "%s\n", s);
58 exit (-1);