aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIOhannes m zmölnig <zmoelnig@users.sourceforge.net>2005-06-02 18:26:48 +0000
committerIOhannes m zmölnig <zmoelnig@users.sourceforge.net>2005-06-02 18:26:48 +0000
commit710c3dcfc0728166ac9477d153a24f5b80ab18c4 (patch)
treed547d013ce5969b3f8ee092738a27306ade809e5 /src
parent0c9b89b1018eb7760708ee5b080cd96846861328 (diff)
added files for release 1.16
svn path=/trunk/externals/iemlib/; revision=3103
Diffstat (limited to 'src')
-rw-r--r--src/iemlib2/iem_anything.c145
-rw-r--r--src/iemlib2/iem_append.c363
-rw-r--r--src/iemlib2/iem_prepend.c252
-rw-r--r--src/iemlib2/iem_receive.c179
-rw-r--r--src/iemlib2/iem_send.c162
-rw-r--r--src/iemlib2/parentdollarzero.c60
-rw-r--r--src/iemlib2/protect_against_open.c103
-rw-r--r--src/iemlib2/receive2list.c222
8 files changed, 1486 insertions, 0 deletions
diff --git a/src/iemlib2/iem_anything.c b/src/iemlib2/iem_anything.c
new file mode 100644
index 0000000..bf92421
--- /dev/null
+++ b/src/iemlib2/iem_anything.c
@@ -0,0 +1,145 @@
+/* For information on usage and redistribution, and for a DISCLAIMER OF ALL
+* WARRANTIES, see the file, "LICENSE.txt," in this distribution.
+
+iemlib2 written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */
+
+#ifdef NT
+#pragma warning( disable : 4244 )
+#pragma warning( disable : 4305 )
+#endif
+
+#include "m_pd.h"
+#include "iemlib.h"
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
+/* ------------------------------- iem_anything ---------------------------------- */
+/* -- storage object for any message (bang, float, symbol, list, selector-list) -- */
+/* ---------- with a hot and a cold inlet (like object float or symbol) ---------- */
+/* ----------- initial arguments are equal to a message of cold inlet ------------ */
+
+struct _iem_anything_proxy;
+
+static t_class *iem_anything_class;
+static t_class *iem_anything_proxy_class;
+
+typedef struct _iem_anything
+{
+ t_object x_obj;
+ struct _iem_anything_proxy *x_proxy_inlet;
+ int x_size;
+ int x_ac;
+ t_atom *x_at;
+ t_symbol *x_selector_sym;
+} t_iem_anything;
+
+typedef struct _iem_anything_proxy
+{
+ t_object p_obj;
+ t_iem_anything *p_owner;
+} t_iem_anything_proxy;
+
+static void iem_anything_atcopy(t_atom *src, t_atom *dst, int n)
+{
+ while(n--)
+ *dst++ = *src++;
+}
+
+static void iem_anything_anything(t_iem_anything *x, t_symbol *s, int ac, t_atom *av)
+{
+ if(ac > x->x_size)
+ {
+ x->x_at = (t_atom *)resizebytes(x->x_at, x->x_size*sizeof(t_atom), (10 + ac)*sizeof(t_atom));
+ x->x_size = 10 + ac;
+ }
+ x->x_ac = ac;
+ x->x_selector_sym = s;
+ iem_anything_atcopy(av, x->x_at, ac);
+ outlet_anything(x->x_obj.ob_outlet, s, ac, av);
+}
+
+static void iem_anything_bang(t_iem_anything *x)
+{
+ if((x->x_selector_sym == &s_bang) && !x->x_ac)
+ {
+ outlet_bang(x->x_obj.ob_outlet);
+ }
+ else
+ {
+ outlet_anything(x->x_obj.ob_outlet, x->x_selector_sym, x->x_ac, x->x_at);
+ }
+}
+
+/* begin of proxy methods (anything inlets) */
+
+static void iem_anything_proxy_anything(t_iem_anything_proxy *p, t_symbol *s, int ac, t_atom *av)
+{
+ t_iem_anything *x = p->p_owner;
+
+ if(ac > x->x_size)
+ {
+ x->x_at = (t_atom *)resizebytes(x->x_at, x->x_size*sizeof(t_atom), (10 + ac)*sizeof(t_atom));
+ x->x_size = 10 + ac;
+ }
+ x->x_ac = ac;
+ x->x_selector_sym = s;
+ iem_anything_atcopy(av, x->x_at, ac);
+}
+
+/* end of proxy methods (anything inlets) */
+
+static void iem_anything_free(t_iem_anything *x)
+{
+ if(x->x_at)
+ freebytes(x->x_at, x->x_size * sizeof(t_atom));
+ if(x->x_proxy_inlet)
+ pd_free((t_pd *)x->x_proxy_inlet);
+}
+
+static void *iem_anything_new(t_symbol *s, int ac, t_atom *av)
+{
+ t_iem_anything *x = (t_iem_anything *)pd_new(iem_anything_class);
+ t_iem_anything_proxy *p = (t_iem_anything_proxy *)pd_new(iem_anything_proxy_class);
+
+ x->x_proxy_inlet = p;
+ p->p_owner = x;
+
+ x->x_size = 10 + ac;
+ x->x_at = (t_atom *)getbytes(x->x_size * sizeof(t_atom));
+ x->x_ac = ac;
+ if(!ac)
+ {
+ x->x_selector_sym = &s_bang;
+ }
+ else if(IS_A_SYMBOL(av, 0))
+ {
+ x->x_selector_sym = atom_getsymbol(av);
+ x->x_ac--;
+ iem_anything_proxy_anything(p, x->x_selector_sym, x->x_ac, av+1);
+ }
+ else
+ {
+ x->x_selector_sym = &s_list;
+ iem_anything_proxy_anything(p, x->x_selector_sym, x->x_ac, av);
+ }
+ inlet_new((t_object *)x, (t_pd *)p, 0, 0);
+ outlet_new(&x->x_obj, &s_list);
+ return (x);
+}
+
+void iem_anything_setup(void)
+{
+ iem_anything_class = class_new(gensym("iem_anything"),
+ (t_newmethod)iem_anything_new, (t_method)iem_anything_free,
+ sizeof(t_iem_anything), 0, A_GIMME, 0);
+ class_addcreator((t_newmethod)iem_anything_new, gensym("any"), A_GIMME, 0);
+
+ class_addanything(iem_anything_class, iem_anything_anything);
+ class_addbang(iem_anything_class, iem_anything_bang);
+ class_sethelpsymbol(iem_anything_class, gensym("iemhelp/help-iem_anything"));
+
+ iem_anything_proxy_class = class_new(gensym("_iem_anything_proxy"),
+ 0, 0, sizeof(t_iem_anything_proxy), CLASS_PD | CLASS_NOINLET, 0);
+ class_addanything(iem_anything_proxy_class, iem_anything_proxy_anything);
+}
diff --git a/src/iemlib2/iem_append.c b/src/iemlib2/iem_append.c
new file mode 100644
index 0000000..23237f6
--- /dev/null
+++ b/src/iemlib2/iem_append.c
@@ -0,0 +1,363 @@
+/* For information on usage and redistribution, and for a DISCLAIMER OF ALL
+* WARRANTIES, see the file, "LICENSE.txt," in this distribution.
+
+iemlib2 written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */
+
+#ifdef NT
+#pragma warning( disable : 4244 )
+#pragma warning( disable : 4305 )
+#endif
+
+#include "m_pd.h"
+#include "iemlib.h"
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
+
+/* ----------------------- iem_append -------------------------- */
+/* -- concatenates message from hot (left) inlet with message -- */
+/* ------ from cold (right) inlet and outputs it; initial ----- */
+/* -- arguments (appendix) are eqal to message of cold inlet --- */
+
+
+struct _iem_append_proxy;
+
+static t_class *iem_append_class;
+static t_class *iem_append_proxy_class;
+
+typedef struct _iem_append
+{
+ t_object x_obj;
+ struct _iem_append_proxy *x_proxy_inlet;
+ int x_size12;
+ int x_size2;
+ int x_ac1;
+ int x_ac2;
+ t_atom *x_at12;
+ t_atom *x_at2;
+ t_symbol *x_selector_sym1;
+ t_symbol *x_selector_sym2;
+ t_atomtype x_type1;
+ t_atomtype x_type2;
+} t_iem_append;
+
+typedef struct _iem_append_proxy
+{
+ t_object p_obj;
+ t_iem_append *p_owner;
+} t_iem_append_proxy;
+
+static void iem_append_atcopy(t_atom *src, t_atom *dst, int n)
+{
+ while(n--)
+ *dst++ = *src++;
+}
+
+static void iem_append_merge(t_iem_append *x, int off)
+{
+ if((x->x_ac1+x->x_ac2+1) > x->x_size12)
+ {
+ x->x_at12 = (t_atom *)resizebytes(x->x_at12, x->x_size12*sizeof(t_atom), 2*(x->x_ac1+x->x_ac2+1)*sizeof(t_atom));
+ x->x_size12 = 2*(x->x_ac1+x->x_ac2+1);
+ }
+ if(off)
+ SETSYMBOL(x->x_at12 + x->x_ac1, x->x_selector_sym2);
+ iem_append_atcopy(x->x_at2, x->x_at12 + x->x_ac1 + off, x->x_ac2);
+}
+
+static void iem_append_out(t_iem_append *x)
+{
+ int off=0;
+
+ if(x->x_type1 == A_GIMME)
+ {
+ if(x->x_type2 == A_COMMA)
+ off = 1;
+ else
+ off = 0;
+ iem_append_merge(x, off);
+ outlet_list(x->x_obj.ob_outlet, &s_list, x->x_ac1+x->x_ac2+off, x->x_at12);
+ }
+ else if(x->x_type1 == A_COMMA)
+ {
+ if(x->x_type2 == A_COMMA)
+ off = 1;
+ else
+ off = 0;
+ iem_append_merge(x, off);
+ outlet_anything(x->x_obj.ob_outlet, x->x_selector_sym1, x->x_ac1+x->x_ac2+off, x->x_at12);
+ }
+ else if(x->x_type1 == A_NULL)/*depends on 2.part*/
+ {
+ iem_append_merge(x, 0);
+ if(x->x_type2 == A_GIMME)
+ outlet_list(x->x_obj.ob_outlet, &s_list, x->x_ac2, x->x_at12);
+ else if(x->x_type2 == A_COMMA)
+ outlet_anything(x->x_obj.ob_outlet, x->x_selector_sym2, x->x_ac2, x->x_at12);
+ else if(x->x_type2 == A_FLOAT)
+ outlet_float(x->x_obj.ob_outlet, atom_getfloat(x->x_at12));
+ else if(x->x_type2 == A_SYMBOL)
+ outlet_symbol(x->x_obj.ob_outlet, atom_getsymbol(x->x_at12));
+ else if(x->x_type2 == A_NULL)
+ outlet_bang(x->x_obj.ob_outlet);
+ else if(x->x_type2 == A_POINTER)
+ outlet_pointer(x->x_obj.ob_outlet, (t_gpointer *)x->x_at12->a_w.w_gpointer);
+ }
+ else
+ {
+ if(x->x_type2 == A_COMMA)
+ off = 1;
+ else
+ off = 0;
+ iem_append_merge(x, off);
+ if(x->x_type2 == A_NULL)
+ {
+ if(x->x_type1 == A_FLOAT)
+ outlet_float(x->x_obj.ob_outlet, atom_getfloat(x->x_at12));
+ else if(x->x_type1 == A_SYMBOL)
+ outlet_symbol(x->x_obj.ob_outlet, atom_getsymbol(x->x_at12));
+ else if(x->x_type1 == A_POINTER)
+ outlet_pointer(x->x_obj.ob_outlet, (t_gpointer *)x->x_at12->a_w.w_gpointer);
+ }
+ else
+ outlet_list(x->x_obj.ob_outlet, &s_list, x->x_ac1+x->x_ac2+off, x->x_at12);
+ }
+}
+
+static void iem_append_bang(t_iem_append *x)
+{
+ x->x_ac1 = 0;
+ x->x_type1 = A_NULL;
+ iem_append_out(x);
+}
+
+static void iem_append_float(t_iem_append *x, t_float f)
+{
+ x->x_ac1 = 1;
+ x->x_type1 = A_FLOAT;
+ SETFLOAT(x->x_at12, f);
+ iem_append_out(x);
+}
+
+static void iem_append_symbol(t_iem_append *x, t_symbol *s)
+{
+ x->x_ac1 = 1;
+ x->x_type1 = A_SYMBOL;
+ SETSYMBOL(x->x_at12, s);
+ iem_append_out(x);
+}
+
+static void iem_append_pointer(t_iem_append *x, t_gpointer *gp)
+{
+ x->x_ac1 = 1;
+ x->x_type1 = A_POINTER;
+ SETPOINTER(x->x_at12, gp);
+ iem_append_out(x);
+}
+
+static void iem_append_list(t_iem_append *x, t_symbol *s, int ac, t_atom *av)
+{
+ if((x->x_size2+ac+1) > x->x_size12)
+ {
+ x->x_at12 = (t_atom *)resizebytes(x->x_at12, x->x_size12*sizeof(t_atom), (x->x_size2+ac+11)*sizeof(t_atom));
+ x->x_size12 = x->x_size2+ac+11;
+ }
+ x->x_ac1 = ac;
+ x->x_type1 = A_GIMME;
+ iem_append_atcopy(av, x->x_at12, ac);
+ x->x_selector_sym1 = &s_list;
+ iem_append_out(x);
+}
+
+static void iem_append_anything(t_iem_append *x, t_symbol *s, int ac, t_atom *av)
+{
+ if((x->x_size2+ac+2) > x->x_size12)
+ {
+ x->x_at12 = (t_atom *)resizebytes(x->x_at12, x->x_size12*sizeof(t_atom), (x->x_size2+ac+12)*sizeof(t_atom));
+ x->x_size12 = x->x_size2+ac+12;
+ }
+ x->x_ac1 = ac;
+ x->x_type1 = A_COMMA;
+ iem_append_atcopy(av, x->x_at12, ac);
+ x->x_selector_sym1 = s;
+ iem_append_out(x);
+}
+
+/* begin of proxy methods (anything inlets) */
+
+static void iem_append_proxy_bang(t_iem_append_proxy *p)
+{
+ t_iem_append *x = p->p_owner;
+
+ x->x_ac2 = 0;
+ x->x_type2 = A_NULL;
+ x->x_selector_sym2 = &s_list;
+}
+
+static void iem_append_proxy_float(t_iem_append_proxy *p, t_float f)
+{
+ t_iem_append *x = p->p_owner;
+
+ x->x_ac2 = 1;
+ x->x_type2 = A_FLOAT;
+ SETFLOAT(x->x_at2, f);
+ x->x_selector_sym2 = &s_list;
+}
+
+static void iem_append_proxy_symbol(t_iem_append_proxy *p, t_symbol *s)
+{
+ t_iem_append *x = p->p_owner;
+
+ x->x_ac2 = 1;
+ x->x_type2 = A_SYMBOL;
+ SETSYMBOL(x->x_at2, s);
+ x->x_selector_sym2 = &s_list;
+}
+
+static void iem_append_proxy_pointer(t_iem_append_proxy *p, t_gpointer *gp)
+{
+ t_iem_append *x = p->p_owner;
+
+ x->x_ac2 = 1;
+ x->x_type2 = A_POINTER;
+ SETPOINTER(x->x_at2, gp);
+ x->x_selector_sym2 = &s_list;
+}
+
+static void iem_append_proxy_list(t_iem_append_proxy *p, t_symbol *s, int ac, t_atom *av)
+{
+ t_iem_append *x = p->p_owner;
+
+ if(ac > x->x_size2)
+ {
+ x->x_at2 = (t_atom *)resizebytes(x->x_at2, x->x_size2*sizeof(t_atom), (ac+10)*sizeof(t_atom));
+ x->x_size2 = (ac+10);
+ }
+ x->x_ac2 = ac;
+ x->x_type2 = A_GIMME;
+ x->x_selector_sym2 = &s_list;
+ iem_append_atcopy(av, x->x_at2, ac);
+}
+
+static void iem_append_proxy_anything(t_iem_append_proxy *p, t_symbol *s, int ac, t_atom *av)
+{
+ t_iem_append *x = p->p_owner;
+
+ if((ac+1) > x->x_size2)
+ {
+ x->x_at2 = (t_atom *)resizebytes(x->x_at2, x->x_size2*sizeof(t_atom), (ac+11)*sizeof(t_atom));
+ x->x_size2 = ac+11;
+ }
+ x->x_ac2 = ac;
+ x->x_type2 = A_COMMA;
+ x->x_selector_sym2 = s;
+ iem_append_atcopy(av, x->x_at2, ac);
+}
+
+/* end of proxy methods (anything inlets) */
+
+static void iem_append_free(t_iem_append *x)
+{
+ if(x->x_at12)
+ freebytes(x->x_at12, x->x_size12 * sizeof(t_atom));
+ if(x->x_at2)
+ freebytes(x->x_at2, x->x_size2 * sizeof(t_atom));
+ if(x->x_proxy_inlet)
+ pd_free((t_pd *)x->x_proxy_inlet);
+}
+
+static void *iem_append_new(t_symbol *s, int ac, t_atom *av)
+{
+ t_iem_append *x = (t_iem_append *)pd_new(iem_append_class);
+ t_iem_append_proxy *p = (t_iem_append_proxy *)pd_new(iem_append_proxy_class);
+
+ x->x_proxy_inlet = p;
+ p->p_owner = x;
+
+ x->x_type1 = A_NULL;
+ x->x_selector_sym1 = &s_list;
+ x->x_size2 = 10;
+ if(ac > 5)
+ x->x_size2 = 2*ac;
+ x->x_at2 = (t_atom *)getbytes(x->x_size2 * sizeof(t_atom));
+ x->x_size12 = x->x_size2 + 10;
+ x->x_at12 = (t_atom *)getbytes(x->x_size12 * sizeof(t_atom));
+ x->x_ac1 = 0;
+
+ if(ac <= 0)
+ {
+ x->x_type2 = A_NULL;
+ x->x_ac2 = 0;
+ x->x_selector_sym2 = &s_list;
+ }
+ else
+ {
+ if(IS_A_FLOAT(av, 0))
+ {
+ if(ac == 1)
+ iem_append_proxy_float(p, atom_getfloat(av));
+ else
+ iem_append_proxy_list(p, &s_list, ac, av);
+ }
+ else if(IS_A_SYMBOL(av, 0))
+ {
+ t_symbol *xsym=atom_getsymbol(av);
+
+ if(xsym == &s_symbol)
+ {
+ if(ac > 1)
+ iem_append_proxy_symbol(p, atom_getsymbol(av+1));
+ else
+ iem_append_proxy_symbol(p, gensym(""));
+ }
+ else if(xsym == &s_float)
+ {
+ if(ac > 1)
+ {
+ if(IS_A_FLOAT(av, 1))
+ iem_append_proxy_float(p, atom_getfloat(av+1));
+ else
+ iem_append_proxy_float(p, 0.0f);
+ }
+ else
+ iem_append_proxy_float(p, 0.0f);
+ }
+ else if(xsym == &s_list)
+ {
+ iem_append_proxy_list(p, &s_list, ac-1, av+1);
+ }
+ else
+ {
+ iem_append_proxy_anything(p, xsym, ac-1, av+1);
+ }
+ }
+ }
+ inlet_new((t_object *)x, (t_pd *)p, 0, 0);
+ outlet_new(&x->x_obj, &s_list);
+ return (x);
+}
+
+void iem_append_setup(void)
+{
+ iem_append_class = class_new(gensym("iem_append"),
+ (t_newmethod)iem_append_new, (t_method)iem_append_free,
+ sizeof(t_iem_append), 0, A_GIMME, 0);
+ class_addcreator((t_newmethod)iem_append_new, gensym("merge_any"), A_GIMME, 0);
+ class_addbang(iem_append_class, (t_method)iem_append_bang);
+ class_addpointer(iem_append_class, iem_append_pointer);
+ class_addfloat(iem_append_class, (t_method)iem_append_float);
+ class_addsymbol(iem_append_class, iem_append_symbol);
+ class_addlist(iem_append_class, iem_append_list);
+ class_addanything(iem_append_class, iem_append_anything);
+ class_sethelpsymbol(iem_append_class, gensym("iemhelp/help-iem_append"));
+
+ iem_append_proxy_class = class_new(gensym("_iem_append_proxy"),
+ 0, 0, sizeof(t_iem_append_proxy), CLASS_PD | CLASS_NOINLET, 0);
+ class_addbang(iem_append_proxy_class, (t_method)iem_append_proxy_bang);
+ class_addpointer(iem_append_proxy_class, iem_append_proxy_pointer);
+ class_addfloat(iem_append_proxy_class, (t_method)iem_append_proxy_float);
+ class_addsymbol(iem_append_proxy_class, iem_append_proxy_symbol);
+ class_addlist(iem_append_proxy_class, iem_append_proxy_list);
+ class_addanything(iem_append_proxy_class, iem_append_proxy_anything);
+}
diff --git a/src/iemlib2/iem_prepend.c b/src/iemlib2/iem_prepend.c
new file mode 100644
index 0000000..44302ad
--- /dev/null
+++ b/src/iemlib2/iem_prepend.c
@@ -0,0 +1,252 @@
+/* For information on usage and redistribution, and for a DISCLAIMER OF ALL
+* WARRANTIES, see the file, "LICENSE.txt," in this distribution.
+
+iemlib2 written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */
+
+#ifdef NT
+#pragma warning( disable : 4244 )
+#pragma warning( disable : 4305 )
+#endif
+
+#include "m_pd.h"
+#include "iemlib.h"
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
+/* ----------------------- iem_prepend --------------------------- */
+/* -- concatenates message from cold (right) inlet with message -- */
+/* ------- from hot (left) inlet and outputs it; initial ------- */
+/* --- arguments (prependix) are eqal to message of cold inlet --- */
+
+struct _iem_prepend_proxy;
+
+static t_class *iem_prepend_class;
+static t_class *iem_prepend_proxy_class;
+
+typedef struct _iem_prepend
+{
+ t_object x_obj;
+ struct _iem_prepend_proxy *x_proxy_inlet;
+ int x_size;
+ int x_ac;
+ t_atom *x_at;
+ t_symbol *x_selector_sym;
+} t_iem_prepend;
+
+typedef struct _iem_prepend_proxy
+{
+ t_object p_obj;
+ t_iem_prepend *p_owner;
+} t_iem_prepend_proxy;
+
+static void iem_prepend_atcopy(t_atom *src, t_atom *dst, int n)
+{
+ while(n--)
+ *dst++ = *src++;
+}
+
+static void iem_prepend_bang(t_iem_prepend *x)
+{
+ outlet_anything(x->x_obj.ob_outlet, x->x_selector_sym, x->x_ac, x->x_at);
+}
+
+static void iem_prepend_float(t_iem_prepend *x, t_float f)
+{
+ if(x->x_selector_sym == &s_bang)
+ outlet_float(x->x_obj.ob_outlet, f);
+ else
+ {
+ SETFLOAT(x->x_at+x->x_ac, f);
+ outlet_anything(x->x_obj.ob_outlet, x->x_selector_sym, x->x_ac+1, x->x_at);
+ }
+}
+
+static void iem_prepend_symbol(t_iem_prepend *x, t_symbol *s)
+{
+ if(x->x_selector_sym == &s_bang)
+ outlet_symbol(x->x_obj.ob_outlet, s);
+ else
+ {
+ SETSYMBOL(x->x_at+x->x_ac, s);
+ outlet_anything(x->x_obj.ob_outlet, x->x_selector_sym, x->x_ac+1, x->x_at);
+ }
+}
+
+static void iem_prepend_pointer(t_iem_prepend *x, t_gpointer *gp)
+{
+ if(x->x_selector_sym == &s_bang)
+ outlet_pointer(x->x_obj.ob_outlet, gp);
+ else
+ {
+ SETPOINTER(x->x_at+x->x_ac, gp);
+ outlet_anything(x->x_obj.ob_outlet, x->x_selector_sym, x->x_ac+1, x->x_at);
+ }
+}
+
+static void iem_prepend_list(t_iem_prepend *x, t_symbol *s, int ac, t_atom *av)
+{
+ if((ac+x->x_ac+1) >= x->x_size)
+ {
+ x->x_at = (t_atom *)resizebytes(x->x_at, x->x_size*sizeof(t_atom), (ac+x->x_ac+11)*sizeof(t_atom));
+ x->x_size = ac + x->x_ac + 11;
+ }
+ if(x->x_selector_sym == &s_bang)
+ outlet_anything(x->x_obj.ob_outlet, &s_list, ac, av);
+ else
+ {
+ iem_prepend_atcopy(av, x->x_at + x->x_ac, ac);
+ outlet_anything(x->x_obj.ob_outlet, x->x_selector_sym, x->x_ac+ac, x->x_at);
+ }
+}
+
+static void iem_prepend_anything(t_iem_prepend *x, t_symbol *s, int ac, t_atom *av)
+{
+ if((ac+x->x_ac+2) >= x->x_size)
+ {
+ x->x_at = (t_atom *)resizebytes(x->x_at, x->x_size*sizeof(t_atom), (ac+x->x_ac+12)*sizeof(t_atom));
+ x->x_size = ac + x->x_ac + 12;
+ }
+ if(x->x_selector_sym == &s_bang)
+ outlet_anything(x->x_obj.ob_outlet, s, ac, av);
+ else
+ {
+ SETSYMBOL(x->x_at + x->x_ac, s);
+ iem_prepend_atcopy(av, x->x_at+x->x_ac+1, ac);
+ outlet_anything(x->x_obj.ob_outlet, x->x_selector_sym, x->x_ac+ac+1, x->x_at);
+ }
+}
+
+/* begin of proxy methods (anything inlets) */
+
+static void iem_prepend_proxy_bang(t_iem_prepend_proxy *p)
+{
+ t_iem_prepend *x = p->p_owner;
+
+ x->x_ac = 0;
+ x->x_selector_sym = &s_bang;
+}
+
+static void iem_prepend_proxy_float(t_iem_prepend_proxy *p, t_float f)
+{
+ t_iem_prepend *x = p->p_owner;
+
+ x->x_ac = 1;
+ SETFLOAT(x->x_at, f);
+ x->x_selector_sym = &s_list;
+}
+
+static void iem_prepend_proxy_symbol(t_iem_prepend_proxy *p, t_symbol *s)
+{
+ t_iem_prepend *x = p->p_owner;
+
+ x->x_ac = 1;
+ SETSYMBOL(x->x_at, s);
+ x->x_selector_sym = &s_list;
+}
+
+static void iem_prepend_proxy_pointer(t_iem_prepend_proxy *p, t_gpointer *gp)
+{
+ t_iem_prepend *x = p->p_owner;
+
+ x->x_ac = 1;
+ SETPOINTER(x->x_at, gp);
+ x->x_selector_sym = &s_list;
+}
+
+static void iem_prepend_proxy_list(t_iem_prepend_proxy *p, t_symbol *s, int ac, t_atom *av)
+{
+ t_iem_prepend *x = p->p_owner;
+
+ if((2*ac+10) > x->x_size)
+ {
+ x->x_at = (t_atom *)resizebytes(x->x_at, x->x_size*sizeof(t_atom), (2*ac+10)*sizeof(t_atom));
+ x->x_size = 2*ac+10;
+ }
+ x->x_ac = ac;
+ x->x_selector_sym = &s_list;
+ iem_prepend_atcopy(av, x->x_at, ac);
+}
+
+static void iem_prepend_proxy_anything(t_iem_prepend_proxy *p, t_symbol *s, int ac, t_atom *av)
+{
+ t_iem_prepend *x = p->p_owner;
+
+ if((2*ac+11) > x->x_size)
+ {
+ x->x_at = (t_atom *)resizebytes(x->x_at, x->x_size*sizeof(t_atom), (2*ac+11)*sizeof(t_atom));
+ x->x_size = 2*ac + 11;
+ }
+ x->x_ac = ac;
+ x->x_selector_sym = s;
+ iem_prepend_atcopy(av, x->x_at, ac);
+}
+
+/* end of proxy methods (anything inlets) */
+
+static void iem_prepend_free(t_iem_prepend *x)
+{
+ if(x->x_at)
+ freebytes(x->x_at, x->x_size * sizeof(t_atom));
+ if(x->x_proxy_inlet)
+ pd_free((t_pd *)x->x_proxy_inlet);
+}
+
+static void *iem_prepend_new(t_symbol *s, int ac, t_atom *av)
+{
+ t_iem_prepend *x = (t_iem_prepend *)pd_new(iem_prepend_class);
+ t_iem_prepend_proxy *p = (t_iem_prepend_proxy *)pd_new(iem_prepend_proxy_class);
+
+ x->x_proxy_inlet = p;
+ p->p_owner = x;
+
+ x->x_size = 30;
+ if(ac > 10)
+ x->x_size = 2*ac + 10;
+ x->x_at = (t_atom *)getbytes(x->x_size * sizeof(t_atom));
+ if(!ac)
+ {
+ x->x_ac = 0;
+ x->x_selector_sym = &s_bang;
+ }
+ else
+ {
+ if(IS_A_FLOAT(av, 0))
+ {
+ iem_prepend_proxy_list(p, &s_list, ac, av);
+ }
+ else if(IS_A_SYMBOL(av, 0))
+ {
+ iem_prepend_proxy_anything(p, atom_getsymbol(av), ac-1, av+1);
+ }
+ }
+ inlet_new((t_object *)x, (t_pd *)p, 0, 0);
+ outlet_new(&x->x_obj, &s_list);
+ return (x);
+}
+
+void iem_prepend_setup(void)
+{
+ iem_prepend_class = class_new(gensym("iem_prepend"),
+ (t_newmethod)iem_prepend_new, (t_method)iem_prepend_free,
+ sizeof(t_iem_prepend), 0, A_GIMME, 0);
+ class_addcreator((t_newmethod)iem_prepend_new, gensym("pp"), A_GIMME, 0);
+ class_addcreator((t_newmethod)iem_prepend_new, gensym("prepend"), A_GIMME, 0);
+
+ class_addbang(iem_prepend_class, (t_method)iem_prepend_bang);
+ class_addpointer(iem_prepend_class, iem_prepend_pointer);
+ class_addfloat(iem_prepend_class, (t_method)iem_prepend_float);
+ class_addsymbol(iem_prepend_class, iem_prepend_symbol);
+ class_addlist(iem_prepend_class, iem_prepend_list);
+ class_addanything(iem_prepend_class, iem_prepend_anything);
+ class_sethelpsymbol(iem_prepend_class, gensym("iemhelp/help-iem_prepend"));
+
+ iem_prepend_proxy_class = class_new(gensym("_iem_prepend_proxy"),
+ 0, 0, sizeof(t_iem_prepend_proxy), CLASS_PD | CLASS_NOINLET, 0);
+ class_addbang(iem_prepend_proxy_class, (t_method)iem_prepend_proxy_bang);
+ class_addpointer(iem_prepend_proxy_class, iem_prepend_proxy_pointer);
+ class_addfloat(iem_prepend_proxy_class, (t_method)iem_prepend_proxy_float);
+ class_addsymbol(iem_prepend_proxy_class, iem_prepend_proxy_symbol);
+ class_addlist(iem_prepend_proxy_class, iem_prepend_proxy_list);
+ class_addanything(iem_prepend_proxy_class, iem_prepend_proxy_anything);
+}
diff --git a/src/iemlib2/iem_receive.c b/src/iemlib2/iem_receive.c
new file mode 100644
index 0000000..dfe23a7
--- /dev/null
+++ b/src/iemlib2/iem_receive.c
@@ -0,0 +1,179 @@
+/* For information on usage and redistribution, and for a DISCLAIMER OF ALL
+* WARRANTIES, see the file, "LICENSE.txt," in this distribution.
+
+iemlib2 written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */
+
+#ifdef NT
+#pragma warning( disable : 4244 )
+#pragma warning( disable : 4305 )
+#endif
+
+#include "m_pd.h"
+#include "iemlib.h"
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
+/* ------------------------ iem_receive ---------------------------- */
+/* -------- like millers r, but with setable receive label --------- */
+
+struct _iem_receive_proxy;
+
+static t_class *iem_receive_class;
+static t_class *iem_receive_proxy_class;
+
+typedef struct _iem_receive
+{
+ t_object x_obj;
+ struct _iem_receive_proxy *x_proxy_receiver;
+ t_symbol *x_receive_label_sym;
+} t_iem_receive;
+
+typedef struct _iem_receive_proxy
+{
+ t_object p_obj;
+ t_iem_receive *p_owner;
+} t_iem_receive_proxy;
+
+static void iem_receive_clear(t_iem_receive *x, t_symbol *s, int ac, t_atom *av)
+{
+ t_iem_receive_proxy *p=x->x_proxy_receiver;
+
+ if(x->x_receive_label_sym)
+ pd_unbind(&p->p_obj.ob_pd, x->x_receive_label_sym);
+ x->x_receive_label_sym = 0;
+}
+
+static void iem_receive_set(t_iem_receive *x, t_symbol *s, int ac, t_atom *av)
+{
+ t_iem_receive_proxy *p=x->x_proxy_receiver;
+
+ if(ac > 0)
+ {
+ if(IS_A_SYMBOL(av,0))
+ {
+ if(x->x_receive_label_sym)
+ pd_unbind(&p->p_obj.ob_pd, x->x_receive_label_sym);
+ x->x_receive_label_sym = atom_getsymbol(av);
+ pd_bind(&p->p_obj.ob_pd, x->x_receive_label_sym);
+ }
+ else if(IS_A_FLOAT(av,0))
+ {
+ char str[32];
+
+ if(x->x_receive_label_sym)
+ pd_unbind(&p->p_obj.ob_pd, x->x_receive_label_sym);
+ sprintf(str, "%g", atom_getfloat(av));
+ x->x_receive_label_sym = gensym(str);
+ pd_bind(&p->p_obj.ob_pd, x->x_receive_label_sym);
+ }
+ }
+}
+
+/* begin of proxy methods (anything inlets) */
+
+static void iem_receive_proxy_bang(t_iem_receive_proxy *p)
+{
+ t_iem_receive *x = p->p_owner;
+
+ outlet_bang(x->x_obj.ob_outlet);
+}
+
+static void iem_receive_proxy_float(t_iem_receive_proxy *p, t_float f)
+{
+ t_iem_receive *x = p->p_owner;
+
+ outlet_float(x->x_obj.ob_outlet, f);
+}
+
+static void iem_receive_proxy_symbol(t_iem_receive_proxy *p, t_symbol *s)
+{
+ t_iem_receive *x = p->p_owner;
+
+ outlet_symbol(x->x_obj.ob_outlet, s);
+}
+
+static void iem_receive_proxy_pointer(t_iem_receive_proxy *p, t_gpointer *gp)
+{
+ t_iem_receive *x = p->p_owner;
+
+ outlet_pointer(x->x_obj.ob_outlet, gp);
+}
+
+static void iem_receive_proxy_list(t_iem_receive_proxy *p, t_symbol *s, int argc, t_atom *argv)
+{
+ t_iem_receive *x = p->p_owner;
+
+ outlet_list(x->x_obj.ob_outlet, &s_list, argc, argv);
+}
+
+static void iem_receive_proxy_anything(t_iem_receive_proxy *p, t_symbol *s, int argc, t_atom *argv)
+{
+ t_iem_receive *x = p->p_owner;
+
+ outlet_anything(x->x_obj.ob_outlet, s, argc, argv);
+}
+
+/* end of proxy methods (anything inlets) */
+
+static void iem_receive_free(t_iem_receive *x)
+{
+ t_iem_receive_proxy *p=x->x_proxy_receiver;
+
+ if(x->x_receive_label_sym)
+ pd_unbind(&p->p_obj.ob_pd, x->x_receive_label_sym);
+ if(x->x_proxy_receiver)
+ pd_free((t_pd *)x->x_proxy_receiver);
+}
+
+static void *iem_receive_new(t_symbol *s, int ac, t_atom *av)
+{
+ t_iem_receive *x = (t_iem_receive *)pd_new(iem_receive_class);
+ t_iem_receive_proxy *p = (t_iem_receive_proxy *)pd_new(iem_receive_proxy_class);
+
+ x->x_proxy_receiver = p;
+ p->p_owner = x;
+
+ if(ac > 0)
+ {
+ if(IS_A_SYMBOL(av,0))
+ {
+ x->x_receive_label_sym = atom_getsymbol(av);
+ pd_bind(&p->p_obj.ob_pd, x->x_receive_label_sym);
+ }
+ else if(IS_A_FLOAT(av,0))
+ {
+ char str[100];
+
+ sprintf(str, "%g", atom_getfloat(av));
+ x->x_receive_label_sym = gensym(str);
+ pd_bind(&p->p_obj.ob_pd, x->x_receive_label_sym);
+ }
+ else
+ x->x_receive_label_sym = 0;
+ }
+ else
+ x->x_receive_label_sym = 0;
+
+ outlet_new(&x->x_obj, &s_list);
+ return (x);
+}
+
+void iem_receive_setup(void)
+{
+ iem_receive_class = class_new(gensym("iem_receive"), (t_newmethod)iem_receive_new,
+ (t_method)iem_receive_free, sizeof(t_iem_receive), 0, A_GIMME, 0);
+ class_addcreator((t_newmethod)iem_receive_new, gensym("iem_r"), A_GIMME, 0);
+ class_addmethod(iem_receive_class, (t_method)iem_receive_clear, gensym("clear"), A_GIMME, 0);
+ class_addmethod(iem_receive_class, (t_method)iem_receive_set, gensym("set"), A_GIMME, 0);
+ class_sethelpsymbol(iem_receive_class, gensym("iemhelp/help-iem_receive"));
+
+ iem_receive_proxy_class = class_new(gensym("_iem_receive_proxy"),
+ 0, 0, sizeof(t_iem_receive_proxy), CLASS_PD | CLASS_NOINLET, 0);
+ class_addbang(iem_receive_proxy_class, iem_receive_proxy_bang);
+ class_addfloat(iem_receive_proxy_class, iem_receive_proxy_float);
+ class_addsymbol(iem_receive_proxy_class, iem_receive_proxy_symbol);
+ class_addpointer(iem_receive_proxy_class, iem_receive_proxy_pointer);
+ class_addlist(iem_receive_proxy_class, iem_receive_proxy_list);
+ class_addanything(iem_receive_proxy_class, iem_receive_proxy_anything);
+}
diff --git a/src/iemlib2/iem_send.c b/src/iemlib2/iem_send.c
new file mode 100644
index 0000000..67c508f
--- /dev/null
+++ b/src/iemlib2/iem_send.c
@@ -0,0 +1,162 @@
+/* For information on usage and redistribution, and for a DISCLAIMER OF ALL
+* WARRANTIES, see the file, "LICENSE.txt," in this distribution.
+
+iemlib2 written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */
+
+#ifdef NT
+#pragma warning( disable : 4244 )
+#pragma warning( disable : 4305 )
+#endif
+
+#include "m_pd.h"
+#include "iemlib.h"
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
+/* -------------------- iem_send ------------------------------ */
+/* ------- like millers s, but with setable send label -------- */
+
+struct _iem_send_proxy;
+
+static t_class *iem_send_class;
+static t_class *iem_send_proxy_class;
+
+typedef struct _iem_send
+{
+ t_object x_obj;
+ struct _iem_send_proxy *x_proxy_inlet;
+ t_symbol *x_send_label_sym;
+} t_iem_send;
+
+typedef struct _iem_send_proxy
+{
+ t_object p_obj;
+ t_iem_send *p_owner;
+} t_iem_send_proxy;
+
+static void iem_send_bang(t_iem_send *x)
+{
+ if(x->x_send_label_sym)
+ if(x->x_send_label_sym->s_thing)
+ pd_bang(x->x_send_label_sym->s_thing);
+}
+
+static void iem_send_float(t_iem_send *x, t_float f)
+{
+ if(x->x_send_label_sym)
+ if(x->x_send_label_sym->s_thing)
+ pd_float(x->x_send_label_sym->s_thing, f);
+}
+
+static void iem_send_symbol(t_iem_send *x, t_symbol *s)
+{
+ if(x->x_send_label_sym)
+ if(x->x_send_label_sym->s_thing)
+ pd_symbol(x->x_send_label_sym->s_thing, s);
+}
+
+static void iem_send_pointer(t_iem_send *x, t_gpointer *gp)
+{
+ if(x->x_send_label_sym)
+ if(x->x_send_label_sym->s_thing)
+ pd_pointer(x->x_send_label_sym->s_thing, gp);
+}
+
+static void iem_send_list(t_iem_send *x, t_symbol *s, int argc, t_atom *argv)
+{
+ if(x->x_send_label_sym)
+ if(x->x_send_label_sym->s_thing)
+ pd_list(x->x_send_label_sym->s_thing, s, argc, argv);
+}
+
+static void iem_send_anything(t_iem_send *x, t_symbol *s, int argc, t_atom *argv)
+{
+ if(x->x_send_label_sym)
+ if(x->x_send_label_sym->s_thing)
+ typedmess(x->x_send_label_sym->s_thing, s, argc, argv);
+}
+
+/* begin of proxy methods (anything inlets) */
+
+static void iem_send_proxy_clear(t_iem_send_proxy *p, t_symbol *s, int ac, t_atom *av)
+{
+ t_iem_send *x = p->p_owner;
+
+ x->x_send_label_sym = 0;
+}
+
+static void iem_send_proxy_set(t_iem_send_proxy *p, t_symbol *s, int ac, t_atom *av)
+{
+ t_iem_send *x = p->p_owner;
+
+ if(ac > 0)
+ {
+ if(IS_A_SYMBOL(av,0))
+ x->x_send_label_sym = atom_getsymbol(av);
+ else if(IS_A_FLOAT(av,0))
+ {
+ char str[32];
+
+ sprintf(str, "%g", atom_getfloat(av));
+ x->x_send_label_sym = gensym(str);
+ }
+ }
+}
+
+/* end of proxy methods (anything inlets) */
+
+static void iem_send_free(t_iem_send *x)
+{
+ if(x->x_proxy_inlet)
+ pd_free((t_pd *)x->x_proxy_inlet);
+}
+
+static void *iem_send_new(t_symbol *s, int ac, t_atom *av)
+{
+ t_iem_send *x = (t_iem_send *)pd_new(iem_send_class);
+ t_iem_send_proxy *p = (t_iem_send_proxy *)pd_new(iem_send_proxy_class);
+
+ x->x_proxy_inlet = p;
+ p->p_owner = x;
+
+ if(ac > 0)
+ {
+ if(IS_A_SYMBOL(av,0))
+ {
+ x->x_send_label_sym = atom_getsymbol(av);
+ }
+ else if(IS_A_FLOAT(av,0))
+ {
+ char str[32];
+
+ sprintf(str, "%g", atom_getfloat(av));
+ x->x_send_label_sym = gensym(str);
+ }
+ else
+ x->x_send_label_sym = 0;
+ }
+ else
+ x->x_send_label_sym = 0;
+ inlet_new((t_object *)x, (t_pd *)p, 0, 0);
+ return (x);
+}
+
+void iem_send_setup(void)
+{
+ iem_send_class = class_new(gensym("iem_send"), (t_newmethod)iem_send_new, (t_method)iem_send_free,
+ sizeof(t_iem_send), 0, A_GIMME, 0);
+ class_addcreator((t_newmethod)iem_send_new, gensym("iem_s"), A_GIMME, 0);
+ class_addbang(iem_send_class, iem_send_bang);
+ class_addfloat(iem_send_class, iem_send_float);
+ class_addsymbol(iem_send_class, iem_send_symbol);
+ class_addpointer(iem_send_class, iem_send_pointer);
+ class_addlist(iem_send_class, iem_send_list);
+ class_addanything(iem_send_class, iem_send_anything);
+ class_sethelpsymbol(iem_send_class, gensym("iemhelp/help-iem_send"));
+
+ iem_send_proxy_class = class_new(gensym("_iem_send_proxy"),
+ 0, 0, sizeof(t_iem_send_proxy), CLASS_PD | CLASS_NOINLET, 0);
+ class_addmethod(iem_send_proxy_class, (t_method)iem_send_proxy_clear, gensym("clear"), A_GIMME, 0);
+ class_addmethod(iem_send_proxy_class, (t_method)iem_send_proxy_set, gensym("set"), A_GIMME, 0);
+}
diff --git a/src/iemlib2/parentdollarzero.c b/src/iemlib2/parentdollarzero.c
new file mode 100644
index 0000000..947d87e
--- /dev/null
+++ b/src/iemlib2/parentdollarzero.c
@@ -0,0 +1,60 @@
+/* For information on usage and redistribution, and for a DISCLAIMER OF ALL
+* WARRANTIES, see the file, "LICENSE.txt," in this distribution.
+
+iemlib2 written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */
+
+#ifdef NT
+#pragma warning( disable : 4244 )
+#pragma warning( disable : 4305 )
+#endif
+
+#include "m_pd.h"
+#include "g_canvas.h"
+#include "iemlib.h"
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <math.h>
+
+/* -------------- parentdollarzero --------------- */
+/* -- receives the $0 value of the parent canvas --*/
+
+static t_class *parentdollarzero_class;
+
+typedef struct _parentdollarzero
+{
+ t_object x_obj;
+ t_symbol *s_parent_unique;
+ unsigned int x_is_there_a_parent;
+} t_parentdollarzero;
+
+static void parentdollarzero_bang(t_parentdollarzero *x)
+{
+ if(x->x_is_there_a_parent)
+ outlet_symbol(x->x_obj.ob_outlet, x->s_parent_unique);
+}
+
+static void *parentdollarzero_new(void)
+{
+ t_parentdollarzero *x = (t_parentdollarzero *)pd_new(parentdollarzero_class);
+ t_glist *glist = (t_glist *)canvas_getcurrent();
+ t_canvas *this_canvas = glist_getcanvas(glist);
+
+ x->x_is_there_a_parent = (unsigned int)this_canvas->gl_owner;
+
+ if(x->x_is_there_a_parent)
+ x->s_parent_unique = canvas_realizedollar((t_canvas *)this_canvas->gl_owner, gensym("$0"));
+ else
+ x->s_parent_unique = gensym("");
+ outlet_new(&x->x_obj, &s_symbol);
+ return (x);
+}
+
+void parentdollarzero_setup(void)
+{
+ parentdollarzero_class = class_new(gensym("parentdollarzero"), (t_newmethod)parentdollarzero_new,
+ 0, sizeof(t_parentdollarzero), 0, 0);
+ class_addcreator((t_newmethod)parentdollarzero_new, gensym("parent$0"), 0);
+ class_addbang(parentdollarzero_class, (t_method)parentdollarzero_bang);
+ class_sethelpsymbol(parentdollarzero_class, gensym("iemhelp/help-parentdollarzero"));
+}
diff --git a/src/iemlib2/protect_against_open.c b/src/iemlib2/protect_against_open.c
new file mode 100644
index 0000000..5203df1
--- /dev/null
+++ b/src/iemlib2/protect_against_open.c
@@ -0,0 +1,103 @@
+/* For information on usage and redistribution, and for a DISCLAIMER OF ALL
+* WARRANTIES, see the file, "LICENSE.txt," in this distribution.
+
+iemlib2 written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */
+
+#ifdef NT
+#pragma warning( disable : 4244 )
+#pragma warning( disable : 4305 )
+#endif
+
+#include "m_pd.h"
+#include "iemlib.h"
+#include "g_canvas.h"
+#include "g_all_guis.h"
+#include <string.h>
+
+#ifdef NT
+#include <io.h>
+#else
+#include <unistd.h>
+#endif
+
+/* ---------------------- protect_against_open ----------------------- */
+/* -- if you putting this object into a subpatch or an abstraction, -- */
+/* ------------ you cannot open again this subpatch ------------------ */
+
+t_widgetbehavior protect_against_open_widgetbehavior;
+static t_class *protect_against_open_class;
+
+typedef struct _protect_against_open
+{
+ t_object x_obj;
+ t_symbol *x_sym;
+ t_pd *x_owner;
+ void *x_clock;
+} t_protect_against_open;
+
+/* ------------------------ cnv widgetbehaviour----------------------------- */
+
+static void protect_against_open_tick(t_protect_against_open *x)
+{
+ t_symbol *sym = gensym("vis");
+ t_atom at[1];
+
+ SETFLOAT(at, 0.0);
+ typedmess(x->x_sym->s_thing, sym, 1, at);
+ clock_unset(x->x_clock);
+}
+
+static void protect_against_open_vis(t_gobj *z, t_glist *glist, int vis)
+{
+ t_protect_against_open *x = (t_protect_against_open *)z;
+
+ if(vis)
+ clock_delay(x->x_clock, 5);
+}
+
+static void *protect_against_open_new(t_symbol *s, int ac, t_atom *av)
+{
+ t_protect_against_open *x = (t_protect_against_open *)pd_new(protect_against_open_class);
+ t_glist *glist = (t_glist *)canvas_getcurrent();
+ t_canvas *this_canvas = glist_getcanvas(glist);
+ t_symbol *s_unique;
+ char str[100];
+
+ x->x_owner = (t_pd *)glist;
+ s_unique = canvas_realizedollar(glist_getcanvas(glist), gensym("$0"));
+ strcpy(str, s_unique->s_name);
+ strcat(str, "-quabla");
+ x->x_sym = gensym(str);
+ if(*x->x_sym->s_name)
+ pd_bind(x->x_owner, x->x_sym);
+ x->x_clock = clock_new(x, (t_method)protect_against_open_tick);
+ return(x);
+}
+
+static void protect_against_open_ff(t_protect_against_open *x)
+{
+ if(*x->x_sym->s_name)
+ pd_unbind(x->x_owner, x->x_sym);
+ clock_free(x->x_clock);
+}
+
+void protect_against_open_setup(void)
+{
+ protect_against_open_class = class_new(gensym("protect_against_open"), (t_newmethod)protect_against_open_new,
+ (t_method)protect_against_open_ff, sizeof(t_protect_against_open), 0, A_GIMME, 0);
+
+ protect_against_open_widgetbehavior.w_getrectfn = NULL;
+ protect_against_open_widgetbehavior.w_displacefn = NULL;
+ protect_against_open_widgetbehavior.w_selectfn = NULL;
+ protect_against_open_widgetbehavior.w_activatefn = NULL;
+ protect_against_open_widgetbehavior.w_deletefn = NULL;
+ protect_against_open_widgetbehavior.w_visfn = protect_against_open_vis;
+ protect_against_open_widgetbehavior.w_clickfn = NULL;
+#if defined(PD_MAJOR_VERSION) && (PD_MINOR_VERSION >= 37)
+
+#else
+ protect_against_open_widgetbehavior.w_propertiesfn = NULL;
+ protect_against_open_widgetbehavior.w_savefn = NULL;
+#endif
+ class_setwidget(protect_against_open_class, &protect_against_open_widgetbehavior);
+}
diff --git a/src/iemlib2/receive2list.c b/src/iemlib2/receive2list.c
new file mode 100644
index 0000000..9b68bc0
--- /dev/null
+++ b/src/iemlib2/receive2list.c
@@ -0,0 +1,222 @@
+/* For information on usage and redistribution, and for a DISCLAIMER OF ALL
+* WARRANTIES, see the file, "LICENSE.txt," in this distribution.
+
+iemlib2 written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */
+
+#ifdef NT
+#pragma warning( disable : 4244 )
+#pragma warning( disable : 4305 )
+#endif
+
+#include "m_pd.h"
+#include "iemlib.h"
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
+/* -------------------------- receive2list ------------------------------ */
+/* -- converts received message to a list with a prepended float index -- */
+
+struct _receive2list_proxy;
+
+static t_class *receive2list_class;
+static t_class *receive2list_proxy_class;
+
+typedef struct _receive2list
+{
+ t_object x_obj;
+ int x_max;
+ struct _receive2list_proxy **x_proxy_receiver;
+ int x_size;
+ t_atom *x_at;
+} t_receive2list;
+
+typedef struct _receive2list_proxy
+{
+ t_object p_obj;
+ t_receive2list *p_owner;
+ t_symbol *p_receive_label_sym;
+ int p_index;
+} t_receive2list_proxy;
+
+static void receive2list_atcopy(t_atom *src, t_atom *dst, int n)
+{
+ while(n--)
+ *dst++ = *src++;
+}
+
+static void receive2list_clear(t_receive2list *x, t_symbol *s, int ac, t_atom *av)
+{
+ t_receive2list_proxy *p;
+ int i, max=x->x_max;
+
+ for(i=0; i<max; i++)
+ {
+ p = x->x_proxy_receiver[i];
+ if(p->p_receive_label_sym)
+ pd_unbind(&p->p_obj.ob_pd, p->p_receive_label_sym);
+ p->p_receive_label_sym = 0;
+ }
+}
+
+static void receive2list_add(t_receive2list *x, t_symbol *s, int ac, t_atom *av)
+{
+ t_receive2list_proxy *p;
+ int i;
+
+ if((ac > 1)&&(IS_A_FLOAT(av,0)))
+ {
+ i = atom_getint(av);
+ if((i >= 0)&&(i < x->x_max))
+ {
+ p = x->x_proxy_receiver[i];
+ if(IS_A_SYMBOL(av,1))
+ {
+ if(p->p_receive_label_sym)
+ pd_unbind(&p->p_obj.ob_pd, p->p_receive_label_sym);
+ p->p_receive_label_sym = atom_getsymbol(av+1);
+ pd_bind(&p->p_obj.ob_pd, p->p_receive_label_sym);
+ }
+ else if(IS_A_FLOAT(av,1))
+ {
+ char str[32];
+
+ if(p->p_receive_label_sym)
+ pd_unbind(&p->p_obj.ob_pd, p->p_receive_label_sym);
+ sprintf(str, "%g", atom_getfloat(av+1));
+ p->p_receive_label_sym = gensym(str);
+ pd_bind(&p->p_obj.ob_pd, p->p_receive_label_sym);
+ }
+ }
+ }
+}
+
+/* begin of proxy methods (anything inlets) */
+
+static void receive2list_proxy_bang(t_receive2list_proxy *p)
+{
+ t_receive2list *x = p->p_owner;
+
+ SETFLOAT(x->x_at, p->p_index);
+ outlet_list(x->x_obj.ob_outlet, &s_list, 1, x->x_at);
+}
+
+static void receive2list_proxy_float(t_receive2list_proxy *p, t_float f)
+{
+ t_receive2list *x = p->p_owner;
+
+ SETFLOAT(x->x_at, p->p_index);
+ SETFLOAT(x->x_at+1, f);
+ outlet_list(x->x_obj.ob_outlet, &s_list, 2, x->x_at);
+}
+
+static void receive2list_proxy_symbol(t_receive2list_proxy *p, t_symbol *s)
+{
+ t_receive2list *x = p->p_owner;
+
+ SETFLOAT(x->x_at, p->p_index);
+ SETSYMBOL(x->x_at+1, s);
+ outlet_list(x->x_obj.ob_outlet, &s_list, 2, x->x_at);
+}
+
+static void receive2list_proxy_pointer(t_receive2list_proxy *p, t_gpointer *gp)
+{
+ t_receive2list *x = p->p_owner;
+
+ SETFLOAT(x->x_at, p->p_index);
+ SETPOINTER(x->x_at+1, gp);
+ outlet_list(x->x_obj.ob_outlet, &s_list, 2, x->x_at);
+}
+
+static void receive2list_proxy_list(t_receive2list_proxy *p, t_symbol *s, int argc, t_atom *argv)
+{
+ t_receive2list *x = p->p_owner;
+
+ if((argc+1) >= x->x_size)
+ {
+ x->x_at = (t_atom *)resizebytes(x->x_at, x->x_size*sizeof(t_atom), (argc+11)*sizeof(t_atom));
+ x->x_size = argc + 11;
+ }
+ SETFLOAT(x->x_at, p->p_index);
+ receive2list_atcopy(argv, x->x_at+1, argc);
+ outlet_list(x->x_obj.ob_outlet, &s_list, argc+1, x->x_at);
+}
+
+static void receive2list_proxy_anything(t_receive2list_proxy *p, t_symbol *s, int argc, t_atom *argv)
+{
+ t_receive2list *x = p->p_owner;
+
+ if((argc+2) >= x->x_size)
+ {
+ x->x_at = (t_atom *)resizebytes(x->x_at, x->x_size*sizeof(t_atom), (argc+12)*sizeof(t_atom));
+ x->x_size = argc + 12;
+ }
+ SETFLOAT(x->x_at, p->p_index);
+ SETSYMBOL(x->x_at+1, s);
+ receive2list_atcopy(argv, x->x_at+2, argc);
+ outlet_list(x->x_obj.ob_outlet, &s_list, argc+2, x->x_at);
+}
+
+/* end of proxy methods (anything inlets) */
+
+static void receive2list_free(t_receive2list *x)
+{
+ t_receive2list_proxy *p;
+ int i, max = x->x_max;
+
+ for(i=0; i<max; i++)
+ {
+ p = x->x_proxy_receiver[i];
+ if(p->p_receive_label_sym)
+ pd_unbind(&p->p_obj.ob_pd, p->p_receive_label_sym);
+ if(x->x_proxy_receiver[i])
+ pd_free((t_pd *)x->x_proxy_receiver[i]);
+ }
+ if(x->x_proxy_receiver)
+ freebytes(x->x_proxy_receiver, x->x_max * sizeof(t_receive2list_proxy *));
+ if(x->x_at)
+ freebytes(x->x_at, x->x_size * sizeof(t_atom));
+}
+
+static void *receive2list_new(t_float fmax)
+{
+ t_receive2list *x = (t_receive2list *)pd_new(receive2list_class);
+ t_receive2list_proxy *p;
+ int i, max = (int)fmax;
+
+ if(max <= 0)
+ max = 80;
+ x->x_max = max;
+ x->x_proxy_receiver = (t_receive2list_proxy **)getbytes(x->x_max * sizeof(t_receive2list_proxy *));
+ x->x_size = 12;
+ x->x_at = (t_atom *)getbytes(x->x_size * sizeof(t_atom));
+ for(i=0; i<max; i++)
+ {
+ x->x_proxy_receiver[i] = (t_receive2list_proxy *)pd_new(receive2list_proxy_class);
+ p = x->x_proxy_receiver[i];
+ p->p_owner = x;
+ p->p_receive_label_sym = 0;
+ p->p_index = i;
+ }
+ outlet_new(&x->x_obj, &s_list);
+ return (x);
+}
+
+void receive2list_setup(void)
+{
+ receive2list_class = class_new(gensym("receive2list"), (t_newmethod)receive2list_new,
+ (t_method)receive2list_free, sizeof(t_receive2list), 0, A_DEFFLOAT, 0);
+ class_addcreator((t_newmethod)receive2list_new, gensym("iem_r"), A_DEFFLOAT, 0);
+ class_addmethod(receive2list_class, (t_method)receive2list_clear, gensym("clear"), A_GIMME, 0);
+ class_addmethod(receive2list_class, (t_method)receive2list_add, gensym("add"), A_GIMME, 0);
+ class_sethelpsymbol(receive2list_class, gensym("iemhelp/help-receive2list"));
+
+ receive2list_proxy_class = class_new(gensym("_receive2list_proxy"),
+ 0, 0, sizeof(t_receive2list_proxy), CLASS_PD | CLASS_NOINLET, 0);
+ class_addbang(receive2list_proxy_class, receive2list_proxy_bang);
+ class_addfloat(receive2list_proxy_class, receive2list_proxy_float);
+ class_addsymbol(receive2list_proxy_class, receive2list_proxy_symbol);
+ class_addpointer(receive2list_proxy_class, receive2list_proxy_pointer);
+ class_addlist(receive2list_proxy_class, receive2list_proxy_list);
+ class_addanything(receive2list_proxy_class, receive2list_proxy_anything);
+}