• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 *******************************************************************************
3 *
4 *   Copyright (C) 1998-2011, International Business Machines
5 *   Corporation and others.  All Rights Reserved.
6 *
7 *******************************************************************************
8 *
9 * File error.c
10 *
11 * Modification History:
12 *
13 *   Date        Name        Description
14 *   05/28/99    stephen     Creation.
15 *******************************************************************************
16 */
17 
18 #include <stdarg.h>
19 #include <stdio.h>
20 #include "cstring.h"
21 #include "errmsg.h"
22 
error(uint32_t linenumber,const char * msg,...)23 U_CFUNC void error(uint32_t linenumber, const char *msg, ...)
24 {
25     va_list va;
26 
27     va_start(va, msg);
28     fprintf(stderr, "%s:%u: ", gCurrentFileName, (int)linenumber);
29     vfprintf(stderr, msg, va);
30     fprintf(stderr, "\n");
31     va_end(va);
32 }
33 
34 static UBool gShowWarning = TRUE;
35 
setShowWarning(UBool val)36 U_CFUNC void setShowWarning(UBool val)
37 {
38     gShowWarning = val;
39 }
40 
getShowWarning()41 U_CFUNC UBool getShowWarning(){
42     return gShowWarning;
43 }
44 
45 static UBool gStrict =FALSE;
isStrict()46 U_CFUNC UBool isStrict(){
47     return gStrict;
48 }
setStrict(UBool val)49 U_CFUNC void setStrict(UBool val){
50     gStrict = val;
51 }
52 static UBool gVerbose =FALSE;
isVerbose()53 U_CFUNC UBool isVerbose(){
54     return gVerbose;
55 }
setVerbose(UBool val)56 U_CFUNC void setVerbose(UBool val){
57     gVerbose = val;
58 }
warning(uint32_t linenumber,const char * msg,...)59 U_CFUNC void warning(uint32_t linenumber, const char *msg, ...)
60 {
61     if (gShowWarning)
62     {
63         va_list va;
64 
65         va_start(va, msg);
66         fprintf(stderr, "%s:%u: warning: ", gCurrentFileName, (int)linenumber);
67         vfprintf(stderr, msg, va);
68         fprintf(stderr, "\n");
69         va_end(va);
70     }
71 }
72