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/* These defaults require int and unsigned int to be exactly 32 bits. */
175#ifndef COSC_TYPE_INT32
176#define COSC_TYPE_INT32 int
177#endif
178#ifndef COSC_TYPE_UINT32
179#define COSC_TYPE_UINT32 unsigned int
180#endif
181
182#ifndef COSC_NOINT64
183#ifndef COSC_TYPE_INT64
184#define COSC_TYPE_INT64 long long
185#endif
186#else
187#define COSC_TYPE_INT64 struct cosc_64bits
188#endif
189
190#ifndef COSC_NOINT64
191#ifndef COSC_TYPE_UINT64
192#define COSC_TYPE_UINT64 unsigned long long
193#endif
194#else
195#define COSC_TYPE_UINT64 struct cosc_64bits
196#endif
197
198#endif /* COSC_NOSTDINT */
199
200#ifndef COSC_NOFLOAT32
201#ifndef COSC_TYPE_FLOAT32
202#define COSC_TYPE_FLOAT32 float
203#endif
204#else
205#define COSC_TYPE_FLOAT32 COSC_TYPE_UINT32
206#endif
207
208#ifndef COSC_NOFLOAT64
209#ifndef COSC_TYPE_FLOAT64
210#define COSC_TYPE_FLOAT64 double
211#endif
212#else
213#define COSC_TYPE_FLOAT64 struct cosc_64bits
214#endif
215
219#define COSC_INT32MAX 2147483647
220
224#define COSC_INT32MIN ((-2147483647)-1)
225
229#define COSC_UINT32MAX 4294967295
230
234#define COSC_INT64MAX 9223372036854775807LL
235
239#define COSC_INT64MIN ((-9223372036854775807LL)-1)
240
244#define COSC_UINT64MAX 18446744073709551615ULL
245
250
255
262#define COSC_64BITS_INIT(hi_, lo_) {{(hi_), (lo_)}}
263
270#define COSC_64BITS_SET(bits_, hi_, lo_) do { COSC_64BITS_HI(bits_) = (hi_); COSC_64BITS_LO(bits_) = (lo_); } while (0)
271
276#define COSC_64BITS_HI(bits_) ((bits_)->w[0])
277
282#define COSC_64BITS_LO(bits_) ((bits_)->w[1])
283
289
295
296#ifndef COSC_NOINT64
297#define COSC_INT64_INIT_ZERO 0
298#define COSC_INT64_SET_ZERO(ptr) (*(ptr) = 0)
299#else
300#define COSC_INT64_INIT_ZERO COSC_64BITS_INIT(0, 0)
301#define COSC_INT64_SET_ZERO(ptr) COSC_64BITS_SET(ptr, 0, 0)
302#endif
303
309
315
316#ifndef COSC_NOFLOAT64
317#define COSC_FLOAT64_INIT_ZERO 0
318#define COSC_FLOAT64_SET_ZERO(ptr) (*(ptr) = 0)
319#else
320#define COSC_FLOAT64_INIT_ZERO COSC_64BITS_INIT(0, 0)
321#define COSC_FLOAT64_SET_ZERO(ptr) COSC_64BITS_SET(ptr, 0, 0)
322#endif
323
328{
329
335
336};
337
342
347
352
357
361#define COSC_SIZE_MAX 2147483644
362
369#define COSC_PADMUST(sz) (4 - ((cosc_uint32)(sz) & 3))
370
376#define COSC_PAD(sz) (COSC_PADMUST(sz) & 3)
377
381#define COSC_LEVEL_TYPE_BUNDLE 'B'
382
386#define COSC_LEVEL_TYPE_MESSAGE 'M'
387
391#define COSC_LEVEL_TYPE_BLOB 'b'
392
397#define COSC_SERIAL_PSIZE 1
398
402#define COSC_EOVERRUN -2
403
407#define COSC_ESIZEMAX -3
408
412#define COSC_ETYPE -4
413
417#define COSC_EPSIZE -5
418
422#define COSC_EINVAL -6
423
427#define COSC_ELEVELMAX -7
428
432#define COSC_ELEVELTYPE -8
433
437#define COSC_EPSIZEFLAG -9
438
442#define COSC_EMSGTYPE -10
443
448{
449
454
459
463 struct
464 {
465
471 const char *s;
472
478
479 } s;
480
484 struct
485 {
486
491 const void *b;
492
497
498 } b;
499
504
509
514
519
524
529 unsigned char m[4];
530
531};
532
537{
538
542 const char *address;
543
549
553 const char *typetag;
554
560
564 union
565 {
566
570 const union cosc_value *write;
571
576
578
583
584};
585
591#define COSC_SERIAL_ISWRITER(serial_) ((serial_)->wbuffer != 0)
592
598#define COSC_SERIAL_ISREADER(serial_) ((serial_)->rbuffer != 0)
599
649
654{
655
659 unsigned char *wbuffer;
660
664 const unsigned char *rbuffer;
665
670
675
680
685
690
695
696};
697
698#ifdef __cplusplus
699extern "C" {
700#endif
701
707
713
719
725
731
737
743
749
755
761
769
776 cosc_int32 c
777);
778
792 const char *address,
793 cosc_int32 address_n,
794 cosc_int32 *invalid
795);
796
803 cosc_int32 c
804);
805
823 const char *typetag,
824 cosc_int32 typetag_n,
825 cosc_int32 *invalid
826);
827
848 char *s,
849 cosc_int32 s_n,
850 const char *typetag,
851 cosc_int32 typetag_n,
852 cosc_int32 *array_members
853);
854
855#ifndef COSC_NOPATTERN
856
865 cosc_int32 c
866);
867
888 const char *s,
889 cosc_int32 s_n,
890 cosc_int32 *invalid
891);
892
923 const char *s,
924 cosc_int32 s_n,
925 const char *pattern,
926 cosc_int32 pattern_n
927);
928
944 const void *buffer,
946 const char *apattern,
947 cosc_int32 apattern_n,
948 const char *tpattern,
949 cosc_int32 tpattern_n,
950 cosc_int32 prefix
951);
952
953#endif /* !COSC_NOPATTERN */
954
955#ifndef COSC_NOTIMETAG
956
967 cosc_uint64 timetag,
968 cosc_uint32 *nanos
969);
970
978 cosc_uint32 seconds,
979 cosc_uint32 nanos
980);
981
982#endif /* !COSC_NOTIMETAG */
983
984#ifndef COSC_NOFLTCONV
985
996 cosc_float64 value
997);
998
1009 cosc_float32 value
1010);
1011
1012#endif /* !COSC_NOFLTCONV */
1013
1029 void *buffer,
1031 cosc_uint32 value
1032);
1033
1048 const void *buffer,
1050 cosc_uint32 *value
1051);
1052
1068 void *buffer,
1070 cosc_int32 value
1071);
1072
1087 const void *buffer,
1089 cosc_int32 *value
1090);
1091
1107 void *buffer,
1109 cosc_float32 value
1110);
1111
1126 const void *buffer,
1128 cosc_float32 *value
1129);
1130
1146 void *buffer,
1148 cosc_uint64 value
1149);
1150
1165 const void *buffer,
1167 cosc_uint64 *value
1168);
1169
1185 void *buffer,
1187 cosc_int64 value
1188);
1189
1204 const void *buffer,
1206 cosc_int64 *value
1207);
1208
1224 void *buffer,
1226 cosc_float64 value
1227);
1228
1243 const void *buffer,
1245 cosc_float64 *value
1246);
1247
1268 void *buffer,
1270 const char *value,
1271 cosc_int32 value_n,
1272 cosc_int32 *length
1273);
1274
1292 const void *buffer,
1294 char *value,
1295 cosc_int32 value_n,
1296 cosc_int32 *length
1297);
1298
1316 void *buffer,
1318 const void *value,
1319 cosc_int32 value_n
1320);
1321
1344 const void *buffer,
1346 void *value,
1347 cosc_int32 value_n,
1348 const void **data,
1349 cosc_int32 *data_size
1350);
1351
1367 void *buffer,
1369 cosc_int32 value
1370);
1371
1386 const void *buffer,
1388 cosc_int32 *value
1389);
1390
1407 void *buffer,
1409 const unsigned char value[4]
1410);
1411
1427 const void *buffer,
1429 unsigned char value[4]
1430);
1431
1454 void *buffer,
1456 cosc_uint64 timetag,
1457 cosc_int32 psize
1458);
1459
1481 const void *buffer,
1483 cosc_uint64 *timetag,
1484 cosc_int32 *psize
1485);
1486
1513 void *buffer,
1515 const char *address,
1516 cosc_int32 address_n,
1517 const char *typetag,
1518 cosc_int32 typetag_n,
1519 cosc_int32 psize
1520);
1521
1551 const void *buffer,
1553 const char **address,
1554 cosc_int32 *address_n,
1555 const char **typetag,
1556 cosc_int32 *typetag_n,
1557 cosc_int32 *psize
1558);
1559
1576 void *buffer,
1578 char type,
1579 const union cosc_value *value
1580);
1581
1597 const void *buffer,
1599 char type,
1600 union cosc_value *value
1601);
1602
1625 void *buffer,
1627 const char *types,
1628 cosc_int32 types_n,
1629 const union cosc_value *values,
1630 cosc_int32 values_n,
1631 cosc_int32 *value_count
1632);
1633
1659 const void *buffer,
1661 const char *types,
1662 cosc_int32 types_n,
1663 union cosc_value *values,
1664 cosc_int32 values_n,
1665 cosc_int32 *value_count,
1666 cosc_int32 exit_early
1667);
1668
1693 void *buffer,
1695 const struct cosc_message *message,
1696 cosc_int32 psize,
1697 cosc_int32 *value_count
1698);
1699
1728 const void *buffer,
1730 struct cosc_message *message,
1731 cosc_int32 *psize,
1732 cosc_int32 *value_count,
1733 cosc_int32 exit_early
1734);
1735
1736#if !defined(COSC_NOSTDLIB) && !defined(COSC_NODUMP)
1737
1751 char *s,
1752 cosc_int32 n,
1753 char type,
1754 const union cosc_value *value
1755);
1756
1769 char *s,
1770 cosc_int32 n,
1771 const struct cosc_message *message
1772);
1773
1774#endif /* !COSC_NOSTDLIB && !COSC_NODUMP */
1775
1776#if !defined(COSC_NOWRITER) || !defined(COSC_NOREADER)
1777
1786 const struct cosc_serial *serial
1787);
1788
1797 const struct cosc_serial *serial
1798);
1799
1810 const struct cosc_serial *serial
1811);
1812
1818 struct cosc_serial *serial
1819);
1820
1821#endif /* !COSC_NOWRITER && !COSC_NOREADER */
1822
1823#ifndef COSC_NOWRITER
1824
1840 struct cosc_serial *serial,
1841 void *buffer,
1842 cosc_int32 buffer_size,
1843 struct cosc_level *levels,
1844 cosc_int32 level_max,
1845 cosc_uint32 flags
1846);
1847
1865 struct cosc_serial *serial,
1866 cosc_uint64 timetag
1867);
1868
1883 struct cosc_serial *serial
1884);
1885
1906 struct cosc_serial *serial,
1907 const char *address,
1908 cosc_int32 address_n,
1909 const char *typetag,
1910 cosc_int32 typetag_n
1911);
1912
1927 struct cosc_serial *serial
1928);
1929
1948 struct cosc_serial *serial
1949);
1950
1969 struct cosc_serial *serial
1970);
1971
1990 struct cosc_serial *serial,
1991 cosc_uint32 value
1992);
1993
2012 struct cosc_serial *serial,
2013 cosc_int32 value
2014);
2015
2034 struct cosc_serial *serial,
2035 cosc_float32 value
2036);
2037
2056 struct cosc_serial *serial,
2057 cosc_uint64 value
2058);
2059
2078 struct cosc_serial *serial,
2079 cosc_int64 value
2080);
2081
2100 struct cosc_serial *serial,
2101 cosc_float64 value
2102);
2103
2126 struct cosc_serial *serial,
2127 const char *value,
2128 cosc_int32 value_n,
2129 cosc_int32 *length
2130);
2131
2153 struct cosc_serial *serial,
2154 const void *value,
2155 cosc_int32 value_n
2156);
2157
2176 struct cosc_serial *serial,
2177 cosc_int32 value
2178);
2179
2199 struct cosc_serial *serial,
2200 const unsigned char value[4]
2201);
2202
2224 struct cosc_serial *serial,
2226 const union cosc_value *value
2227);
2228
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
2506 struct cosc_serial *serial
2507);
2508
2528 struct cosc_serial *serial,
2529 cosc_uint32 *value
2530);
2531
2551 struct cosc_serial *serial,
2552 cosc_int32 *value
2553);
2554
2574 struct cosc_serial *serial,
2575 cosc_float32 *value
2576);
2577
2597 struct cosc_serial *serial,
2598 cosc_uint64 *value
2599);
2600
2620 struct cosc_serial *serial,
2621 cosc_int64 *value
2622);
2623
2643 struct cosc_serial *serial,
2644 cosc_float64 *value
2645);
2646
2670 struct cosc_serial *serial,
2671 char *value,
2672 cosc_int32 value_n,
2673 cosc_int32 *length
2674);
2675
2703 struct cosc_serial *serial,
2704 void *value,
2705 cosc_int32 value_n,
2706 const void **data,
2707 cosc_int32 *data_size
2708);
2709
2729 struct cosc_serial *serial,
2730 cosc_int32 *value
2731);
2732
2753 struct cosc_serial *serial,
2754 unsigned char value[4]
2755);
2756
2779 struct cosc_serial *serial,
2781 union cosc_value *value
2782);
2783
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
2873 struct cosc_serial *serial
2874);
2875
2876#endif /* !COSC_NOREADER */
2877
2878#ifdef __cplusplus
2879}
2880#endif
2881
2882#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:3407
COSC_TYPE_INT32 cosc_int32
Signed 32-bit integer.
Definition cosc.h:254
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:1415
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:1962
COSC_API cosc_int32 cosc_writer_float64(struct cosc_serial *serial, cosc_float64 value)
Write a 64-bit float.
Definition cosc.c:2715
COSC_API cosc_int32 cosc_reader_end_bundle(struct cosc_serial *serial)
End a bundle level.
Definition cosc.c:3006
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:3367
COSC_API cosc_int32 cosc_reader_int32(struct cosc_serial *serial, cosc_int32 *value)
Read a signed 32-bit integer.
Definition cosc.c:3189
#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:2090
COSC_API cosc_int32 cosc_write_midi(void *buffer, cosc_int32 size, const unsigned char value[4])
Write a MIDI message.
Definition cosc.c:1506
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:2949
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:1254
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:1164
#define COSC_TYPE_FLOAT32
Used to typedef cosc_float32.
Definition cosc.h:202
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:2485
#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:346
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:1228
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:1242
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:3448
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:3020
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:1687
COSC_API cosc_int32 cosc_feature_swap(void)
Feature test for endian swapping.
Definition cosc.c:378
COSC_API cosc_int32 cosc_reader_skip(struct cosc_serial *serial)
Skip a value.
Definition cosc.c:3429
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:643
COSC_API cosc_int32 cosc_feature_pattern(void)
Feature test for pattern support.
Definition cosc.c:396
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:2926
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:1594
COSC_API cosc_int32 cosc_writer_start_blob(struct cosc_serial *serial)
Start a new blob level.
Definition cosc.c:2608
COSC_API cosc_int32 cosc_reader_end_message(struct cosc_serial *serial, cosc_int32 exit_early)
End a message level.
Definition cosc.c:3076
COSC_API cosc_int32 cosc_write_char(void *buffer, cosc_int32 size, cosc_int32 value)
Write an ASCII character.
Definition cosc.c:1475
COSC_API cosc_int32 cosc_writer_skip(struct cosc_serial *serial)
Skip a value.
Definition cosc.c:2907
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:1751
COSC_API cosc_int32 cosc_writer_midi(struct cosc_serial *serial, const unsigned char value[4])
Write a MIDI message.
Definition cosc.c:2782
COSC_API cosc_int32 cosc_feature_reader(void)
Feature test for reader support.
Definition cosc.c:432
COSC_API cosc_int32 cosc_reader_value(struct cosc_serial *serial, cosc_int32 type, union cosc_value *value)
Read a value.
Definition cosc.c:3323
COSC_API cosc_int32 cosc_writer_blob(struct cosc_serial *serial, const void *value, cosc_int32 value_n)
Write a blob.
Definition cosc.c:2749
COSC_API cosc_int32 cosc_reader_int64(struct cosc_serial *serial, cosc_int64 *value)
Read a signed 64-bit integer.
Definition cosc.c:3228
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:1649
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:1790
COSC_API cosc_int32 cosc_writer_float32(struct cosc_serial *serial, cosc_float32 value)
Write a 32-bit float.
Definition cosc.c:2676
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:832
#define COSC_TYPE_FLOAT64
Used to typedef cosc_float64.
Definition cosc.h:210
#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:1537
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:1445
COSC_API cosc_int32 cosc_writer_uint32(struct cosc_serial *serial, cosc_uint32 value)
Write an unsigned 32-bit integer.
Definition cosc.c:2650
COSC_API cosc_int32 cosc_typetag_char_validate(cosc_int32 c)
Check if an typetag character is valid.
Definition cosc.c:507
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:1190
#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:360
COSC_API cosc_int32 cosc_address_char_validate(cosc_int32 c)
Check if an address character is valid.
Definition cosc.c:447
COSC_API cosc_int32 cosc_reader_float32(struct cosc_serial *serial, cosc_float32 *value)
Read a 32-bit float.
Definition cosc.c:3202
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:1875
COSC_API cosc_int32 cosc_reader_start_bundle(struct cosc_serial *serial, cosc_uint64 *timetag)
Start a new bundle level.
Definition cosc.c:2976
COSC_API cosc_uint32 cosc_timetag_to_time(cosc_uint64 timetag, cosc_uint32 *nanos)
Convert a timetag to seconds and nanoseconds.
Definition cosc.c:890
COSC_API cosc_uint64 cosc_time_to_timetag(cosc_uint32 seconds, cosc_uint32 nanos)
Convert time to a timetag.
Definition cosc.c:916
COSC_API cosc_float64 cosc_float32_to_float64(cosc_float32 value)
Convert a 32-bit float to a 64-bit float.
Definition cosc.c:1059
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:2728
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:514
COSC_API cosc_int32 cosc_read_midi(const void *buffer, cosc_int32 size, unsigned char value[4])
Read a MIDI message.
Definition cosc.c:1524
COSC_API cosc_int32 cosc_feature_int64(void)
Feature test for 64-bit integer support.
Definition cosc.c:351
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:1176
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:2847
COSC_API cosc_int32 cosc_writer_end_bundle(struct cosc_serial *serial)
End a bundle level.
Definition cosc.c:2522
COSC_TYPE_FLOAT64 cosc_float64
64-bit floating point.
Definition cosc.h:356
COSC_API cosc_int32 cosc_writer_char(struct cosc_serial *serial, cosc_int32 value)
Write an ASCII character.
Definition cosc.c:2769
COSC_API cosc_int32 cosc_reader_start_blob(struct cosc_serial *serial, cosc_int32 *value_size)
Start a new blob level.
Definition cosc.c:3126
COSC_API cosc_int32 cosc_feature_array(void)
Feature test for array support.
Definition cosc.c:387
COSC_API cosc_int32 cosc_serial_get_size(const struct cosc_serial *serial)
Get the number of written or read bytes.
Definition cosc.c:2448
COSC_API cosc_int32 cosc_writer_uint64(struct cosc_serial *serial, cosc_uint64 value)
Write an unsigned 64-bit integer.
Definition cosc.c:2689
COSC_API cosc_int32 cosc_feature_writer(void)
Feature test for writer support.
Definition cosc.c:423
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:2457
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:1216
COSC_TYPE_INT64 cosc_int64
Signed 64-bit integer.
Definition cosc.h:341
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:853
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:1150
COSC_API cosc_float32 cosc_float64_to_float32(cosc_float64 value)
Convert a 64-bit float to a 32-bit float.
Definition cosc.c:943
COSC_API cosc_int32 cosc_reader_uint64(struct cosc_serial *serial, cosc_uint64 *value)
Read an unsigned 64-bit integer.
Definition cosc.c:3215
COSC_API cosc_int32 cosc_feature_float64(void)
Feature test for 64-bit float support.
Definition cosc.c:369
COSC_API cosc_int32 cosc_writer_int32(struct cosc_serial *serial, cosc_int32 value)
Write a signed 32-bit integer.
Definition cosc.c:2663
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:441
COSC_API cosc_int32 cosc_writer_end_blob(struct cosc_serial *serial)
End a blob level.
Definition cosc.c:2629
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:2159
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:1337
COSC_API cosc_int32 cosc_writer_int64(struct cosc_serial *serial, cosc_int64 value)
Write a signed 64-bit integer.
Definition cosc.c:2702
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:2937
COSC_API cosc_int32 cosc_reader_end_blob(struct cosc_serial *serial)
End a blob level.
Definition cosc.c:3157
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:1280
COSC_API cosc_int32 cosc_feature_timetag(void)
Feature test for timetag conversion support.
Definition cosc.c:405
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:2536
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:1268
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:1568
#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:1493
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:2883
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:592
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:1379
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:1307
COSC_API void cosc_serial_reset(struct cosc_serial *serial)
Reset serial.
Definition cosc.c:2473
COSC_API cosc_int32 cosc_reader_uint32(struct cosc_serial *serial, cosc_uint32 *value)
Read an unsigned 32-bit integer.
Definition cosc.c:3176
COSC_API cosc_int32 cosc_reader_midi(struct cosc_serial *serial, unsigned char value[4])
Read a MIDI message.
Definition cosc.c:3310
COSC_API cosc_int32 cosc_pattern_char_validate(cosc_int32 c)
Check if an pattern character is valid.
Definition cosc.c:636
COSC_API cosc_int32 cosc_reader_char(struct cosc_serial *serial, cosc_int32 *value)
Read an ASCII character.
Definition cosc.c:3297
COSC_API cosc_int32 cosc_feature_fltconv(void)
Feature test for float conversion support.
Definition cosc.c:414
COSC_API cosc_int32 cosc_reader_string(struct cosc_serial *serial, char *value, cosc_int32 value_n, cosc_int32 *length)
Read a string.
Definition cosc.c:3254
COSC_API cosc_int32 cosc_reader_float64(struct cosc_serial *serial, cosc_float64 *value)
Read a 64-bit float.
Definition cosc.c:3241
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:467
COSC_API cosc_int32 cosc_reader_blob(struct cosc_serial *serial, void *value, cosc_int32 value_n, const void **data, cosc_int32 *data_size)
Read a blob.
Definition cosc.c:3275
COSC_TYPE_UINT32 cosc_uint32
Unsigned 32-bit integer.
Definition cosc.h:249
COSC_API cosc_int32 cosc_writer_end_message(struct cosc_serial *serial)
End a message level.
Definition cosc.c:2583
COSC_TYPE_FLOAT32 cosc_float32
32-bit floating point.
Definition cosc.h:351
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:2441
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:1202
COSC_API cosc_int32 cosc_writer_start_bundle(struct cosc_serial *serial, cosc_uint64 timetag)
Start a new bundle level.
Definition cosc.c:2497
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:2795
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:2018
Used when 64-bit types are not available.
Definition cosc.h:328
cosc_uint32 w[2]
Most significant bits first then the least significant, i.e big endian layout for the words.
Definition cosc.h:334
Used to manage the levels of a serial.
Definition cosc.h:604
cosc_int32 ttindex
The current index in the typetag.
Definition cosc.h:646
cosc_int32 size
The number of written or read bytes.
Definition cosc.h:627
cosc_int32 ttend
The buffer byte offset of the typetag end, including it's zero terminator and pad zero bytes (i....
Definition cosc.h:640
cosc_int32 start
The buffer byte offset of the level start.
Definition cosc.h:614
cosc_int32 size_max
The level max size.
Definition cosc.h:622
cosc_int32 ttstart
The buffer byte offset of the typetag start.
Definition cosc.h:633
cosc_int32 type
The level type.
Definition cosc.h:609
A message.
Definition cosc.h:537
cosc_int32 values_n
Write/read at most this many values.
Definition cosc.h:582
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:548
union cosc_message::@050073337162334015163030171201070055033256045255 values
Const safety.
union cosc_value * read
Read values.
Definition cosc.h:575
const char * typetag
The typetag.
Definition cosc.h:553
const char * address
The address.
Definition cosc.h:542
const union cosc_value * write
Write values.
Definition cosc.h:570
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:559
A serial.
Definition cosc.h:654
cosc_int32 level_max
Maximum level.
Definition cosc.h:679
cosc_uint32 flags
Serial flags.
Definition cosc.h:694
cosc_int32 size
The number of written/read bytes, not including levels not yet ended.
Definition cosc.h:689
cosc_int32 level
Current level.
Definition cosc.h:684
const unsigned char * rbuffer
Read buffer, NULL if writing.
Definition cosc.h:664
cosc_int32 buffer_size
Maximum number of bytes the buffer has available.
Definition cosc.h:669
unsigned char * wbuffer
Write buffer, NULL if reading.
Definition cosc.h:659
struct cosc_level * levels
A pointer to an array of levels.
Definition cosc.h:674
A value.
Definition cosc.h:448
unsigned char m[4]
MIDI message.
Definition cosc.h:529
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:477
cosc_int32 size
The size of the blob data in bytes.
Definition cosc.h:496
cosc_int64 h
64-bit signed integer.
Definition cosc.h:503
cosc_float64 d
64-bit floating point.
Definition cosc.h:513
cosc_uint64 t
64-bit unsigned integer (timetag).
Definition cosc.h:508
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:491
cosc_int32 c
8-bit unsigned integer (ASCII character).
Definition cosc.h:518
cosc_float32 f
32-bit floating point.
Definition cosc.h:458
cosc_int32 i
32-bit signed integer.
Definition cosc.h:453
const char * s
A pointer to the string, when writing NULL indicates an empty string, when reading the string is neve...
Definition cosc.h:471
cosc_uint32 r
32-bit unsigned integer.
Definition cosc.h:523