output.c

Sun, 03 Nov 2002 03:51:35 +0100

author
tuomov
date
Sun, 03 Nov 2002 03:51:35 +0100
changeset 42
4fdc7ea2bc38
parent 36
63cd573ffbcf
child 52
0228b3741a42
permissions
-rw-r--r--

trunk: changeset 45
(void*)+n fixed

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.
0
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
5 * See the included file LICENSE for details.
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
6 */
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
7
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
8 #include <stdio.h>
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
9 #include <stdlib.h>
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
10 #include <errno.h>
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
11 #include <strings.h>
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
12 #include <string.h>
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
13
5
f878a9ffa3e0 trunk: changeset 8
tuomov
parents: 0
diff changeset
14 #include <libtu/misc.h>
f878a9ffa3e0 trunk: changeset 8
tuomov
parents: 0
diff changeset
15 #include <libtu/output.h>
f878a9ffa3e0 trunk: changeset 8
tuomov
parents: 0
diff changeset
16 #include <libtu/util.h>
0
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
17
35
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
18 #if !defined(HAS_SYSTEM_ASPRINTF)
25
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
19 #include "../snprintf_2.2/snprintf.h"
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
20 #endif
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
21
0
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
22
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
23 /* verbose
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
24 */
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
25
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
26 static bool verbose_mode=FALSE;
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
27 static int verbose_indent_lvl=0;
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
28 static bool progname_enable=TRUE;
35
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
29 static WarnHandler *current_warn_handler=NULL;
0
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
30
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
31 #define INDENTATOR_LENGTH 4
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 static char indentator[]={' ', ' ', ' ', ' '};
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
34
35
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
35 static void do_dispatch_message(const char *message);
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
36
0
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
37
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
38 void verbose(const char *p, ...)
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 va_list args;
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_start(args, p);
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 verbose_v(p, args);
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 va_end(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
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 void verbose_v(const char *p, va_list args)
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 int i;
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 if(verbose_mode){
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
55 for(i=0; i<verbose_indent_lvl; i++)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
56 writef(stdout, indentator, INDENTATOR_LENGTH);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
57
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
58 vprintf(p, args);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
59 fflush(stdout);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
60 }
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
61 }
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 void verbose_enable(bool enable)
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 verbose_mode=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
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 int verbose_indent(int depth)
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 old=verbose_indent_lvl;
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 if(depth>=0)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
75 verbose_indent_lvl=depth;
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
76
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
77 return old;
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
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 void warn_progname_enable(bool enable)
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 progname_enable=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
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 static void put_prog_name()
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 const char*progname;
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 if(!progname_enable)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
92 return;
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
93
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
94 progname=prog_execname();
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 if(progname==NULL)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
97 return;
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
98
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
99 fprintf(stderr, "%s: ", (char*)progname);
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
27
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
102 /* warn
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
103 */
0
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
104
35
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
105
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
106 static void fallback_warn()
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
107 {
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
108 put_prog_name();
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
109 fprintf(stderr, "Oops. Error string compilation failed: %s",
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
110 strerror(errno));
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
111 }
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
112
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
113
25
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
114 #define CALL_V(NAME, ARGS) \
35
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
115 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
116
35
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
117 #define DO_DISPATCH(NAME, ARGS) \
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
118 do{ \
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
119 char *msg; \
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
120 if((msg=NAME ARGS)!=NULL){ \
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
121 do_dispatch_message(msg); \
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
122 free(msg);\
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
123 }else{ \
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
124 fallback_warn(); \
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
125 } \
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
126 }while(0)
25
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
127
33
3a0064eb9421 trunk: changeset 36
tuomov
parents: 31
diff changeset
128
31
e9cad8bd8ec8 trunk: changeset 34
tuomov
parents: 27
diff changeset
129 void libtu_asprintf(char **ret, const char *p, ...)
e9cad8bd8ec8 trunk: changeset 34
tuomov
parents: 27
diff changeset
130 {
e9cad8bd8ec8 trunk: changeset 34
tuomov
parents: 27
diff changeset
131 CALL_V(vasprintf, (ret, p, args));
e9cad8bd8ec8 trunk: changeset 34
tuomov
parents: 27
diff changeset
132 }
e9cad8bd8ec8 trunk: changeset 34
tuomov
parents: 27
diff changeset
133
e9cad8bd8ec8 trunk: changeset 34
tuomov
parents: 27
diff changeset
134
e9cad8bd8ec8 trunk: changeset 34
tuomov
parents: 27
diff changeset
135 void libtu_vasprintf(char **ret, const char *p, va_list args)
e9cad8bd8ec8 trunk: changeset 34
tuomov
parents: 27
diff changeset
136 {
e9cad8bd8ec8 trunk: changeset 34
tuomov
parents: 27
diff changeset
137 vasprintf(ret, p, args);
e9cad8bd8ec8 trunk: changeset 34
tuomov
parents: 27
diff changeset
138 }
e9cad8bd8ec8 trunk: changeset 34
tuomov
parents: 27
diff changeset
139
33
3a0064eb9421 trunk: changeset 36
tuomov
parents: 31
diff changeset
140
0
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
141 void warn(const char *p, ...)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
142 {
25
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
143 CALL_V(warn_v, (p, args));
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
144 }
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
145
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
146
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
147 void warn_obj(const char *obj, const char *p, ...)
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
148 {
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
149 CALL_V(warn_obj_v, (obj, p, args));
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_line(const char *obj, int line, const char *p, ...)
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
154 {
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
155 CALL_V(warn_obj_line_v, (obj, line, p, args));
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_v(const char *obj, const char *p, va_list args)
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
160 {
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
161 warn_obj_line_v(obj, -1, p, args);
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
0
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
165 void warn_v(const char *p, va_list args)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
166 {
35
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
167 DO_DISPATCH(errmsg_v, (p, args));
0
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
168 }
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
169
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 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
172 {
35
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
173 DO_DISPATCH(errmsg_obj_line_v, (obj, line, 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
27
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
177 void warn_err()
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
178 {
35
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
179 DO_DISPATCH(errmsg_err, ());
27
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
180 }
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
181
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
182
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
183 void warn_err_obj(const char *obj)
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
184 {
35
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
185 DO_DISPATCH(errmsg_err_obj, (obj));
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 void warn_err_obj_line(const char *obj, int line)
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
189 {
35
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
190 DO_DISPATCH(errmsg_err_obj_line, (obj, line));
27
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
191 }
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 /* errmsg
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
195 */
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
196
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
197 #define CALL_V_RET(NAME, ARGS) \
35
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
198 char *ret; va_list args; va_start(args, p); ret=NAME ARGS; \
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
199 va_end(args); return ret;
27
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
200
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
201
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
202 char* errmsg(const char *p, ...)
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
203 {
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
204 CALL_V_RET(errmsg_v, (p, args));
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
205 }
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_obj(const char *obj, const char *p, ...)
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
209 {
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
210 CALL_V_RET(errmsg_obj_v, (obj, p, args));
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_line(const char *obj, int line, const char *p, ...)
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
215 {
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
216 CALL_V_RET(errmsg_obj_line_v, (obj, line, p, args));
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_v(const char *obj, const char *p, va_list args)
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
221 {
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
222 return errmsg_obj_line_v(obj, -1, p, args);
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_v(const char *p, va_list args)
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
227 {
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
228 char *res;
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
229 vasprintf(&res, p, args);
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
230 return res;
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
231 }
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
232
228f64ffb422 trunk: changeset 30
tuomov
parents: 26
diff changeset
233
25
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
234 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
235 {
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
236 char *res1=NULL, *res2, *res3;
35
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
237
25
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
238 if(obj!=NULL){
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
239 if(line>0)
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
240 asprintf(&res1, TR("%s:%d: "), obj, line);
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
241 else
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
242 asprintf(&res1, "%s: ", obj);
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
243 }else{
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
244 if(line>0)
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
245 asprintf(&res1, TR("%d: "), line);
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
246 }
35
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
247 vasprintf(&res2, p, args);
25
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
248 if(res1!=NULL){
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
249 if(res2==NULL)
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
250 return NULL;
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
251 res3=scat(res1, res2);
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
252 free(res1);
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
253 free(res2);
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
254 return res3;
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
255 }
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
256 return res2;
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
257 }
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
258
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
259
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
260 char *errmsg_err()
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
261 {
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
262 char *res;
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
263 asprintf(&res, "%s\n", strerror(errno));
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
264 return res;
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
265 }
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
266
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
267
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
268 char *errmsg_err_obj(const char *obj)
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
269 {
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
270 char *res;
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
271 if(obj!=NULL)
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
272 asprintf(&res, "%s: %s\n", obj, strerror(errno));
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
273 else
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
274 asprintf(&res, "%s\n", strerror(errno));
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
275 return res;
0
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
276 }
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
277
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
278
25
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
279 char *errmsg_err_obj_line(const char *obj, int line)
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
280 {
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
281 char *res;
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
282 if(obj!=NULL){
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
283 if(line>0)
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
284 asprintf(&res, TR("%s:%d: %s\n"), obj, line, strerror(errno));
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
285 else
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
286 asprintf(&res, "%s: %s\n", obj, strerror(errno));
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
287 }else{
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
288 if(line>0)
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
289 asprintf(&res, TR("%d: %s\n"), line, strerror(errno));
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
290 else
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
291 asprintf(&res, TR("%s\n"), strerror(errno));
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
292 }
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
293 return res;
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
294 }
31
e9cad8bd8ec8 trunk: changeset 34
tuomov
parents: 27
diff changeset
295
25
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
296
0
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
297 /* die
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
298 */
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
299
35
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
300
0
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
301 void die(const char *p, ...)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
302 {
35
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
303 set_warn_handler(NULL);
25
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
304 CALL_V(die_v, (p, args));
0
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
305 }
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
306
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 void die_v(const char *p, va_list args)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
309 {
35
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
310 set_warn_handler(NULL);
0
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
311 warn_v(p, args);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
312 exit(EXIT_FAILURE);
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
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 void die_obj(const char *obj, const char *p, ...)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
317 {
35
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
318 set_warn_handler(NULL);
25
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
319 CALL_V(die_obj_v, (obj, p, args));
0
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
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
323 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
324 {
35
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
325 set_warn_handler(NULL);
25
9d41e3611050 trunk: changeset 28
tuomov
parents: 9
diff changeset
326 CALL_V(die_obj_line_v, (obj, line, p, args));
0
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
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
330 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
331 {
35
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
332 set_warn_handler(NULL);
0
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
333 warn_obj_v(obj, p, args);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
334 exit(EXIT_FAILURE);
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
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 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
339 {
35
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
340 set_warn_handler(NULL);
0
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
341 warn_obj_line_v(obj, line, p, args);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
342 exit(EXIT_FAILURE);
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
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 void die_err()
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
347 {
35
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
348 set_warn_handler(NULL);
0
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
349 warn_err();
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
350 exit(EXIT_FAILURE);
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
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 void die_err_obj(const char *obj)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
355 {
35
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
356 set_warn_handler(NULL);
0
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
357 warn_err_obj(obj);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
358 exit(EXIT_FAILURE);
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
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 void die_err_obj_line(const char *obj, int line)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
363 {
35
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
364 set_warn_handler(NULL);
0
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
365 warn_err_obj_line(obj, line);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
366 exit(EXIT_FAILURE);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
367 }
35
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
368
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
369
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
370 static void default_warn_handler(const char *message)
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
371 {
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
372 put_prog_name();
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
373 fprintf(stderr, "%s", message);
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
374 putc('\n', stderr);
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
375 }
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
376
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
377
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
378 static void do_dispatch_message(const char *message)
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
379 {
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
380 if(current_warn_handler!=NULL)
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
381 current_warn_handler(message);
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
382 else
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
383 default_warn_handler(message);
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
384 }
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
385
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
386
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
387 WarnHandler *set_warn_handler(WarnHandler *handler)
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
388 {
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
389 WarnHandler *old=current_warn_handler;
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
390 current_warn_handler=handler;
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
391 return old;
5a71d53d0228 trunk: changeset 38
tuomov
parents: 33
diff changeset
392 }

mercurial