diff options
Diffstat (limited to 'externals/detox')
-rw-r--r-- | externals/detox/detox-help.pd | 108 | ||||
-rw-r--r-- | externals/detox/detox.c | 1 | ||||
-rw-r--r-- | externals/detox/makefile | 92 |
3 files changed, 0 insertions, 201 deletions
diff --git a/externals/detox/detox-help.pd b/externals/detox/detox-help.pd deleted file mode 100644 index 247c0d28..00000000 --- a/externals/detox/detox-help.pd +++ /dev/null @@ -1,108 +0,0 @@ -#N canvas 0 22 814 758 10; -#X msg 58 114 <toxine name="fastfood">; -#X obj 274 400 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 -1; -#X msg 274 417 mode \$1; -#X msg 72 133 <class name="italian">; -#X obj 59 363 tosymbol; -#X msg 120 400 reset; -#X msg 85 152 <dish name="pizza">; -#X msg 353 314 <person died = '1954-06-07' born = "1912-06-23">Alan -Turing</person>; -#X obj 225 603 prepend set; -#X msg 225 622 anchovi -56; -#X obj 225 645 prepend set; -#X msg 225 663 name margherita; -#X text 348 414 1: all attribute:value pairs; -#X text 164 399 reset tag-tree; -#X floatatom 227 469 8 0 0 0 - - -; -#X obj 226 545 prepend set; -#X msg 226 563 toxine class dish pizza item; -#X text 406 463 0 invalid tag; -#X text 406 478 1 closed tag; -#X text 406 493 2 opening tag; -#X text 406 508 3 closing tag; -#X text 406 523 4 meta tag; -#X msg 97 171 <pizza name = "margherita">; -#X msg 110 223 <item>anchovi \$1</item>; -#X floatatom 110 208 5 0 0 0 - - -; -#X msg 115 244 </topping>; -#X msg 114 263 </pizza>; -#X msg 114 281 </dish>; -#X msg 115 299 </class>; -#X msg 115 318 </toxine>; -#X text 348 399 0: first attribute:value pair; -#X text 296 399 mode:; -#X obj 59 437 detox 1; -#X text 462 559 -1 when unmatched closing tag; -#X msg 187 318 </error>; -#X text 405 545 returns: 0 when tree is empty; -#X obj 61 598 print tag_type; -#X obj 61 616 print tag_tree; -#X obj 61 634 print tag_content; -#X obj 61 652 print attribute:value; -#X obj 352 150 openpanel; -#X obj 351 248 textfile; -#X obj 364 222 bng 15 250 50 0 empty empty empty 0 -6 0 8 -150892 -1 --1; -#X obj 352 133 bng 15 250 50 0 empty empty empty 0 -6 0 8 -166441 -1 --1; -#X msg 364 204 rewind; -#X msg 352 168 read \$1 cr; -#X text 433 199 go to start of file; -#X text 433 214 step through file; -#X obj 351 266 print input_line; -#X text 375 132 open wellformed xml-file; -#X msg 110 190 <topping name = "mozarella">; -#X text 354 298 closed tag w/ multiple attributes; -#X obj -14 13 cnv 15 780 40 empty empty detox 20 12 0 24 -237236 -66577 -0; -#X text 85 21 extract values \, contents \, attributes from xml-tag -structures; -#X text 85 35 argument (optional): mode 0/1; -#X text 666 18 jasch 05/2006; -#X text 624 34 http://www.jasch.ch; -#X obj 310 465 cnv 15 90 20 empty empty tag_type: 10 10 0 10 -233017 --66577 0; -#X obj 312 542 cnv 15 90 20 empty empty tag_tree: 10 10 0 10 -233017 --66577 0; -#X obj 312 600 cnv 15 90 20 empty empty tag_content: 10 10 0 10 -233017 --66577 0; -#X obj 311 643 cnv 15 200 18 empty empty attribute/value_pairs: 10 -10 0 10 -233017 -66577 0; -#X connect 0 0 4 0; -#X connect 1 0 2 0; -#X connect 2 0 32 0; -#X connect 3 0 4 0; -#X connect 4 0 32 0; -#X connect 5 0 32 0; -#X connect 6 0 4 0; -#X connect 7 0 4 0; -#X connect 8 0 9 0; -#X connect 10 0 11 0; -#X connect 15 0 16 0; -#X connect 22 0 4 0; -#X connect 23 0 4 0; -#X connect 24 0 23 0; -#X connect 25 0 4 0; -#X connect 26 0 4 0; -#X connect 27 0 4 0; -#X connect 28 0 4 0; -#X connect 29 0 4 0; -#X connect 32 0 10 0; -#X connect 32 0 39 0; -#X connect 32 1 8 0; -#X connect 32 1 38 0; -#X connect 32 2 15 0; -#X connect 32 2 37 0; -#X connect 32 3 14 0; -#X connect 32 3 36 0; -#X connect 34 0 4 0; -#X connect 40 0 45 0; -#X connect 41 0 4 0; -#X connect 41 0 48 0; -#X connect 42 0 41 0; -#X connect 43 0 40 0; -#X connect 44 0 41 0; -#X connect 45 0 41 0; -#X connect 50 0 4 0; diff --git a/externals/detox/detox.c b/externals/detox/detox.c deleted file mode 100644 index 448faaae..00000000 --- a/externals/detox/detox.c +++ /dev/null @@ -1 +0,0 @@ -/*__________________________________________________________________________
detox á extract value/content from tag-structured symbol
Copyright (C) 2003 jan schacher
thanks to tim place for inspiration and sample code
revised tree output 20040712
initial build 200300502
____________________________________________________________________________*/
#include "m_pd.h"
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <locale.h>
#define VERSION "1.2"
#define CLIP(x,a,b) (x)=(x)<(a)?(a):(x)>(b)?(b):(x)
typedef struct _detox
{
t_object ob;
t_atom t_tree[257], t_attrpair[2];
t_atom t_comp, t_blip;
long t_treecount;
short t_debug;
short t_mode;
void *s_outlet, *s_outlet2, *s_outlet3, *s_outlet4;
} t_detox;
t_symbol *ps_nothing;
void *detox_class;
void *detox_new(t_symbol *s, long argc, t_atom *argv);
void detox_free(t_detox *x);
void detox_reset(t_detox *x);
void detox_debug(t_detox *x, float f);
void detox_mode(t_detox *x, float f);
void detox_anything(t_detox *x, t_symbol *s, long argc, t_atom *argv);
long clip(long in, long min, long max);
void version(t_detox *x);
void detox_setup(void)
{
detox_class = class_new(gensym("detox"), (t_newmethod)detox_new,
(t_method)detox_free, sizeof(t_detox), 0, A_GIMME, 0);
class_addsymbol(detox_class, (t_method)detox_anything);
// class_addmethod(detox_class, (t_method)detox_anything, gensym("anything"), A_GIMME,0);
class_addmethod(detox_class, (t_method)detox_debug, gensym("debug"), A_FLOAT, 0);
class_addmethod(detox_class, (t_method)detox_mode, gensym("mode"), A_FLOAT, 0);
class_addmethod(detox_class, (t_method)detox_reset, gensym("reset"), 0);
class_addmethod(detox_class, (t_method)version, gensym("version"), 0);
post(". detox . jasch . "__DATE__" ");
ps_nothing = gensym("");
}
void *detox_new(t_symbol *s, long argc, t_atom *argv)
{
t_detox *x = (t_detox *)pd_new(detox_class);
x->s_outlet = outlet_new(&x->ob, NULL);
x->s_outlet2 = outlet_new(&x->ob, NULL);
x->s_outlet3 = outlet_new(&x->ob, NULL);
x->s_outlet4 = outlet_new(&x->ob, gensym("float"));
x->t_treecount = 0;
x->t_debug = 0;
if((argc >= 1)&&(argv[0].a_type == A_FLOAT)){
if(argv[0].a_w.w_float == 0){
x->t_mode = 0;
}else{
x->t_mode = 1;
}
}else{
x->t_mode = 1;
}
x->t_debug = 0;
if(x->t_debug) post("mode is %ld", x->t_mode);
return (x);
}
void detox_reset(t_detox *x)
{
short i;
x->t_treecount = 0;
for(i=0;i<256; i++) x->t_tree[i].a_w.w_symbol = ps_nothing;
}
void detox_debug(t_detox *x, float f)
{
if(f == 0.0){
x->t_debug = 0;
}else if(f != 0){
x->t_debug = 1;
}
}
void detox_mode(t_detox *x, float f)
{
if(f == 0.0){
x->t_mode = 0;
}else if(f != 0){
x->t_mode = 1;
}
}
void detox_anything(t_detox *x, t_symbol *s, long argc, t_atom *argv)
{
t_atom *outlist, *comp, *attrpair;
char local[1024], local2[1024];
char temp[1024];
char tempstring[2];
char *ptr, *ptr2, *ptr3, *ptr4, *ptr5;
long i, j, k, last, len, len2, tempcount = 0, pos = 0;
short tagtype = 0; // 0 = closed, 1 = open, 2 = closing
short outsize = 0;
long quotetype = 0;
short attrpresent = 0;
i = 0;
strcpy(tempstring, " ");
outlist = x->t_tree;
attrpair = x->t_attrpair;
x->t_attrpair[0].a_type = A_SYMBOL;
x->t_attrpair[1].a_type = A_SYMBOL;
if(s->s_name == "debug"){
x->t_debug = CLIP(argv[0].a_w.w_float, 0, 1);
return;
}
strcpy(local2, s->s_name);
last = strlen(local2); // test for tag
if(x->t_debug) post("input is %s", s->s_name);
k=0;
while(isspace(local2[k])){ // remove whitespace/tab/cr/linefeed
k++;
}
if(x->t_debug) post("k is %ld, last is %ld", k, last);
for(i=k, j=0; i<last; i++, j++){ // remove whitespace/tab/cr/linefeed
local[j] = local2[i];
}
local[j] = 0; // terminate string
if((local[0] != '<') || (local[j-1] != '>')){
tagtype = 0; // not a well formed tag
if(x->t_debug) post("tagtype 0");
goto content;
}
if((local[1] == '?') || (local[1] == '!')){
tagtype = 4; // this might be a metatag
if(x->t_debug) post("tagtype 4");
goto content;
}
ptr = strchr(local, '/'); // is it a closing tag ?
if(x->t_debug) post("ptr contains %s", s->s_name);
if(ptr == NULL){ // we have new open tag
tagtype = 2;
if(x->t_debug) post("tagtype 2");
}else if((local[1] == '/')){ // is it at beginning
tagtype = 3;
if(x->t_debug) post("tagtype 3");
}else if(local[1] != '/'){ // is it elsewhere
if(x->t_debug) post("tagtype 1");
tagtype = 1;
}
switch(tagtype){
case 1: // closed tag :: add temporarily to tree
ptr = strchr(local, '>');
ptr2 = strchr(local, ' ');
if(ptr2 != NULL) *ptr2 = 0;
if(ptr != NULL){
*ptr = 0;
}else{
return;
}
len = strlen(local);
ptr5 = (char *)memmove((local + 0),(local + 1), len-1);
local[len-1] = 0;
ptr5 = local;
x->t_blip.a_type = A_SYMBOL;
x->t_blip.a_w.w_symbol = gensym(ptr5);
tempcount = 1;
break;
case 2: // opening tag :: add to tree, increment count
ptr2 = strchr(local, ' ');
if(ptr2 != NULL){
*ptr2 = 0;
if(x->t_debug) post("inside opening tag w/ whitespace, %s", local);
}else{
local[strlen(local) - 1] = 0;
// local[strlen(ptr2) -1] = 0;
if(x->t_debug) post("inside opening tag no whitespace, %s", local);
// return;
}
len = strlen(local);
ptr5 = (char *)memmove((local + 0),(local + 1), len-1);
if(x->t_debug) post("ptr5 is %s", ptr5);
local[len-1] = 0;
ptr5 = local;
x->t_tree[x->t_treecount].a_type = A_SYMBOL;
x->t_tree[x->t_treecount].a_w.w_symbol = gensym(ptr5);
x->t_treecount++;
x->t_treecount = clip(x->t_treecount, 0, 255);
break;
case 3: // closing tag :: remove from tree, decrement count
ptr2 = strchr(local, '>');
if(ptr2 != NULL){
*ptr2 = 0;
}else{
return;
}
len = strlen(local);
ptr5 = (char *)memmove((local + 0),(local + 2), len-2);
local[len-2] = 0;
ptr5 = local;
x->t_comp.a_type = A_SYMBOL;
x->t_comp.a_w.w_symbol = gensym(ptr5);
if(x->t_comp.a_w.w_symbol->s_name == x->t_tree[x->t_treecount-1].a_w.w_symbol->s_name){
x->t_treecount -= 1;
x->t_treecount = clip(x->t_treecount, 0, 255);
}else{
outlet_float(x->s_outlet4, 3);
outlet_float(x->s_outlet3, -1);
return;
}
break;
}
content:
outlet_float(x->s_outlet4, tagtype);
if(tagtype == 0) return;
if(x->t_treecount > 0){
if(tempcount){
outsize = x->t_treecount + 1;
x->t_tree[outsize-1] = x->t_blip;
}else{
outsize = x->t_treecount;
}
outlet_list(x->s_outlet3, 0L, outsize, outlist); // ouput tree
}else if(x->t_treecount == 0){
if(tempcount){
outlet_anything(x->s_outlet3, x->t_blip.a_w.w_symbol, 0, NULL); // ouput tree
}else{
outlet_float(x->s_outlet3, 0); // ouput tree
}
}
strcpy(local, s->s_name);
ptr = strchr(local, '>'); // parse content between enclosing tags <tag>blah</tag>
if(ptr == NULL) goto onward;
*ptr = 0;
++ptr;
ptr2 = strchr(ptr, '<');
if(ptr2 == NULL) goto onward;
*ptr2 = 0;
outlet_anything(x->s_outlet2, gensym(ptr), 0, NULL);
onward:
strcpy(local, s->s_name); // get full buffer again
switch(x->t_mode){
case 0: // the old way of attribute parsing (mode 0)
if(x->t_debug) post("content: before strtok %s", local);
ptr = strtok(local,tempstring);
while (ptr != NULL){
ptr3 = strchr(ptr, '"');
if(ptr3 != NULL){
*ptr3 = 0;
++ptr3;
ptr4 = strchr(ptr3, '"');
*ptr4 = 0;
outlet_anything(x->s_outlet, gensym(ptr3), 0, NULL);
if(x->t_debug) post("content: after strtok %s", ptr);
}
ptr = strtok(NULL, tempstring);
}
break;
case 1: // the new way of attribute parsing (mode 1)
ptr = local;
if(strcspn(ptr, "=\"\'") == strlen(ptr)) break; // no attr-chars found, bail ouit
ptr = strchr(local, 32); // find first whitespace
if(ptr == NULL) break; // no whitespace found bail
attr_loop:
while((ptr[0] == ' ') && (ptr != NULL)) ptr++; // find next non-whitespace char
ptr2 = ptr;
while(!((ptr2[0] == ' ')||(ptr2[0] == '=')) && (ptr2 != NULL)) ptr2++; // find next non-white or not equal-sign
len = strlen(ptr) - strlen(ptr2);
strncpy(temp, ptr, len); // copy into temp-buffer
temp[len] = 0; // terminate temp_buffer
attrpair[0].a_type = A_SYMBOL;
attrpair[0].a_w.w_symbol = gensym(temp); // put into output symbol
ptr = ptr2;
while(!((ptr[0] == '\'') || (ptr[0] == '\"')) && (ptr != NULL)){ // move until single or double quote
ptr++;
quotetype = ptr[0];
}
ptr2 = ++ptr;
while((ptr2[0] != quotetype) && (ptr2 != NULL)) ptr2++;
len = strlen(ptr) - strlen(ptr2);
strncpy(temp, ptr, len);
temp[len] = 0;
attrpair[1].a_type = A_SYMBOL;
attrpair[1].a_w.w_symbol = gensym(temp);
outlet_anything(x->s_outlet, x->t_attrpair[0].a_w.w_symbol, 1, &x->t_attrpair[1]);
ptr = ++ptr2;
while((ptr[0] == ' ')&&(ptr != NULL)){ ptr++; } // find next non-whitespace char
if((ptr[0] == '/') || (ptr[0] == '>') || (ptr[0] == '?') || (ptr == NULL)){ // if char is "/" or ">" or "?" bail out
break;
}else{
goto attr_loop;
}
break;
}
}
void detox_free(t_detox *x)
{
// notify_free((t_object *)x);
}
long clip(long in, long min, long max)
{
return in < min? min: (in > max? max : in);
}
void version(t_detox *x)
{
post("á detox á jasch - version " VERSION" compiled "__DATE__" "__TIME__ );
}
\ No newline at end of file diff --git a/externals/detox/makefile b/externals/detox/makefile deleted file mode 100644 index d836eefd..00000000 --- a/externals/detox/makefile +++ /dev/null @@ -1,92 +0,0 @@ -NAME=detox -CSYM=detox - -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 |