cosc 0.1.0
OSC library for C99 or C++11.
Loading...
Searching...
No Matches
cosc.h
Go to the documentation of this file.
1
63#ifndef COSC_H
64#define COSC_H
65
69
73
77
82
83#ifndef COSC_API
84#ifdef COSC_BUILD_SHARED
85#ifdef _MSC_VER
86#define COSC_API __declspec(dllexport)
87#else
88#define COSC_API
89#endif
90#else /* COSC_BUILD_SHARED */
91#if defined(__clang__) || defined(__GNUC__)
92#define COSC_API __attribute__ ((visibility ("hidden")))
93#else
94#define COSC_API
95#endif
96#endif /* COSC_BUILD_SHARED */
97#endif /* COSC_API */
98
105
112
119
126
133
140
141#ifndef COSC_NOSTDINT
142
143#ifdef __cplusplus
144#include <cstdint>
145#else
146#include <stdint.h>
147#endif
148
149#ifndef COSC_TYPE_INT32
150#define COSC_TYPE_INT32 int32_t
151#endif
152#ifndef COSC_TYPE_UINT32
153#define COSC_TYPE_UINT32 uint32_t
154#endif
155
156#ifndef COSC_NOINT64
157#ifndef COSC_TYPE_INT64
158#define COSC_TYPE_INT64 int64_t
159#endif
160#else
161#define COSC_TYPE_INT64 struct cosc_64bits
162#endif
163
164#ifndef COSC_NOINT64
165#ifndef COSC_TYPE_UINT64
166#define COSC_TYPE_UINT64 uint64_t
167#endif
168#else
169#define COSC_TYPE_UINT64 struct cosc_64bits
170#endif
171
172#else /* COSC_NOSTDINT */
173
174#ifndef COSC_TYPE_INT32
175#define COSC_TYPE_INT32 int
176#endif
177#ifndef COSC_TYPE_UINT32
178#define COSC_TYPE_UINT32 unsigned int
179#endif
180
181#ifndef COSC_NOINT64
182#ifndef COSC_TYPE_INT64
183#define COSC_TYPE_INT64 long long
184#endif
185#else
186#define COSC_TYPE_INT64 struct cosc_64bits
187#endif
188
189#ifndef COSC_NOINT64
190#ifndef COSC_TYPE_UINT64
191#define COSC_TYPE_UINT64 unsigned long long
192#endif
193#else
194#define COSC_TYPE_UINT64 struct cosc_64bits
195#endif
196
197#endif /* COSC_NOSTDINT */
198
199#ifndef COSC_NOFLOAT32
200#ifndef COSC_TYPE_FLOAT32
201#define COSC_TYPE_FLOAT32 float
202#endif
203#else
204#define COSC_TYPE_FLOAT32 COSC_TYPE_UINT32
205#endif
206
207#ifndef COSC_NOFLOAT64
208#ifndef COSC_TYPE_FLOAT64
209#define COSC_TYPE_FLOAT64 double
210#endif
211#else
212#define COSC_TYPE_FLOAT64 struct cosc_64bits
213#endif
214
218#define COSC_INT32MAX 2147483647
219
223#define COSC_INT32MIN ((-2147483647)-1)
224
228#define COSC_UINT32MAX 4294967295
229
233#define COSC_INT64MAX 9223372036854775807LL
234
238#define COSC_INT64MIN ((-9223372036854775807LL)-1)
239
243#define COSC_UINT64MAX 18446744073709551615ULL
244
249
254
261#define COSC_64BITS_INIT(hi_, lo_) {{(hi_), (lo_)}}
262
269#define COSC_64BITS_SET(bits_, hi_, lo_) do { COSC_64BITS_HI(bits_) = (hi_); COSC_64BITS_LO(bits_) = (lo_); } while (0)
270
275#define COSC_64BITS_HI(bits_) ((bits_)->w[0])
276
281#define COSC_64BITS_LO(bits_) ((bits_)->w[1])
282
288
294
295#ifndef COSC_NOINT64
296#define COSC_INT64_INIT_ZERO 0
297#define COSC_INT64_SET_ZERO(ptr) (*(ptr) = 0)
298#else
299#define COSC_INT64_INIT_ZERO COSC_64BITS_INIT(0, 0)
300#define COSC_INT64_SET_ZERO(ptr) COSC_64BITS_SET(ptr, 0, 0)
301#endif
302
308
314
315#ifndef COSC_NOFLOAT64
316#define COSC_FLOAT64_INIT_ZERO 0
317#define COSC_FLOAT64_SET_ZERO(ptr) (*(ptr) = 0)
318#else
319#define COSC_FLOAT64_INIT_ZERO COSC_64BITS_INIT(0, 0)
320#define COSC_FLOAT64_SET_ZERO(ptr) COSC_64BITS_SET(ptr, 0, 0)
321#endif
322
327{
328
334
335};
336
341
346
351
356
360#define COSC_SIZE_MAX 2147483644
361
368#define COSC_PADMUST(sz) (4 - ((cosc_uint32)(sz) & 3))
369
375#define COSC_PAD(sz) (COSC_PADMUST(sz) & 3)
376
380#define COSC_LEVEL_TYPE_BUNDLE 'B'
381
385#define COSC_LEVEL_TYPE_MESSAGE 'M'
386
390#define COSC_LEVEL_TYPE_BLOB 'b'
391
396#define COSC_SERIAL_PSIZE 1
397
401#define COSC_EOVERRUN -2
402
406#define COSC_ESIZEMAX -3
407
411#define COSC_ETYPE -4
412
416#define COSC_EPSIZE -5
417
421#define COSC_EINVAL -6
422
426#define COSC_ELEVELMAX -7
427
431#define COSC_ELEVELTYPE -8
432
436#define COSC_EPSIZEFLAG -9
437
441#define COSC_EMSGTYPE -10
442
447{
448
453
458
462 struct
463 {
464
470 const char *s;
471
477
478 } s;
479
483 struct
484 {
485
490 const void *b;
491
496
497 } b;
498
503
508
513
518
523
528 unsigned char m[4];
529
530};
531
536{
537
541 const char *address;
542
548
552 const char *typetag;
553
559
563 union
564 {
565
569 const union cosc_value *write;
570
575
577
582
583};
584
590#define COSC_SERIAL_ISWRITER(serial_) ((serial_)->wbuffer != 0)
591
597#define COSC_SERIAL_ISREADER(serial_) ((serial_)->rbuffer != 0)
598
648
653{
654
658 unsigned char *wbuffer;
659
663 const unsigned char *rbuffer;
664
669
674
679
684
689
694
695};
696
697#ifdef __cplusplus
698extern "C" {
699#endif
700
706
712
718
724
730
736
742
748
754
760
768
775 cosc_int32 c
776);
777
791 const char *address,
792 cosc_int32 address_n,
793 cosc_int32 *invalid
794);
795
802 cosc_int32 c
803);
804
822 const char *typetag,
823 cosc_int32 typetag_n,
824 cosc_int32 *invalid
825);
826
847 char *s,
848 cosc_int32 s_n,
849 const char *typetag,
850 cosc_int32 typetag_n,
851 cosc_int32 *array_members
852);
853
854#ifndef COSC_NOPATTERN
855
864 cosc_int32 c
865);
866
887 const char *s,
888 cosc_int32 s_n,
889 cosc_int32 *invalid
890);
891
922 const char *s,
923 cosc_int32 s_n,
924 const char *pattern,
925 cosc_int32 pattern_n
926);
927
943 const void *buffer,
945 const char *apattern,
946 cosc_int32 apattern_n,
947 const char *tpattern,
948 cosc_int32 tpattern_n,
949 cosc_int32 prefix
950);
951
952#endif /* !COSC_NOPATTERN */
953
954#ifndef COSC_NOTIMETAG
955
966 cosc_uint64 timetag,
967 cosc_uint32 *nanos
968);
969
977 cosc_uint32 seconds,
978 cosc_uint32 nanos
979);
980
981#endif /* !COSC_NOTIMETAG */
982
983#ifndef COSC_NOFLTCONV
984
995 cosc_float64 value
996);
997
1008 cosc_float32 value
1009);
1010
1011#endif /* !COSC_NOFLTCONV */
1012
1028 void *buffer,
1030 cosc_uint32 value
1031);
1032
1047 const void *buffer,
1049 cosc_uint32 *value
1050);
1051
1067 void *buffer,
1069 cosc_int32 value
1070);
1071
1086 const void *buffer,
1088 cosc_int32 *value
1089);
1090
1106 void *buffer,
1108 cosc_float32 value
1109);
1110
1125 const void *buffer,
1127 cosc_float32 *value
1128);
1129
1145 void *buffer,
1147 cosc_uint64 value
1148);
1149
1164 const void *buffer,
1166 cosc_uint64 *value
1167);
1168
1184 void *buffer,
1186 cosc_int64 value
1187);
1188
1203 const void *buffer,
1205 cosc_int64 *value
1206);
1207
1223 void *buffer,
1225 cosc_float64 value
1226);
1227
1242 const void *buffer,
1244 cosc_float64 *value
1245);
1246
1267 void *buffer,
1269 const char *value,
1270 cosc_int32 value_n,
1271 cosc_int32 *length
1272);
1273
1291 const void *buffer,
1293 char *value,
1294 cosc_int32 value_n,
1295 cosc_int32 *length
1296);
1297
1315 void *buffer,
1317 const void *value,
1318 cosc_int32 value_n
1319);
1320
1343 const void *buffer,
1345 void *value,
1346 cosc_int32 value_n,
1347 const void **data,
1348 cosc_int32 *data_size
1349);
1350
1366 void *buffer,
1368 cosc_int32 value
1369);
1370
1385 const void *buffer,
1387 cosc_int32 *value
1388);
1389
1406 void *buffer,
1408 const unsigned char value[4]
1409);
1410
1426 const void *buffer,
1428 unsigned char value[4]
1429);
1430
1453 void *buffer,
1455 cosc_uint64 timetag,
1456 cosc_int32 psize
1457);
1458
1480 const void *buffer,
1482 cosc_uint64 *timetag,
1483 cosc_int32 *psize
1484);
1485
1512 void *buffer,
1514 const char *address,
1515 cosc_int32 address_n,
1516 const char *typetag,
1517 cosc_int32 typetag_n,
1518 cosc_int32 psize
1519);
1520
1550 const void *buffer,
1552 const char **address,
1553 cosc_int32 *address_n,
1554 const char **typetag,
1555 cosc_int32 *typetag_n,
1556 cosc_int32 *psize
1557);
1558
1575 void *buffer,
1577 char type,
1578 const union cosc_value *value
1579);
1580
1596 const void *buffer,
1598 char type,
1599 union cosc_value *value
1600);
1601
1624 void *buffer,
1626 const char *types,
1627 cosc_int32 types_n,
1628 const union cosc_value *values,
1629 cosc_int32 values_n,
1630 cosc_int32 *value_count
1631);
1632
1658 const void *buffer,
1660 const char *types,
1661 cosc_int32 types_n,
1662 union cosc_value *values,
1663 cosc_int32 values_n,
1664 cosc_int32 *value_count,
1665 cosc_int32 exit_early
1666);
1667
1692 void *buffer,
1694 const struct cosc_message *message,
1695 cosc_int32 psize,
1696 cosc_int32 *value_count
1697);
1698
1727 const void *buffer,
1729 struct cosc_message *message,
1730 cosc_int32 *psize,
1731 cosc_int32 *value_count,
1732 cosc_int32 exit_early
1733);
1734
1735#if !defined(COSC_NOSTDLIB) && !defined(COSC_NODUMP)
1736
1750 char *s,
1751 cosc_int32 n,
1752 char type,
1753 const union cosc_value *value
1754);
1755
1768 char *s,
1769 cosc_int32 n,
1770 const struct cosc_message *message
1771);
1772
1773#endif /* !COSC_NOSTDLIB && !COSC_NODUMP */
1774
1775#if !defined(COSC_NOWRITER) || !defined(COSC_NOREADER)
1776
1785 const struct cosc_serial *serial
1786);
1787
1796 const struct cosc_serial *serial
1797);
1798
1809 const struct cosc_serial *serial
1810);
1811
1817 struct cosc_serial *serial
1818);
1819
1820#endif /* !COSC_NOWRITER && !COSC_NOREADER */
1821
1822#ifndef COSC_NOWRITER
1823
1839 struct cosc_serial *serial,
1840 void *buffer,
1841 cosc_int32 buffer_size,
1842 struct cosc_level *levels,
1843 cosc_int32 level_max,
1844 cosc_uint32 flags
1845);
1846
1864 struct cosc_serial *serial,
1865 cosc_uint64 timetag
1866);
1867
1882 struct cosc_serial *serial
1883);
1884
1905 struct cosc_serial *serial,
1906 const char *address,
1907 cosc_int32 address_n,
1908 const char *typetag,
1909 cosc_int32 typetag_n
1910);
1911
1926 struct cosc_serial *serial
1927);
1928
1947 struct cosc_serial *serial
1948);
1949
1968 struct cosc_serial *serial
1969);
1970
1989 struct cosc_serial *serial,
1990 cosc_uint32 value
1991);
1992
2011 struct cosc_serial *serial,
2012 cosc_int32 value
2013);
2014
2033 struct cosc_serial *serial,
2034 cosc_float32 value
2035);
2036
2055 struct cosc_serial *serial,
2056 cosc_uint64 value
2057);
2058
2077 struct cosc_serial *serial,
2078 cosc_int64 value
2079);
2080
2099 struct cosc_serial *serial,
2100 cosc_float64 value
2101);
2102
2125 struct cosc_serial *serial,
2126 const char *value,
2127 cosc_int32 value_n,
2128 cosc_int32 *length
2129);
2130
2152 struct cosc_serial *serial,
2153 const void *value,
2154 cosc_int32 value_n
2155);
2156
2175 struct cosc_serial *serial,
2176 cosc_int32 value
2177);
2178
2198 struct cosc_serial *serial,
2199 const unsigned char value[4]
2200);
2201
2223 struct cosc_serial *serial,
2225 const union cosc_value *value
2226);
2227
2249 struct cosc_serial *serial,
2250 const struct cosc_message *message,
2251 cosc_int32 *value_count
2252);
2253
2271 struct cosc_serial *serial,
2272 const void *value,
2273 cosc_int32 value_n
2274);
2275
2294 struct cosc_serial *serial
2295);
2296
2316 struct cosc_serial *serial
2317);
2318
2319#endif /* !COSC_NOWRITER */
2320
2321#ifndef COSC_NOREADER
2322
2338 struct cosc_serial *serial,
2339 const void *buffer,
2340 cosc_int32 buffer_size,
2341 struct cosc_level *levels,
2342 cosc_int32 level_max,
2343 cosc_uint32 flags
2344);
2345
2367 struct cosc_serial *serial,
2368 cosc_uint64 *timetag,
2369 cosc_int32 *psize
2370);
2371
2391 struct cosc_serial *serial,
2392 cosc_uint64 *timetag
2393);
2394
2409 struct cosc_serial *serial
2410);
2411
2438 struct cosc_serial *serial,
2439 const char **address,
2440 cosc_int32 *address_n,
2441 const char **typetag,
2442 cosc_int32 *typetag_n
2443);
2444
2462 struct cosc_serial *serial,
2463 cosc_int32 exit_early
2464);
2465
2486 struct cosc_serial *serial,
2487 cosc_int32 *value_size
2488);
2489
2508 struct cosc_serial *serial
2509);
2510
2530 struct cosc_serial *serial,
2531 cosc_uint32 *value
2532);
2533
2553 struct cosc_serial *serial,
2554 cosc_int32 *value
2555);
2556
2576 struct cosc_serial *serial,
2577 cosc_float32 *value
2578);
2579
2599 struct cosc_serial *serial,
2600 cosc_uint64 *value
2601);
2602
2622 struct cosc_serial *serial,
2623 cosc_int64 *value
2624);
2625
2645 struct cosc_serial *serial,
2646 cosc_float64 *value
2647);
2648
2671 struct cosc_serial *serial,
2672 char *value,
2673 cosc_int32 value_n,
2674 cosc_int32 *length
2675);
2676
2704 struct cosc_serial *serial,
2705 void *value,
2706 cosc_int32 value_n,
2707 const void **data,
2708 cosc_int32 *data_size
2709);
2710
2730 struct cosc_serial *serial,
2731 cosc_int32 *value
2732);
2733
2754 struct cosc_serial *serial,
2755 unsigned char value[4]
2756);
2757
2780 struct cosc_serial *serial,
2782 union cosc_value *value
2783);
2784
2808 struct cosc_serial *serial,
2809 struct cosc_message *message,
2810 cosc_int32 *value_count,
2811 cosc_int32 exit_early
2812);
2813
2832 struct cosc_serial *serial,
2833 void *value,
2834 cosc_int32 value_n
2835);
2836
2855 struct cosc_serial *serial
2856);
2857
2874 struct cosc_serial *serial
2875);
2876
2877#endif /* !COSC_NOREADER */
2878
2879#ifdef __cplusplus
2880}
2881#endif
2882
2883#endif
COSC_API cosc_int32 cosc_reader_bytes(struct cosc_serial *serial, void *value, cosc_int32 value_n)
Read bytes to a started blob level.
Definition cosc.c:3277
COSC_TYPE_INT32 cosc_int32
Signed 32-bit integer.
Definition cosc.h:253
COSC_API cosc_int32 cosc_write_blob(void *buffer, cosc_int32 size, const void *value, cosc_int32 value_n)
Write a blob.
Definition cosc.c:1386
COSC_API cosc_int32 cosc_write_message(void *buffer, cosc_int32 size, const struct cosc_message *message, cosc_int32 psize, cosc_int32 *value_count)
Write an OSC message.
Definition cosc.c:1923
COSC_API cosc_int32 cosc_writer_float64(struct cosc_serial *serial, cosc_float64 value)
Write a 64-bit float.
Definition cosc.c:2629
COSC_API cosc_int32 cosc_reader_end_bundle(struct cosc_serial *serial)
End a bundle level.
Definition cosc.c:2907
COSC_API cosc_int32 cosc_reader_message(struct cosc_serial *serial, struct cosc_message *message, cosc_int32 *value_count, cosc_int32 exit_early)
Read an OSC message.
Definition cosc.c:3237
COSC_API cosc_int32 cosc_reader_int32(struct cosc_serial *serial, cosc_int32 *value)
Write a signed 32-bit integer.
Definition cosc.c:3064
#define COSC_TYPE_UINT64
Used to typedef cosc_uint64.
Definition cosc.h:166
COSC_API cosc_int32 cosc_value_dump(char *s, cosc_int32 n, char type, const union cosc_value *value)
Dump an OSC value to string.
Definition cosc.c:2041
COSC_API cosc_int32 cosc_write_midi(void *buffer, cosc_int32 size, const unsigned char value[4])
Write a MIDI message.
Definition cosc.c:1477
COSC_API cosc_int32 cosc_reader_peek_bundle(struct cosc_serial *serial, cosc_uint64 *timetag, cosc_int32 *psize)
Check if the buffer has a bundle at the current read size.
Definition cosc.c:2858
COSC_API cosc_int32 cosc_write_int64(void *buffer, cosc_int32 size, cosc_int64 value)
Write a 64-bit big endian signed integer.
Definition cosc.c:1225
COSC_API cosc_int32 cosc_read_uint32(const void *buffer, cosc_int32 size, cosc_uint32 *value)
Read a 32-bit big endian unsigned integer.
Definition cosc.c:1135
#define COSC_TYPE_FLOAT32
Used to typedef cosc_float32.
Definition cosc.h:201
COSC_API void cosc_writer_setup(struct cosc_serial *serial, void *buffer, cosc_int32 buffer_size, struct cosc_level *levels, cosc_int32 level_max, cosc_uint32 flags)
Setup a serial for writing.
Definition cosc.c:2408
#define COSC_API
Used to declare linkage for functions.
Definition cosc.h:94
COSC_TYPE_UINT64 cosc_uint64
Unsigned 64-bit integer.
Definition cosc.h:345
COSC_API cosc_int32 cosc_write_uint64(void *buffer, cosc_int32 size, cosc_uint64 value)
Write a 64-bit, big endian unsigned integer.
Definition cosc.c:1199
COSC_API cosc_int32 cosc_read_uint64(const void *buffer, cosc_int32 size, cosc_uint64 *value)
Read a 64-bit big endian unsigned integer.
Definition cosc.c:1213
COSC_API cosc_int32 cosc_reader_repeat(struct cosc_serial *serial)
Repeat typetag from the beginning of an array start, not including the starting '[' character.
Definition cosc.c:3318
COSC_API cosc_int32 cosc_reader_start_message(struct cosc_serial *serial, const char **address, cosc_int32 *address_n, const char **typetag, cosc_int32 *typetag_n)
Start a new message level.
Definition cosc.c:2921
COSC_API cosc_int32 cosc_write_value(void *buffer, cosc_int32 size, char type, const union cosc_value *value)
Write an OSC value.
Definition cosc.c:1653
COSC_API cosc_int32 cosc_feature_swap(void)
Feature test for endian swapping.
Definition cosc.c:485
COSC_API cosc_int32 cosc_reader_skip(struct cosc_serial *serial)
Skip a value, if the value has payload it will be zeroes.
Definition cosc.c:3299
COSC_API cosc_int32 cosc_pattern_validate(const char *s, cosc_int32 s_n, cosc_int32 *invalid)
Scan matching pattern for invalid characters.
Definition cosc.c:740
COSC_API cosc_int32 cosc_feature_pattern(void)
Feature test for pattern support.
Definition cosc.c:503
COSC_API cosc_int32 cosc_writer_repeat(struct cosc_serial *serial)
Repeat typetag from the beginning of an array start, where the array starts with a '['.
Definition cosc.c:2835
COSC_API cosc_int32 cosc_write_signature(void *buffer, cosc_int32 size, const char *address, cosc_int32 address_n, const char *typetag, cosc_int32 typetag_n, cosc_int32 psize)
Write an OSC message signature.
Definition cosc.c:1565
COSC_API cosc_int32 cosc_writer_start_blob(struct cosc_serial *serial)
Start a new blob level.
Definition cosc.c:2525
COSC_API cosc_int32 cosc_reader_end_message(struct cosc_serial *serial, cosc_int32 exit_early)
End a message level.
Definition cosc.c:2973
COSC_API cosc_int32 cosc_write_char(void *buffer, cosc_int32 size, cosc_int32 value)
Write an ASCII character.
Definition cosc.c:1446
COSC_API cosc_int32 cosc_writer_skip(struct cosc_serial *serial)
Skip a value, if the value has payload it will be zeroes.
Definition cosc.c:2816
COSC_API cosc_int32 cosc_read_value(const void *buffer, cosc_int32 size, char type, union cosc_value *value)
Read an OSC value.
Definition cosc.c:1717
COSC_API cosc_int32 cosc_writer_midi(struct cosc_serial *serial, const unsigned char value[4])
Write a MIDI message.
Definition cosc.c:2696
COSC_API cosc_int32 cosc_feature_reader(void)
Feature test for reader support.
Definition cosc.c:539
COSC_API cosc_int32 cosc_reader_value(struct cosc_serial *serial, cosc_int32 type, union cosc_value *value)
Read a value.
Definition cosc.c:3198
COSC_API cosc_int32 cosc_writer_blob(struct cosc_serial *serial, const void *value, cosc_int32 value_n)
Write a blob.
Definition cosc.c:2663
COSC_API cosc_int32 cosc_reader_int64(struct cosc_serial *serial, cosc_int64 *value)
Write a signed 64-bit integer.
Definition cosc.c:3103
COSC_API cosc_int32 cosc_read_signature(const void *buffer, cosc_int32 size, const char **address, cosc_int32 *address_n, const char **typetag, cosc_int32 *typetag_n, cosc_int32 *psize)
Read an OSC message signature.
Definition cosc.c:1616
COSC_API cosc_int32 cosc_write_values(void *buffer, cosc_int32 size, const char *types, cosc_int32 types_n, const union cosc_value *values, cosc_int32 values_n, cosc_int32 *value_count)
Write OSC values.
Definition cosc.c:1756
COSC_API cosc_int32 cosc_writer_float32(struct cosc_serial *serial, cosc_float32 value)
Write a 32-bit float.
Definition cosc.c:2590
COSC_API cosc_int32 cosc_pattern_match(const char *s, cosc_int32 s_n, const char *pattern, cosc_int32 pattern_n)
Match an address or typetag.
Definition cosc.c:801
#define COSC_TYPE_FLOAT64
Used to typedef cosc_float64.
Definition cosc.h:209
#define COSC_TYPE_INT32
Used to typedef cosc_int32.
Definition cosc.h:150
COSC_API cosc_int32 cosc_write_bundle(void *buffer, cosc_int32 size, cosc_uint64 timetag, cosc_int32 psize)
Write an OSC bundle head.
Definition cosc.c:1508
COSC_API cosc_int32 cosc_read_blob(const void *buffer, cosc_int32 size, void *value, cosc_int32 value_n, const void **data, cosc_int32 *data_size)
Read a blob.
Definition cosc.c:1416
COSC_API cosc_int32 cosc_writer_uint32(struct cosc_serial *serial, cosc_uint32 value)
Write an unsigned 32-bit integer.
Definition cosc.c:2564
COSC_API cosc_int32 cosc_typetag_char_validate(cosc_int32 c)
Check if an typetag character is valid.
Definition cosc.c:608
COSC_API cosc_int32 cosc_read_int32(const void *buffer, cosc_int32 size, cosc_int32 *value)
Read a 32-bit big endian signed integer.
Definition cosc.c:1161
#define COSC_TYPE_UINT32
Used to typedef cosc_uint32.
Definition cosc.h:153
COSC_API cosc_int32 cosc_feature_float32(void)
Feature test for 32-bit float support.
Definition cosc.c:467
COSC_API cosc_int32 cosc_address_char_validate(cosc_int32 c)
Check if an address character is valid.
Definition cosc.c:554
COSC_API cosc_int32 cosc_reader_float32(struct cosc_serial *serial, cosc_float32 *value)
Write a 32-bit float.
Definition cosc.c:3077
COSC_API cosc_int32 cosc_read_values(const void *buffer, cosc_int32 size, const char *types, cosc_int32 types_n, union cosc_value *values, cosc_int32 values_n, cosc_int32 *value_count, cosc_int32 exit_early)
Read OSC values.
Definition cosc.c:1839
COSC_API cosc_int32 cosc_reader_start_bundle(struct cosc_serial *serial, cosc_uint64 *timetag)
Start a new bundle level.
Definition cosc.c:2880
COSC_API cosc_uint32 cosc_timetag_to_time(cosc_uint64 timetag, cosc_uint32 *nanos)
Convert a timetag to seconds and nanoseconds.
Definition cosc.c:970
COSC_API cosc_uint64 cosc_time_to_timetag(cosc_uint32 seconds, cosc_uint32 nanos)
Convert time to a timetag.
Definition cosc.c:996
COSC_API cosc_float64 cosc_float32_to_float64(cosc_float32 value)
Convert a 32-bit float to a 64-bit float.
Definition cosc.c:1080
COSC_API cosc_int32 cosc_writer_string(struct cosc_serial *serial, const char *value, cosc_int32 value_n, cosc_int32 *length)
Write a string.
Definition cosc.c:2642
COSC_API cosc_int32 cosc_typetag_validate(const char *typetag, cosc_int32 typetag_n, cosc_int32 *invalid)
Scan typetag for invalid characters.
Definition cosc.c:615
COSC_API cosc_int32 cosc_read_midi(const void *buffer, cosc_int32 size, unsigned char value[4])
Read an ASCII character.
Definition cosc.c:1495
COSC_API cosc_int32 cosc_feature_int64(void)
Feature test for 64-bit integer support.
Definition cosc.c:458
COSC_API cosc_int32 cosc_write_int32(void *buffer, cosc_int32 size, cosc_int32 value)
Write a 32-bit big endian signed integer.
Definition cosc.c:1147
COSC_API cosc_int32 cosc_writer_message(struct cosc_serial *serial, const struct cosc_message *message, cosc_int32 *value_count)
Write an OSC message.
Definition cosc.c:2756
COSC_API cosc_int32 cosc_writer_end_bundle(struct cosc_serial *serial)
End a bundle level.
Definition cosc.c:2442
COSC_TYPE_FLOAT64 cosc_float64
64-bit floating point.
Definition cosc.h:355
COSC_API cosc_int32 cosc_writer_char(struct cosc_serial *serial, cosc_int32 value)
Write an ASCII character.
Definition cosc.c:2683
COSC_API cosc_int32 cosc_reader_start_blob(struct cosc_serial *serial, cosc_int32 *value_size)
Start a new blob level.
Definition cosc.c:3006
COSC_API cosc_int32 cosc_feature_array(void)
Feature test for array support.
Definition cosc.c:494
COSC_API cosc_int32 cosc_serial_get_size(const struct cosc_serial *serial)
Get the number of written or read bytes.
Definition cosc.c:2371
COSC_API cosc_int32 cosc_writer_uint64(struct cosc_serial *serial, cosc_uint64 value)
Write an unsigned 64-bit integer.
Definition cosc.c:2603
COSC_API cosc_int32 cosc_feature_writer(void)
Feature test for writer support.
Definition cosc.c:530
COSC_API cosc_int32 cosc_serial_get_msgtype(const struct cosc_serial *serial)
Get the current typetag type of a message level.
Definition cosc.c:2380
COSC_API cosc_int32 cosc_read_float32(const void *buffer, cosc_int32 size, cosc_float32 *value)
Read a 32-bit big endian floating point.
Definition cosc.c:1187
COSC_TYPE_INT64 cosc_int64
Signed 64-bit integer.
Definition cosc.h:340
COSC_API cosc_int32 cosc_signature_match(const void *buffer, cosc_int32 size, const char *apattern, cosc_int32 apattern_n, const char *tpattern, cosc_int32 tpattern_n, cosc_int32 prefix)
Match an address and typetag.
Definition cosc.c:935
COSC_API cosc_int32 cosc_write_uint32(void *buffer, cosc_int32 size, cosc_uint32 value)
Write a 32-bit, big endian unsigned integer.
Definition cosc.c:1121
COSC_API cosc_float32 cosc_float64_to_float32(cosc_float64 value)
Convert a 64-bit float to a 32-bit float.
Definition cosc.c:1023
COSC_API cosc_int32 cosc_reader_uint64(struct cosc_serial *serial, cosc_uint64 *value)
Write an unsigned 64-bit integer.
Definition cosc.c:3090
COSC_API cosc_int32 cosc_feature_float64(void)
Feature test for 64-bit float support.
Definition cosc.c:476
COSC_API cosc_int32 cosc_writer_int32(struct cosc_serial *serial, cosc_int32 value)
Write a signed 32-bit integer.
Definition cosc.c:2577
COSC_API cosc_int32 cosc_big_endian(void)
If big endian was detected when building this function returns non-zero, otherwise zero.
Definition cosc.c:548
COSC_API cosc_int32 cosc_writer_end_blob(struct cosc_serial *serial)
End a blob level.
Definition cosc.c:2543
COSC_API cosc_int32 cosc_message_dump(char *s, cosc_int32 n, const struct cosc_message *message)
Dump an OSC message to string.
Definition cosc.c:2105
COSC_API cosc_int32 cosc_write_string(void *buffer, cosc_int32 size, const char *value, cosc_int32 value_n, cosc_int32 *length)
Write a string.
Definition cosc.c:1308
COSC_API cosc_int32 cosc_writer_int64(struct cosc_serial *serial, cosc_int64 value)
Write a signed 64-bit integer.
Definition cosc.c:2616
COSC_API void cosc_reader_setup(struct cosc_serial *serial, const void *buffer, cosc_int32 buffer_size, struct cosc_level *levels, cosc_int32 level_max, cosc_uint32 flags)
Setup a serial for reading.
Definition cosc.c:2846
COSC_API cosc_int32 cosc_reader_end_blob(struct cosc_serial *serial)
End a blob level.
Definition cosc.c:3032
COSC_API cosc_int32 cosc_write_float64(void *buffer, cosc_int32 size, cosc_float64 value)
Write a 64-bit big endian floating point.
Definition cosc.c:1251
COSC_API cosc_int32 cosc_feature_timetag(void)
Feature test for timetag conversion support.
Definition cosc.c:512
COSC_API cosc_int32 cosc_writer_start_message(struct cosc_serial *serial, const char *address, cosc_int32 address_n, const char *typetag, cosc_int32 typetag_n)
Start a new message level.
Definition cosc.c:2456
COSC_API cosc_int32 cosc_read_int64(const void *buffer, cosc_int32 size, cosc_int64 *value)
Read a 64-bit big endian signed integer.
Definition cosc.c:1239
COSC_API cosc_int32 cosc_read_bundle(const void *buffer, cosc_int32 size, cosc_uint64 *timetag, cosc_int32 *psize)
Read an OSC bundle head.
Definition cosc.c:1539
#define COSC_TYPE_INT64
Used to typedef cosc_int64.
Definition cosc.h:158
COSC_API cosc_int32 cosc_read_char(const void *buffer, cosc_int32 size, cosc_int32 *value)
Read an ASCII character.
Definition cosc.c:1464
COSC_API cosc_int32 cosc_writer_bytes(struct cosc_serial *serial, const void *value, cosc_int32 value_n)
Write bytes to a started blob level.
Definition cosc.c:2792
COSC_API cosc_int32 cosc_typetag_payload(char *s, cosc_int32 s_n, const char *typetag, cosc_int32 typetag_n, cosc_int32 *array_members)
Scan typetag for types with payload, ignoring the comma prefix, array syntax and types T,...
Definition cosc.c:689
COSC_API cosc_int32 cosc_read_string(const void *buffer, cosc_int32 size, char *value, cosc_int32 value_n, cosc_int32 *length)
Read a string.
Definition cosc.c:1350
COSC_API cosc_int32 cosc_read_float64(const void *buffer, cosc_int32 size, cosc_float64 *value)
Read a 64-bit big endian floating point.
Definition cosc.c:1278
COSC_API void cosc_serial_reset(struct cosc_serial *serial)
Reset serial.
Definition cosc.c:2396
COSC_API cosc_int32 cosc_reader_uint32(struct cosc_serial *serial, cosc_uint32 *value)
Write an unsigned 32-bit integer.
Definition cosc.c:3051
COSC_API cosc_int32 cosc_reader_midi(struct cosc_serial *serial, unsigned char value[4])
Write a MIDI message.
Definition cosc.c:3185
COSC_API cosc_int32 cosc_pattern_char_validate(cosc_int32 c)
Check if an pattern character is valid.
Definition cosc.c:733
COSC_API cosc_int32 cosc_reader_char(struct cosc_serial *serial, cosc_int32 *value)
Write an ASCII character.
Definition cosc.c:3172
COSC_API cosc_int32 cosc_feature_fltconv(void)
Feature test for float conversion support.
Definition cosc.c:521
COSC_API cosc_int32 cosc_reader_string(struct cosc_serial *serial, char *value, cosc_int32 value_n, cosc_int32 *length)
Write a string.
Definition cosc.c:3129
COSC_API cosc_int32 cosc_reader_float64(struct cosc_serial *serial, cosc_float64 *value)
Write a 64-bit float.
Definition cosc.c:3116
COSC_API cosc_int32 cosc_address_validate(const char *address, cosc_int32 address_n, cosc_int32 *invalid)
Scan address for invalid characters.
Definition cosc.c:574
COSC_API cosc_int32 cosc_reader_blob(struct cosc_serial *serial, void *value, cosc_int32 value_n, const void **data, cosc_int32 *data_size)
Write a blob.
Definition cosc.c:3150
COSC_TYPE_UINT32 cosc_uint32
Unsigned 32-bit integer.
Definition cosc.h:248
COSC_API cosc_int32 cosc_writer_end_message(struct cosc_serial *serial)
End a message level.
Definition cosc.c:2500
COSC_TYPE_FLOAT32 cosc_float32
32-bit floating point.
Definition cosc.h:350
COSC_API cosc_int32 cosc_serial_get_buffer_size(const struct cosc_serial *serial)
The maximum number of bytes that can be written/read to/from the buffer.
Definition cosc.c:2364
COSC_API cosc_int32 cosc_write_float32(void *buffer, cosc_int32 size, cosc_float32 value)
Write a 32-bit big endian floating point.
Definition cosc.c:1173
COSC_API cosc_int32 cosc_writer_start_bundle(struct cosc_serial *serial, cosc_uint64 timetag)
Start a new bundle level.
Definition cosc.c:2420
COSC_API cosc_int32 cosc_writer_value(struct cosc_serial *serial, cosc_int32 type, const union cosc_value *value)
Write a value.
Definition cosc.c:2709
COSC_API cosc_int32 cosc_read_message(const void *buffer, cosc_int32 size, struct cosc_message *message, cosc_int32 *psize, cosc_int32 *value_count, cosc_int32 exit_early)
Read an OSC message.
Definition cosc.c:1975
Used when 64-bit types are not available.
Definition cosc.h:327
cosc_uint32 w[2]
Most significant bits first then the least significant, i.e big endian layout for the words.
Definition cosc.h:333
Used to manage the levels of a serial.
Definition cosc.h:603
cosc_int32 ttindex
The current index in the typetag.
Definition cosc.h:645
cosc_int32 size
The number of written or read bytes.
Definition cosc.h:626
cosc_int32 ttend
The buffer byte offset of the typetag end, including it's zero terminator and pad zero bytes (i....
Definition cosc.h:639
cosc_int32 start
The buffer byte offset of the level start.
Definition cosc.h:613
cosc_int32 size_max
The level max size.
Definition cosc.h:621
cosc_int32 ttstart
The buffer byte offset of the typetag start.
Definition cosc.h:632
cosc_int32 type
The level type.
Definition cosc.h:608
A message.
Definition cosc.h:536
cosc_int32 values_n
Write/read at most this many values.
Definition cosc.h:581
cosc_int32 address_n
When writing read at most this many bytes from the address, when reading the length excluding the zer...
Definition cosc.h:547
union cosc_message::@050073337162334015163030171201070055033256045255 values
Const safety.
union cosc_value * read
Read values.
Definition cosc.h:574
const char * typetag
The typetag.
Definition cosc.h:552
const char * address
The address.
Definition cosc.h:541
const union cosc_value * write
Write values.
Definition cosc.h:569
cosc_int32 typetag_n
When writing read at most this many bytes from the typetag, when reading the length excluding the zer...
Definition cosc.h:558
A serial.
Definition cosc.h:653
cosc_int32 level_max
Maximum level.
Definition cosc.h:678
cosc_uint32 flags
Serial flags.
Definition cosc.h:693
cosc_int32 size
The number of written/read bytes, not including levels not yet ended.
Definition cosc.h:688
cosc_int32 level
Current level.
Definition cosc.h:683
const unsigned char * rbuffer
Read buffer, NULL if writing.
Definition cosc.h:663
cosc_int32 buffer_size
Maximum number of bytes the buffer has available.
Definition cosc.h:668
unsigned char * wbuffer
Write buffer, NULL if reading.
Definition cosc.h:658
struct cosc_level * levels
A pointer to an array of levels.
Definition cosc.h:673
A value.
Definition cosc.h:447
unsigned char m[4]
MIDI message.
Definition cosc.h:528
cosc_int32 length
When writing read at most this many bytes from s, when reading this is the length excluding the zero ...
Definition cosc.h:476
cosc_int32 size
The size of the blob data in bytes.
Definition cosc.h:495
cosc_int64 h
64-bit signed integer.
Definition cosc.h:502
cosc_float64 d
64-bit floating point.
Definition cosc.h:512
cosc_uint64 t
64-bit unsigned integer (timetag).
Definition cosc.h:507
const void * b
A pointer to the data, when writing NULL will fill write zeroes, when reading NULL indicates a zero s...
Definition cosc.h:490
cosc_int32 c
8-bit unsigned integer (ASCII character).
Definition cosc.h:517
cosc_float32 f
32-bit floating point.
Definition cosc.h:457
cosc_int32 i
32-bit signed integer.
Definition cosc.h:452
const char * s
A pointer to the string, when writing NULL indicates an empty string, when reading the string is neve...
Definition cosc.h:470
cosc_uint32 r
32-bit unsigned integer.
Definition cosc.h:522