diff options
Diffstat (limited to 'apps/plugins/pdbox/PDa/src/s_print.c')
-rw-r--r-- | apps/plugins/pdbox/PDa/src/s_print.c | 300 |
1 files changed, 300 insertions, 0 deletions
diff --git a/apps/plugins/pdbox/PDa/src/s_print.c b/apps/plugins/pdbox/PDa/src/s_print.c new file mode 100644 index 0000000000..1ef0eb6926 --- /dev/null +++ b/apps/plugins/pdbox/PDa/src/s_print.c | |||
@@ -0,0 +1,300 @@ | |||
1 | /* Copyright (c) 1997-1999 Miller Puckette. | ||
2 | * For information on usage and redistribution, and for a DISCLAIMER OF ALL | ||
3 | * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ | ||
4 | |||
5 | #include "m_pd.h" | ||
6 | #include <stdlib.h> | ||
7 | #include <stdio.h> | ||
8 | #include <stdarg.h> | ||
9 | #include <string.h> | ||
10 | #include <errno.h> | ||
11 | |||
12 | void post(char *fmt, ...) | ||
13 | { | ||
14 | va_list ap; | ||
15 | t_int arg[8]; | ||
16 | int i; | ||
17 | va_start(ap, fmt); | ||
18 | vfprintf(stderr, fmt, ap); | ||
19 | va_end(ap); | ||
20 | putc('\n', stderr); | ||
21 | } | ||
22 | |||
23 | void startpost(char *fmt, ...) | ||
24 | { | ||
25 | va_list ap; | ||
26 | t_int arg[8]; | ||
27 | int i; | ||
28 | va_start(ap, fmt); | ||
29 | |||
30 | for (i = 0 ; i < 8; i++) arg[i] = va_arg(ap, t_int); | ||
31 | va_end(ap); | ||
32 | fprintf(stderr, fmt, arg[0], arg[1], arg[2], arg[3], | ||
33 | arg[4], arg[5], arg[6], arg[7]); | ||
34 | } | ||
35 | |||
36 | void poststring(char *s) | ||
37 | { | ||
38 | fprintf(stderr, " %s", s); | ||
39 | } | ||
40 | |||
41 | void postatom(int argc, t_atom *argv) | ||
42 | { | ||
43 | int i; | ||
44 | for (i = 0; i < argc; i++) | ||
45 | { | ||
46 | char buf[80]; | ||
47 | atom_string(argv+i, buf, 80); | ||
48 | poststring(buf); | ||
49 | } | ||
50 | } | ||
51 | |||
52 | void postfloat(float f) | ||
53 | { | ||
54 | char buf[80]; | ||
55 | t_atom a; | ||
56 | SETFLOAT(&a, f); | ||
57 | postatom(1, &a); | ||
58 | } | ||
59 | |||
60 | void endpost(void) | ||
61 | { | ||
62 | fprintf(stderr, "\n"); | ||
63 | } | ||
64 | |||
65 | void error(char *fmt, ...) | ||
66 | { | ||
67 | va_list ap; | ||
68 | t_int arg[8]; | ||
69 | int i; | ||
70 | va_start(ap, fmt); | ||
71 | fprintf(stderr, "error: "); | ||
72 | vfprintf(stderr, fmt, ap); | ||
73 | va_end(ap); | ||
74 | putc('\n', stderr); | ||
75 | } | ||
76 | |||
77 | /* here's the good way to log errors -- keep a pointer to the | ||
78 | offending or offended object around so the user can search for it | ||
79 | later. */ | ||
80 | |||
81 | static void *error_object; | ||
82 | static char error_string[256]; | ||
83 | void canvas_finderror(void *object); | ||
84 | |||
85 | void pd_error(void *object, char *fmt, ...) | ||
86 | { | ||
87 | va_list ap; | ||
88 | t_int arg[8]; | ||
89 | int i; | ||
90 | static int saidit = 0; | ||
91 | va_start(ap, fmt); | ||
92 | vsprintf(error_string, fmt, ap); | ||
93 | va_end(ap); | ||
94 | fprintf(stderr, "error: %s\n", error_string); | ||
95 | error_object = object; | ||
96 | if (!saidit) | ||
97 | { | ||
98 | post("... you might be able to track this down from the Find menu."); | ||
99 | saidit = 1; | ||
100 | } | ||
101 | } | ||
102 | |||
103 | void glob_finderror(t_pd *dummy) | ||
104 | { | ||
105 | if (!error_object) | ||
106 | post("no findable error yet."); | ||
107 | else | ||
108 | { | ||
109 | post("last trackable error:"); | ||
110 | post("%s", error_string); | ||
111 | canvas_finderror(error_object); | ||
112 | } | ||
113 | } | ||
114 | |||
115 | void bug(char *fmt, ...) | ||
116 | { | ||
117 | va_list ap; | ||
118 | t_int arg[8]; | ||
119 | int i; | ||
120 | va_start(ap, fmt); | ||
121 | |||
122 | for (i = 0 ; i < 8; i++) arg[i] = va_arg(ap, t_int); | ||
123 | va_end(ap); | ||
124 | fprintf(stderr, "Consistency check failed: "); | ||
125 | fprintf(stderr, fmt, arg[0], arg[1], arg[2], arg[3], | ||
126 | arg[4], arg[5], arg[6], arg[7]); | ||
127 | putc('\n', stderr); | ||
128 | } | ||
129 | |||
130 | /* this isn't worked out yet. */ | ||
131 | static char *errobject; | ||
132 | static char *errstring; | ||
133 | |||
134 | void sys_logerror(char *object, char *s) | ||
135 | { | ||
136 | errobject = object; | ||
137 | errstring = s; | ||
138 | } | ||
139 | |||
140 | void sys_unixerror(char *object) | ||
141 | { | ||
142 | errobject = object; | ||
143 | errstring = strerror(errno); | ||
144 | } | ||
145 | |||
146 | void sys_ouch(void) | ||
147 | { | ||
148 | if (*errobject) error("%s: %s", errobject, errstring); | ||
149 | else error("%s", errstring); | ||
150 | } | ||
151 | /* Copyright (c) 1997-1999 Miller Puckette. | ||
152 | * For information on usage and redistribution, and for a DISCLAIMER OF ALL | ||
153 | * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ | ||
154 | |||
155 | #include "m_pd.h" | ||
156 | #include <stdlib.h> | ||
157 | #include <stdio.h> | ||
158 | #include <stdarg.h> | ||
159 | #include <string.h> | ||
160 | #include <errno.h> | ||
161 | |||
162 | void post(char *fmt, ...) | ||
163 | { | ||
164 | va_list ap; | ||
165 | t_int arg[8]; | ||
166 | int i; | ||
167 | va_start(ap, fmt); | ||
168 | vfprintf(stderr, fmt, ap); | ||
169 | va_end(ap); | ||
170 | putc('\n', stderr); | ||
171 | } | ||
172 | |||
173 | void startpost(char *fmt, ...) | ||
174 | { | ||
175 | va_list ap; | ||
176 | t_int arg[8]; | ||
177 | int i; | ||
178 | va_start(ap, fmt); | ||
179 | |||
180 | for (i = 0 ; i < 8; i++) arg[i] = va_arg(ap, t_int); | ||
181 | va_end(ap); | ||
182 | fprintf(stderr, fmt, arg[0], arg[1], arg[2], arg[3], | ||
183 | arg[4], arg[5], arg[6], arg[7]); | ||
184 | } | ||
185 | |||
186 | void poststring(char *s) | ||
187 | { | ||
188 | fprintf(stderr, " %s", s); | ||
189 | } | ||
190 | |||
191 | void postatom(int argc, t_atom *argv) | ||
192 | { | ||
193 | int i; | ||
194 | for (i = 0; i < argc; i++) | ||
195 | { | ||
196 | char buf[80]; | ||
197 | atom_string(argv+i, buf, 80); | ||
198 | poststring(buf); | ||
199 | } | ||
200 | } | ||
201 | |||
202 | void postfloat(float f) | ||
203 | { | ||
204 | char buf[80]; | ||
205 | t_atom a; | ||
206 | SETFLOAT(&a, f); | ||
207 | postatom(1, &a); | ||
208 | } | ||
209 | |||
210 | void endpost(void) | ||
211 | { | ||
212 | fprintf(stderr, "\n"); | ||
213 | } | ||
214 | |||
215 | void error(char *fmt, ...) | ||
216 | { | ||
217 | va_list ap; | ||
218 | t_int arg[8]; | ||
219 | int i; | ||
220 | va_start(ap, fmt); | ||
221 | fprintf(stderr, "error: "); | ||
222 | vfprintf(stderr, fmt, ap); | ||
223 | va_end(ap); | ||
224 | putc('\n', stderr); | ||
225 | } | ||
226 | |||
227 | /* here's the good way to log errors -- keep a pointer to the | ||
228 | offending or offended object around so the user can search for it | ||
229 | later. */ | ||
230 | |||
231 | static void *error_object; | ||
232 | static char error_string[256]; | ||
233 | void canvas_finderror(void *object); | ||
234 | |||
235 | void pd_error(void *object, char *fmt, ...) | ||
236 | { | ||
237 | va_list ap; | ||
238 | t_int arg[8]; | ||
239 | int i; | ||
240 | static int saidit = 0; | ||
241 | va_start(ap, fmt); | ||
242 | vsprintf(error_string, fmt, ap); | ||
243 | va_end(ap); | ||
244 | fprintf(stderr, "error: %s\n", error_string); | ||
245 | error_object = object; | ||
246 | if (!saidit) | ||
247 | { | ||
248 | post("... you might be able to track this down from the Find menu."); | ||
249 | saidit = 1; | ||
250 | } | ||
251 | } | ||
252 | |||
253 | void glob_finderror(t_pd *dummy) | ||
254 | { | ||
255 | if (!error_object) | ||
256 | post("no findable error yet."); | ||
257 | else | ||
258 | { | ||
259 | post("last trackable error:"); | ||
260 | post("%s", error_string); | ||
261 | canvas_finderror(error_object); | ||
262 | } | ||
263 | } | ||
264 | |||
265 | void bug(char *fmt, ...) | ||
266 | { | ||
267 | va_list ap; | ||
268 | t_int arg[8]; | ||
269 | int i; | ||
270 | va_start(ap, fmt); | ||
271 | |||
272 | for (i = 0 ; i < 8; i++) arg[i] = va_arg(ap, t_int); | ||
273 | va_end(ap); | ||
274 | fprintf(stderr, "Consistency check failed: "); | ||
275 | fprintf(stderr, fmt, arg[0], arg[1], arg[2], arg[3], | ||
276 | arg[4], arg[5], arg[6], arg[7]); | ||
277 | putc('\n', stderr); | ||
278 | } | ||
279 | |||
280 | /* this isn't worked out yet. */ | ||
281 | static char *errobject; | ||
282 | static char *errstring; | ||
283 | |||
284 | void sys_logerror(char *object, char *s) | ||
285 | { | ||
286 | errobject = object; | ||
287 | errstring = s; | ||
288 | } | ||
289 | |||
290 | void sys_unixerror(char *object) | ||
291 | { | ||
292 | errobject = object; | ||
293 | errstring = strerror(errno); | ||
294 | } | ||
295 | |||
296 | void sys_ouch(void) | ||
297 | { | ||
298 | if (*errobject) error("%s: %s", errobject, errstring); | ||
299 | else error("%s", errstring); | ||
300 | } | ||