2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $XConsortium: error.c /main/3 1995/11/08 11:04:57 rswiston $ */
24 /* Copyright (c) 1986, 1987, 1988, 1989 Hewlett-Packard Co. */
26 /* Error.c contains procedures for issuing error messages and warnings in
32 extern FILE *m_errfile ;
34 extern LOGICAL errexit ;
56 char *text, const M_WCHAR *arg
62 char *text, const char *arg
68 const char *text, const M_WCHAR *arg1, const M_WCHAR *arg2
74 char *text, M_WCHAR *arg1, M_WCHAR *arg2, M_WCHAR *arg3
80 char *text, M_WCHAR *arg1, M_WCHAR *arg2, M_WCHAR *arg3, M_WCHAR *arg4,
99 char *text, char *arg1
129 char *text, M_WCHAR *arg
135 char *text, M_WCHAR *arg1, M_WCHAR *arg2
141 char *text, M_WCHAR *arg1, M_WCHAR *arg2, M_WCHAR *arg3
147 char *text, M_WCHAR *arg1, M_WCHAR *arg2, M_WCHAR *arg3, M_WCHAR *arg4
151 /* Write error message prefix */
153 void eprefix(LOGICAL flag)
159 if (flag) errexit = TRUE ;
160 fprintf(stderr, "\n**** ") ;
161 fprintf(m_errfile, "\n**** ") ;
164 /* Writes part of an error message. Called from m_malloc instead of
165 m_err1, since PARSER's version of m_err1 calls m_malloc and recursive
166 calls are possible when the heap is exhausted */
170 fputs(text, stderr) ;
171 fputs(text, m_errfile) ;
174 /* Writes an error message to standard error and file "error" */
179 fprintf(stderr,"%s", text) ;
180 fprintf(m_errfile,"%s", text) ;
185 /* Writes an error message with one argument to standard error and file
188 void m_err1(char *text, const M_WCHAR *arg)
190 void m_err1(text, arg)
197 mb_arg = MakeMByteString(arg);
199 fprintf(stderr, text, mb_arg) ;
200 fprintf(m_errfile, text, mb_arg) ;
203 m_free(mb_arg,"multi-byte string");
207 void m_mberr1(char *text, const char *arg)
209 void m_err1(text, arg)
215 fprintf(stderr, text, arg) ;
216 fprintf(m_errfile, text, arg) ;
221 /* Writes an error message with two arguments to standard error and file
224 void m_err2( const char *text, const M_WCHAR *arg1, const M_WCHAR *arg2)
226 void m_err2(text, arg1, arg2)
228 M_WCHAR *arg1, *arg2 ;
231 char *mb_arg1, *mb_arg2;
233 mb_arg1 = MakeMByteString(arg1);
234 mb_arg2 = MakeMByteString(arg2);
236 fprintf(stderr, text, mb_arg1, mb_arg2) ;
237 fprintf(m_errfile, text, mb_arg1, mb_arg2) ;
240 m_free(mb_arg1,"multi-byte string");
241 m_free(mb_arg2,"multi-byte string");
244 /* Writes an error message with three arguments to standard error and file
247 void m_err3( char *text, M_WCHAR *arg1, M_WCHAR *arg2, M_WCHAR *arg3)
249 void m_err3(text, arg1, arg2, arg3)
251 M_WCHAR *arg1, *arg2, *arg3 ;
254 char *mb_arg1, *mb_arg2, *mb_arg3;
256 mb_arg1 = MakeMByteString(arg1);
257 mb_arg2 = MakeMByteString(arg2);
258 mb_arg3 = MakeMByteString(arg3);
260 fprintf(stderr, text, mb_arg1, mb_arg2, mb_arg3) ;
261 fprintf(m_errfile, text, mb_arg1, mb_arg2, mb_arg3) ;
264 m_free(mb_arg1,"multi-byte string");
265 m_free(mb_arg2,"multi-byte string");
266 m_free(mb_arg3,"multi-byte string");
269 /* Writes an error message with five arguments to standard error and file
272 void m_err5( char *text, M_WCHAR *arg1, M_WCHAR *arg2, M_WCHAR *arg3,
273 M_WCHAR *arg4, M_WCHAR *arg5)
275 void m_err5(text, arg1, arg2, arg3, arg4, arg5)
277 M_WCHAR *arg1, *arg2, *arg3, *arg4, *arg5 ;
280 char *mb_arg1, *mb_arg2, *mb_arg3, *mb_arg4, *mb_arg5;
282 mb_arg1 = MakeMByteString(arg1);
283 mb_arg2 = MakeMByteString(arg2);
284 mb_arg3 = MakeMByteString(arg3);
285 mb_arg4 = MakeMByteString(arg4);
286 mb_arg5 = MakeMByteString(arg5);
287 fprintf(stderr, text, mb_arg1, mb_arg2, mb_arg3, mb_arg4, mb_arg5) ;
288 fprintf(m_errfile, text, mb_arg1, mb_arg2, mb_arg3, mb_arg4, mb_arg5) ;
291 m_free(mb_arg1,"multi-byte string");
292 m_free(mb_arg2,"multi-byte string");
293 m_free(mb_arg3,"multi-byte string");
294 m_free(mb_arg4,"multi-byte string");
295 m_free(mb_arg5,"multi-byte string");
298 /* Write error message suffix */
299 void esuffix(M_NOPAR)
301 fprintf(stderr, " (line %d) ****\n", m_line) ;
302 fprintf(m_errfile, " (line %d) ****\n", m_line) ;
305 /* Print something to both stderr and m_errfile */
309 fprintf(stderr, text) ;
310 fprintf(m_errfile, text) ;
313 /* Print something to both stderr and m_errfile */
314 void msg1line(text, arg1)
317 fprintf(stderr, text, arg1) ;
318 fprintf(m_errfile, text, arg1) ;
321 /* Trace used for m_malloc trace output */
333 mb_text = MakeMByteString(text);
335 m_free(mb_text,"multi-byte string");
338 /* Writes a nonfatal error message to standard error and file "error" */
343 fprintf(stderr,"%s", text) ;
344 fprintf(m_errfile,"%s", text) ;
348 /* Writes a nonfatal error message with one argument to standard error
351 void warning1( char *text, M_WCHAR *arg)
353 void warning1(text, arg)
360 mb_arg = MakeMByteString(arg);
362 fprintf(stderr, text, mb_arg) ;
363 fprintf(m_errfile, text, mb_arg) ;
365 m_free(mb_arg,"multi-byte string");
368 /* Writes a nonfatal error message with two arguments to standard error
371 void warning2(char *text, M_WCHAR *arg1, M_WCHAR *arg2)
373 void warning2(text, arg1, arg2)
375 M_WCHAR *arg1, *arg2 ;
378 char *mb_arg1, *mb_arg2;
380 mb_arg1 = MakeMByteString(arg1);
381 mb_arg2 = MakeMByteString(arg2);
383 fprintf(stderr, text, mb_arg1, mb_arg2) ;
384 fprintf(m_errfile, text, mb_arg1, mb_arg2) ;
386 m_free(mb_arg1,"multi-byte string");
387 m_free(mb_arg2,"multi-byte string");
390 /* Writes a nonfatal error message with three arguments to standard error
393 void warning3(char *text, M_WCHAR *arg1, M_WCHAR *arg2, M_WCHAR *arg3)
395 void warning3(text, arg1, arg2, arg3)
397 M_WCHAR *arg1, *arg2, *arg3 ;
400 char *mb_arg1, *mb_arg2, *mb_arg3;
402 mb_arg1 = MakeMByteString(arg1);
403 mb_arg2 = MakeMByteString(arg2);
404 mb_arg3 = MakeMByteString(arg3);
406 fprintf(stderr, text, mb_arg1, mb_arg2, mb_arg3) ;
407 fprintf(m_errfile, text, mb_arg1, mb_arg2, mb_arg3) ;
409 m_free(mb_arg1,"multi-byte string");
410 m_free(mb_arg2,"multi-byte string");
411 m_free(mb_arg3,"multi-byte string");
414 /* Writes a nonfatal error message with four arguments to standard error
417 void warning4(char *text, M_WCHAR *arg1, M_WCHAR *arg2, M_WCHAR *arg3,
420 void warning4(text, arg1, arg2, arg3, arg4)
422 M_WCHAR *arg1, *arg2, *arg3, *arg4 ;
425 char *mb_arg1, *mb_arg2, *mb_arg3, *mb_arg4;
427 mb_arg1 = MakeMByteString(arg1);
428 mb_arg2 = MakeMByteString(arg2);
429 mb_arg3 = MakeMByteString(arg3);
430 mb_arg4 = MakeMByteString(arg4);
432 fprintf(stderr, text, mb_arg1, mb_arg2, mb_arg3, mb_arg4) ;
433 fprintf(m_errfile, text, mb_arg1, mb_arg2, mb_arg3, mb_arg4) ;
435 m_free(mb_arg1,"multi-byte string");
436 m_free(mb_arg2,"multi-byte string");
437 m_free(mb_arg3,"multi-byte string");
438 m_free(mb_arg4,"multi-byte string");