-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathosc_bundle_s.h
151 lines (129 loc) · 6.26 KB
/
osc_bundle_s.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/*
Written by John MacCallum, The Center for New Music and Audio Technologies,
University of California, Berkeley. Copyright (c) 2009-ll, The Regents of
the University of California (Regents).
Permission to use, copy, modify, distribute, and distribute modified versions
of this software and its documentation without fee and without a signed
licensing agreement, is hereby granted, provided that the above copyright
notice, this paragraph and the following two paragraphs appear in all copies,
modifications, and distributions.
IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING
OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS
BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED
HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE
MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*/
/** \file osc_bundle_s.h
\author John MacCallum
\brief Utilities for manipulating serialized OSC bundles
*/
#ifndef __OSC_BUNDLE_S_H__
#define __OSC_BUNDLE_S_H__
#ifdef __cplusplus
extern "C" {
#endif
typedef struct _osc_bundle_s t_osc_bundle_s, t_osc_bndl_s;
#ifdef SWIG
#define OSC_DEPRECATED(decl, msg) decl;
#else
#define OSC_DEPRECATED(decl, msg) decl __attribute__((deprecated(msg)));
#endif
#include <stdint.h>
#include "osc_message_s.h"
#include "osc_bundle_u.h"
#include "osc_error.h"
#include "osc_array.h"
#include "osc_timetag.h"
#ifdef __WIN32
#include <malloc.h> // for alloca in the macro below
#endif
#ifdef LINUX_VERSION
#include <alloca.h>
#endif
typedef t_osc_array t_osc_bundle_array_s, t_osc_bndl_ar_s;
#define osc_bundle_s_wrap_naked_message(len, ptr){\
if(ptr && len >= 8){\
if(strncmp("#bundle\0", (char *)(ptr), 8)){ \
char *oldptr = (char *)ptr;\
long oldlen = len;\
len += 4 + OSC_HEADER_SIZE;\
ptr = (long)alloca(len);\
char alloc = 0;\
osc_bundle_s_wrapMessage(oldlen, oldptr, &len, (char **)(&ptr), &alloc);\
}\
}\
}
t_osc_bndl_s *osc_bundle_s_alloc(long len, char *ptr);
t_osc_bndl_s *osc_bundle_s_allocEmptyBundle(void);
t_osc_err osc_bundle_s_deepCopy(t_osc_bndl_s **dest, t_osc_bndl_s *src);
size_t osc_bundle_s_getStructSize(void);
void osc_bundle_s_free(t_osc_bndl_s *bndl);
void osc_bundle_s_deepFree(t_osc_bndl_s *bndl);
char *osc_bundle_s_getPtr(t_osc_bndl_s *bndl);
long osc_bundle_s_getLen(t_osc_bndl_s *bndl);
void osc_bundle_s_setLen(t_osc_bndl_s *bndl, long len);
void osc_bundle_s_setPtr(t_osc_bndl_s *bndl, char *ptr);
t_osc_err osc_bundle_s_getMsgCount(int len, char *buf, int *count);
t_osc_msg_s *osc_bundle_s_getFirstMsg(t_osc_bndl_s *bndl);
t_osc_err osc_bundle_s_getMessagesWithCallback(int len, char *buf, void (*f)(t_osc_msg_s*, void *), void *context);
t_osc_err osc_bundle_s_addressIsBound(long len, char *buf, char *address, int fullmatch, int *res);
t_osc_err osc_bundle_s_addressExists(long len, char *buf, char *address, int fullmatch, int *res);
t_osc_msg_ar_s *osc_bundle_s_lookupAddress(long len, char *buf, const char *address, int fullmatch);
t_osc_msg_ar_s *osc_bundle_s_lookupAddress_b(t_osc_bndl_s *bndl, const char *address, int fullmatch);
char *osc_bundle_s_getFirstFullMatch(long len, char *ptr, char *address);
char *osc_bundle_s_getFirstEqualAddr(long len, char *ptr, char *address);
t_osc_err osc_bundle_s_wrapMessage(long len, char *msg, long *bndllen, char **bndl, char *alloc);
t_osc_err osc_bundle_s_removeMessage(char *pattern, long *len, char *ptr, int fullmatch);
t_osc_err osc_bundle_s_replaceMessage(long *buflen,
long *bufpos,
char **bndl,
t_osc_msg_s *oldmsg,
t_osc_msg_s *newmsg);
t_osc_err osc_bundle_s_appendMessage(long *len, char **bndl, t_osc_msg_s *msg);
t_osc_err osc_bundle_s_appendMessage_b(t_osc_bndl_s **bndl, t_osc_msg_s *msg);
t_osc_err osc_bundle_s_setBundleID(char *buf);
t_osc_err osc_bundle_s_setBundleID_b(t_osc_bndl_s *bndl);
int osc_bundle_s_strcmpID(char *buf);
t_osc_timetag osc_bundle_s_getTimetag(long len, char *buf);
void osc_bundle_s_setTimetag(long len, char *buf, t_osc_timetag t);
t_osc_err osc_bundle_s_flatten(t_osc_bndl_s **dest,
t_osc_bndl_s *src,
int maxlevel,
char *sep,
int remove_enclosing_address_if_empty);
t_osc_err osc_bundle_s_explode(t_osc_bndl_s **dest, t_osc_bndl_s *src, int maxlevel, char *sep);
t_osc_bndl_u *osc_bundle_s_deserialize(long len, char *ptr);
long osc_bundle_s_getFormattedSize(long len, char *bndl);
char *osc_bundle_s_format(long len, char *bndl);
char *osc_bundle_s_pformat(t_osc_bundle_s *bndl);
long osc_bundle_s_nformat(char *buf, long n, long bndllen, char *bndl, int nindent);
long osc_bundle_s_nformatNestedBndl(char *buf, long n, long bndllen, char *bndl, int nindent);
t_osc_bndl_s *osc_bundle_s_union(t_osc_bndl_s *lhs, t_osc_bndl_s *rhs);
t_osc_err osc_bundle_s_intersection(long len1, char *bndl1, long len2, char *bndl2, long *len_out, char **bndl_out);
t_osc_err osc_bundle_s_difference(long len1, char *bndl1, long len2, char *bndl2, long *len_out, char **bndl_out);
// returns len which is len1 + len2 - OSC_HEADER_SIZE
int osc_bundle_s_concat(long len1, char *bndl1, long len2, char *bndl2, char *bndl);
t_osc_array *osc_bundle_array_s_alloc(long len);
t_osc_bundle_array_s *osc_bundle_array_s_alloc(long len);
void osc_bundle_array_s_free(t_osc_bundle_array_s *ar);
void osc_bundle_array_s_clear(t_osc_bundle_array_s *ar);
t_osc_bndl_s *osc_bundle_array_s_get(t_osc_bundle_array_s *ar, long idx);
long osc_bundle_array_s_getLen(t_osc_bundle_array_s *ar);
t_osc_bundle_array_s *osc_bundle_array_s_copy(t_osc_bundle_array_s *ar);
t_osc_err osc_bundle_array_s_resize(t_osc_bundle_array_s *ar, long newlen);
/*
#define osc_bundle_array_s_free(ar) osc_array_free((ar))
#define osc_bundle_array_s_clear(ar) osc_array_clear((ar))
#define osc_bundle_array_s_get(ar, idx) osc_array_get((ar), (idx))
#define osc_bundle_array_s_getLen(ar) osc_array_getLen((ar))
#define osc_bundle_array_s_copy(ar) osc_array_copy((ar))
#define osc_bundle_array_s_resize(ar, newlen) osc_array_resize((ar), (newlen))
*/
#ifdef __cplusplus
}
#endif
#endif // __OSC_BUNDLE_S_H__