61#define ose_pnbytes(n) (((n) + OSE_ALIGN_) & ~(OSE_ALIGN_ - 1))
64#define OSE_TYPETAGS_PLEN(n) ose_pnbytes((n) + 1)
167bool ose_blobContainsBundleAtOffset(ose_constbundle
B,
168 const int32_t offset);
169bool ose_blobContainsBundle(ose_constbundle
B);
384 const char *
const s,
386 int32_t slen_padded);
388int32_t ose_processEscapes(
char *s);
438#define ose_addToInt32(b, offset, amt) \
439 ose_writeInt32((b), \
441 ose_readInt32((b), (offset)) + (amt))
516 const char *
const blob);
518#ifdef OSE_PROVIDE_TYPE_SYMBOL
519#define ose_readSymbol(b, o) ose_readString((b), (o))
520#define ose_writeSymbol(b, o, s) ose_writeString((b), (o), (s))
522#ifdef OSE_PROVIDE_TYPE_DOUBLE
523double ose_readDouble(ose_constbundle
B, int32_t offset);
524int32_t ose_writeDouble(
ose_bundle B, int32_t offset,
double f);
526#ifdef OSE_PROVIDE_TYPE_INT8
527#define ose_readInt8(b, o) ose_readInt32((b), (o))
528#define ose_writeInt8(b, o, i) ose_writeInt32((b), (o), (i))
530#ifdef OSE_PROVIDE_TYPE_UINT8
531#define ose_readUInt8(b, o) ose_readInt32((b), (o))
532#define ose_writeUInt8(b, o, i) ose_writeInt32((b), (o), (i))
534#ifdef OSE_PROVIDE_TYPE_INT16
535int16_t ose_readInt16(ose_constbundle
B, int32_t offset);
536int32_t ose_writeInt16(
ose_bundle B, int32_t offset, int16_t i);
538#ifdef OSE_PROVIDE_TYPE_UINT16
539uint16_t ose_readUInt16(ose_constbundle
B, int32_t offset);
544#ifdef OSE_PROVIDE_TYPE_UINT32
545uint32_t ose_readUInt32(ose_constbundle
B, int32_t offset);
550#ifdef OSE_PROVIDE_TYPE_INT64
551int64_t ose_readInt64(ose_constbundle
B, int32_t offset);
552int32_t ose_writeInt64(
ose_bundle B, int32_t offset, int64_t i);
554#ifdef OSE_PROVIDE_TYPE_UINT64
555uint64_t ose_readUInt64(ose_constbundle
B, int32_t offset);
648 const int32_t offset);
662 const void *
const ptr);
679 const int32_t offset,
680 const void *
const ptr);
686#define OSE_ALIGNEDPTR_ITEM_SIZE ((int32_t)(OSE_SIZEWORD_LEN + 2 * sizeof(intptr_t)))
697 const void *
const ptr,
698 const char *
const name);
716 const int32_t item_offset);
724 const int32_t item_offset,
725 const char *
const name);
731 const int32_t item_offset);
845 const char *
const addr);
867 const char *
const addr);
884 const char *
const addr);
889int32_t ose_getPayloadItemSize_hook(ose_constbundle
B,
891 const int32_t msg_offset,
892 const int32_t item_offset);
924 int32_t item_offset);
929int32_t ose_getPayloadItemLength_hook(ose_constbundle
B,
931 const int32_t msg_offset,
932 const int32_t item_offset);
964 int32_t item_offset);
1008 int32_t *typetags_offset,
1009 int32_t *num_typetags,
1010 int32_t *last_typetag_offset,
1011 int32_t *payload_offset,
1012 int32_t *last_payload_item_offset);
1079 const int32_t offset,
1080 const char *
const address,
1083 const char *
const name);
1088 const char *
const address,
1101 const char *
const address,
1118 const char *
const address,
1119 const int32_t addresslen,
1131 const char *
const address,
1132 const int32_t addresslen,
1137int32_t ose_printTypeof0(ose_constbundle
B,
1138 const int32_t offset,
1141int32_t ose_printTypeof1(ose_constbundle
B,
1142 const int32_t offset,
1145int32_t ose_printTypeof2(ose_constbundle
B,
1146 const int32_t offset,
1189 const char *
const pattern);
1209 const char *
const pattern);
1236 const char *
const pattern);
1253 const char *
const pattern,
1270 const char *
const pattern,
1299 const char *
const pattern,
1304int32_t ose_fromString_hook(
ose_bundle bundle,
1306 const char *
const str);
1310 const char *
const getPayloadItemLength_addr,
1311 ose_getPayloadItemLengthFn getPayloadItemLength,
1312 const char *
const getPayloadItemSize_addr,
1313 ose_getPayloadItemSizeFn getPayloadItemSize,
1314 const char *
const pprintPayloadItem_addr,
1315 ose_pprintPayloadItemFn pprintPayloadItem,
1316 const char *
const evalType_addr,
1318 const char *
const fromString_addr,
1396 const int32_t size);
1398int32_t ose_validateMessage(
const char *
const bytes,
const int32_t size);
1402 const int32_t size);
1422#if !defined(OSE_CONF_DEBUG) && !defined(OSE_INLINE_ACCESSORS_OFF)
1426static inline int32_t ose_readInt32_inline(ose_constbundle
B, int32_t o)
1427{
return ose_ntohl(*((
const int32_t *)(ose_getBundlePtr(
B) + o))); }
1428static inline char ose_readByte_inline(ose_constbundle
B, int32_t o)
1429{
return ose_getBundlePtr(
B)[o]; }
1430#define ose_readInt32(B, o) ose_readInt32_inline((B), (o))
1431#define ose_readByte(B, o) ose_readByte_inline((B), (o))
1432static inline bool ose_bundleIsEmpty_inline(ose_constbundle
B)
1433{
return ose_readSize(
B) <= OSE_BUNDLE_HEADER_LEN; }
1434static inline char ose_getBundleElemType_inline(ose_constbundle
B, int32_t o)
1436 const char *
const b = ose_getBundlePtr(
B) + o + OSE_SIZEWORD_LEN;
1437 return (b[0] == OSE_BUNDLE_ID_[0] && !memcmp(b, OSE_BUNDLE_ID, 8))
1438 ? OSETT_BUNDLE : OSETT_MESSAGE;
1440static inline int32_t ose_getLastBundleElemOffset_inline(ose_constbundle
B)
1442 const int32_t bs = ose_readSize(
B);
1443 int32_t o = OSE_BUNDLE_HEADER_LEN, s;
1444 if(bs == OSE_BUNDLE_HEADER_LEN)
1446 return OSE_BUNDLE_HEADER_LEN;
1449 while(o + s + OSE_SIZEWORD_LEN < bs)
1456 o += s + OSE_SIZEWORD_LEN;
1461#define ose_bundleIsEmpty(B) ose_bundleIsEmpty_inline(B)
1462#define ose_getBundleElemType(B, o) ose_getBundleElemType_inline((B), (o))
1463#define ose_getLastBundleElemOffset(B) ose_getLastBundleElemOffset_inline(B)
provides global definitions and types
void(* ose_fn)(ose_bundle)
Function pointer for the basic OSE function that operates on a bundle.
Definition ose.h:435
contains functions that structure an OSC bundle for use with other parts of this library
Status codes for context bundles.
@ OSE_ERR_MALFORMED
Definition ose_errno.h:50
#define B(...)
Instantiate a top-level OSC bundle.
Definition ose_test_ctosc.h:339
int32_t ose_getFirstOffsetForMatch(ose_bundle B, const char *const addr)
Get the offset of the first element whose address matches a string, using simple string comparison.
Definition ose_util.c:1389
int32_t ose_writeFnMessage(ose_bundle B, const int32_t offset, const char *const address, int32_t addresslen, ose_fn fn, const char *const name)
Write a message with arguments into a bundle at an offset.
Definition ose_stackops.c:608
int32_t ose_writeString(ose_bundle B, int32_t offset, const char *const s, int32_t slen, int32_t slen_padded)
Read a byte at an offset.
Definition ose_util.c:563
char ose_getBundleElemType(ose_bundle B, int32_t offset)
Get the type of a bundle element.
Definition ose_util.c:413
const char * ose_readAlignedPtrName(ose_bundle B, const int32_t item_offset)
The name of the 'p' item at item_offset, or NULL if it has none.
Definition ose_util.c:1142
int32_t ose_getStringLen(ose_bundle B, int32_t offset)
Get the length of a string at an offset.
Definition ose_util.c:525
int32_t ose_wildPtrItemSize(const char *name)
The bytes a 'P' item holding name occupies.
Definition ose_util.c:1137
char ose_readByte(ose_bundle B, int32_t offset)
Read a byte at an offset.
Definition ose_util.c:436
int32_t ose_getBundleElemPayloadOffset(ose_bundle B, int32_t elemoffset)
Get the offset in bytes of the payload of an element.
Definition ose_util.c:1366
const char * ose_readWildPtrName(ose_bundle B, const int32_t item_offset)
The name held by the 'P' item at item_offset.
Definition ose_util.c:1176
float ose_readFloat(ose_bundle B, int32_t offset)
Read a 32-bit float at an offset.
Definition ose_util.c:479
const char * ose_readBlob(ose_bundle B, int32_t offset)
Read a blob at an offset.
Definition ose_util.c:728
int32_t ose_typechk1(ose_bundle B, const char *const pattern)
Check a bundle's element types.
Definition ose_util.c:2783
void *const ose_readAlignedPtr(ose_bundle B, const int32_t offset)
Read a pointer at an offset.
Definition ose_util.c:1060
bool ose_isStringType(char typetag)
Determine whether a given character is a string type.
Definition ose_util.c:156
int32_t ose_writeFloat(ose_bundle B, int32_t offset, float f)
Write a 32-bit float at an offset.
Definition ose_util.c:492
int32_t ose_writeAlignedPtr_impl(char *b, const void *const ptr)
Write a pointer.
Definition ose_util.c:1074
int32_t ose_getFirstOffsetForFullPMatch(ose_bundle B, const char *const addr)
Get the offset of the first element whose address fully matches a string, using OSC pattern matching ...
Definition ose_util.c:1477
int32_t ose_typechk0(ose_bundle B, const char *const pattern)
Check the type of a bundle itself.
Definition ose_util.c:2778
int32_t ose_getBundleElemElemCount(ose_bundle B, int32_t offset)
Get the number of items in a bundle element.
Definition ose_util.c:355
int32_t ose_validateMessageInternal(const char *const bytes, const int32_t size)
ose_validateMessage() for the VM's own state: as ose_validateBundleInternal() is to ose_validateBundl...
Definition ose_util.c:3315
int32_t ose_getBundleElemTTOffset(ose_bundle B, int32_t elemoffset)
Get the offset in bytes of the typetag / timetag field of an element.
Definition ose_util.c:1350
bool ose_bundleIsEmpty(ose_bundle B)
Determine whether a bundle contains any elements.
Definition ose_util.c:316
int32_t ose_writeInt32(ose_bundle B, int32_t offset, int32_t i)
Write a 32-bit int at an offset.
Definition ose_util.c:467
const char * ose_readString(ose_bundle B, int32_t offset)
Read a string at an offset.
Definition ose_util.c:507
double ose_timetagToDouble(struct ose_timetag tt)
Convert a timetag to a double-precision float.
Definition ose_util.c:1030
const char * ose_readBlobPayload(ose_bundle B, int32_t offset)
Get a pointer to the payload of a blob at an offset.
Definition ose_util.c:790
int32_t ose_writeBlob(ose_bundle B, int32_t offset, int32_t blobsize, const char *const blob)
Write a blob at an offset.
Definition ose_util.c:801
bool ose_isBoolType(char typetag)
Determine whether a given character is either OSETT_TRUE or OSETT_FALSE.
Definition ose_util.c:251
int32_t ose_readBlobSize(ose_bundle B, int32_t offset)
Get the size of a blob.
Definition ose_util.c:737
int32_t ose_typechk0_ex(ose_bundle B, const char *const pattern, int32_t *elem, int32_t *item)
As ose_typechk0, additionally reporting where the mismatch was.
Definition ose_util.c:2760
int32_t ose_vcomputeMessageSize(ose_bundle B, const char *const address, const int32_t addresslen, const int32_t n, va_list ap)
Compute the size of a message.
Definition ose_util.c:1805
int32_t ose_writeAlignedPtr(ose_bundle B, const int32_t offset, const void *const ptr)
Write a pointer at an offset.
Definition ose_util.c:1087
struct ose_timetag ose_readTimetag(ose_bundle B, int32_t offset)
Read a timetag at an offset.
Definition ose_util.c:997
int32_t ose_typechk1_ex(ose_bundle B, const char *const pattern, int32_t *elem, int32_t *item)
As ose_typechk1, additionally reporting where the mismatch was.
Definition ose_util.c:2766
int32_t ose_getBundleElemAddressOffset(ose_bundle B, int32_t elemoffset)
Get the offset in bytes of the address of an element.
Definition ose_util.c:1339
bool ose_isAddressChar(char c)
Determine whether a given character is a valid OSC address character.
Definition ose_util.c:44
bool ose_isKnownTypetag(char typetag)
Determine whether a given character is a typetag known to the system.
Definition ose_util.c:74
void ose_getNthPayloadItem(ose_bundle B, int32_t n, int32_t msg_offset, int32_t *typetags_offset, int32_t *num_typetags, int32_t *last_typetag_offset, int32_t *payload_offset, int32_t *last_payload_item_offset)
Get the offset of the nth payload item of a message.
Definition ose_util.c:1727
int32_t ose_getLastBundleElemOffset(ose_bundle B)
Get the offset in bytes of the last bundle element.
Definition ose_util.c:1286
void ose_writeAlignedPtrName(ose_bundle B, const int32_t item_offset, const char *const name)
Rename the 'p' item at item_offset: for a message holding more than one pointer, whose address names ...
Definition ose_util.c:1159
int32_t ose_writeWildPtrItem_impl(char *b, const char *name)
Write a 'P' item: [n][name, padded], n the padded length.
Definition ose_util.c:1123
int32_t ose_vwriteMessage(ose_bundle B, int32_t offset, const char *const address, int32_t addresslen, int32_t n, va_list ap)
Write a message with arguments into a bundle at an offset.
Definition ose_util.c:1980
int32_t ose_getBundleElemCount(ose_bundle B)
Get the number of elements in a bundle.
Definition ose_util.c:334
bool ose_isBundle(ose_bundle B)
Determine whether the data pointed to contains a bundle or not.
Definition ose_util.c:281
int32_t ose_typechk2(ose_bundle B, const char *const pattern)
Check a bundle's element types and their contents.
Definition ose_util.c:2788
int32_t ose_getPaddedBlobSize(ose_bundle B, int32_t offset)
Get the padded size of a blob at an offset.
Definition ose_util.c:764
int32_t ose_getPayloadItemLength(ose_bundle B, char typetag, int32_t msg_offset, int32_t item_offset)
Calculate the length of a typed OSC item.
Definition ose_util.c:1626
bool ose_isNumericType(char typetag)
Determine whether a given character is a numeric type.
Definition ose_util.c:216
int32_t ose_writeByte(ose_bundle B, int32_t offset, char i)
Write a byte at an offset.
Definition ose_util.c:445
int32_t ose_pstrlen(const char *const s)
Get the padded length of a string.
Definition ose_util.c:38
int32_t ose_getBlobPaddingForNBytes(int32_t n)
Get the number of bytes required to pad a blob size to a multiple of 4 bytes.
Definition ose_util.c:746
void ose_dropAtOffset(ose_bundle B, int32_t offset)
Drop the last element in the bundle.
Definition ose_util.c:1184
int32_t ose_getFirstOffsetForPMatch(ose_bundle B, const char *const addr)
Get the offset of the first element whose pattern matches a string, using OSC pattern matching (see o...
Definition ose_util.c:1449
bool ose_isUnitType(char typetag)
Determine whether a given character is a unit type.
Definition ose_util.c:233
bool ose_isIntegerType(char typetag)
Determine whether a given character is an integer type.
Definition ose_util.c:170
bool ose_isFloatType(char typetag)
Determine whether a given character is a floating point type.
Definition ose_util.c:202
int32_t ose_writeAlignedPtrItem_impl(char *b, const void *const ptr, const char *const name)
Write a 'p' item: [2 x sizeof(intptr_t)][ptr][name].
Definition ose_util.c:1105
int32_t ose_getPaddedStringLen(ose_bundle B, int32_t offset)
Get the padded length of a string at an offset.
Definition ose_util.c:542
int32_t ose_readInt32(ose_bundle B, int32_t offset)
Read a 32-bit int at an offset.
Definition ose_util.c:458
int32_t ose_validateBundle(const char *const bytes, const int32_t size)
Check that bytes is a well formed OSC bundle, entirely within size bytes.
Definition ose_util.c:3296
int32_t ose_validateBundleInternal(const char *const bytes, const int32_t size)
As ose_validateBundle(), for a single message with no bundle header.
Definition ose_util.c:3305
bool ose_bundleHasAtLeastNElems(ose_bundle B, int32_t n)
Determine whether a bundle has a minimum number of elements.
Definition ose_util.c:386
void *const ose_readAlignedPtr_impl(const char *const b)
Read a pointer.
Definition ose_util.c:1049
int32_t ose_computeMessageSize(ose_bundle B, const char *const address, const int32_t addresslen, const int32_t n,...)
Compute the size of a message.
Definition ose_util.c:1959
int32_t ose_getPayloadItemSize(ose_bundle B, char typetag, int32_t msg_offset, int32_t item_offset)
Calculate the size of a typed OSC item.
Definition ose_util.c:1514
int32_t ose_writeTimetag(ose_bundle B, int32_t offset, uint32_t sec, uint32_t fsec)
Write a timetag at an offset.
Definition ose_util.c:1013
int32_t ose_typechk2_ex(ose_bundle B, const char *const pattern, int32_t *elem, int32_t *item)
As ose_typechk2, additionally reporting where the mismatch was.
Definition ose_util.c:2772
struct ose_timetag ose_doubleToTimetag(double d)
Convert a double-precision float to a timetag.
Definition ose_util.c:1036