Real Time Open Sound Control librtosc
 All Classes Namespaces Files Functions Variables Typedefs Macros Pages
rtosc.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012 Mark McCurry
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice (including the next
12  * paragraph) shall be included in all copies or substantial portions of the
13  * Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19  * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  * DEALINGS IN THE SOFTWARE.
23  *
24  * @file rtosc.h
25  */
26 #ifndef RTOSC_H
27 #define RTOSC_H
28 #include <stdarg.h>
29 #include <stdint.h>
30 #include <stddef.h>
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
37 typedef struct {
38  int32_t len; //< length of blob's data section in bytes
39  uint8_t *data;//< pointer to blob's data section
40 } rtosc_blob_t;
41 
43 typedef union {
44  int32_t i; //< i,c,r types
45  char T; //< I,T,F,N types
46  float f; //< f type
47  double d; //< d type
48  int64_t h; //< h type
49  uint64_t t; //< t type
50  uint8_t m[4];//< m type
51  const char *s; //< s,S types
52  rtosc_blob_t b; //< b type
53 } rtosc_arg_t;
54 
80 size_t rtosc_message(char *buffer,
81  size_t len,
82  const char *address,
83  const char *arguments,
84  ...);
85 
89 size_t rtosc_vmessage(char *buffer,
90  size_t len,
91  const char *address,
92  const char *arguments,
93  va_list va);
94 
98 size_t rtosc_amessage(char *buffer,
99  size_t len,
100  const char *address,
101  const char *arguments,
102  const rtosc_arg_t *args);
103 
117 unsigned rtosc_narguments(const char *msg);
118 
131 char rtosc_type(const char *msg, unsigned i);
132 
148 rtosc_arg_t rtosc_argument(const char *msg, unsigned i);
149 
160 size_t rtosc_message_length(const char *msg, size_t len);
161 
163 typedef struct {
164  char *data;
165  size_t len;
166 } ring_t;
167 
179 size_t rtosc_message_ring_length(ring_t *ring);
180 
193 const char *rtosc_argument_string(const char *msg);
194 
212 size_t rtosc_bundle(char *buffer, size_t len, uint64_t tt, int elms, ...);
213 
221 size_t rtosc_bundle_elements(const char *msg, size_t len);
222 
230 const char *rtosc_bundle_fetch(const char *msg, unsigned i);
231 
238 int rtosc_bundle_p(const char *msg);
239 
244 uint64_t rtosc_bundle_timetag(const char *msg);
245 
246 #ifdef __cplusplus
247 };
248 #endif
249 #endif