From 992bd94dddb021b297fcf28cb5248cc94f48aaf3 Mon Sep 17 00:00:00 2001 From: jdl Date: Tue, 2 Jul 2002 20:32:59 +0000 Subject: This commit was generated by cvs2svn to compensate for changes in r24, which included commits to RCS files with non-trunk default branches. svn path=/trunk/externals/cxc/; revision=25 --- hex2dec.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 hex2dec.c (limited to 'hex2dec.c') diff --git a/hex2dec.c b/hex2dec.c new file mode 100644 index 0000000..1176838 --- /dev/null +++ b/hex2dec.c @@ -0,0 +1,47 @@ +#include "m_pd.h" +#include + +#include +#include + +/* ----------------------- hex2dec --------------------- */ + +static t_class *hex2dec_class; + +typedef struct _hex2dec +{ + t_object x_obj; + t_symbol *x_format; +} t_hex2dec; + +static void *hex2dec_new(t_symbol *s) +{ + t_hex2dec *x = (t_hex2dec *)pd_new(hex2dec_class); + if (!s->s_name) s = gensym("file.%d"); + outlet_new(&x->x_obj, &s_symbol); + x->x_format = s; + return (x); +} + +static void hex2dec_float(t_hex2dec *x, t_floatarg f) +{ + char buf[MAXPDSTRING]; + sprintf(buf, x->x_format->s_name, (int)f); + outlet_symbol(x->x_obj.ob_outlet, gensym(buf)); +} + +static void hex2dec_symbol(t_hex2dec *x, t_symbol *s) +{ + char buf[MAXPDSTRING]; + sprintf(buf, x->x_format->s_name, s->s_name); + outlet_symbol(x->x_obj.ob_outlet, gensym(buf)); +} + +static void hex2dec_setup(void) +{ + hex2dec_class = class_new(gensym("hex2dec"), + (t_newmethod)hex2dec_new, 0, + sizeof(t_hex2dec), 0, A_DEFSYM, 0); + class_addfloat(hex2dec_class, hex2dec_float); + class_addsymbol(hex2dec_class, hex2dec_symbol); +} -- cgit v1.2.1