From 4d64e4cd434426234a5c313c151cd79b6afc299e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juha=20Vehvil=C3=A4inen?= Date: Sat, 6 Jul 2002 17:50:18 +0000 Subject: *** empty log message *** svn path=/trunk/Framestein/; revision=27 --- Patches/buildstr.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 Patches/buildstr.c (limited to 'Patches/buildstr.c') diff --git a/Patches/buildstr.c b/Patches/buildstr.c new file mode 100644 index 0000000..6ba6b15 --- /dev/null +++ b/Patches/buildstr.c @@ -0,0 +1,51 @@ +#include + +#define MAXLEN 500 + +static t_class *buildstr_class; + +typedef struct _buildstr { + t_object x_obj; + t_symbol s; + char buf[MAXLEN]; + int pos; +} t_buildstr; + +void buildstr_bang(t_buildstr *x) +{ + x->s.s_name = t_getbytes(strlen(x->buf)+1); + strcpy(x->s.s_name, x->buf); + outlet_symbol(x->x_obj.ob_outlet, &x->s); + t_freebytes(x->s.s_name, strlen(x->buf)+1); +} + +void buildstr_float(t_buildstr *x, t_float f) +{ + x->buf[x->pos] = (char)f; + x->pos++; + + if(f==0) + { + x->pos=0; + buildstr_bang(x); + } +} + +void *buildstr_new(t_symbol *s) +{ + t_buildstr *x = (t_buildstr *)pd_new(buildstr_class); + + x->pos = 0; + + outlet_new(&x->x_obj, gensym("symbol")); + + return (void *)x; +} + +void buildstr_setup(void) +{ + buildstr_class = class_new(gensym("buildstr"), (t_newmethod)buildstr_new, 0, sizeof(t_buildstr), CLASS_DEFAULT, A_DEFSYMBOL, 0); + + class_addbang(buildstr_class, buildstr_bang); + class_addfloat(buildstr_class, buildstr_float); +} -- cgit v1.2.1