1 /*
2 * $Id$
3 *
4 * Copyright (C) 1993-1999 by Jochen Wiedmann and Marcin Orlowski
5 * Copyright (C) 2002-2015 FlexCat Open Source Team
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or (at
10 * your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 *
21 */
22
23 #include <stdarg.h>
24 #include "flexcat.h"
25 #include "readprefs.h"
26 #include "globals.h"
27 #include "utils.h"
28
29 /// ShowError
30
31 /* This shows an error message and quits. */
32
ShowError(const char * msg,...)33 void ShowError(const char *msg, ...)
34 {
35 va_list args;
36 char header[256];
37 char message[256];
38
39 snprintf(header, sizeof(header), MSG_ERR_ERROR, ScanFile, ScanLine);
40 va_start(args, msg);
41 vsnprintf(message, sizeof(message), msg, args);
42 va_end(args);
43 fprintf(stderr, "%s %s\n", header, message);
44
45 #ifdef AMIGA
46 NumberOfWarnings++;
47 #endif
48
49 MyExit(10);
50 }
51
52 ///
53 /// ShowErrorQuick
54
55 /* Same as ShowError but in this case we omit any line number. */
56
ShowErrorQuick(const char * msg,...)57 void ShowErrorQuick(const char *msg, ...)
58 {
59 va_list args;
60 char header[256];
61 char message[256];
62
63 snprintf(header, sizeof(header), MSG_ERR_ERROR_QUICK, ScanFile);
64 va_start(args, msg);
65 vsnprintf(message, sizeof(message), msg, args);
66 va_end(args);
67 fprintf(stderr, "%s %s\n", header, message);
68
69 #ifdef AMIGA
70 NumberOfWarnings++;
71 #endif
72
73 MyExit ( 10 );
74 }
75
76 ///
77 /// MemError
78
79 /* This shows the 'Memory error' message. */
80
MemError(void)81 void MemError(void)
82 {
83 ShowError(MSG_ERR_NOMEMORY);
84 }
85
86 ///
87 /// ShowWarn
88
89 /* This shows a warning. */
90
ShowWarn(const char * msg,...)91 void ShowWarn(const char *msg, ...)
92 {
93 if(!Quiet)
94 {
95 va_list args;
96 char header[256];
97 char message[256];
98
99 snprintf(header, sizeof(header), MSG_ERR_WARNING, ScanFile, ScanLine);
100 va_start(args, msg);
101 vsnprintf(message, sizeof(message), msg, args);
102 va_end(args);
103 fprintf(stderr, "%s %s\n", header, message);
104 }
105
106 NumberOfWarnings++;
107 GlobalReturnCode = 5;
108 }
109
110 ///
111 /// ShowWarnQuick
112
113 /* This shows a warning without line number. */
114
ShowWarnQuick(const char * msg,...)115 void ShowWarnQuick(const char *msg, ...)
116 {
117 if(!Quiet)
118 {
119 va_list args;
120 char header[256];
121 char message[256];
122
123 snprintf(header, sizeof(header), MSG_ERR_WARNING_QUICK, ScanFile);
124 va_start(args, msg);
125 vsnprintf(message, sizeof(message), msg, args);
126 va_end(args);
127 fprintf(stderr, "%s %s\n", header, message);
128 }
129
130 NumberOfWarnings++;
131 GlobalReturnCode = 5;
132 }
133
134 ///
135