aboutsummaryrefslogtreecommitdiff
path: root/strtok
diff options
context:
space:
mode:
Diffstat (limited to 'strtok')
-rw-r--r--strtok/makefile92
-rw-r--r--strtok/strtok-help.pd16
-rw-r--r--strtok/strtok.c1
3 files changed, 109 insertions, 0 deletions
diff --git a/strtok/makefile b/strtok/makefile
new file mode 100644
index 0000000..6086bc8
--- /dev/null
+++ b/strtok/makefile
@@ -0,0 +1,92 @@
+NAME=strtok
+CSYM=strtok
+
+current: pd_darwin
+
+# ----------------------- NT -----------------------
+
+pd_nt: $(NAME).dll
+
+.SUFFIXES: .dll
+
+PDNTCFLAGS = /W3 /WX /DNT /DPD /nologo
+VC="C:\Program Files\Microsoft Visual Studio\Vc98"
+
+PDNTINCLUDE = /I. /I..\..\src /I$(VC)\include
+
+PDNTLDIR = $(VC)\lib
+PDNTLIB = $(PDNTLDIR)\libc.lib \
+ $(PDNTLDIR)\oldnames.lib \
+ $(PDNTLDIR)\kernel32.lib \
+ ..\..\bin\pd.lib
+
+.c.dll:
+ cl $(PDNTCFLAGS) $(PDNTINCLUDE) /c $*.c
+ link /dll /export:$(CSYM)_setup $*.obj $(PDNTLIB)
+
+# ----------------------- IRIX 5.x -----------------------
+
+pd_irix5: $(NAME).pd_irix5
+
+.SUFFIXES: .pd_irix5
+
+SGICFLAGS5 = -o32 -DPD -DUNIX -DIRIX -O2
+
+SGIINCLUDE = -I../../src
+
+.c.pd_irix5:
+ $(CC) $(SGICFLAGS5) $(SGIINCLUDE) -o $*.o -c $*.c
+ ld -elf -shared -rdata_shared -o $*.pd_irix5 $*.o
+ rm $*.o
+
+# ----------------------- IRIX 6.x -----------------------
+
+pd_irix6: $(NAME).pd_irix6
+
+.SUFFIXES: .pd_irix6
+
+SGICFLAGS6 = -n32 -DPD -DUNIX -DIRIX -DN32 -woff 1080,1064,1185 \
+ -OPT:roundoff=3 -OPT:IEEE_arithmetic=3 -OPT:cray_ivdep=true \
+ -Ofast=ip32
+
+.c.pd_irix6:
+ $(CC) $(SGICFLAGS6) $(SGIINCLUDE) -o $*.o -c $*.c
+ ld -n32 -IPA -shared -rdata_shared -o $*.pd_irix6 $*.o
+ rm $*.o
+
+# ----------------------- LINUX i386 -----------------------
+
+pd_linux: $(NAME).pd_linux
+
+.SUFFIXES: .pd_linux
+
+LINUXCFLAGS = -DPD -O2 -funroll-loops -fomit-frame-pointer -fPIC \
+ -Wall -W -Wshadow -Wstrict-prototypes \
+ -Wno-unused -Wno-parentheses -Wno-switch $(CFLAGS)
+
+LINUXINCLUDE = -I../../src
+
+.c.pd_linux:
+ $(CC) $(LINUXCFLAGS) $(LINUXINCLUDE) -o $*.o -c $*.c
+ ld -export_dynamic -shared -o $*.pd_linux $*.o -lc -lm
+ strip --strip-unneeded $*.pd_linux
+ rm -f $*.o
+
+# ----------------------- Mac OSX -----------------------
+
+pd_darwin: $(NAME).pd_darwin
+
+.SUFFIXES: .pd_darwin
+
+DARWINCFLAGS = -DPD -O2 -Wall -W -Wshadow -Wstrict-prototypes \
+ -Wno-unused -Wno-parentheses -Wno-switch
+
+.c.pd_darwin:
+ $(CC) $(DARWINCFLAGS) $(LINUXINCLUDE) -o $*.o -c $*.c
+ $(CC) -bundle -undefined suppress -flat_namespace -o $*.pd_darwin $*.o
+ rm -f $*.o
+
+# ----------------------------------------------------------
+
+clean:
+ rm -f *.o *.pd_* so_locations
diff --git a/strtok/strtok-help.pd b/strtok/strtok-help.pd
new file mode 100644
index 0000000..067fce8
--- /dev/null
+++ b/strtok/strtok-help.pd
@@ -0,0 +1,16 @@
+#N canvas 0 22 458 308 10;
+#X msg 118 40 alpha/beta/gamma/delta;
+#X obj 106 86 tosymbol;
+#X obj 106 156 print;
+#X msg 236 94 set /;
+#X msg 106 21 alpha_beta_gamma_delta;
+#X msg 194 94 set _;
+#X msg 130 59 alpha:beta:gamma:delta;
+#X obj 105 117 strtok /;
+#X connect 0 0 1 0;
+#X connect 1 0 7 0;
+#X connect 3 0 7 0;
+#X connect 4 0 1 0;
+#X connect 5 0 7 0;
+#X connect 6 0 1 0;
+#X connect 7 0 2 0;
diff --git a/strtok/strtok.c b/strtok/strtok.c
new file mode 100644
index 0000000..bdc7223
--- /dev/null
+++ b/strtok/strtok.c
@@ -0,0 +1 @@
+/*__________________________________________________________________________ strtok á strtok c-string function wrapper Copyright (C) 2003 jan schacher This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA initial build 20030507 ____________________________________________________________________________*/ #include "m_pd.h" #include <strings.h> typedef struct strtok { t_object ob; void *s_outlet; char s_tempstring[4096]; } t_strtok; void *strtok_class; void *strtok_new(t_symbol *s, long argc, t_atom *argv); void strtok_free(t_strtok *x); //void strtok_assist(t_strtok *x, void *b, long msg, long arg, char *dst); void strtok_anything(t_strtok *x, t_symbol *s, long argc, t_atom *argv); void strtok_set(t_strtok *x, t_symbol *s, long argc, t_atom *argv); void strtok_setup(void) { strtok_class = class_new(gensym("strtok"), (t_newmethod)strtok_new, (t_method)strtok_free, sizeof(t_strtok), 0, A_GIMME, 0); class_addsymbol(strtok_class, (t_method)strtok_anything); class_addmethod(strtok_class, (t_method)strtok_set, gensym("set"), A_GIMME, 0); post(". strtok . jasch . "__DATE__" ",0); } void *strtok_new(t_symbol *s, long argc, t_atom *argv) { t_strtok *x; x = (t_strtok *)pd_new(strtok_class); x->s_outlet = outlet_new(&x->ob, gensym("list")); if((argc >= 1)&&(argv[0].a_type == A_SYMBOL)){ strcpy(x->s_tempstring, argv[0].a_w.w_symbol->s_name); // post("argument is %s", argv[0].a_w.w_symbol->s_name); }else{ strcpy(x->s_tempstring, "/"); // post("defualt-argument is %s", x->s_tempstring); } return (x); } void strtok_anything(t_strtok *x, t_symbol *s, long argc, t_atom *argv) { char *ptr; char local[4096]; long status = 0; short i, j; t_atom result[256]; t_atom head; i = 0; strcpy(local, s->s_name); ptr = strtok(local,x->s_tempstring); while (ptr != NULL){ result[i].a_type = A_SYMBOL; result[i].a_w.w_symbol = gensym(ptr); ptr = strtok (NULL, x->s_tempstring); i++; } j = i; head.a_w.w_symbol = result[0].a_w.w_symbol; for(j=0;j<i;j++) result[j] = result[j+1]; outlet_anything(x->s_outlet,head.a_w.w_symbol,i-1,result); return; } void strtok_set(t_strtok *x, t_symbol *s, long argc, t_atom *argv) { switch (argv[0].a_type) { case A_FLOAT: error("wrong argument type for set");break; // case A_LONG:error("wrong argument type for set"); break; case A_SYMBOL: strcpy(x->s_tempstring, argv[0].a_w.w_symbol->s_name); break; } } void strtok_free(t_strtok *x) { // notify_free((t_object *)x); } \ No newline at end of file