00001 /* 00002 Copyright © 1998. The Regents of the University of California (Regents). 00003 All Rights Reserved. 00004 00005 Written by Matt Wright, The Center for New Music and Audio Technologies, 00006 University of California, Berkeley. 00007 00008 Permission to use, copy, modify, distribute, and distribute modified versions 00009 of this software and its documentation without fee and without a signed 00010 licensing agreement, is hereby granted, provided that the above copyright 00011 notice, this paragraph and the following two paragraphs appear in all copies, 00012 modifications, and distributions. 00013 00014 IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, 00015 SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING 00016 OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS 00017 BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00018 00019 REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 00020 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00021 PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED 00022 HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE 00023 MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 00024 00025 The OpenSound Control WWW page is 00026 http://www.cnmat.berkeley.edu/OpenSoundControl 00027 */ 00028 00029 00030 /* OSC-string-help.h 00031 Procedures that could be useful to programmers writing OSC methods that 00032 take string arguments. 00033 00034 by Matt Wright, 3/19/98 00035 */ 00036 00037 /* Use this to deal with OSC null-padded 4 byte-aligned strings 00038 00039 The argument is a block of data beginning with a string. The string 00040 has (presumably) been padded with extra null characters so that the 00041 overall length is a multiple of 4 bytes. Return a pointer to the next 00042 byte after the null byte(s). The boundary argument points to the 00043 character after the last valid character in the buffer---if the string 00044 hasn't ended by there, something's wrong. 00045 00046 If the data looks wrong, return 0, and set *errorMsg */ 00047 00048 char *OSCDataAfterAlignedString(const char *string, const char *boundary, char **errorMsg); 00049 00050 00051 /* Given a normal C-style string with a single padding byte, return the 00052 length of the string including the necessary 1-4 padding bytes. 00053 (Basically strlen()+1 rounded up to the next multiple of 4.) */ 00054 int OSCPaddedStrlen(const char *s); 00055 00056 /* Copy a given C-style string into the given destination, including the 00057 requisite padding byte(s). Unlike strcpy(), this returns a pointer to 00058 the next character after the copied string's null bytes, like 00059 what OSCDataAfterAlignedString() returns. */ 00060 char *OSCPaddedStrcpy(char *target, const char *source); 00061 00062 00063 /* Given an args pointer that should be nothing but a list of strings, fill 00064 result[] with pointers to the beginnings of each string, and set 00065 *numStrings to be the number of strings found. maxStrings gives the size 00066 of the result array. Return FALSE if any strings are malformatted or if 00067 there are more than maxStrings many strings. */ 00068 00069 Boolean OSCParseStringList(const char *result[], int *numStrings, int maxStrings, 00070 const char *args, int numBytes);
1.5.8