Add FS #10214. Initial commit of the original PDa code for the GSoC Pure Data plugin...
[kugel-rb.git] / apps / plugins / pdbox / PDa / src / s_print.c
blob1ef0eb6926043636d559f3b859654eb13dee6df7
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. */
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>
12 void post(char *fmt, ...)
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);
23 void startpost(char *fmt, ...)
25 va_list ap;
26 t_int arg[8];
27 int i;
28 va_start(ap, fmt);
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]);
36 void poststring(char *s)
38 fprintf(stderr, " %s", s);
41 void postatom(int argc, t_atom *argv)
43 int i;
44 for (i = 0; i < argc; i++)
46 char buf[80];
47 atom_string(argv+i, buf, 80);
48 poststring(buf);
52 void postfloat(float f)
54 char buf[80];
55 t_atom a;
56 SETFLOAT(&a, f);
57 postatom(1, &a);
60 void endpost(void)
62 fprintf(stderr, "\n");
65 void error(char *fmt, ...)
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);
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. */
81 static void *error_object;
82 static char error_string[256];
83 void canvas_finderror(void *object);
85 void pd_error(void *object, char *fmt, ...)
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)
98 post("... you might be able to track this down from the Find menu.");
99 saidit = 1;
103 void glob_finderror(t_pd *dummy)
105 if (!error_object)
106 post("no findable error yet.");
107 else
109 post("last trackable error:");
110 post("%s", error_string);
111 canvas_finderror(error_object);
115 void bug(char *fmt, ...)
117 va_list ap;
118 t_int arg[8];
119 int i;
120 va_start(ap, fmt);
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);
130 /* this isn't worked out yet. */
131 static char *errobject;
132 static char *errstring;
134 void sys_logerror(char *object, char *s)
136 errobject = object;
137 errstring = s;
140 void sys_unixerror(char *object)
142 errobject = object;
143 errstring = strerror(errno);
146 void sys_ouch(void)
148 if (*errobject) error("%s: %s", errobject, errstring);
149 else error("%s", errstring);
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. */
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>
162 void post(char *fmt, ...)
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);
173 void startpost(char *fmt, ...)
175 va_list ap;
176 t_int arg[8];
177 int i;
178 va_start(ap, fmt);
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]);
186 void poststring(char *s)
188 fprintf(stderr, " %s", s);
191 void postatom(int argc, t_atom *argv)
193 int i;
194 for (i = 0; i < argc; i++)
196 char buf[80];
197 atom_string(argv+i, buf, 80);
198 poststring(buf);
202 void postfloat(float f)
204 char buf[80];
205 t_atom a;
206 SETFLOAT(&a, f);
207 postatom(1, &a);
210 void endpost(void)
212 fprintf(stderr, "\n");
215 void error(char *fmt, ...)
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);
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. */
231 static void *error_object;
232 static char error_string[256];
233 void canvas_finderror(void *object);
235 void pd_error(void *object, char *fmt, ...)
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)
248 post("... you might be able to track this down from the Find menu.");
249 saidit = 1;
253 void glob_finderror(t_pd *dummy)
255 if (!error_object)
256 post("no findable error yet.");
257 else
259 post("last trackable error:");
260 post("%s", error_string);
261 canvas_finderror(error_object);
265 void bug(char *fmt, ...)
267 va_list ap;
268 t_int arg[8];
269 int i;
270 va_start(ap, fmt);
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);
280 /* this isn't worked out yet. */
281 static char *errobject;
282 static char *errstring;
284 void sys_logerror(char *object, char *s)
286 errobject = object;
287 errstring = s;
290 void sys_unixerror(char *object)
292 errobject = object;
293 errstring = strerror(errno);
296 void sys_ouch(void)
298 if (*errobject) error("%s: %s", errobject, errstring);
299 else error("%s", errstring);