From da941320c90e2cf7256645de5a03337471c22586 Mon Sep 17 00:00:00 2001 From: musil Date: Thu, 11 Dec 2008 19:56:33 +0000 Subject: some OSC converting stuff: symbol to list of ASCII and list of ASCII to symbol svn path=/trunk/externals/iemlib/; revision=10449 --- iemlib2/src/iem_alisttosym.c | 66 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 iemlib2/src/iem_alisttosym.c (limited to 'iemlib2/src/iem_alisttosym.c') diff --git a/iemlib2/src/iem_alisttosym.c b/iemlib2/src/iem_alisttosym.c new file mode 100644 index 0000000..c9a4484 --- /dev/null +++ b/iemlib2/src/iem_alisttosym.c @@ -0,0 +1,66 @@ +/* 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 - 2008 */ + + +#include "m_pd.h" +#include "iemlib.h" + + +/* ------------------------ iem_alisttosym ---------------------------- */ +/* ---------- converts a ASCII list of floats to a symbol ------------- */ + +static t_class *iem_alisttosym_class; + +typedef struct _iem_alisttosym +{ + t_object x_obj; + char x_string[MAXPDSTRING]; +} t_iem_alisttosym; + +static void iem_alisttosym_list(t_iem_alisttosym *x, t_symbol *s, int ac, t_atom *av) +{ + t_int i=0, j=0, k=0; + unsigned char uc=0; + + if(ac > 0) + { + for(i=0, j=0; i= 0) && (k <= 255)) + { + uc = (unsigned char)k; + x->x_string[j++] = (char)uc; + } + } + if(j >= (MAXPDSTRING - 2)) + break; + } + } + x->x_string[j] = 0; + outlet_symbol(x->x_obj.ob_outlet, gensym(x->x_string)); +} + +static void iem_alisttosym_free(t_iem_alisttosym *x) +{ +} + +static void *iem_alisttosym_new(void) +{ + t_iem_alisttosym *x = (t_iem_alisttosym *)pd_new(iem_alisttosym_class); + + x->x_string[0] = 0; + outlet_new(&x->x_obj, &s_symbol); + return (x); +} + +void iem_alisttosym_setup(void) +{ + iem_alisttosym_class = class_new(gensym("iem_alisttosym"), (t_newmethod)iem_alisttosym_new, + 0, sizeof(t_iem_alisttosym), 0, 0); + class_addlist(iem_alisttosym_class, iem_alisttosym_list); +} -- cgit v1.2.1