Ibiltari Nora / OSC
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers OSCMatch.h Source File

OSCMatch.h

00001 /*
00002  Written by John MacCallum, The Center for New Music and Audio Technologies,
00003  University of California, Berkeley.  Copyright (c) 2009, The Regents of
00004  the University of California (Regents).
00005  Permission to use, copy, modify, distribute, and distribute modified versions
00006  of this software and its documentation without fee and without a signed
00007  licensing agreement, is hereby granted, provided that the above copyright
00008  notice, this paragraph and the following two paragraphs appear in all copies,
00009  modifications, and distributions.
00010 
00011  IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
00012  SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING
00013  OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS
00014  BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00015 
00016  REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
00017  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00018  PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED
00019  HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE
00020  MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
00021  */
00022 
00023 #ifndef __OSC_MATCH_H__
00024 #define __OSC_MATCH_H__
00025 
00026 #ifdef __cplusplus
00027 extern "C" {
00028 #endif
00029 
00030     /**
00031      * Switch this off to disable matching against a pattern with 2 stars
00032      */
00033     //#define OSC_MATCH_ENABLE_2STARS       1
00034     /**
00035      * Switch this off to disable matching against a pattern with more than 2 stars which will
00036      * be done recursively.
00037      */
00038     //#define OSC_MATCH_ENABLE_NSTARS       1
00039 
00040     /**
00041      * Return code for osc_match() that indicates that the entire address was successfully matched
00042      */
00043 #define OSC_MATCH_ADDRESS_COMPLETE  1
00044 
00045     /**
00046      * Return code for osc_match() that indicates that the entire pattern was successfully matched
00047      */
00048 #define OSC_MATCH_PATTERN_COMPLETE  2
00049     /*
00050      typedef struct _osc_callback {
00051      const char* address;           // Address
00052      struct _osc_callback *child;       // RAM
00053      struct _osc_callback *sibling;     // RAM
00054      struct _osc_callback *parent;      // RAM
00055      int callback;              // ROM
00056      } osc_callback;
00057      */
00058 
00059     /**
00060      * Match a pattern against an address.  In the case of a partial match, pattern_offset
00061      * and address_offset will contain the number of bytes into their respective strings
00062      * where the match failed.
00063      *
00064      * @param pattern The pattern to match
00065      * @param address The address to match
00066      * @param pattern_offset The number of bytes into the pattern that were matched successfully
00067      * @param address_offset The number of bytes into the address that were matched successfully
00068      * @return 0 if the match failed altogether, or an or'd combination of OSC_MATCH_ADDRESS_COMPLETE and
00069      * OSC_MATCH_PATTERN_COMPLETE.
00070      */
00071     int osc_match(const char *pattern, const char *address, int *pattern_offset, int *address_offset);
00072 
00073 #ifdef __cplusplus
00074 }
00075 #endif
00076 
00077 #endif // __OSC_MATCH_H__
00078