OSC-string-help.h

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 #ifndef OSC_STRING_HELP_H
00030 #define OSC_STRING_HELP_H
00031 
00032 #ifdef __cplusplus
00033 extern "C" {
00034 #endif
00035 
00036 /* OSC-string-help.h
00037    Procedures that could be useful to programmers writing OSC methods that
00038    take string arguments.
00039 
00040    by Matt Wright, 3/19/98
00041 */
00042 
00043 typedef int Boolean;
00044 #ifndef TRUE
00045 #define TRUE 1
00046 #endif
00047 #ifndef FALSE
00048 #define FALSE 0
00049 #endif
00050 
00051 /* Use this to deal with OSC null-padded 4 byte-aligned strings
00052 
00053    The argument is a block of data beginning with a string.  The string
00054    has (presumably) been padded with extra null characters so that the
00055    overall length is a multiple of 4 bytes.  Return a pointer to the next
00056    byte after the null byte(s).  The boundary argument points to the
00057    character after the last valid character in the buffer---if the string
00058    hasn't ended by there, something's wrong.
00059 
00060    If the data looks wrong, return 0, and set *errorMsg */
00061 
00062 char *OSCDataAfterAlignedString(const char *string, const char *boundary, char **errorMsg);
00063 
00064 /* Given a normal C-style string with a single padding byte, return the
00065    length of the string including the necessary 1-4 padding bytes.
00066    (Basically strlen()+1 rounded up to the next multiple of 4.) */
00067 int OSCPaddedStrlen(const char *s);
00068 
00069 /* Copy a given C-style string into the given destination, including the
00070    requisite padding byte(s).  Unlike strcpy(), this returns a pointer to
00071    the next character after the copied string's null bytes, like
00072    what OSCDataAfterAlignedString() returns. */
00073 char *OSCPaddedStrcpy(char *target, const char *source);
00074 
00075 
00076 /* Given an args pointer that should be nothing but a list of strings, fill
00077    result[] with pointers to the beginnings of each string, and set
00078    *numStrings to be the number of strings found.  maxStrings gives the size
00079    of the result array.  Return FALSE if any strings are malformatted or if
00080    there are more than maxStrings many strings. */
00081 
00082 Boolean OSCParseStringList(const char *result[], int *numStrings, int maxStrings,
00083                            const char *args, int numBytes);
00084 
00085 #ifdef __cplusplus
00086 }
00087 #endif
00088 
00089 #endif

Generated on Thu Mar 2 23:51:35 2006 for libOSC++ by  doxygen 1.4.6