Revision: 9848 http://pure-data.svn.sourceforge.net/pure-data/?rev=9848&view=rev Author: eighthave Date: 2008-05-18 10:31:21 -0700 (Sun, 18 May 2008)
Log Message: ----------- cleaned up code and added anything method to [setenv] to allow for easy setting of values
Modified Paths: -------------- branches/pd-extended/v0-40/externals/hcs/setenv-help.pd branches/pd-extended/v0-40/externals/hcs/setenv.c branches/pd-extended/v0-40/externals/hcs/unsetenv-help.pd branches/pd-extended/v0-40/externals/hcs/unsetenv.c
Modified: branches/pd-extended/v0-40/externals/hcs/setenv-help.pd =================================================================== --- branches/pd-extended/v0-40/externals/hcs/setenv-help.pd 2008-05-18 17:10:01 UTC (rev 9847) +++ branches/pd-extended/v0-40/externals/hcs/setenv-help.pd 2008-05-18 17:31:21 UTC (rev 9848) @@ -16,6 +16,9 @@ #X msg 66 308 symbol /Users/hans; #X text 33 10 by default , it will not overwrite existing values; #X msg 72 89 symbol /blah; +#X obj 247 358 setenv SHELL 1; +#X symbolatom 248 401 0 0 0 0 - - -; +#X msg 246 300 this is a test; #X connect 0 0 2 0; #X connect 1 0 0 0; #X connect 3 0 5 0; @@ -27,3 +30,5 @@ #X connect 12 0 11 0; #X connect 13 0 11 0; #X connect 15 0 5 0; +#X connect 16 0 17 0; +#X connect 18 0 16 0;
Modified: branches/pd-extended/v0-40/externals/hcs/setenv.c =================================================================== --- branches/pd-extended/v0-40/externals/hcs/setenv.c 2008-05-18 17:10:01 UTC (rev 9847) +++ branches/pd-extended/v0-40/externals/hcs/setenv.c 2008-05-18 17:31:21 UTC (rev 9848) @@ -33,13 +33,9 @@ #include <stdlib.h> #endif
-static char *version = "$Revision: 1.3 $"; +#define DEBUG(x) +//#define DEBUG(x) x
-t_int setenv_instance_count; - -//#define DEBUG(x) -#define DEBUG(x) x - /*------------------------------------------------------------------------------ * CLASS DEF */ @@ -73,19 +69,31 @@ }
- static void setenv_symbol(t_setenv* x, t_symbol *s) { DEBUG(post("setenv_output");); if(x->x_overwrite == 0) - error("[setenv]: not in overwrite mode, ignoring value."); + post("[setenv]: not in overwrite mode."); setenv(x->x_variable_name->s_name, s->s_name, x->x_overwrite); // 1 means overwrite setenv_output(x); }
static void setenv_anything(t_setenv* x, t_symbol* s, int argc, t_atom* argv) { - + t_binbuf *argument_binbuf = binbuf_new(); + char *argument_buffer; + int buffer_length; + if(s != &s_list) + { + t_atom selector; + SETSYMBOL(&selector, s); + binbuf_add(argument_binbuf, 1, &selector); + } + binbuf_add(argument_binbuf, argc, argv); + binbuf_gettext(argument_binbuf, &argument_buffer, &buffer_length); + binbuf_free(argument_binbuf); + argument_buffer[buffer_length] = 0; + setenv_symbol(x, gensym(argument_buffer)); }
Modified: branches/pd-extended/v0-40/externals/hcs/unsetenv-help.pd =================================================================== --- branches/pd-extended/v0-40/externals/hcs/unsetenv-help.pd 2008-05-18 17:10:01 UTC (rev 9847) +++ branches/pd-extended/v0-40/externals/hcs/unsetenv-help.pd 2008-05-18 17:31:21 UTC (rev 9848) @@ -1,15 +1,18 @@ -#N canvas 199 179 551 341 10; -#X obj 196 145 setenv; -#X msg 196 47 bang; -#X symbolatom 195 192 0 0 0 0 - - -; +#N canvas 315 28 551 341 10; +#X obj 261 152 setenv; +#X msg 261 54 bang; +#X symbolatom 260 199 0 0 0 0 - - -; #X msg 59 51 bang; -#X msg 229 113 symbol SHELL; -#X msg 316 113 symbol PATH; -#X msg 396 113 symbol HOME; +#X msg 294 120 symbol SHELL; +#X msg 381 120 symbol PATH; +#X msg 461 120 symbol HOME; #X obj 59 134 unsetenv HOME; +#X msg 134 107 symbol SHELL; +#X text 107 51 bang unsets; #X connect 0 0 2 0; #X connect 1 0 0 0; #X connect 3 0 7 0; #X connect 4 0 0 1; #X connect 5 0 0 1; #X connect 6 0 0 1; +#X connect 8 0 7 1;
Modified: branches/pd-extended/v0-40/externals/hcs/unsetenv.c =================================================================== --- branches/pd-extended/v0-40/externals/hcs/unsetenv.c 2008-05-18 17:10:01 UTC (rev 9847) +++ branches/pd-extended/v0-40/externals/hcs/unsetenv.c 2008-05-18 17:31:21 UTC (rev 9848) @@ -67,12 +67,7 @@ x->x_variable_name = s; }
-static void unsetenv_anything(t_unsetenv* x, t_symbol* s, int argc, t_atom* argv) -{ - -}
- static void *unsetenv_new(t_symbol* s) { DEBUG(post("unsetenv_new");); @@ -99,6 +94,5 @@ /* add inlet datatype methods */ class_addbang(unsetenv_class, (t_method)unsetenv_bang); class_addsymbol(unsetenv_class, (t_method)unsetenv_symbol); - class_addanything(unsetenv_class, (t_method)unsetenv_anything); }
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.