output.c

Wed, 10 Mar 2004 17:53:04 +0100

author
tuomov
date
Wed, 10 Mar 2004 17:53:04 +0100
changeset 68
7a97a1769840
parent 62
aae5facf9fc5
child 70
e866dc825481
permissions
-rw-r--r--

trunk: changeset 1373
Added myself to copyright notices of rb code.

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

mercurial