aboutsummaryrefslogtreecommitdiff
path: root/externals/extra/stdout
diff options
context:
space:
mode:
authorHans-Christoph Steiner <eighthave@users.sourceforge.net>2011-01-10 06:03:02 +0000
committerHans-Christoph Steiner <eighthave@users.sourceforge.net>2011-01-10 06:03:02 +0000
commit5af7081222ef801b23857fb904c78d0798f5d0df (patch)
tree68ac177c010b99c8eb837ea323c69cb541497148 /externals/extra/stdout
parentb77e38f5d194fb2ed72563d8ed20815d02a88efc (diff)
build Pd's extra as a libdir
svn path=/trunk/; revision=14694
Diffstat (limited to 'externals/extra/stdout')
-rw-r--r--externals/extra/stdout/stdout-help.pd19
-rw-r--r--externals/extra/stdout/stdout.c50
2 files changed, 69 insertions, 0 deletions
diff --git a/externals/extra/stdout/stdout-help.pd b/externals/extra/stdout/stdout-help.pd
new file mode 100644
index 00000000..91edbc41
--- /dev/null
+++ b/externals/extra/stdout/stdout-help.pd
@@ -0,0 +1,19 @@
+#N canvas 121 60 488 321 12;
+#X msg 126 203 walk the dog;
+#X msg 117 156 1;
+#X obj 117 240 stdout;
+#X text 269 287 updated for Pd version 0.42;
+#X obj 14 13 stdout;
+#X text 67 14 - write messages to standard output;
+#X msg 122 179 1 2;
+#X obj 119 291 pd~;
+#X text 44 291 see also:;
+#X text 34 39 Sends messages to Pd's standard output. This is useful
+in conjunction with the pd~ object \, which starts a pd sub-process.
+Messages sent to the sub-process standard output appear on the output
+of the pd~ object in the owning process. This might also be useful
+in other situations. Note that there's no corresponding "stdin" object
+- there seems to be no one canonical way such a thing should act.;
+#X connect 0 0 2 0;
+#X connect 1 0 2 0;
+#X connect 6 0 2 0;
diff --git a/externals/extra/stdout/stdout.c b/externals/extra/stdout/stdout.c
new file mode 100644
index 00000000..5cd52f25
--- /dev/null
+++ b/externals/extra/stdout/stdout.c
@@ -0,0 +1,50 @@
+/* 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_free(t_stdout *x)
+{
+ fflush(stdout);
+}
+
+void stdout_setup(void)
+{
+ stdout_class = class_new(gensym("stdout"), (t_newmethod)stdout_new,
+ (t_method)stdout_free, sizeof(t_stdout), 0, 0);
+ class_addanything(stdout_class, stdout_anything);
+}