asoma.dev · the C reference for libose
libose
the C library every o.se host is built on
Loading...
Searching...
No Matches
ose_util.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
37#ifndef OSE_UTIL_H
38#define OSE_UTIL_H
39
40#ifdef __cplusplus
41extern "C" {
42#endif
43
44#include <inttypes.h>
45#include <stdarg.h>
46#include "ose.h"
47
61#define ose_pnbytes(n) (((n) + OSE_ALIGN_) & ~(OSE_ALIGN_ - 1))
62/* The padded length of a typetag string of n tags: the comma, the tags,
63 the terminator, to the alignment. ",i" is 4 bytes; so is ",". */
64#define OSE_TYPETAGS_PLEN(n) ose_pnbytes((n) + 1)
65
74int32_t ose_pstrlen(const char * const s);
75
84bool ose_isAddressChar(char c);
85
94bool ose_isKnownTypetag(char typetag);
95
103bool ose_isStringType(char typetag);
104
112bool ose_isIntegerType(char typetag);
113
122bool ose_isFloatType(char typetag);
123
131bool ose_isNumericType(char typetag);
132
145bool ose_isUnitType(char typetag);
146
155bool ose_isBoolType(char typetag);
156
165bool ose_isBundle(ose_constbundle B);
166
167bool ose_blobContainsBundleAtOffset(ose_constbundle B,
168 const int32_t offset);
169bool ose_blobContainsBundle(ose_constbundle B);
170
180bool ose_bundleIsEmpty(ose_constbundle B);
181
190int32_t ose_getBundleElemCount(ose_constbundle B);
191
203int32_t ose_getBundleElemElemCount(ose_constbundle B,
204 int32_t offset);
205
217bool ose_bundleHasAtLeastNElems(ose_constbundle B,
218 int32_t n);
219
232char ose_getBundleElemType(ose_constbundle B, int32_t offset);
233
234
245char ose_readByte(ose_constbundle B, int32_t offset);
246
247
259int32_t ose_writeByte(ose_bundle B, int32_t offset, char i);
260
261
273int32_t ose_readInt32(ose_constbundle B, int32_t offset);
274
275
288int32_t ose_writeInt32(ose_bundle B, int32_t offset, int32_t i);
289
290
302float ose_readFloat(ose_constbundle B, int32_t offset);
303
316int32_t ose_writeFloat(ose_bundle B, int32_t offset, float f);
317
318
332const char *ose_readString(ose_constbundle B, int32_t offset);
333
334
346int32_t ose_getStringLen(ose_constbundle B, int32_t offset);
347
348
361int32_t ose_getPaddedStringLen(ose_constbundle B,
362 int32_t offset);
363
364
383 int32_t offset,
384 const char * const s,
385 int32_t slen,
386 int32_t slen_padded);
387
388int32_t ose_processEscapes(char *s);
389
406const char *ose_readBlob(ose_constbundle B, int32_t offset);
407
408
423int32_t ose_readBlobSize(ose_constbundle B, int32_t offset);
424
425
438#define ose_addToInt32(b, offset, amt) \
439 ose_writeInt32((b), \
440 (offset), \
441 ose_readInt32((b), (offset)) + (amt))
442
443
444
458int32_t ose_getBlobPaddingForNBytes(int32_t n);
459
472int32_t ose_getPaddedBlobSize(ose_constbundle B,
473 int32_t offset);
474
493const char *ose_readBlobPayload(ose_constbundle B,
494 int32_t offset);
495
514 int32_t offset,
515 int32_t blobsize,
516 const char * const blob);
517
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))
521#endif
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);
525#endif
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))
529#endif
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))
533#endif
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);
537#endif
538#ifdef OSE_PROVIDE_TYPE_UINT16
539uint16_t ose_readUInt16(ose_constbundle B, int32_t offset);
540int32_t ose_writeUInt16(ose_bundle B,
541 int32_t offset,
542 uint16_t i);
543#endif
544#ifdef OSE_PROVIDE_TYPE_UINT32
545uint32_t ose_readUInt32(ose_constbundle B, int32_t offset);
546int32_t ose_writeUInt32(ose_bundle B,
547 int32_t offset,
548 uint32_t i);
549#endif
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);
553#endif
554#ifdef OSE_PROVIDE_TYPE_UINT64
555uint64_t ose_readUInt64(ose_constbundle B, int32_t offset);
556int32_t ose_writeUInt64(ose_bundle B,
557 int32_t offset,
558 uint64_t i);
559#endif
560
574struct ose_timetag ose_readTimetag(ose_constbundle B,
575 int32_t offset);
576
591 int32_t offset,
592 uint32_t sec,
593 uint32_t fsec);
594
604double ose_timetagToDouble(struct ose_timetag tt);
605
613struct ose_timetag ose_doubleToTimetag(double d);
614
628void * const ose_readAlignedPtr_impl(const char * const b);
629
647void * const ose_readAlignedPtr(ose_constbundle B,
648 const int32_t offset);
649
661int32_t ose_writeAlignedPtr_impl(char *b,
662 const void * const ptr);
663
679 const int32_t offset,
680 const void * const ptr);
681
686#define OSE_ALIGNEDPTR_ITEM_SIZE ((int32_t)(OSE_SIZEWORD_LEN + 2 * sizeof(intptr_t)))
687
696int32_t ose_writeAlignedPtrItem_impl(char *b,
697 const void * const ptr,
698 const char * const name);
699
705int32_t ose_writeWildPtrItem_impl(char *b, const char *name);
706
710int32_t ose_wildPtrItemSize(const char *name);
711
715const char *ose_readAlignedPtrName(ose_constbundle B,
716 const int32_t item_offset);
717
724 const int32_t item_offset,
725 const char * const name);
726
730const char *ose_readWildPtrName(ose_constbundle B,
731 const int32_t item_offset);
732
756void ose_dropAtOffset(ose_bundle B, int32_t offset);
757
773int32_t ose_getLastBundleElemOffset(ose_constbundle B);
774
791int32_t ose_getBundleElemAddressOffset(ose_constbundle B,
792 int32_t elemoffset);
793
809int32_t ose_getBundleElemTTOffset(ose_constbundle B,
810 int32_t elemoffset);
811
827int32_t ose_getBundleElemPayloadOffset(ose_constbundle B,
828 int32_t elemoffset);
829
844int32_t ose_getFirstOffsetForMatch(ose_constbundle B,
845 const char * const addr);
846
866int32_t ose_getFirstOffsetForPMatch(ose_constbundle B,
867 const char * const addr);
868
883int32_t ose_getFirstOffsetForFullPMatch(ose_constbundle B,
884 const char * const addr);
885
889int32_t ose_getPayloadItemSize_hook(ose_constbundle B,
890 const char typetag,
891 const int32_t msg_offset,
892 const int32_t item_offset);
893
921int32_t ose_getPayloadItemSize(ose_constbundle B,
922 char typetag,
923 int32_t msg_offset,
924 int32_t item_offset);
925
929int32_t ose_getPayloadItemLength_hook(ose_constbundle B,
930 const char typetag,
931 const int32_t msg_offset,
932 const int32_t item_offset);
961int32_t ose_getPayloadItemLength(ose_constbundle B,
962 char typetag,
963 int32_t msg_offset,
964 int32_t item_offset);
965
1005void ose_getNthPayloadItem(ose_constbundle B,
1006 int32_t n,
1007 int32_t msg_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);
1013
1079 const int32_t offset,
1080 const char * const address,
1081 int32_t addresslen,
1082 ose_fn fn,
1083 const char * const name);
1084
1085#ifndef SWIGCSHARP
1086int32_t ose_writeMessage(ose_bundle B,
1087 int32_t offset,
1088 const char * const address,
1089 int32_t addresslen,
1090 int32_t n, ...);
1091#endif
1092
1098#ifndef SWIGCSHARP
1100 int32_t offset,
1101 const char * const address,
1102 int32_t addresslen,
1103 int32_t n,
1104 va_list ap);
1105#endif
1106
1116#ifndef SWIGCSHARP
1118 const char * const address,
1119 const int32_t addresslen,
1120 const int32_t n,
1121 ...);
1122#endif
1123
1129#ifndef SWIGCSHARP
1131 const char * const address,
1132 const int32_t addresslen,
1133 const int32_t n,
1134 va_list ap);
1135#endif
1136
1137int32_t ose_printTypeof0(ose_constbundle B,
1138 const int32_t offset,
1139 char *buf,
1140 int32_t buflen);
1141int32_t ose_printTypeof1(ose_constbundle B,
1142 const int32_t offset,
1143 char *buf,
1144 int32_t buflen);
1145int32_t ose_printTypeof2(ose_constbundle B,
1146 const int32_t offset,
1147 char *buf,
1148 int32_t buflen);
1149
1188int32_t ose_typechk0(ose_constbundle B,
1189 const char * const pattern);
1190
1208int32_t ose_typechk1(ose_constbundle B,
1209 const char * const pattern);
1210
1235int32_t ose_typechk2(ose_constbundle B,
1236 const char * const pattern);
1237
1252int32_t ose_typechk0_ex(ose_constbundle B,
1253 const char * const pattern,
1254 int32_t *elem,
1255 int32_t *item);
1256
1269int32_t ose_typechk1_ex(ose_constbundle B,
1270 const char * const pattern,
1271 int32_t *elem,
1272 int32_t *item);
1273
1298int32_t ose_typechk2_ex(ose_constbundle B,
1299 const char * const pattern,
1300 int32_t *elem,
1301 int32_t *item);
1304int32_t ose_fromString_hook(ose_bundle bundle,
1305 char typetag,
1306 const char * const str);
1307
1308void ose_registerType_hook(ose_bundle bundle,
1309 char typetag,
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,
1317 void (*evalType)(ose_bundle),
1318 const char * const fromString_addr,
1319 void (*fromString)(ose_bundle));
1320
1321/* SLIP framing lives in ose_slip.h now. */
1322
1323
1324/* The extern "C" block used to close HERE, leaving the three validators
1325 below outside it. From C++ they took C++ linkage and did not resolve
1326 against the C definitions -- so ose_validateBundle(),
1327 ose_validateBundleInternal() and ose_validateMessage() were unusable from
1328 every C++ host.
1329
1330 They are the boundary functions. Being unreachable from C++ meant the
1331 hosts most likely to be handed bytes off a socket were the ones that
1332 could not check them, and one such host's UDP read carried a
1333 "need to do a sanity check here!" comment where the call belongs. The
1334 block now closes at the end of the header, where it should have. */
1335
1364int32_t ose_validateBundle(const char * const bytes, const int32_t size);
1365
1395int32_t ose_validateBundleInternal(const char * const bytes,
1396 const int32_t size);
1397
1398int32_t ose_validateMessage(const char * const bytes, const int32_t size);
1401int32_t ose_validateMessageInternal(const char * const bytes,
1402 const int32_t size);
1403
1404#ifdef __cplusplus
1405}
1406#endif
1407
1408
1409
1410/* INLINE IN A RELEASE BUILD: ose_readInt32, ose_readByte,
1411 ose_bundleIsEmpty, ose_getBundleElemType and ose_getLastBundleElemOffset.
1412
1413 They are the most called functions in the VM and do almost nothing, and a
1414 call into another file cannot be inlined without link-time optimisation --
1415 which a host built as several libraries cannot have across them. Measured
1416 on one host's heaviest message path, seven of these inline took 20.7 to
1417 15.7 us; the whole of LTO took it to 13.2.
1418
1419 The functions are still defined and exported, for anything that takes
1420 their address or calls them from another language. A debug build calls
1421 them, and gets their asserts. OSE_INLINE_ACCESSORS_OFF turns this off. */
1422#if !defined(OSE_CONF_DEBUG) && !defined(OSE_INLINE_ACCESSORS_OFF)
1423#include <string.h>
1424#include "ose_errno.h"
1425#include "ose_context.h"
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)
1435{
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;
1439}
1440static inline int32_t ose_getLastBundleElemOffset_inline(ose_constbundle B)
1441{
1442 const int32_t bs = ose_readSize(B);
1443 int32_t o = OSE_BUNDLE_HEADER_LEN, s;
1444 if(bs == OSE_BUNDLE_HEADER_LEN)
1445 {
1446 return OSE_BUNDLE_HEADER_LEN;
1447 }
1448 s = ose_readInt32(B, o);
1449 while(o + s + OSE_SIZEWORD_LEN < bs)
1450 {
1451 if(s <= 0)
1452 {
1453 ose_context_set_status((ose_bundle)B, OSE_ERR_MALFORMED);
1454 return o;
1455 }
1456 o += s + OSE_SIZEWORD_LEN;
1457 s = ose_readInt32(B, o);
1458 }
1459 return o;
1460}
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)
1464#endif
1465
1466#endif
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
Definition ose.h:400
Convenience struct for OSC/NTP timetags.
Definition ose.h:446
uint32_t sec
Definition ose.h:447
uint32_t fsec
Definition ose.h:448