Revision: 9849 http://pure-data.svn.sourceforge.net/pure-data/?rev=9849&view=rev Author: eighthave Date: 2008-05-18 11:02:14 -0700 (Sun, 18 May 2008)
Log Message: ----------- ported to Windows/MinGW
Modified Paths: -------------- branches/pd-extended/v0-40/externals/hcs/setenv.c branches/pd-extended/v0-40/externals/hcs/unsetenv.c
Modified: branches/pd-extended/v0-40/externals/hcs/setenv.c =================================================================== --- branches/pd-extended/v0-40/externals/hcs/setenv.c 2008-05-18 17:31:21 UTC (rev 9848) +++ branches/pd-extended/v0-40/externals/hcs/setenv.c 2008-05-18 18:02:14 UTC (rev 9849) @@ -72,9 +72,13 @@ static void setenv_symbol(t_setenv* x, t_symbol *s) { DEBUG(post("setenv_output");); +#ifdef _WIN32 + SetEnvironmentVariable(x->x_variable_name->s_name, s->s_name); +#else if(x->x_overwrite == 0) post("[setenv]: not in overwrite mode."); - setenv(x->x_variable_name->s_name, s->s_name, x->x_overwrite); // 1 means overwrite + setenv(x->x_variable_name->s_name, s->s_name, x->x_overwrite); +#endif setenv_output(x); }
Modified: branches/pd-extended/v0-40/externals/hcs/unsetenv.c =================================================================== --- branches/pd-extended/v0-40/externals/hcs/unsetenv.c 2008-05-18 17:31:21 UTC (rev 9848) +++ branches/pd-extended/v0-40/externals/hcs/unsetenv.c 2008-05-18 18:02:14 UTC (rev 9849) @@ -42,9 +42,9 @@ static t_class *unsetenv_class;
typedef struct _unsetenv { - t_object x_obj; + t_object x_obj; t_symbol* x_variable_name; - t_outlet* x_data_outlet; + t_outlet* x_data_outlet; } t_unsetenv;
/*------------------------------------------------------------------------------ @@ -53,46 +53,56 @@
static void unsetenv_bang(t_unsetenv* x) { - DEBUG(post("unsetenv_bang");); + DEBUG(post("unsetenv_bang"););
+#ifdef _WIN32 if(x->x_variable_name != &s_) + { + char buf[MAXPDSTRING]; + strncpy(buf, x->x_variable_name->s_name, MAXPDSTRING - 1); + strcat(buf, "="); + putenv(buf); + } +#else + if(x->x_variable_name != &s_) unsetenv(x->x_variable_name->s_name); +#endif }
static void unsetenv_symbol(t_unsetenv* x, t_symbol *s) { - DEBUG(post("unsetenv_bang");); + DEBUG(post("unsetenv_bang");); x->x_variable_name = s; }
static void *unsetenv_new(t_symbol* s) { - DEBUG(post("unsetenv_new");); - t_unsetenv *x = (t_unsetenv *)pd_new(unsetenv_class); + DEBUG(post("unsetenv_new");); + t_unsetenv *x = (t_unsetenv *)pd_new(unsetenv_class);
symbolinlet_new(&x->x_obj, &x->x_variable_name);
x->x_variable_name = s;
- return (x); + return (x); }
void unsetenv_setup(void) { - DEBUG(post("unsetenv_setup");); - unsetenv_class = class_new(gensym("unsetenv"), + DEBUG(post("unsetenv_setup");); + unsetenv_class = class_new(gensym("unsetenv"), (t_newmethod)unsetenv_new, 0, sizeof(t_unsetenv), 0, A_DEFSYMBOL, 0); - /* add inlet datatype methods */ - class_addbang(unsetenv_class, (t_method)unsetenv_bang); - class_addsymbol(unsetenv_class, (t_method)unsetenv_symbol); + /* add inlet datatype methods */ + class_addbang(unsetenv_class, (t_method)unsetenv_bang); + class_addsymbol(unsetenv_class, (t_method)unsetenv_symbol); }
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.