PageRenderTime 21ms CodeModel.GetById 2ms app.highlight 16ms RepoModel.GetById 0ms app.codeStats 1ms

/cde/programs/dthelp/parser.ccdf/htag/util/error.c

https://bitbucket.org/tifan/cde
C | 439 lines | 338 code | 49 blank | 52 comment | 1 complexity | e9c7faf4194ed3c2b1f35781b2787852 MD5 | raw file
  1/*
  2 * CDE - Common Desktop Environment
  3 *
  4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
  5 *
  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)
 10 * any later version.
 11 *
 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
 16 * details.
 17 *
 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
 22 */
 23/* $XConsortium: error.c /main/3 1995/11/08 11:39:17 rswiston $ */
 24/* Copyright (c) 1986, 1987, 1988, 1989 Hewlett-Packard Co. */
 25
 26/* Error.c contains procedures for issuing error messages and warnings in
 27   BUILD and ELTDEF */
 28
 29#include <stdio.h>
 30#include "basic.h"
 31
 32extern FILE *m_errfile ;
 33extern int m_line ;
 34extern LOGICAL errexit ;
 35
 36void eprefix(
 37#if defined(M_PROTO)
 38  LOGICAL flag
 39#endif
 40  ) ;
 41
 42void m_errline(
 43#if defined(M_PROTO)
 44  char *text
 45#endif
 46  ) ;
 47
 48void m_error(
 49#if defined(M_PROTO)
 50  char *text
 51#endif
 52  ) ;
 53
 54void m_err1(
 55#if defined(M_PROTO)
 56  char *text, const M_WCHAR *arg
 57#endif
 58  ) ;
 59
 60void m_mberr1(
 61#if defined(M_PROTO)
 62  char *text, const char *arg
 63#endif
 64  ) ;
 65
 66void m_err2(
 67#if defined(M_PROTO)
 68  const char *text, const M_WCHAR *arg1, const M_WCHAR *arg2
 69#endif
 70  ) ;
 71
 72void m_err3(
 73#if defined(M_PROTO)
 74  char *text, M_WCHAR *arg1, M_WCHAR *arg2, M_WCHAR *arg3
 75#endif
 76  ) ;
 77
 78void m_err5(
 79#if defined(M_PROTO)
 80  char *text, M_WCHAR *arg1, M_WCHAR *arg2, M_WCHAR *arg3, M_WCHAR *arg4,
 81	      M_WCHAR *arg5
 82#endif
 83  ) ;
 84
 85void esuffix(
 86#if defined(M_PROTO)
 87  void
 88#endif
 89  ) ;
 90
 91void msgline(
 92#if defined(M_PROTO)
 93  char *text
 94#endif
 95  ) ;
 96
 97void msg1line(
 98#if defined(M_PROTO)
 99  char *text, char *arg1
100#endif
101  ) ;
102
103void skiptoend(
104#if defined(M_PROTO)
105  M_NOPAR
106#endif
107  ) ;
108
109void m_wctrace(
110#if defined(M_PROTO)
111  M_WCHAR *text
112#endif
113  ) ;
114
115void m_trace(
116#if defined(M_PROTO)
117  char *text
118#endif
119  ) ;
120
121void warning(
122#if defined(M_PROTO)
123  char *text
124#endif
125  ) ;
126
127void warning1(
128#if defined(M_PROTO)
129  char *text, M_WCHAR *arg
130#endif
131  ) ;
132
133void warning2(
134#if defined(M_PROTO)
135  char *text, M_WCHAR *arg1, M_WCHAR *arg2
136#endif
137  ) ;
138
139void warning3(
140#if defined(M_PROTO)
141  char *text, M_WCHAR *arg1, M_WCHAR *arg2, M_WCHAR *arg3
142#endif
143  ) ;
144
145void warning4(
146#if defined(M_PROTO)
147  char *text, M_WCHAR *arg1, M_WCHAR *arg2, M_WCHAR *arg3, M_WCHAR *arg4
148#endif
149  ) ;
150
151/* Write error message prefix */
152#if defined(M_PROTO)
153void eprefix(LOGICAL flag)
154#else
155void eprefix(flag)
156  LOGICAL flag ;
157#endif
158  {
159    if (flag) errexit = TRUE ;
160    fprintf(stderr, "\n**** ") ;
161    fprintf(m_errfile, "\n**** ") ;
162    }
163
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 */
167void m_errline(text)
168char *text ;
169{
170fputs(text, stderr) ;
171fputs(text, m_errfile) ;
172}
173
174/* Writes an error message to standard error and file "error" */
175void m_error(text)
176  char *text ;
177  {
178    eprefix(TRUE) ;
179    fprintf(stderr,"%s", text) ;
180    fprintf(m_errfile,"%s", text) ;
181    esuffix() ;
182    skiptoend() ;
183  }
184
185/* Writes an error message with one argument to standard error and file
186   "error" */
187#if defined(M_PROTO)
188void m_err1(char *text, const M_WCHAR *arg)
189#else
190void m_err1(text, arg)
191  char *text;
192  M_WCHAR *arg ;
193#endif
194{
195char *mb_arg;
196
197mb_arg = MakeMByteString(arg);
198eprefix(TRUE) ;
199fprintf(stderr, text, mb_arg) ;
200fprintf(m_errfile, text, mb_arg) ;
201esuffix() ;
202skiptoend() ;
203m_free(mb_arg,"multi-byte string");
204}
205
206#if defined(M_PROTO)
207void m_mberr1(char *text, const char *arg)
208#else
209void m_err1(text, arg)
210  char *text;
211  char *arg ;
212#endif
213{
214eprefix(TRUE) ;
215fprintf(stderr, text, arg) ;
216fprintf(m_errfile, text, arg) ;
217esuffix() ;
218skiptoend() ;
219}
220
221/* Writes an error message with two arguments to standard error and file
222   "error" */
223#if defined(M_PROTO)
224void m_err2( const char *text, const M_WCHAR *arg1, const M_WCHAR *arg2)
225#else
226void m_err2(text, arg1, arg2)
227char *text;
228M_WCHAR *arg1, *arg2 ;
229#endif
230{
231char *mb_arg1, *mb_arg2;
232
233mb_arg1 = MakeMByteString(arg1);
234mb_arg2 = MakeMByteString(arg2);
235eprefix(TRUE) ;
236fprintf(stderr, text, mb_arg1, mb_arg2) ;
237fprintf(m_errfile, text, mb_arg1, mb_arg2) ;
238esuffix() ;
239skiptoend() ;
240m_free(mb_arg1,"multi-byte string");
241m_free(mb_arg2,"multi-byte string");
242}
243
244/* Writes an error message with three arguments to standard error and file
245   "error" */
246#if defined(M_PROTO)
247void m_err3( char *text, M_WCHAR *arg1, M_WCHAR *arg2, M_WCHAR *arg3)
248#else
249void m_err3(text, arg1, arg2, arg3)
250char *text;
251M_WCHAR *arg1, *arg2, *arg3 ;
252#endif
253{
254char *mb_arg1, *mb_arg2, *mb_arg3;
255
256mb_arg1 = MakeMByteString(arg1);
257mb_arg2 = MakeMByteString(arg2);
258mb_arg3 = MakeMByteString(arg3);
259eprefix(TRUE) ;
260fprintf(stderr, text, mb_arg1, mb_arg2, mb_arg3) ;
261fprintf(m_errfile, text, mb_arg1, mb_arg2, mb_arg3) ;
262esuffix() ;
263skiptoend() ;
264m_free(mb_arg1,"multi-byte string");
265m_free(mb_arg2,"multi-byte string");
266m_free(mb_arg3,"multi-byte string");
267}
268
269/* Writes an error message with five arguments to standard error and file
270   "error" */
271#if defined(M_PROTO)
272void m_err5( char *text, M_WCHAR *arg1, M_WCHAR *arg2, M_WCHAR *arg3,
273	     M_WCHAR *arg4, M_WCHAR *arg5)
274#else
275void m_err5(text, arg1, arg2, arg3, arg4, arg5)
276char *text;
277M_WCHAR *arg1, *arg2, *arg3, *arg4, *arg5 ;
278#endif
279{
280char *mb_arg1, *mb_arg2, *mb_arg3, *mb_arg4, *mb_arg5;
281
282mb_arg1 = MakeMByteString(arg1);
283mb_arg2 = MakeMByteString(arg2);
284mb_arg3 = MakeMByteString(arg3);
285mb_arg4 = MakeMByteString(arg4);
286mb_arg5 = MakeMByteString(arg5);
287fprintf(stderr, text, mb_arg1, mb_arg2, mb_arg3, mb_arg4, mb_arg5) ;
288fprintf(m_errfile, text, mb_arg1, mb_arg2, mb_arg3, mb_arg4, mb_arg5) ;
289esuffix() ;
290skiptoend() ;
291m_free(mb_arg1,"multi-byte string");
292m_free(mb_arg2,"multi-byte string");
293m_free(mb_arg3,"multi-byte string");
294m_free(mb_arg4,"multi-byte string");
295m_free(mb_arg5,"multi-byte string");
296}
297
298/* Write error message suffix */
299void esuffix(M_NOPAR)
300  {
301    fprintf(stderr, " (line %d) ****\n", m_line) ;
302    fprintf(m_errfile, " (line %d) ****\n", m_line) ;
303    }
304
305/* Print something to both stderr and m_errfile */
306void msgline(text)
307  char *text ;
308  {
309    fprintf(stderr, text) ;
310    fprintf(m_errfile, text) ;
311    }
312
313/* Print something to both stderr and m_errfile */
314void msg1line(text, arg1)
315  char *text, *arg1 ;
316  {
317    fprintf(stderr, text, arg1) ;
318    fprintf(m_errfile, text, arg1) ;
319    }
320
321/* Trace used for m_malloc trace output */
322void m_trace(text)
323char *text ;
324{
325m_errline(text) ;
326}
327
328void m_wctrace(text)
329M_WCHAR *text ;
330{
331char *mb_text;
332
333mb_text = MakeMByteString(text);
334m_trace(mb_text);
335m_free(mb_text,"multi-byte string");
336}
337
338/* Writes a nonfatal error message to standard error and file "error" */
339void warning(text)
340  char *text ;
341  {
342    eprefix(FALSE) ;
343    fprintf(stderr,"%s", text) ;
344    fprintf(m_errfile,"%s", text) ;
345    esuffix() ;
346  }
347
348/* Writes a nonfatal error message with one argument to standard error
349   and file "error" */
350#if defined(M_PROTO)
351void warning1( char *text, M_WCHAR *arg)
352#else
353void warning1(text, arg)
354char *text;
355M_WCHAR *arg ;
356#endif
357{
358char *mb_arg;
359
360mb_arg = MakeMByteString(arg);
361eprefix(FALSE) ;
362fprintf(stderr, text, mb_arg) ;
363fprintf(m_errfile, text, mb_arg) ;
364esuffix() ;
365m_free(mb_arg,"multi-byte string");
366}
367
368/* Writes a nonfatal error message with two arguments to standard error
369   and file "error" */
370#if defined(M_PROTO)
371void warning2(char *text, M_WCHAR *arg1, M_WCHAR *arg2)
372#else
373void warning2(text, arg1, arg2)
374char *text;
375M_WCHAR *arg1, *arg2 ;
376#endif
377{
378char *mb_arg1, *mb_arg2;
379
380mb_arg1 = MakeMByteString(arg1);
381mb_arg2 = MakeMByteString(arg2);
382eprefix(FALSE) ;
383fprintf(stderr, text, mb_arg1, mb_arg2) ;
384fprintf(m_errfile, text, mb_arg1, mb_arg2) ;
385esuffix() ;
386m_free(mb_arg1,"multi-byte string");
387m_free(mb_arg2,"multi-byte string");
388}
389
390/* Writes a nonfatal error message with three arguments to standard error
391   and file "error" */
392#if defined(M_PROTO)
393void warning3(char *text, M_WCHAR *arg1, M_WCHAR *arg2, M_WCHAR *arg3)
394#else
395void warning3(text, arg1, arg2, arg3)
396char *text;
397M_WCHAR *arg1, *arg2, *arg3 ;
398#endif
399{
400char *mb_arg1, *mb_arg2, *mb_arg3;
401
402mb_arg1 = MakeMByteString(arg1);
403mb_arg2 = MakeMByteString(arg2);
404mb_arg3 = MakeMByteString(arg3);
405eprefix(FALSE) ;
406fprintf(stderr, text, mb_arg1, mb_arg2, mb_arg3) ;
407fprintf(m_errfile, text, mb_arg1, mb_arg2, mb_arg3) ;
408esuffix() ;
409m_free(mb_arg1,"multi-byte string");
410m_free(mb_arg2,"multi-byte string");
411m_free(mb_arg3,"multi-byte string");
412}
413
414/* Writes a nonfatal error message with four arguments to standard error
415   and file "error" */
416#if defined(M_PROTO)
417void warning4(char *text, M_WCHAR *arg1, M_WCHAR *arg2, M_WCHAR *arg3,
418	      M_WCHAR *arg4)
419#else
420void warning4(text, arg1, arg2, arg3, arg4)
421char *text;
422M_WCHAR *arg1, *arg2, *arg3, *arg4 ;
423#endif
424{
425char *mb_arg1, *mb_arg2, *mb_arg3, *mb_arg4;
426
427mb_arg1 = MakeMByteString(arg1);
428mb_arg2 = MakeMByteString(arg2);
429mb_arg3 = MakeMByteString(arg3);
430mb_arg4 = MakeMByteString(arg4);
431eprefix(FALSE) ;
432fprintf(stderr, text, mb_arg1, mb_arg2, mb_arg3, mb_arg4) ;
433fprintf(m_errfile, text, mb_arg1, mb_arg2, mb_arg3, mb_arg4) ;
434esuffix() ;
435m_free(mb_arg1,"multi-byte string");
436m_free(mb_arg2,"multi-byte string");
437m_free(mb_arg3,"multi-byte string");
438m_free(mb_arg4,"multi-byte string");
439}