From a340c7d62240db6628c0f7a13e04ae6ff52bda0d Mon Sep 17 00:00:00 2001 From: Frank Barknecht Date: Tue, 28 Jun 2005 18:37:59 +0000 Subject: Added back a test against "/*" which will strip off the first element in a OSC-message. svn path=/trunk/externals/OSCx/; revision=3265 --- src/OSCroute.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/OSCroute.c b/src/OSCroute.c index c0a31a0..895a492 100644 --- a/src/OSCroute.c +++ b/src/OSCroute.c @@ -30,6 +30,7 @@ The OSC webpage is http://cnmat.cnmat.berkeley.edu/OpenSoundControl To-do: Match a pattern against a pattern? + [Done: Only Slash-Star is allowed, see MyPatternMatch.] Declare outlet types / distinguish leaf nodes from other children More sophisticated (2-pass?) allmessages scheme set message? @@ -70,6 +71,20 @@ The OSC webpage is http://cnmat.cnmat.berkeley.edu/OpenSoundControl Version 1.05: Allows "list" messages as well as "message" messages. */ +static Boolean MyPatternMatch (const char *pattern, const char *test) +{ + // This allows the special case of "OSCroute /* " to be an outlet that + // matches anything; i.e., it always outputs the input with the first level + // of the address stripped off. + + if (test[0] == '*' && test[1] == '\0') { + return 1; + } else { + return PatternMatch(pattern, test); + } +} + + static t_class *OSCroute_class; typedef struct _OSCroute @@ -310,7 +325,7 @@ void OSCroute_doanything(t_OSCroute *x, t_symbol *s, int argc, t_atom *argv) { #endif for (i = 0; i < x->x_num; ++i) { - if (PatternMatch(pattern+1, x->x_prefixes[i]+1)) { + if (MyPatternMatch(pattern+1, x->x_prefixes[i]+1)) { ++matchedAnything; // I hate stupid Max lists with a special first element @@ -351,7 +366,7 @@ void OSCroute_doanything(t_OSCroute *x, t_symbol *s, int argc, t_atom *argv) { StrCopyUntilSlash(patternBegin, pattern+1); for (i = 0; i < x->x_num; ++i) { - if (PatternMatch(patternBegin, x->x_prefixes[i]+1)) { + if (MyPatternMatch(patternBegin, x->x_prefixes[i]+1)) { ++matchedAnything; if (restOfPattern == 0) { restOfPattern = gensym(nextSlash); -- cgit v1.2.1