libose
Loading...
Searching...
No Matches
ose.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2019-23 John MacCallum Permission is hereby granted,
3 free of charge, to any person obtaining a copy of this software
4 and associated documentation files (the "Software"), to deal in
5 the Software without restriction, including without limitation the
6 rights to use, copy, modify, merge, publish, distribute,
7 sublicense, and/or sell copies of the Software, and to permit
8 persons to whom the Software is furnished to do so, subject to the
9 following conditions:
10
11 The above copyright notice and this permission notice shall be
12 included in all copies or substantial portions of the Software.
13
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
18 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
19 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 DEALINGS IN THE SOFTWARE.
22*/
23
49#ifndef OSE_H
50#define OSE_H
51
52#ifdef __cplusplus
53extern "C" {
54#endif
55
56#include <limits.h>
57#if !defined(SWIG) && CHAR_BIT != 8
58#error "Unsupported hardware (CHAR_BIT != 8)"
59#endif
60
61#include <inttypes.h>
62
63/* Would be nice to use this, but the compiler for the */
64/* ESP8266 doesn't support it :( */
65/* #if __has_include("sys/ose_endian.h") */
66/* #include "sys/ose_endian.h" */
67/* #endif */
68#ifdef HAVE_OSE_ENDIAN_H
69#include "sys/ose_endian.h"
70#endif
71
72#ifdef OSE_IN_DOXYGEN
77#define OSE_CONF_DEBUG
78
86#define OSE_CONF_MEMPROFILE
/* conf_debug */
88#endif
89
90#ifdef OSE_IN_DOXYGEN
103#define OSE_CONF_WRAP_BUNDLE_PTR
/* conf_debug */
105#endif
106
107#ifdef OSE_CONF_WRAP_BUNDLE_PTR
108#define OSE_WRAP_BUNDLE_PTR
109#endif
110
111#ifdef OSE_CONF_MEMPROFILE
112#define OSE_MEMPROFILE
113#endif
114
128#ifdef OSE_CONF_HOT
129#define OSE_HOT OSE_CONF_HOT
130#else
131#define OSE_HOT
132#endif
133
144#ifdef ESP_PLATFORM
145#include <stddef.h>
146void *ose_memmove(void *dst, const void *src, size_t n);
147#else
148#define ose_memmove memmove
149#endif
150
166#ifdef OSE_CONF_VALIDATE_VM_STEP
167#define OSE_VALIDATE_VM_STEP
168#endif
169
171#ifdef OSE_CONF_DEBUG
172#ifdef NDEBUG
173#undef NDEBUG
174#endif
175#ifndef OSE_DEBUG
176#define OSE_DEBUG
177#endif
178#ifndef OSE_WRAP_BUNDLE_PTR
179#define OSE_WRAP_BUNDLE_PTR
180#endif
181#ifndef OSE_MEMPROFILE
182#define OSE_MEMPROFILE
183#endif
184#else
185#ifndef NDEBUG
186#define NDEBUG
187#endif
188#endif
/* DOXYGEN_SKIP */
190
196#if defined (__unix__) \
197 || ( defined (__APPLE__) \
198 && defined (__MACH__) ) \
199 || defined (__EMSCRIPTEN__)
200#include <arpa/inet.h>
201#elif defined (_WIN32) || defined (_WIN64)
202#include <Windows.h>
203#include <Winsock.h>
204#else
205
206#ifndef htonl
207#define OSE_NEED_HTONL
208int32_t htonl(int32_t x);
209#define OSE_BYTE_SWAP32(x) \
210 ((((x) & 0xff000000) >> 24) | \
211 (((x) & 0x00ff0000) >> 8) | \
212 (((x) & 0x0000ff00) << 8) | \
213 (((x) & 0x000000ff) << 24))
214#endif
215
216#ifndef ntohl
217#define OSE_NEED_NTOHL
218int32_t ntohl(int32_t x);
219#define OSE_BYTE_SWAP64(x) \
220 ((((x) & 0xff00000000000000LL) >> 56) | \
221 (((x) & 0x00ff000000000000LL) >> 40) | \
222 (((x) & 0x0000ff0000000000LL) >> 24) | \
223 (((x) & 0x000000ff00000000LL) >> 8) | \
224 (((x) & 0x00000000ff000000LL) << 8) | \
225 (((x) & 0x0000000000ff0000LL) << 24) | \
226 (((x) & 0x000000000000ff00LL) << 40) | \
227 (((x) & 0x00000000000000ffLL) << 56))
228#endif
229#endif
230
231
232#define ose_htonl(x) htonl(x)
233#define ose_ntohl(x) ntohl(x)
234#ifndef htonll
235#define ose_htonll(x) \
236 ((1==ose_htonl(1)) \
237 ? (x) \
238 : ((uint64_t)ose_htonl((x) \
239 & 0xFFFFFFFF) << 32) \
240 | ose_htonl((x) >> 32))
241#else
242#define ose_htonll(x) htonll(x)
243#endif
244
245#ifndef ntohll
246#define ose_ntohll(x) \
247 ((1==ose_ntohl(1)) \
248 ? (x) \
249 : ((uint64_t)ose_ntohl((x) \
250 & 0xFFFFFFFF) << 32) \
251 | ose_ntohl((x) >> 32))
252#else
253#define ose_ntohll(x) ntohll(x)
254#endif
255
256#define OSE_INT32_TO_BUF_SWAP(buf, i) \
257 { \
258 (buf)[0] = ((i) & 0xFF000000) >> 24; \
259 (buf)[1] = ((i) & 0x00FF0000) >> 16; \
260 (buf)[2] = ((i) & 0x0000FF00) >> 8; \
261 (buf)[3] = ((i) & 0x000000FF); \
262 }
263#define OSE_INT32_TO_BUF(buf, i) memcpy((buf), &(i), 4);
264
265#define OSE_INT64_TO_BUF_SWAP(buf, i) \
266 { \
267 (buf)[0] = ((i) & 0xFF00000000000000) >> 56; \
268 (buf)[1] = ((i) & 0x00FF000000000000) >> 48; \
269 (buf)[2] = ((i) & 0x0000FF0000000000) >> 40; \
270 (buf)[3] = ((i) & 0x000000FF00000000) >> 32; \
271 (buf)[4] = ((i) & 0x00000000FF000000) >> 24; \
272 (buf)[5] = ((i) & 0x0000000000FF0000) >> 16; \
273 (buf)[6] = ((i) & 0x000000000000FF00) >> 8; \
274 (buf)[7] = ((i) & 0x00000000000000FF); \
275 }
276#define OSE_INT64_TO_BUF(buf, i) memcpy((buf), &(i), 8);
277
278#define OSE_BUF_TO_INT32_SWAP(buf, i) \
279 { \
280 i = (((uint64_t)b[0]) & 0xFF) << 24 \
281 | (((uint64_t)b[1]) & 0xFF) << 16 \
282 | (((uint64_t)b[2]) & 0xFF) << 8 \
283 | (((uint64_t)b[3]) & 0xFF); \
284 }
285#define OSE_BUF_TO_INT32(buf, i) memcpy(&(i), (buf), 4);
286
287#define OSE_BUF_TO_INT64_SWAP(buf, i) \
288 { \
289 i = (((uint64_t)b[0]) & 0xFF) << 56 \
290 | (((uint64_t)b[1]) & 0xFF) << 48 \
291 | (((uint64_t)b[2]) & 0xFF) << 40 \
292 | (((uint64_t)b[3]) & 0xFF) << 32 \
293 | (((uint64_t)b[4]) & 0xFF) << 24 \
294 | (((uint64_t)b[5]) & 0xFF) << 16 \
295 | (((uint64_t)b[6]) & 0xFF) << 8 \
296 | (((uint64_t)b[7]) & 0xFF); \
297 }
298#define OSE_BUF_TO_INT64(buf, i) memcpy(&(i), (buf), 8);
299
300#if defined(OSE_ENDIAN)
301#if OSE_ENDIAN == OSE_LITTLE_ENDIAN
302#define OSE_BYTE_SWAP32_INT_TO_BUF(buf, i)\
303 OSE_INT32_TO_BUF_SWAP(buf, i)
304#define OSE_BYTE_SWAP64_INT_TO_BUF(buf, i)\
305 OSE_INT64_TO_BUF_SWAP(buf, i)
306
307#define OSE_BYTE_SWAP32_BUF_TO_INT(buf, i)\
308 OSE_BUF_TO_INT32_SWAP(buf, i)
309#define OSE_BYTE_SWAP64_BUF_TO_INT(buf, i)\
310 OSE_BUF_TO_INT64_SWAP(buf, i)
311
312#else /* OSE_BIG_ENDIAN */
313
314#define OSE_BYTE_SWAP32_INT_TO_BUF(buf, i)\
315 OSE_INT32_TO_BUF(buf, i)
316#define OSE_BYTE_SWAP64_INT_TO_BUF(buf, i)\
317 OSE_INT64_TO_BUF(buf, i)
318
319#define OSE_BYTE_SWAP32_BUF_TO_INT(buf, i)\
320 OSE_BUF_TO_INT32(buf, i)
321#define OSE_BYTE_SWAP64_BUF_TO_INT(buf, i)\
322 OSE_BUF_TO_INT64(buf, i)
323
324#endif
325
326#else /* defined(OSE_ENDIAN) */
327
328#define OSE_BYTE_SWAP32_INT_TO_BUF(buf, i) \
329 if(ose_ntohl(1) == 1) \
330 { \
331 OSE_INT32_TO_BUF(buf, i); \
332 } \
333 else \
334 { \
335 OSE_INT32_TO_BUF_SWAP(buf, i); \
336 }
337#define OSE_BYTE_SWAP64_INT_TO_BUF(buf, i) \
338 if(ose_ntohl(1) == 1) \
339 { \
340 OSE_INT64_TO_BUF(buf, i); \
341 } \
342 else \
343 { \
344 OSE_INT64_TO_BUF_SWAP(buf, i); \
345 }
346
347#define OSE_BYTE_SWAP32_BUF_TO_INT(buf, i) \
348 if(ose_ntohl(1) == 1) \
349 { \
350 OSE_BUF_TO_INT32(buf, i); \
351 } \
352 else \
353 { \
354 OSE_BUF_TO_INT32_SWAP(buf, i); \
355 }
356#define OSE_BYTE_SWAP64_BUF_TO_INT(buf, i) \
357 if(ose_ntohl(1) == 1) \
358 { \
359 OSE_BUF_TO_INT64(buf, i); \
360 } \
361 else \
362 { \
363 OSE_BUF_TO_INT64_SWAP(buf, i); \
364 }
365
366#endif
/* DOXYGEN_SKIP */
368
372#ifdef OSE_WRAP_BUNDLE_PTR
373typedef struct ose_bundle
374{
375 char *b;
376} ose_bundle;
377#define ose_constbundle ose_bundle
378ose_bundle ose_makeBundle(const char * const p);
379#define ose_makeConstBundle ose_makeBundle
380#define ose_getBundlePtr(bundle) (bundle).b
381#else
385typedef char* ose_bundle;
389#define ose_makeBundle(charptr) charptr
394#define ose_makeConstBundle(charptr) charptr
398#define ose_getBundlePtr(bundle) (bundle)
402#define ose_constbundle const char *
403#endif
404
409typedef void (*ose_fn)(ose_bundle);
410
414#define OSE_INTPTR2 (sizeof(intptr_t) * 2)
415
420{
421 uint32_t sec;
422 uint32_t fsec;
423};
424
425#if !defined(__cplusplus) && !defined(SWIG)
426#ifndef __bool_true_false_are_defined
427typedef enum
428{
429 false = 0,
430 true
431} bool;
432#endif
433#endif
434
/* Types */
436
441#define OSETT_ID_ ','
442static const char OSETT_ID = OSETT_ID_;
443#define OSETTSTR_ID_ ","
444static const char * const OSETTSTR_ID = OSETTSTR_ID_;
445
446#define OSETT_INT32_ 'i'
447static const char OSETT_INT32 = OSETT_INT32_;
448#define OSETTSTR_INT32_ "i"
449static const char * const OSETTSTR_INT32 = OSETTSTR_INT32_;
450
451#define OSETT_FLOAT_ 'f'
452static const char OSETT_FLOAT = OSETT_FLOAT_;
453#define OSETTSTR_FLOAT_ "f"
454static const char * const OSETTSTR_FLOAT = OSETTSTR_FLOAT_;
455
456#define OSETT_STRING_ 's'
457static const char OSETT_STRING = OSETT_STRING_;
458#define OSETTSTR_STRING_ "s"
459static const char * const OSETTSTR_STRING = OSETTSTR_STRING_;
460
461#define OSETT_BLOB_ 'b'
462static const char OSETT_BLOB = OSETT_BLOB_;
463#define OSETTSTR_BLOB_ "b"
464static const char * const OSETTSTR_BLOB = OSETTSTR_BLOB_;
/* OSC 1.0 Types */
466
467#ifdef OSE_IN_DOXYGEN
472#define OSE_CONF_PROVIDE_TYPE_SYMBOL
473#define OSE_CONF_PROVIDE_TYPE_DOUBLE
474#define OSE_CONF_PROVIDE_TYPE_INT8
475#define OSE_CONF_PROVIDE_TYPE_UINT8
476#define OSE_CONF_PROVIDE_TYPE_INT16
477#define OSE_CONF_PROVIDE_TYPE_UINT16
478#define OSE_CONF_PROVIDE_TYPE_UINT32
479#define OSE_CONF_PROVIDE_TYPE_INT64
480#define OSE_CONF_PROVIDE_TYPE_UINT64
481#define OSE_CONF_PROVIDE_TYPE_TIMETAG
482#define OSE_CONF_PROVIDE_TYPE_TRUE
483#define OSE_CONF_PROVIDE_TYPE_FALSE
484#define OSE_CONF_PROVIDE_TYPE_NIL
485#define OSE_CONF_PROVIDE_TYPE_INFINITUM
/* conf_types */
487#endif /* OSE_IN_DOXYGEN */
488
493#ifdef OSE_CONF_PROVIDE_TYPE_SYMBOL
494#define OSE_PROVIDE_TYPE_SYMBOL
495#define OSETT_SYMBOL_ 'S'
496static const char OSETT_SYMBOL = OSETT_SYMBOL_;
497#define OSETTSTR_SYMBOL_ "S"
498static const char * const OSETTSTR_SYMBOL = OSETTSTR_SYMBOL_;
499#endif
500#ifdef OSE_CONF_PROVIDE_TYPE_DOUBLE
501#define OSE_PROVIDE_TYPE_DOUBLE
502#define OSETT_DOUBLE_ 'd'
503static const char OSETT_DOUBLE = OSETT_DOUBLE_;
504#define OSETTSTR_DOUBLE_ "d"
505static const char * const OSETTSTR_DOUBLE = OSETTSTR_DOUBLE_;
506#endif
507#ifdef OSE_CONF_PROVIDE_TYPE_INT8
508#define OSE_PROVIDE_TYPE_INT8
509#define OSETT_INT8_ 'c'
510static const char OSETT_INT8 = OSETT_INT8_;
511#define OSETTSTR_INT8_ "c"
512static const char * const OSETTSTR_INT8 = OSETTSTR_INT8_;
513#endif
514#ifdef OSE_CONF_PROVIDE_TYPE_UINT8
515#define OSE_PROVIDE_TYPE_UINT8
516#define OSETT_UINT8_ 'C'
517static const char OSETT_UINT8 = OSETT_UINT8_;
518#define OSETTSTR_UINT8_ "C"
519static const char * const OSETTSTR_UINT8 = OSETTSTR_UINT8_;
520#endif
521#ifdef OSE_CONF_PROVIDE_TYPE_INT16
522#define OSE_PROVIDE_TYPE_INT16
523#define OSETT_INT16_ 'u'
524static const char OSETT_INT16 = OSETT_INT16_;
525#define OSETTSTR_INT16_ "u"
526static const char * const OSETTSTR_INT16 = OSETTSTR_INT16_;
527#endif
528#ifdef OSE_CONF_PROVIDE_TYPE_UINT16
529#define OSE_PROVIDE_TYPE_UINT16
530#define OSETT_UINT16_ 'U'
531static const char OSETT_UINT16 = OSETT_UINT16_;
532#define OSETTSTR_UINT16_ "U"
533static const char * const OSETTSTR_UINT16 = OSETTSTR_UINT16_;
534#endif
535#ifdef OSE_CONF_PROVIDE_TYPE_UINT32
536#define OSE_PROVIDE_TYPE_UINT32
537#define OSETT_UINT32_ 'k'
538static const char OSETT_UINT32 = OSETT_UINT32_;
539#define OSETTSTR_UINT32_ "k"
540static const char * const OSETTSTR_UINT32 = OSETTSTR_UINT32_;
541#endif
542#ifdef OSE_CONF_PROVIDE_TYPE_INT64
543#define OSE_PROVIDE_TYPE_INT64
544#define OSETT_INT64_ 'h'
545static const char OSETT_INT64 = OSETT_INT64_;
546#define OSETTSTR_INT64_ "h"
547static const char * const OSETTSTR_INT64 = OSETTSTR_INT64_;
548#endif
549#ifdef OSE_CONF_PROVIDE_TYPE_UINT64
550#define OSE_PROVIDE_TYPE_UINT64
551#define OSETT_UINT64_ 'H'
552static const char OSETT_UINT64 = OSETT_UINT64_;
553#define OSETTSTR_UINT64_ "H"
554static const char * const OSETTSTR_UINT64 = OSETTSTR_UINT64_;
555#endif
556#ifdef OSE_CONF_PROVIDE_TYPE_TIMETAG
557#define OSE_PROVIDE_TYPE_TIMETAG
558#define OSETT_TIMETAG_ 't'
559static const char OSETT_TIMETAG = OSETT_TIMETAG_;
560#define OSETTSTR_TIMETAG_ "t"
561static const char * const OSETTSTR_TIMETAG = OSETTSTR_TIMETAG_;
562#endif
563#ifdef OSE_CONF_PROVIDE_TYPE_TRUE
564#define OSE_PROVIDE_TYPE_TRUE
565#define OSETT_TRUE_ 'T'
566static const char OSETT_TRUE = OSETT_TRUE_;
567#define OSETTSTR_TRUE_ "T"
568static const char * const OSETTSTR_TRUE = OSETTSTR_TRUE_;
569static const char * const ose_str_true = "/,/T";
570static const int32_t ose_strlen_true = 4;
571static const int32_t ose_pstrlen_true = 8;
572#endif
573#ifdef OSE_CONF_PROVIDE_TYPE_FALSE
574#define OSE_PROVIDE_TYPE_FALSE
575#define OSETT_FALSE_ 'F'
576static const char OSETT_FALSE = OSETT_FALSE_;
577#define OSETTSTR_FALSE_ "F"
578static const char * const OSETTSTR_FALSE = OSETTSTR_FALSE_;
579static const char * const ose_str_false = "/,/F";
580static const int32_t ose_strlen_false = 4;
581static const int32_t ose_pstrlen_false = 8;
582#endif
583#ifdef OSE_CONF_PROVIDE_TYPE_NIL
584#define OSE_PROVIDE_TYPE_NIL
585#define OSETT_NIL_ 'N'
586static const char OSETT_NIL = OSETT_NIL_;
587#define OSETTSTR_NIL_ "N"
588static const char * const OSETTSTR_NIL = OSETTSTR_NIL_;
589static const char * const ose_str_nil = "/,/N";
590static const int32_t ose_strlen_nil = 4;
591static const int32_t ose_pstrlen_nil = 8;
592#endif
593#ifdef OSE_CONF_PROVIDE_TYPE_INFINITUM
594#define OSE_PROVIDE_TYPE_INFINITUM
595#define OSETT_INFINITUM_ 'I'
596static const char OSETT_INFINITUM = OSETT_INFINITUM_;
597#define OSETTSTR_INFINITUM_ "I"
598static const char * const OSETTSTR_INFINITUM = OSETTSTR_INFINITUM_;
599static const char * const ose_str_infinitum = "/,/I";
600static const int32_t ose_strlen_infinitum = 4;
601static const int32_t ose_pstrlen_infinitum = 8;
602#endif
/* Extended Types */
604
605/* non-osc data types
606 these are never written into a bundle
607 (unless they are defined above) */
608#ifndef OSE_PROVIDE_TYPE_TRUE
609#define OSETT_TRUE_ 'T'
610static const char OSETT_TRUE = OSETT_TRUE_;
611#define OSETTSTR_TRUE_ "T"
612static const char * const OSETTSTR_TRUE = OSETTSTR_TRUE_;
613#endif
614
615#ifndef OSE_PROVIDE_TYPE_TRUE
616#define OSETT_FALSE_ 'F'
617static const char OSETT_FALSE = OSETT_FALSE_;
618#define OSETTSTR_FALSE_ "F"
619static const char * const OSETTSTR_FALSE = OSETTSTR_FALSE_;
620#endif
621
645#define OSETT_ALIGNEDPTR_ 'p'
646static const char OSETT_ALIGNEDPTR = OSETT_ALIGNEDPTR_;
647#define OSETTSTR_ALIGNEDPTR_ "p"
648static const char * const OSETTSTR_ALIGNEDPTR = OSETTSTR_ALIGNEDPTR_;
649
680#define OSETT_WILDPTR_ 'P'
681static const char OSETT_WILDPTR = OSETT_WILDPTR_;
682#define OSETTSTR_WILDPTR_ "P"
683static const char * const OSETTSTR_WILDPTR = OSETTSTR_WILDPTR_;
/* Extension type */
685
710#define OSETT_NOTYPETAG_ 0
711static const char OSETT_NOTYPETAG = OSETT_NOTYPETAG_;
712#define OSETTSTR_NOTYPETAG_ "0"
713static const char * const OSETTSTR_NOTYPETAG = OSETTSTR_NOTYPETAG_;
714
715#define OSETT_BUNDLE_ '|'
716static const char OSETT_BUNDLE = OSETT_BUNDLE_;
717#define OSETTSTR_BUNDLE_ "|"
718static const char * const OSETTSTR_BUNDLE = OSETTSTR_BUNDLE_;
719
720#define OSETT_MESSAGE_ '-'
721static const char OSETT_MESSAGE = OSETT_MESSAGE_;
722#define OSETTSTR_MESSAGE_ "-"
723static const char * const OSETTSTR_MESSAGE = OSETTSTR_MESSAGE_;
724
/* Internal types */
726
731#define OSE_BUNDLE_ID_ "#bundle\0"
732#define OSE_BUNDLE_ID_LEN_ 8
733#define OSE_TIMETAG_NULL_ "\0\0\0\0\0\0\0\0"
734#define OSE_TIMETAG_LEN_ 8
735static const char * const OSE_BUNDLE_ID = OSE_BUNDLE_ID_;
736static const int32_t OSE_BUNDLE_ID_LEN = OSE_BUNDLE_ID_LEN_;
737static const char * const OSE_TIMETAG_NULL = OSE_TIMETAG_NULL_;
738static const int32_t OSE_TIMETAG_LEN = OSE_TIMETAG_LEN_;
739static const char * const OSE_BUNDLE_HEADER =
740 OSE_BUNDLE_ID_ OSE_TIMETAG_NULL_;
741static const int32_t OSE_BUNDLE_HEADER_LEN =
742 (OSE_BUNDLE_ID_LEN_ + OSE_TIMETAG_LEN_);
743
744#define OSE_EMPTY_TYPETAG_STRING_ ",\0\0\0"
745static const char * const OSE_EMPTY_TYPETAG_STRING =
746 OSE_EMPTY_TYPETAG_STRING_;
747static const int32_t OSE_EMPTY_TYPETAG_STRING_LEN = 1;
748static const int32_t OSE_EMPTY_TYPETAG_STRING_SIZE = 4;
749
750/* undocumented for now -- consider dropping support for changing this */
751#ifdef OSE_CONF_ADDRESS_ANONVAL
752#define OSE_USER_ADDRESS_ANONVAL
753#include <stdint.h>
754static const char * const OSE_ADDRESS_ANONVAL =
755 OSE_CONF_ADDRESS_ANONVAL;
756static const int32_t OSE_ADDRESS_ANONVAL_LEN =
757 OSE_CONF_ADDRESS_ANONVAL_LEN;
758static const int32_t OSE_ADDRESS_ANONVAL_SIZE =
759 OSE_CONF_ADDRESS_ANONVAL_SIZE;
760static const char * const OSE_ADDRESS_ANONVAL_EMPTY_TYPETAG_STRING =
761 OSE_CONF_ADDRESS_ANONVAL OSE_EMPTY_TYPETAG_STRING_;
762
763#else /* OSE_CONF_ADDRESS_ANONVAL */
764
765#define OSE_ADDRESS_ANONVAL_ "\0\0\0\0"
766static const char * const OSE_ADDRESS_ANONVAL = OSE_ADDRESS_ANONVAL_;
767static const int32_t OSE_ADDRESS_ANONVAL_LEN = 0;
768static const int32_t OSE_ADDRESS_ANONVAL_SIZE = 4;
769static const char * const OSE_ADDRESS_ANONVAL_EMPTY_TYPETAG_STRING =
770 OSE_ADDRESS_ANONVAL_ OSE_EMPTY_TYPETAG_STRING_;
771#endif /* OSE_CONF_ADDRESS_ANONVAL */
772
773static const int32_t OSE_ADDRESS_MIN_LEN = 0;
774static const int32_t OSE_ADDRESS_MIN_PLEN = 4;
/* Constants */
776
782typedef int32_t (*ose_getPayloadItemLengthFn)(ose_constbundle, char,
783 int32_t, int32_t);
784typedef int32_t (*ose_getPayloadItemSizeFn)(ose_constbundle, char,
785 int32_t, int32_t);
786typedef int32_t (*ose_pprintPayloadItemFn)(ose_bundle, char,
787 int32_t, int32_t);
788typedef int32_t (*ose_fromStringFn)(ose_bundle, char,
789 int32_t, int32_t);
790
791#define OSE_TYPE_ADDR_PREFIX "/"
792
793#define OSE_TYPE_ADDR_PPRINTPAYLOADITEM_SUFFIX "/PPPI"
794#define OSE_PPRINTPAYLOADITEM_ADDR_ \
795 OSE_TYPE_ADDR_PREFIX "%c" OSE_TYPE_ADDR_PPRINTPAYLOADITEM_SUFFIX
796static const char * const OSE_PPRINTPAYLOADITEM_ADDR =
797 OSE_PPRINTPAYLOADITEM_ADDR_;
798static const int32_t OSE_PPRINTPAYLOADITEM_ADDR_LEN =
799 sizeof(OSE_PPRINTPAYLOADITEM_ADDR_);
800#ifndef OSE_PPRINTPAYLOADITEM_HOOK
801#define OSE_PPRINTPAYLOADITEM_HOOK ose_pprintPayloadItem_hook
802#else
803extern int32_t OSE_PPRINTPAYLOADITEM_HOOK (ose_bundle bundle,
804 char typetag,
805 int32_t msg_offset,
806 int32_t item_offset);
807#endif
808
809#define OSE_TYPE_ADDR_GETPAYLOADITEMLENGTH_SUFFIX "/GPIL"
810#define OSE_GETPAYLOADITEMLENGTH_ADDR_ \
811 OSE_TYPE_ADDR_PREFIX "%c" OSE_TYPE_ADDR_GETPAYLOADITEMLENGTH_SUFFIX
812static const char * const OSE_GETPAYLOADITEMLENGTH_ADDR =
813 OSE_GETPAYLOADITEMLENGTH_ADDR_;
814static const int32_t OSE_GETPAYLOADITEMLENGTH_ADDR_LEN =
815 sizeof(OSE_GETPAYLOADITEMLENGTH_ADDR_);
816#ifndef OSE_GETPAYLOADITEMLENGTH_HOOK
817#define OSE_GETPAYLOADITEMLENGTH_HOOK ose_getPayloadItemLength_hook
818#else
819extern int32_t OSE_GETPAYLOADITEMLENGTH_HOOK (ose_constbundle bundle,
820 char typetag,
821 int32_t msg_offset,
822 int32_t item_offset);
823#endif
824
825#define OSE_TYPE_ADDR_GETPAYLOADITEMSIZE_SUFFIX "/GPIS"
826#define OSE_GETPAYLOADITEMSIZE_ADDR_ \
827 OSE_TYPE_ADDR_PREFIX "%c" OSE_TYPE_ADDR_GETPAYLOADITEMSIZE_SUFFIX
828static const char * const OSE_GETPAYLOADITEMSIZE_ADDR =
829 OSE_GETPAYLOADITEMSIZE_ADDR_;
830static const int32_t OSE_GETPAYLOADITEMSIZE_ADDR_LEN =
831 sizeof(OSE_GETPAYLOADITEMSIZE_ADDR_);
832#ifndef OSE_GETPAYLOADITEMSIZE_HOOK
833#define OSE_GETPAYLOADITEMSIZE_HOOK ose_getPayloadItemSize_hook
834#else
835extern int32_t OSE_GETPAYLOADITEMSIZE_HOOK (ose_constbundle bundle,
836 char typetag,
837 int32_t msg_offset,
838 int32_t item_offset);
839#endif
840
841#define OSE_TYPE_ADDR_FROMSTRING_SUFFIX "/FRST"
842#define OSE_FROMSTRING_ADDR_ \
843 OSE_TYPE_ADDR_PREFIX "%c" OSE_TYPE_ADDR_FROMSTRING_SUFFIX
844static const char * const OSE_FROMSTRING_ADDR =
845 OSE_FROMSTRING_ADDR_;
846static const int32_t OSE_FROMSTRING_ADDR_LEN =
847 sizeof(OSE_FROMSTRING_ADDR_);
848#ifndef OSE_FROMSTRING_HOOK
849#define OSE_FROMSTRING_HOOK ose_fromString_hook
850#else
851extern int32_t OSE_FROMSTRING_HOOK (ose_bundle bundle,
852 char typetag,
853 const char * const str);
854#endif
855
856#ifndef OSE_REGISTERTYPE_HOOK
857#define OSE_REGISTERTYPE_HOOK ose_registerType_hook
858#else
859extern void
860OSE_REGISTERTYPE_HOOK (ose_bundle bundle,
861 char typetag,
862 const char * const getPayloadItemLength_addr,
863 ose_getPayloadItemLengthFn getPayloadItemLength,
864 const char * const getPayloadItemSize_addr,
865 ose_getPayloadItemSizeFn getPayloadItemSize,
866 const char * const pprintPayloadItem_addr,
867 ose_pprintPayloadItemFn pprintPayloadItem,
868 const char * const evalType_addr,
869 void (*evalType)(ose_bundle),
870 const char * const fromString_addr,
871 void (*fromString)(ose_bundle));
872#endif
873
/* Type Extensibility Hooks */
875
880const char *ose_version_string(void);
881const char *ose_debug_string(void);
882const char *ose_date_compiled_string(void);
/* Version */
884
885/*
886 This struct will be populated by the VM if present,
887 and used by the stdlib module to provide a message
888 for most of these.
889*/
891{
892 void (*ASSIGN)(ose_bundle);
893 void (*LOOKUP)(ose_bundle);
894 void (*FUNCALL)(ose_bundle);
895 void (*QUOTE)(ose_bundle);
896 void (*COPYREGISTERTOELEM)(ose_bundle);
897 void (*APPENDELEMTOREGISTER)(ose_bundle);
898 void (*REPLACEREGISTERWITHELEM)(ose_bundle);
899 void (*MOVEELEMTOREGISTER)(ose_bundle);
900 void (*TOTYPE)(ose_bundle);
901 void (*TOINT32)(ose_bundle);
902 void (*TOFLOAT)(ose_bundle);
903 void (*TOSTRING)(ose_bundle);
904 void (*TOBLOB)(ose_bundle);
905#ifdef OSE_PROVIDE_TYPE_SYMBOL
906 void (*TOSYMBOL)(ose_bundle);
907#endif
908#ifdef OSE_PROVIDE_TYPE_DOUBLE
909 void (*TODOUBLE)(ose_bundle);
910#endif
911#ifdef OSE_PROVIDE_TYPE_INT8
912 void (*TOINT8)(ose_bundle);
913#endif
914#ifdef OSE_PROVIDE_TYPE_UINT8
915 void (*TOUINT8)(ose_bundle);
916#endif
917#ifdef OSE_PROVIDE_TYPE_INT16
918 void (*TOINT16)(ose_bundle);
919#endif
920#ifdef OSE_PROVIDE_TYPE_UINT16
921 void (*TOUINT16)(ose_bundle);
922#endif
923#ifdef OSE_PROVIDE_TYPE_UINT32
924 void (*TOUINT32)(ose_bundle);
925#endif
926#ifdef OSE_PROVIDE_TYPE_INT64
927 void (*TOINT64)(ose_bundle);
928#endif
929#ifdef OSE_PROVIDE_TYPE_UINT64
930 void (*TOUINT64)(ose_bundle);
931#endif
932#ifdef OSE_PROVIDE_TYPE_TIMETAG
933 void (*TOTIMETAG)(ose_bundle);
934#endif
935#ifdef OSE_PROVIDE_TYPE_TRUE
936 void (*TOTRUE)(ose_bundle);
937#endif
938#ifdef OSE_PROVIDE_TYPE_FALSE
939 void (*TOFALSE)(ose_bundle);
940#endif
941#ifdef OSE_PROVIDE_TYPE_NIL
942 void (*TONIL)(ose_bundle);
943#endif
944#ifdef OSE_PROVIDE_TYPE_INFINITUM
945 void (*TOINFINITUM)(ose_bundle);
946#endif
947 void (*APPENDBYTE)(ose_bundle);
948 void (*RESPONDTOSTRING)(ose_bundle);
949 void (*PREINPUT)(ose_bundle);
950 void (*POSTINPUT)(ose_bundle);
951 void (*POPINPUTTOCONTROL)(ose_bundle);
952 void (*POSTCONTROL)(ose_bundle);
953 void (*EVALTYPE)(ose_bundle);
954};
955
956#ifdef __cplusplus
957}
958#endif
959
960#endif
#define ose_memmove
Move bytes that may overlap: memmove, or on the ESP32 a faster way.
Definition ose.h:148
#define OSETT_WILDPTR_
A bound function from another process, kept but not callable.
Definition ose.h:680
void(* ose_fn)(ose_bundle)
Function pointer for the basic OSE function that operates on a bundle.
Definition ose.h:409
Definition ose.h:374
Convenience struct for OSC/NTP timetags.
Definition ose.h:420
uint32_t sec
Definition ose.h:421
uint32_t fsec
Definition ose.h:422
Definition ose.h:891