aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrank Barknecht <fbar@users.sourceforge.net>2005-06-28 18:37:59 +0000
committerFrank Barknecht <fbar@users.sourceforge.net>2005-06-28 18:37:59 +0000
commita340c7d62240db6628c0f7a13e04ae6ff52bda0d (patch)
treef53fe8df5bc2634f4d916804ab5ace5ca7d9b87f
parent5f3005ce3dc129afcc5a5feb9876366ad4313b65 (diff)
Added back a test against "/*" which will strip off the first element in a
OSC-message. svn path=/trunk/externals/OSCx/; revision=3265
-rw-r--r--src/OSCroute.c19
1 files 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);