diff options
Diffstat (limited to 'pd/extra/stdout')
-rw-r--r-- | pd/extra/stdout/makefile | 4 | ||||
-rw-r--r-- | pd/extra/stdout/stdout-help.pd | 13 | ||||
-rw-r--r-- | pd/extra/stdout/stdout.c | 51 |
3 files changed, 68 insertions, 0 deletions
diff --git a/pd/extra/stdout/makefile b/pd/extra/stdout/makefile new file mode 100644 index 00000000..67801999 --- /dev/null +++ b/pd/extra/stdout/makefile @@ -0,0 +1,4 @@ +NAME=stdout +CSYM=stdout + +include ../makefile diff --git a/pd/extra/stdout/stdout-help.pd b/pd/extra/stdout/stdout-help.pd new file mode 100644 index 00000000..b3d02489 --- /dev/null +++ b/pd/extra/stdout/stdout-help.pd @@ -0,0 +1,13 @@ +#N canvas 110 37 789 525 10; +#X msg 84 147 walk the dog; +#X msg 91 169 1; +#X msg 90 215 flush; +#X obj 84 240 stdout; +#X text 472 410 updated for Pd version 0.42; +#X obj 14 13 stdout; +#X text 67 14 - write messages to standard output; +#X msg 96 192 1 2; +#X connect 0 0 3 0; +#X connect 1 0 3 0; +#X connect 2 0 3 0; +#X connect 7 0 3 0; diff --git a/pd/extra/stdout/stdout.c b/pd/extra/stdout/stdout.c new file mode 100644 index 00000000..06c99308 --- /dev/null +++ b/pd/extra/stdout/stdout.c @@ -0,0 +1,51 @@ +/* stdout -- write messages to standard output. + + Copyright 2008 Miller Puckette + BSD license; see README.txt in this distribution for details. +*/ + +#include "m_pd.h" +#include <stdio.h> +#include <string.h> +static t_class *stdout_class; + +typedef struct _stdout +{ + t_object x_obj; +} t_stdout; + +static void *stdout_new(t_float fnonrepeat) +{ + t_stdout *x = (t_stdout *)pd_new(stdout_class); + return (x); +} + +static void stdout_anything(t_stdout *x, t_symbol *s, int argc, t_atom *argv) +{ + char msgbuf[MAXPDSTRING], *sp, *ep = msgbuf+MAXPDSTRING; + msgbuf[0] = 0; + strncpy(msgbuf, s->s_name, MAXPDSTRING); + msgbuf[MAXPDSTRING-1] = 0; + sp = msgbuf + strlen(msgbuf); + while (argc--) + { + if (sp < ep-1) + sp[0] = ' ', sp[1] = 0, sp++; + atom_string(argv++, sp, ep-sp); + sp += strlen(sp); + } + printf("%s;\n", msgbuf); +} + +static void stdout_flush(t_stdout *x) +{ + fflush(stdout); +} + +void stdout_setup(void) +{ + stdout_class = class_new(gensym("stdout"), (t_newmethod)stdout_new, + (t_method)stdout_flush, sizeof(t_stdout), 0, 0); + class_addmethod(stdout_class, (t_method)stdout_flush, gensym("flush"), 0); + class_addanything(stdout_class, stdout_anything); +} |