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
969 cosc_uint64 timetag,
970 cosc_uint32 *nanos
971);
972
982 cosc_uint32 seconds,
983 cosc_uint32 nanos
984);
985
986#endif /* !COSC_NOTIMETAG */
987
988#ifndef COSC_NOFLTCONV
989
1000 cosc_float64 value
1001);
1002
1013 cosc_float32 value
1014);
1015
1016#endif /* !COSC_NOFLTCONV */
1017
1033 void *buffer,
1035 cosc_uint32 value
1036);
1037
1052 const void *buffer,
1054 cosc_uint32 *value
1055);
1056
1072 void *buffer,
1074 cosc_int32 value
1075);
1076
1091 const void *buffer,
1093 cosc_int32 *value
1094);
1095
1111 void *buffer,
1113 cosc_float32 value
1114);
1115
1130 const void *buffer,
1132 cosc_float32 *value
1133);
1134
1150 void *buffer,
1152 cosc_uint64 value
1153);
1154
1169 const void *buffer,
1171 cosc_uint64 *value
1172);
1173
1189 void *buffer,
1191 cosc_int64 value
1192);
1193
1208 const void *buffer,
1210 cosc_int64 *value
1211);
1212
1228 void *buffer,
1230 cosc_float64 value
1231);
1232
1247 const void *buffer,
1249 cosc_float64 *value
1250);
1251
1272 void *buffer,
1274 const char *value,
1275 cosc_int32 value_n,
1276 cosc_int32 *length
1277);
1278
1296 const void *buffer,
1298 char *value,
1299 cosc_int32 value_n,
1300 cosc_int32 *length
1301);
1302
1320 void *buffer,
1322 const void *value,
1323 cosc_int32 value_n
1324);
1325
1348 const void *buffer,
1350 void *value,
1351 cosc_int32 value_n,
1352 const void **data,
1353 cosc_int32 *data_size
1354);
1355
1371 void *buffer,
1373 cosc_int32 value
1374);
1375
1390 const void *buffer,
1392 cosc_int32 *value
1393);
1394
1411 void *buffer,
1413 const unsigned char value[4]
1414);
1415
1431 const void *buffer,
1433 unsigned char value[4]
1434);
1435
1458 void *buffer,
1460 cosc_uint64 timetag,
1461 cosc_int32 psize
1462);
1463
1485 const void *buffer,
1487 cosc_uint64 *timetag,
1488 cosc_int32 *psize
1489);
1490
1517 void *buffer,
1519 const char *address,
1520 cosc_int32 address_n,
1521 const char *typetag,
1522 cosc_int32 typetag_n,
1523 cosc_int32 psize
1524);
1525
1555 const void *buffer,
1557 const char **address,
1558 cosc_int32 *address_n,
1559 const char **typetag,
1560 cosc_int32 *typetag_n,
1561 cosc_int32 *psize
1562);
1563
1580 void *buffer,
1582 char type,
1583 const union cosc_value *value
1584);
1585
1601 const void *buffer,
1603 char type,
1604 union cosc_value *value
1605);
1606
1631 void *buffer,
1633 const char *types,
1634 cosc_int32 types_n,
1635 const union cosc_value *values,
1636 cosc_int32 values_n,
1637 cosc_int32 *value_count
1638);
1639
1667 const void *buffer,
1669 const char *types,
1670 cosc_int32 types_n,
1671 union cosc_value *values,
1672 cosc_int32 values_n,
1673 cosc_int32 *value_count,
1674 cosc_int32 exit_early
1675);
1676
1703 void *buffer,
1705 const struct cosc_message *message,
1706 cosc_int32 psize,
1707 cosc_int32 *value_count
1708);
1709
1740 const void *buffer,
1742 struct cosc_message *message,
1743 cosc_int32 *psize,
1744 cosc_int32 *value_count,
1745 cosc_int32 exit_early
1746);
1747
1748#if !defined(COSC_NOSTDLIB) && !defined(COSC_NODUMP)
1749
1763 char *s,
1764 cosc_int32 n,
1765 char type,
1766 const union cosc_value *value
1767);
1768
1781 char *s,
1782 cosc_int32 n,
1783 const struct cosc_message *message
1784);
1785
1786#endif /* !COSC_NOSTDLIB && !COSC_NODUMP */
1787
1788#if !defined(COSC_NOWRITER) || !defined(COSC_NOREADER)
1789
1798 const struct cosc_serial *serial
1799);
1800
1809 const struct cosc_serial *serial
1810);
1811
1822 const struct cosc_serial *serial
1823);
1824
1832 struct cosc_serial *serial
1833);
1834
1835#endif /* !COSC_NOWRITER && !COSC_NOREADER */
1836
1837#ifndef COSC_NOWRITER
1838
1854 struct cosc_serial *serial,
1855 void *buffer,
1856 cosc_int32 buffer_size,
1857 struct cosc_level *levels,
1858 cosc_int32 level_max,
1859 cosc_uint32 flags
1860);
1861
1879 struct cosc_serial *serial,
1880 cosc_uint64 timetag
1881);
1882
1897 struct cosc_serial *serial
1898);
1899
1920 struct cosc_serial *serial,
1921 const char *address,
1922 cosc_int32 address_n,
1923 const char *typetag,
1924 cosc_int32 typetag_n
1925);
1926
1941 struct cosc_serial *serial
1942);
1943
1962 struct cosc_serial *serial
1963);
1964
1983 struct cosc_serial *serial
1984);
1985
2004 struct cosc_serial *serial,
2005 cosc_uint32 value
2006);
2007
2026 struct cosc_serial *serial,
2027 cosc_int32 value
2028);
2029
2048 struct cosc_serial *serial,
2049 cosc_float32 value
2050);
2051
2070 struct cosc_serial *serial,
2071 cosc_uint64 value
2072);
2073
2092 struct cosc_serial *serial,
2093 cosc_int64 value
2094);
2095
2114 struct cosc_serial *serial,
2115 cosc_float64 value
2116);
2117
2140 struct cosc_serial *serial,
2141 const char *value,
2142 cosc_int32 value_n,
2143 cosc_int32 *length
2144);
2145
2167 struct cosc_serial *serial,
2168 const void *value,
2169 cosc_int32 value_n
2170);
2171
2190 struct cosc_serial *serial,
2191 cosc_int32 value
2192);
2193
2213 struct cosc_serial *serial,
2214 const unsigned char value[4]
2215);
2216
2238 struct cosc_serial *serial,
2240 const union cosc_value *value
2241);
2242
2263 struct cosc_serial *serial,
2264 const struct cosc_message *message,
2265 cosc_int32 *value_count
2266);
2267
2285 struct cosc_serial *serial,
2286 const void *value,
2287 cosc_int32 value_n
2288);
2289
2308 struct cosc_serial *serial
2309);
2310
2330 struct cosc_serial *serial
2331);
2332
2333#endif /* !COSC_NOWRITER */
2334
2335#ifndef COSC_NOREADER
2336
2352 struct cosc_serial *serial,
2353 const void *buffer,
2354 cosc_int32 buffer_size,
2355 struct cosc_level *levels,
2356 cosc_int32 level_max,
2357 cosc_uint32 flags
2358);
2359
2381 struct cosc_serial *serial,
2382 cosc_uint64 *timetag,
2383 cosc_int32 *psize
2384);
2385
2405 struct cosc_serial *serial,
2406 cosc_uint64 *timetag
2407);
2408
2423 struct cosc_serial *serial
2424);
2425
2452 struct cosc_serial *serial,
2453 const char **address,
2454 cosc_int32 *address_n,
2455 const char **typetag,
2456 cosc_int32 *typetag_n
2457);
2458
2476 struct cosc_serial *serial,
2477 cosc_int32 exit_early
2478);
2479
2500 struct cosc_serial *serial,
2501 cosc_int32 *value_size
2502);
2503
2520 struct cosc_serial *serial
2521);
2522
2542 struct cosc_serial *serial,
2543 cosc_uint32 *value
2544);
2545
2565 struct cosc_serial *serial,
2566 cosc_int32 *value
2567);
2568
2588 struct cosc_serial *serial,
2589 cosc_float32 *value
2590);
2591
2611 struct cosc_serial *serial,
2612 cosc_uint64 *value
2613);
2614
2634 struct cosc_serial *serial,
2635 cosc_int64 *value
2636);
2637
2657 struct cosc_serial *serial,
2658 cosc_float64 *value
2659);
2660
2684 struct cosc_serial *serial,
2685 char *value,
2686 cosc_int32 value_n,
2687 cosc_int32 *length
2688);
2689
2717 struct cosc_serial *serial,
2718 void *value,
2719 cosc_int32 value_n,
2720 const void **data,
2721 cosc_int32 *data_size
2722);
2723
2743 struct cosc_serial *serial,
2744 cosc_int32 *value
2745);
2746
2767 struct cosc_serial *serial,
2768 unsigned char value[4]
2769);
2770
2793 struct cosc_serial *serial,
2795 union cosc_value *value
2796);
2797
2822 struct cosc_serial *serial,
2823 struct cosc_message *message,
2824 cosc_int32 *value_count,
2825 cosc_int32 exit_early
2826);
2827
2846 struct cosc_serial *serial,
2847 void *value,
2848 cosc_int32 value_n
2849);
2850
2869 struct cosc_serial *serial
2870);
2871
2887 struct cosc_serial *serial
2888);
2889
2890#endif /* !COSC_NOREADER */
2891
2892#ifdef __cplusplus
2893}
2894#endif
2895
2896#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