output.c

Wed, 28 May 2003 23:48:16 +0200

author
tuomov
date
Wed, 28 May 2003 23:48:16 +0200
changeset 53
f8f9366b359c
parent 52
0228b3741a42
child 55
d32ef6ce17a4
permissions
-rw-r--r--

trunk: changeset 57
License changed to Artistic/LGPL dual license.

0
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
1 /*
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
2 * libtu/output.c
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
3 *
36
63cd573ffbcf trunk: changeset 39
tuomov
parents: 35
diff changeset
4 * Copyright (c) Tuomo Valkonen 1999-2002.
53
f8f9366b359c trunk: changeset 57
tuomov
parents: 52
diff changeset
5 *
f8f9366b359c trunk: changeset 57
tuomov
parents: 52
diff changeset
6 * You may distribute and modify this library under the terms of either
f8f9366b359c trunk: changeset 57
tuomov
parents: 52
diff changeset
7 * the Clarified Artistic License or the GNU LGPL, version 2.1 or later.
0
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
8 */
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
9
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
10 #include <stdio.h>
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
11 #include <stdlib.h>
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
12 #include <errno.h>
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
13 #include <strings.h>
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
14 #include <string.h>
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
15
5
f878a9ffa3e0 trunk: changeset 8
tuomov
parents: 0
diff changeset
16 #include <libtu/misc.h>
f878a9ffa3e0 trunk: changeset 8
tuomov
parents: 0
diff changeset
17 #include <libtu/output.h>
f878a9ffa3e0 trunk: changeset 8
tuomov
parents: 0
diff changeset
18 #include <libtu/util.h>
0
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
19
35
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
20 #if !defined(HAS_SYSTEM_ASPRINTF)
25
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
21 #include "../snprintf_2.2/snprintf.h"
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
22 #endif
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
23
0
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
24
52
0228b3741a42 trunk: changeset 56
tuomov
parents: 36
diff changeset
25 static void default_warn_handler(const char *message);
0228b3741a42 trunk: changeset 56
tuomov
parents: 36
diff changeset
26
0
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
27
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
28 static bool verbose_mode=FALSE;
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
29 static int verbose_indent_lvl=0;
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
30 static bool progname_enable=TRUE;
52
0228b3741a42 trunk: changeset 56
tuomov
parents: 36
diff changeset
31 static WarnHandler *current_warn_handler=default_warn_handler;
0
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
32
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
33 #define INDENTATOR_LENGTH 4
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
34
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
35 static char indentator[]={' ', ' ', ' ', ' '};
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
36
35
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
37 static void do_dispatch_message(const char *message);
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
38
0
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
39
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
40 void verbose(const char *p, ...)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
41 {
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
42 va_list args;
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
43
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
44 va_start(args, p);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
45
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
46 verbose_v(p, args);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
47
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
48 va_end(args);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
49 }
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
50
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
51
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
52 void verbose_v(const char *p, va_list args)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
53 {
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
54 int i;
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
55
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
56 if(verbose_mode){
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
57 for(i=0; i<verbose_indent_lvl; i++)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
58 writef(stdout, indentator, INDENTATOR_LENGTH);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
59
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
60 vprintf(p, args);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
61 fflush(stdout);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
62 }
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
63 }
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
64
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
65
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
66 void verbose_enable(bool enable)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
67 {
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
68 verbose_mode=enable;
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
69 }
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
70
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
71
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
72 int verbose_indent(int depth)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
73 {
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
74 int old=verbose_indent_lvl;
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
75
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
76 if(depth>=0)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
77 verbose_indent_lvl=depth;
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
78
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
79 return old;
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
80 }
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
81
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
82
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
83 void warn_progname_enable(bool enable)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
84 {
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
85 progname_enable=enable;
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
86 }
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
87
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
88
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
89 static void put_prog_name()
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
90 {
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
91 const char*progname;
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
92
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
93 if(!progname_enable)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
94 return;
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
95
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
96 progname=prog_execname();
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
97
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
98 if(progname==NULL)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
99 return;
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
100
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
101 fprintf(stderr, "%s: ", (char*)progname);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
102 }
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
103
27
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
104 /* warn
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
105 */
0
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
106
35
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
107
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
108 static void fallback_warn()
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
109 {
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
110 put_prog_name();
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
111 fprintf(stderr, "Oops. Error string compilation failed: %s",
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
112 strerror(errno));
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
113 }
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
114
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
115
25
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
116 #define CALL_V(NAME, ARGS) \
35
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
117 do { va_list args; va_start(args, p); NAME ARGS; va_end(args); } while(0)
27
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
118
35
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
119 #define DO_DISPATCH(NAME, ARGS) \
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
120 do{ \
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
121 char *msg; \
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
122 if((msg=NAME ARGS)!=NULL){ \
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
123 do_dispatch_message(msg); \
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
124 free(msg);\
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
125 }else{ \
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
126 fallback_warn(); \
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
127 } \
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
128 }while(0)
25
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
129
33
3a0064eb9421 trunk: changeset 36
tuomov
parents: 31
diff changeset
130
31
e9cad8bd8ec8 trunk: changeset 34
tuomov
parents: 27
diff changeset
131 void libtu_asprintf(char **ret, const char *p, ...)
e9cad8bd8ec8 trunk: changeset 34
tuomov
parents: 27
diff changeset
132 {
e9cad8bd8ec8 trunk: changeset 34
tuomov
parents: 27
diff changeset
133 CALL_V(vasprintf, (ret, p, args));
e9cad8bd8ec8 trunk: changeset 34
tuomov
parents: 27
diff changeset
134 }
e9cad8bd8ec8 trunk: changeset 34
tuomov
parents: 27
diff changeset
135
e9cad8bd8ec8 trunk: changeset 34
tuomov
parents: 27
diff changeset
136
e9cad8bd8ec8 trunk: changeset 34
tuomov
parents: 27
diff changeset
137 void libtu_vasprintf(char **ret, const char *p, va_list args)
e9cad8bd8ec8 trunk: changeset 34
tuomov
parents: 27
diff changeset
138 {
e9cad8bd8ec8 trunk: changeset 34
tuomov
parents: 27
diff changeset
139 vasprintf(ret, p, args);
e9cad8bd8ec8 trunk: changeset 34
tuomov
parents: 27
diff changeset
140 }
e9cad8bd8ec8 trunk: changeset 34
tuomov
parents: 27
diff changeset
141
33
3a0064eb9421 trunk: changeset 36
tuomov
parents: 31
diff changeset
142
0
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
143 void warn(const char *p, ...)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
144 {
25
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
145 CALL_V(warn_v, (p, args));
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
146 }
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
147
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
148
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
149 void warn_obj(const char *obj, const char *p, ...)
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
150 {
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
151 CALL_V(warn_obj_v, (obj, p, args));
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
152 }
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
153
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
154
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
155 void warn_obj_line(const char *obj, int line, const char *p, ...)
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
156 {
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
157 CALL_V(warn_obj_line_v, (obj, line, p, args));
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
158 }
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
159
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
160
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
161 void warn_obj_v(const char *obj, const char *p, va_list args)
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
162 {
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
163 warn_obj_line_v(obj, -1, p, args);
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
164 }
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
165
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
166
0
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
167 void warn_v(const char *p, va_list args)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
168 {
35
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
169 DO_DISPATCH(errmsg_v, (p, args));
0
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
170 }
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
171
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
172
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
173 void warn_obj_line_v(const char *obj, int line, const char *p, va_list args)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
174 {
35
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
175 DO_DISPATCH(errmsg_obj_line_v, (obj, line, p, args));
0
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
176 }
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
177
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
178
27
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
179 void warn_err()
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
180 {
35
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
181 DO_DISPATCH(errmsg_err, ());
27
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
182 }
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
183
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
184
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
185 void warn_err_obj(const char *obj)
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
186 {
35
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
187 DO_DISPATCH(errmsg_err_obj, (obj));
27
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
188 }
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
189
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
190 void warn_err_obj_line(const char *obj, int line)
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
191 {
35
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
192 DO_DISPATCH(errmsg_err_obj_line, (obj, line));
27
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
193 }
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
194
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
195
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
196 /* errmsg
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
197 */
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
198
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
199 #define CALL_V_RET(NAME, ARGS) \
35
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
200 char *ret; va_list args; va_start(args, p); ret=NAME ARGS; \
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
201 va_end(args); return ret;
27
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
202
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
203
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
204 char* errmsg(const char *p, ...)
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
205 {
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
206 CALL_V_RET(errmsg_v, (p, args));
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
207 }
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
208
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
209
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
210 char *errmsg_obj(const char *obj, const char *p, ...)
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
211 {
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
212 CALL_V_RET(errmsg_obj_v, (obj, p, args));
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
213 }
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
214
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
215
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
216 char *errmsg_obj_line(const char *obj, int line, const char *p, ...)
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
217 {
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
218 CALL_V_RET(errmsg_obj_line_v, (obj, line, p, args));
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
219 }
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
220
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
221
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
222 char* errmsg_obj_v(const char *obj, const char *p, va_list args)
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
223 {
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
224 return errmsg_obj_line_v(obj, -1, p, args);
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
225 }
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
226
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
227
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
228 char *errmsg_v(const char *p, va_list args)
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
229 {
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
230 char *res;
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
231 vasprintf(&res, p, args);
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
232 return res;
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
233 }
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
234
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
235
25
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
236 char *errmsg_obj_line_v(const char *obj, int line, const char *p, va_list args)
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
237 {
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
238 char *res1=NULL, *res2, *res3;
35
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
239
25
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
240 if(obj!=NULL){
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
241 if(line>0)
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
242 asprintf(&res1, TR("%s:%d: "), obj, line);
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
243 else
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
244 asprintf(&res1, "%s: ", obj);
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
245 }else{
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
246 if(line>0)
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
247 asprintf(&res1, TR("%d: "), line);
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
248 }
35
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
249 vasprintf(&res2, p, args);
25
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
250 if(res1!=NULL){
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
251 if(res2==NULL)
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
252 return NULL;
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
253 res3=scat(res1, res2);
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
254 free(res1);
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
255 free(res2);
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
256 return res3;
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
257 }
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
258 return res2;
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
259 }
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
260
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
261
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
262 char *errmsg_err()
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
263 {
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
264 char *res;
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
265 asprintf(&res, "%s\n", strerror(errno));
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
266 return res;
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
267 }
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
268
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
269
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
270 char *errmsg_err_obj(const char *obj)
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
271 {
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
272 char *res;
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
273 if(obj!=NULL)
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
274 asprintf(&res, "%s: %s\n", obj, strerror(errno));
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
275 else
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
276 asprintf(&res, "%s\n", strerror(errno));
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
277 return res;
0
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
278 }
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
279
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
280
25
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
281 char *errmsg_err_obj_line(const char *obj, int line)
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
282 {
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
283 char *res;
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
284 if(obj!=NULL){
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
285 if(line>0)
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
286 asprintf(&res, TR("%s:%d: %s\n"), obj, line, strerror(errno));
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
287 else
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
288 asprintf(&res, "%s: %s\n", obj, strerror(errno));
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
289 }else{
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
290 if(line>0)
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
291 asprintf(&res, TR("%d: %s\n"), line, strerror(errno));
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
292 else
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
293 asprintf(&res, TR("%s\n"), strerror(errno));
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
294 }
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
295 return res;
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
296 }
31
e9cad8bd8ec8 trunk: changeset 34
tuomov
parents: 27
diff changeset
297
25
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
298
0
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
299 /* die
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
300 */
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
301
35
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
302
0
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
303 void die(const char *p, ...)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
304 {
35
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
305 set_warn_handler(NULL);
25
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
306 CALL_V(die_v, (p, args));
0
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
307 }
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
308
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
309
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
310 void die_v(const char *p, va_list args)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
311 {
35
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
312 set_warn_handler(NULL);
0
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
313 warn_v(p, args);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
314 exit(EXIT_FAILURE);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
315 }
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
316
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
317
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
318 void die_obj(const char *obj, const char *p, ...)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
319 {
35
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
320 set_warn_handler(NULL);
25
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
321 CALL_V(die_obj_v, (obj, p, args));
0
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
322 }
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
323
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
324
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
325 void die_obj_line(const char *obj, int line, const char *p, ...)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
326 {
35
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
327 set_warn_handler(NULL);
25
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
328 CALL_V(die_obj_line_v, (obj, line, p, args));
0
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
329 }
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
330
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
331
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
332 void die_obj_v(const char *obj, const char *p, va_list args)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
333 {
35
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
334 set_warn_handler(NULL);
0
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
335 warn_obj_v(obj, p, args);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
336 exit(EXIT_FAILURE);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
337 }
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
338
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
339
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
340 void die_obj_line_v(const char *obj, int line, const char *p, va_list args)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
341 {
35
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
342 set_warn_handler(NULL);
0
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
343 warn_obj_line_v(obj, line, p, args);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
344 exit(EXIT_FAILURE);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
345 }
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
346
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
347
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
348 void die_err()
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
349 {
35
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
350 set_warn_handler(NULL);
0
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
351 warn_err();
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
352 exit(EXIT_FAILURE);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
353 }
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
354
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
355
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
356 void die_err_obj(const char *obj)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
357 {
35
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
358 set_warn_handler(NULL);
0
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
359 warn_err_obj(obj);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
360 exit(EXIT_FAILURE);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
361 }
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
362
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
363
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
364 void die_err_obj_line(const char *obj, int line)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
365 {
35
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
366 set_warn_handler(NULL);
0
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
367 warn_err_obj_line(obj, line);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
368 exit(EXIT_FAILURE);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
369 }
35
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
370
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
371
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
372 static void default_warn_handler(const char *message)
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
373 {
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
374 put_prog_name();
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
375 fprintf(stderr, "%s", message);
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
376 putc('\n', stderr);
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
377 }
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
378
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
379
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
380 static void do_dispatch_message(const char *message)
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
381 {
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
382 if(current_warn_handler!=NULL)
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
383 current_warn_handler(message);
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
384 else
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
385 default_warn_handler(message);
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
386 }
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
387
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
388
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
389 WarnHandler *set_warn_handler(WarnHandler *handler)
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
390 {
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
391 WarnHandler *old=current_warn_handler;
52
0228b3741a42 trunk: changeset 56
tuomov
parents: 36
diff changeset
392 current_warn_handler=(handler!=NULL ? handler : default_warn_handler);
35
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
393 return old;
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
394 }

mercurial