OSCMatch.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. Written by John MacCallum, The Center for New Music and Audio Technologies,
  3. University of California, Berkeley. Copyright (c) 2009, The Regents of
  4. the University of California (Regents).
  5. Permission to use, copy, modify, distribute, and distribute modified versions
  6. of this software and its documentation without fee and without a signed
  7. licensing agreement, is hereby granted, provided that the above copyright
  8. notice, this paragraph and the following two paragraphs appear in all copies,
  9. modifications, and distributions.
  10. IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
  11. SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING
  12. OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS
  13. BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  14. REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  15. THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  16. PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED
  17. HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE
  18. MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  19. */
  20. #ifndef __OSC_MATCH_H__
  21. #define __OSC_MATCH_H__
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. /**
  26. * Switch this off to disable matching against a pattern with 2 stars
  27. */
  28. //#define OSC_MATCH_ENABLE_2STARS 1
  29. /**
  30. * Switch this off to disable matching against a pattern with more than 2 stars which will
  31. * be done recursively.
  32. */
  33. //#define OSC_MATCH_ENABLE_NSTARS 1
  34. /**
  35. * Return code for osc_match() that indicates that the entire address was successfully matched
  36. */
  37. #define OSC_MATCH_ADDRESS_COMPLETE 1
  38. /**
  39. * Return code for osc_match() that indicates that the entire pattern was successfully matched
  40. */
  41. #define OSC_MATCH_PATTERN_COMPLETE 2
  42. /*
  43. typedef struct _osc_callback {
  44. const char* address; // Address
  45. struct _osc_callback *child; // RAM
  46. struct _osc_callback *sibling; // RAM
  47. struct _osc_callback *parent; // RAM
  48. int callback; // ROM
  49. } osc_callback;
  50. */
  51. /**
  52. * Match a pattern against an address. In the case of a partial match, pattern_offset
  53. * and address_offset will contain the number of bytes into their respective strings
  54. * where the match failed.
  55. *
  56. * @param pattern The pattern to match
  57. * @param address The address to match
  58. * @param pattern_offset The number of bytes into the pattern that were matched successfully
  59. * @param address_offset The number of bytes into the address that were matched successfully
  60. * @return 0 if the match failed altogether, or an or'd combination of OSC_MATCH_ADDRESS_COMPLETE and
  61. * OSC_MATCH_PATTERN_COMPLETE.
  62. */
  63. int osc_match(const char *pattern, const char *address, int *pattern_offset, int *address_offset);
  64. #ifdef __cplusplus
  65. }
  66. #endif
  67. #endif // __OSC_MATCH_H__