output.c

Tue, 29 Aug 2000 00:03:00 +0200

author
tuomov
date
Tue, 29 Aug 2000 00:03:00 +0200
changeset 23
5f8005150227
parent 9
55e7f2ff6021
child 25
9d41e3611050
permissions
-rw-r--r--

trunk: changeset 26
Once again, 'make install' portability fixes

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 *
9
55e7f2ff6021 trunk: changeset 12
tuomov
parents: 5
diff changeset
4 * Copyright (c) Tuomo Valkonen 1999-2000.
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
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
18
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
19 /* verbose
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
20 */
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
21
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
22 static bool verbose_mode=FALSE;
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
23 static int verbose_indent_lvl=0;
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
24 static bool progname_enable=TRUE;
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 #define INDENTATOR_LENGTH 4
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 char indentator[]={' ', ' ', ' ', ' '};
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
29
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 void verbose(const char *p, ...)
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 va_list args;
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 va_start(args, p);
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 verbose_v(p, args);
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 va_end(args);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
40 }
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
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
43 void verbose_v(const char *p, va_list args)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
44 {
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
45 int i;
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
46
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
47 if(verbose_mode){
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
48 for(i=0; i<verbose_indent_lvl; i++)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
49 writef(stdout, indentator, INDENTATOR_LENGTH);
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 vprintf(p, args);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
52 fflush(stdout);
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 }
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
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
57 void verbose_enable(bool enable)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
58 {
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
59 verbose_mode=enable;
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 int verbose_indent(int depth)
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 int old=verbose_indent_lvl;
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
66
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
67 if(depth>=0)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
68 verbose_indent_lvl=depth;
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 return old;
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
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 /* warn
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
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
77 void warn_progname_enable(bool enable)
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 progname_enable=enable;
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 static void put_prog_name()
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 const char*progname;
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 if(!progname_enable)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
88 return;
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
89
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
90 progname=prog_execname();
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 if(progname==NULL)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
93 return;
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
94
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
95 fprintf(stderr, "%s: ", (char*)progname);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
96 }
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
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
99 void warn(const char *p, ...)
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 va_list args;
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 va_start(args, p);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
104
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
105 warn_v(p, args);
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 va_end(args);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
108 }
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
109
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
110
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
111 void warn_v(const char *p, va_list args)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
112 {
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
113 put_prog_name();
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
114 vfprintf(stderr, p, args);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
115 putc('\n', stderr);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
116 }
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
117
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
118
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
119 void warn_obj(const char *obj, const char *p, ...)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
120 {
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
121 va_list args;
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
122
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
123 va_start(args, p);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
124
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
125 warn_obj_v(obj, p, args);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
126
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
127 va_end(args);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
128 }
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
129
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
130
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
131 void warn_obj_line(const char *obj, int line, const char *p, ...)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
132 {
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
133 va_list args;
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
134
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
135 va_start(args, p);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
136
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
137 warn_obj_line_v(obj, line, p, args);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
138
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
139 va_end(args);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
140 }
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
141
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
142
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
143 void warn_obj_v(const char *obj, const char *p, va_list args)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
144 {
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
145 put_prog_name();
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
146 if(obj!=NULL)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
147 fprintf(stderr,"%s: ", obj);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
148 vfprintf(stderr, p, args);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
149 putc('\n', stderr);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
150 }
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
151
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
152
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
153 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
154 {
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
155 put_prog_name();
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
156 if(obj!=NULL){
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
157 if(line>0)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
158 fprintf(stderr, TR("%s:%d: "), obj, line);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
159 else
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
160 fprintf(stderr, "%s: ", obj);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
161 }else{
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
162 if(line>0)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
163 fprintf(stderr, TR("%d: "), line);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
164 }
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
165 vfprintf(stderr, p, args);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
166 putc('\n', stderr);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
167 }
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 void warn_err()
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 put_prog_name();
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
173 fprintf(stderr, "%s\n", strerror(errno));
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_err_obj(const char *obj)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
178 {
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
179 put_prog_name();
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
180 if(obj!=NULL)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
181 fprintf(stderr, "%s: %s\n", obj, strerror(errno));
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
182 else
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
183 fprintf(stderr, "%s\n", strerror(errno));
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
184
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
185 }
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
186
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
187
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
188 void warn_err_obj_line(const char *obj, int line)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
189 {
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
190 put_prog_name();
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
191 if(obj!=NULL){
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
192 if(line>0)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
193 fprintf(stderr, TR("%s:%d: %s\n"), obj, line, strerror(errno));
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
194 else
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
195 fprintf(stderr, "%s: %s\n", obj, strerror(errno));
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
196 }else{
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
197 if(line>0)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
198 fprintf(stderr, TR("%d: %s\n"), line, strerror(errno));
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
199 else
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
200 fprintf(stderr, TR("%s\n"), strerror(errno));
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
201 }
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
202
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
203 }
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
204
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
205
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
206 /* die
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
207 */
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
208
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
209 void die(const char *p, ...)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
210 {
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
211 va_list args;
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
212
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
213 va_start(args, p);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
214
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
215 die_v(p, args);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
216
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
217 va_end(args);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
218 }
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
219
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
220
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
221 void die_v(const char *p, va_list args)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
222 {
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
223 warn_v(p, args);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
224 exit(EXIT_FAILURE);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
225 }
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
226
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
227
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
228 void die_obj(const char *obj, const char *p, ...)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
229 {
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
230 va_list args;
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
231
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
232 va_start(args, p);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
233 die_obj_v(obj, p, args);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
234 va_end(args);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
235 }
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
236
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
237
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
238 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
239 {
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
240 va_list args;
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
241
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
242 va_start(args, p);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
243 die_obj_line_v(obj, line, p, args);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
244 va_end(args);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
245 }
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
246
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
247
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
248 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
249 {
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
250 warn_obj_v(obj, p, args);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
251 exit(EXIT_FAILURE);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
252 }
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
253
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
254
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
255 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
256 {
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
257 warn_obj_line_v(obj, line, p, args);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
258 exit(EXIT_FAILURE);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
259 }
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
260
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
261
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
262 void die_err()
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
263 {
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
264 warn_err();
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
265 exit(EXIT_FAILURE);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
266 }
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
267
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
268
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
269 void die_err_obj(const char *obj)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
270 {
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
271 warn_err_obj(obj);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
272 exit(EXIT_FAILURE);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
273 }
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
274
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
275
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
276 void die_err_obj_line(const char *obj, int line)
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 warn_err_obj_line(obj, line);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
279 exit(EXIT_FAILURE);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
280 }

mercurial