Titan Core Initial Contribution
[deliverable/titan.core.git] / langviz / error.c
1 ///////////////////////////////////////////////////////////////////////////////
2 // Copyright (c) 2000-2014 Ericsson Telecom AB
3 // All rights reserved. This program and the accompanying materials
4 // are made available under the terms of the Eclipse Public License v1.0
5 // which accompanies this distribution, and is available at
6 // http://www.eclipse.org/legal/epl-v10.html
7 ///////////////////////////////////////////////////////////////////////////////
8 #include "error.h"
9 #include <stdio.h>
10 #include <stdlib.h>
11 #include <stdarg.h>
12
13 unsigned verb_level=0x0007; /* default value */
14
15 const char *argv0; /* the programname :) */
16
17 void fatal_error(const char *filename, int lineno, const char *fmt, ...)
18 {
19 va_list parameters;
20 fprintf(stderr, "FATAL ERROR: %s: In line %d of %s: ",
21 argv0, lineno, filename);
22 va_start(parameters, fmt);
23 vfprintf(stderr, fmt, parameters);
24 va_end(parameters);
25 fprintf(stderr, "\n");
26 fflush(stderr);
27 abort();
28 }
29
30 void ERROR(const char *fmt, ...)
31 {
32 fprintf(stderr, "%s: error: ", argv0);
33 va_list parameters;
34 va_start(parameters, fmt);
35 vfprintf(stderr, fmt, parameters);
36 va_end(parameters);
37 fprintf(stderr, "\n");
38 fflush(stderr);
39 }
40
41 void WARNING(const char *fmt, ...)
42 {
43 if(!(verb_level & 2)) return;
44 fprintf(stderr, "%s: warning: ", argv0);
45 va_list parameters;
46 va_start(parameters, fmt);
47 vfprintf(stderr, fmt, parameters);
48 va_end(parameters);
49 fprintf(stderr, "\n");
50 fflush(stderr);
51 }
52
53 void NOTSUPP(const char *fmt, ...)
54 {
55 if(!(verb_level & 1)) return;
56 fprintf(stderr, "%s: warning: not supported: ", argv0);
57 va_list parameters;
58 va_start(parameters, fmt);
59 vfprintf(stderr, fmt, parameters);
60 va_end(parameters);
61 fprintf(stderr, "\n");
62 fflush(stderr);
63 }
64
65 void NOTIFY(const char *fmt, ...)
66 {
67 if(!(verb_level & 4)) return;
68 fprintf(stderr, "Notify: ");
69 va_list parameters;
70 va_start(parameters, fmt);
71 vfprintf(stderr, fmt, parameters);
72 va_end(parameters);
73 fprintf(stderr, "\n");
74 fflush(stderr);
75 }
76
77 void DEBUG(unsigned level, const char *fmt, ...)
78 {
79 if((level>7?7:level)>((verb_level>>3)&0x07)) return;
80 fprintf(stderr, "%*sDebug: ", level, "");
81 va_list parameters;
82 va_start(parameters, fmt);
83 vfprintf(stderr, fmt, parameters);
84 va_end(parameters);
85 fprintf(stderr, "\n");
86 fflush(stderr);
87 }
This page took 0.037864 seconds and 5 git commands to generate.