aboutsummaryrefslogtreecommitdiff
path: root/openpatch.c
diff options
context:
space:
mode:
authordieter kovacic <d13@users.sourceforge.net>2002-07-09 12:41:56 +0000
committerdieter kovacic <d13@users.sourceforge.net>2002-07-09 12:41:56 +0000
commit7312e58d17e331d71d4f47e21bf15499609bace8 (patch)
tree23e7fba2466041f82bc29ce4adf5e7ac35d2d508 /openpatch.c
This commit was generated by cvs2svn to compensate for changes in r33,svn2git-root
which included commits to RCS files with non-trunk default branches. svn path=/trunk/externals/ext13/; revision=34
Diffstat (limited to 'openpatch.c')
-rw-r--r--openpatch.c68
1 files changed, 68 insertions, 0 deletions
diff --git a/openpatch.c b/openpatch.c
new file mode 100644
index 0000000..a9a6ddb
--- /dev/null
+++ b/openpatch.c
@@ -0,0 +1,68 @@
+#include "ext13.h"
+#include "m_pd.h"
+#include <sys/stat.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+
+#ifdef NT
+#pragma warning( disable : 4244 )
+#pragma warning( disable : 4305 )
+#endif
+
+/* -------------------------- openpatch ------------------------------ */
+static t_class *openpatch_class;
+
+typedef struct _openpatch
+{
+ t_object x_obj;
+ t_symbol *x_s;
+ t_symbol *x_path;
+} t_openpatch;
+
+
+static void *openpatch_new(t_symbol *s)
+{
+ t_openpatch *x = (t_openpatch *)pd_new(openpatch_class);
+ x->x_s = s;
+ x->x_path=gensym("./");
+ symbolinlet_new(&x->x_obj, &x->x_path);
+ return (x);
+}
+
+
+
+static void openpatch_symbol(t_openpatch *x, t_symbol *s)
+{
+ char *lastslash;
+ char path[MAXPDSTRING], filename[MAXPDSTRING];
+ x->x_s = s;
+ lastslash=strrchr (s->s_name,'/');
+ if (lastslash){
+ strncpy (path,s->s_name,lastslash-s->s_name+1);
+ path[lastslash-s->s_name]=0;
+ strcpy (filename,lastslash+1);
+ filename[lastslash-s->s_name+1]=0;
+ }
+ else {
+ strcpy (filename,s->s_name);
+ sprintf (path,x->x_path->s_name);
+ }
+ post ("path:%s , name:%s",path,filename);
+ glob_evalfile(0,gensym(filename),gensym(path));
+}
+
+
+static void openpatch_bang(t_openpatch *x)
+{
+ if (x->x_s){openpatch_symbol (x,x->x_s);}
+}
+
+void openpatch_setup(void)
+{
+ openpatch_class = class_new(gensym("openpatch"), (t_newmethod)openpatch_new, 0,
+ sizeof(t_openpatch), 0, A_DEFFLOAT, 0);
+ class_addcreator((t_newmethod)openpatch_new, gensym("opa"), A_DEFFLOAT, 0);
+ class_addbang(openpatch_class, openpatch_bang);
+ class_addsymbol(openpatch_class, openpatch_symbol);
+}