21 #ifndef LE_PACK_H_INCLUDE_GUARD 22 #define LE_PACK_H_INCLUDE_GUARD 26 #if UINT32_MAX == UINTPTR_MAX || INT32_MAX == UINTPTR_MAX 27 # define IFGEN_PTR32 1 28 #elif UINT64_MAX == UINTPTR_MAX || INT64_MAX == UINTPTR_MAX 29 # define IFGEN_PTR64 1 31 # error "Unsupported pointer size -- only 32- and 64-bit are supported for local services." 41 typedef uint16_t le_pack_SemanticTag_t;
44 typedef enum le_pack_Type
46 LE_PACK_TYPE_POS_INTEGER = 0,
47 LE_PACK_TYPE_NEG_INTEGER = 1,
48 LE_PACK_TYPE_BYTE_STRING = 2,
49 LE_PACK_TYPE_TEXT_STRING = 3,
50 LE_PACK_TYPE_ITEM_ARRAY = 4,
51 LE_PACK_TYPE_SEMANTIC_TAG = 5,
52 LE_PACK_TYPE_BOOLEAN = 6,
53 LE_PACK_TYPE_DOUBLE = 7,
54 LE_PACK_TYPE_INDEF_END = 8,
55 LE_PACK_TYPE_INVALID_TYPE = 9,
65 #define LE_PACK_UINT8_MAX_SIZE (1 + sizeof(uint8_t)) 66 #define LE_PACK_UINT16_MAX_SIZE (1 + sizeof(uint16_t)) 67 #define LE_PACK_UINT32_MAX_SIZE (1 + sizeof(uint32_t)) 68 #define LE_PACK_UINT64_MAX_SIZE (1 + sizeof(uint64_t)) 69 #define LE_PACK_INT8_MAX_SIZE (1 + sizeof(int8_t)) 70 #define LE_PACK_INT16_MAX_SIZE (1 + sizeof(int16_t)) 71 #define LE_PACK_INT32_MAX_SIZE (1 + sizeof(int32_t)) 72 #define LE_PACK_INT64_MAX_SIZE (1 + sizeof(int64_t)) 73 #define LE_PACK_POS_INTEGER_MAX_SIZE (1 + sizeof(uint64_t)) 74 #define LE_PACK_NEG_INTEGER_MAX_SIZE (1 + sizeof(int64_t)) 75 #define LE_PACK_SEMANTIC_TAG_MAX_SIZE (1 + sizeof(le_pack_SemanticTag_t)) 76 #define LE_PACK_BOOL_MAX_SIZE (1) 77 #define LE_PACK_DOUBLE_MAX_SIZE (9) 78 #define LE_PACK_INDEF_END_MAX_SIZE (1) 79 #define LE_PACK_STR_HEADER_MAX_SIZE (1 + sizeof(uint32_t)) 80 #define LE_PACK_ARRAY_HEADER_MAX_SIZE (1 + sizeof(uint32_t)) 81 #define LE_PACK_INDEF_ARRAY_HEADER_MAX_SIZE (1) 82 #define LE_PACK_SIZE_POINTER_TUPLE_MAX_SIZE (1 + 1 + sizeof(size_t) + 1 + sizeof(intptr_t)) 85 #define LE_PACK_UINT8_MAX_SIZE (sizeof(uint8_t)) 86 #define LE_PACK_UINT16_MAX_SIZE (sizeof(uint16_t)) 87 #define LE_PACK_UINT32_MAX_SIZE (sizeof(uint32_t)) 88 #define LE_PACK_UINT64_MAX_SIZE (sizeof(uint64_t)) 89 #define LE_PACK_INT8_MAX_SIZE (sizeof(int8_t)) 90 #define LE_PACK_INT16_MAX_SIZE (sizeof(int16_t)) 91 #define LE_PACK_INT32_MAX_SIZE (sizeof(int32_t)) 92 #define LE_PACK_INT64_MAX_SIZE (sizeof(int64_t)) 93 #define LE_PACK_POS_INTEGER_MAX_SIZE (sizeof(uint64_t)) 94 #define LE_PACK_NEG_INTEGER_MAX_SIZE (sizeof(int64_t)) 95 #define LE_PACK_SEMANTIC_TAG_MAX_SIZE (0) 96 #define LE_PACK_BOOL_MAX_SIZE (sizeof(bool)) 97 #define LE_PACK_DOUBLE_MAX_SIZE (sizeof(double)) 98 #define LE_PACK_INDEF_END_MAX_SIZE (0) 99 #define LE_PACK_STR_HEADER_MAX_SIZE (sizeof(uint32_t)) 100 #define LE_PACK_ARRAY_HEADER_MAX_SIZE (sizeof(uint32_t)) 101 #define LE_PACK_INDEF_ARRAY_HEADER_MAX_SIZE (0) 102 #define LE_PACK_SIZE_POINTER_TUPLE_MAX_SIZE (sizeof(size_t) + sizeof(intptr_t)) 111 #define LE_PACK_REFERENCE (2001) 113 #define LE_PACK_IN_STRING_POINTER (2002) 114 #define LE_PACK_OUT_STRING_POINTER (2003) 115 #define LE_PACK_IN_BYTE_STR_POINTER (2004) 116 #define LE_PACK_OUT_BYTE_STR_POINTER (2005) 118 #define LE_PACK_CONTEXT_PTR_REFERENCE (2006) 119 #define LE_PACK_ASYNC_HANDLER_REFERENCE (2007) 121 #define LE_PACK_FILESTREAM_ID (2008) 122 #define LE_PACK_FILESTREAM_FLAG (2009) 123 #define LE_PACK_FILESTREAM_REQUEST_SIZE (2010) 125 #define LE_PACK_OUT_STRING_SIZE (2011) 126 #define LE_PACK_OUT_BYTE_STR_SIZE (2012) 128 #define LE_PACK_OUT_STRING_RESPONSE (2013) 129 #define LE_PACK_OUT_BYTE_STR_RESPONSE (2014) 137 #define _LE_PACK_CBOR_POS_INTEGER 0 138 #define _LE_PACK_CBOR_NEG_INTEGER 1 139 #define _LE_PACK_CBOR_BYTE_STRING 2 140 #define _LE_PACK_CBOR_TEXT_STRING 3 141 #define _LE_PACK_CBOR_ITEM_ARRAY 4 142 #define _LE_PACK_CBOR_PAIR_MAP 5 143 #define _LE_PACK_CBOR_SEMANTIC_TAG 6 144 #define _LE_PACK_CBOR_PRIMITVE 7 146 #define _LE_PACK_CBOR_COMPLEX_THRESHOLD 24 148 #define _LE_PACK_CBOR_PRIMITIVE_FALSE 20 149 #define _LE_PACK_CBOR_PRIMITIVE_TRUE 21 150 #define _LE_PACK_CBOR_PRIMITIVE_DOUBLE 27 151 #define _LE_PACK_CBOR_PRIMITIVE_BREAK 31 152 #define _LE_PACK_CBOR_PRIMITIVE_INDEFINITE 31 163 #define LE_PACK_PACK_SIMPLE_VALUE(value) \ 165 memcpy(*bufferPtr, &(value), sizeof(value)); \ 166 *bufferPtr = *bufferPtr + sizeof(value); \ 175 #define LE_PACK_PACK_SIMPLE_BUFFER(desPtr, length) \ 177 memcpy(*bufferPtr, desPtr, length); \ 178 *bufferPtr += length; \ 186 #define LE_PACK_PACK_TINY_ITEM(major, additional) \ 188 *(*bufferPtr) = ((major & 0x7) << 5) | (additional); \ 197 void _le_pack_packInteger
209 void _le_pack_packNegativeInteger
220 void _le_pack_packPositiveInteger
236 bool le_pack_PackSemanticTag
239 le_pack_SemanticTag_t value
245 le_pack_SemanticTag_t value
262 bool le_pack_PackInt8_rpc(uint8_t** bufferPtr, int8_t value);
263 bool le_pack_PackInt16_rpc(uint8_t** bufferPtr, int16_t value);
264 bool le_pack_PackInt32_rpc(uint8_t** bufferPtr, int32_t value);
265 bool le_pack_PackInt64_rpc(uint8_t** bufferPtr, int64_t value);
266 bool le_pack_PackDouble_rpc(uint8_t** bufferPtr,
double value);
267 bool le_pack_PackResult_rpc(uint8_t** bufferPtr,
le_result_t value);
268 bool le_pack_PackTaggedSizeUint32Tuple_rpc(uint8_t** bufferPtr,
size_t size, uint32_t value,
269 le_pack_SemanticTag_t tagId);
270 bool le_pack_PackTaggedSizeUint64Tuple_rpc(uint8_t** bufferPtr,
size_t size, uint64_t value,
271 le_pack_SemanticTag_t tagId);
272 bool le_pack_PackString_rpc(uint8_t** bufferPtr,
const char *stringPtr, uint32_t maxStringCount);
273 bool le_pack_PackIndefArrayHeader_rpc(uint8_t** bufferPtr);
274 bool le_pack_PackEndOfIndefArray_rpc(uint8_t** bufferPtr);
275 bool le_pack_PackBool_rpc(uint8_t** bufferPtr,
bool value);
293 _le_pack_packPositiveInteger(bufferPtr, value);
295 LE_PACK_PACK_SIMPLE_VALUE(value);
313 le_pack_SemanticTag_t tagId
317 le_pack_PackSemanticTag(bufferPtr, tagId);
321 le_pack_PackUint8(bufferPtr, value);
337 _le_pack_packPositiveInteger(bufferPtr, value);
339 LE_PACK_PACK_SIMPLE_VALUE(value);
358 le_pack_SemanticTag_t tagId
362 le_pack_PackSemanticTag(bufferPtr, tagId);
366 le_pack_PackUint16(bufferPtr, value);
382 _le_pack_packPositiveInteger(bufferPtr, value);
384 LE_PACK_PACK_SIMPLE_VALUE(value);
403 le_pack_SemanticTag_t tagId
407 le_pack_PackSemanticTag(bufferPtr, tagId);
411 le_pack_PackUint32(bufferPtr, value);
427 _le_pack_packPositiveInteger(bufferPtr, value);
429 LE_PACK_PACK_SIMPLE_VALUE(value);
447 le_pack_SemanticTag_t tagId
451 le_pack_PackSemanticTag(bufferPtr, tagId);
455 le_pack_PackUint64(bufferPtr, value);
471 return le_pack_PackInt8_rpc(bufferPtr, value);
473 LE_PACK_PACK_SIMPLE_VALUE(value);
491 le_pack_SemanticTag_t tagId
495 le_pack_PackSemanticTag(bufferPtr, tagId);
499 le_pack_PackInt8(bufferPtr, value);
515 return le_pack_PackInt16_rpc(bufferPtr, value);
517 LE_PACK_PACK_SIMPLE_VALUE(value);
535 le_pack_SemanticTag_t tagId
539 le_pack_PackSemanticTag(bufferPtr, tagId);
543 le_pack_PackInt16(bufferPtr, value);
559 return le_pack_PackInt32_rpc(bufferPtr, value);
561 LE_PACK_PACK_SIMPLE_VALUE(value);
579 le_pack_SemanticTag_t tagId
583 le_pack_PackSemanticTag(bufferPtr, tagId);
587 le_pack_PackInt32(bufferPtr, value);
603 return le_pack_PackInt64_rpc(bufferPtr, value);
605 LE_PACK_PACK_SIMPLE_VALUE(value);
623 le_pack_SemanticTag_t tagId
627 le_pack_PackSemanticTag(bufferPtr, tagId);
631 le_pack_PackInt64(bufferPtr, value);
649 _le_pack_packPositiveInteger(bufferPtr, value);
652 return le_pack_PackUint32(bufferPtr, value);
671 le_pack_SemanticTag_t tagId
675 return le_pack_PackTaggedSizeUint32Tuple_rpc(bufferPtr, size, value, tagId);
679 result = le_pack_PackSize(bufferPtr, size);
682 result = le_pack_PackUint32(bufferPtr, value);
703 le_pack_SemanticTag_t tagId
707 return le_pack_PackTaggedSizeUint64Tuple_rpc(bufferPtr, size, value, tagId);
711 result = le_pack_PackSize(bufferPtr, size);
714 result = le_pack_PackUint64(bufferPtr, value);
730 le_pack_SemanticTag_t tagId
734 uint32_t rawValue = (uint32_t)value;
735 return le_pack_PackTaggedSizeUint32Tuple(bufferPtr, size, rawValue, tagId);
737 uint64_t rawValue = (uint64_t)value;
738 return le_pack_PackTaggedSizeUint64Tuple(bufferPtr, size, rawValue, tagId);
740 # error "Unsupported pointer size -- only 32- and 64-bit are supported for local services." 756 le_pack_SemanticTag_t tagId
759 if (value > UINT32_MAX)
764 return le_pack_PackTaggedUint32(bufferPtr, value, tagId);
779 return le_pack_PackBool_rpc(bufferPtr, value);
783 uint8_t simpleValue = ((value)?1:0);
784 LE_PACK_PACK_SIMPLE_VALUE(simpleValue);
802 le_pack_SemanticTag_t tagId
806 le_pack_PackSemanticTag(bufferPtr, tagId);
810 le_pack_PackBool(bufferPtr, value);
826 _le_pack_packPositiveInteger(bufferPtr, value);
828 LE_PACK_PACK_SIMPLE_VALUE(value);
846 le_pack_SemanticTag_t tagId
850 le_pack_PackSemanticTag(bufferPtr, tagId);
854 le_pack_PackChar(bufferPtr, value);
870 return le_pack_PackDouble_rpc(bufferPtr, value);
872 LE_PACK_PACK_SIMPLE_VALUE(value);
890 le_pack_SemanticTag_t tagId
894 le_pack_PackSemanticTag(bufferPtr, tagId);
898 le_pack_PackDouble(bufferPtr, value);
914 return le_pack_PackResult_rpc(bufferPtr, value);
916 LE_PACK_PACK_SIMPLE_VALUE(value);
934 le_pack_SemanticTag_t tagId
938 le_pack_PackSemanticTag(bufferPtr, tagId);
942 le_pack_PackResult(bufferPtr, value);
958 le_pack_PackUint8(bufferPtr, value);
960 LE_PACK_PACK_SIMPLE_VALUE(value);
978 le_pack_SemanticTag_t tagId
982 le_pack_PackSemanticTag(bufferPtr, tagId);
986 le_pack_PackOnOff(bufferPtr, value);
990 #undef LE_PACK_PACK_SIMPLE_VALUE 1003 size_t refAsInt = (size_t)ref;
1008 if ((refAsInt <= UINT32_MAX) &&
1009 ((refAsInt & 0x01) ||
1012 #ifdef LE_CONFIG_RPC 1013 return le_pack_PackTaggedUint32(bufferPtr, (uint32_t)refAsInt, LE_PACK_REFERENCE);
1015 return le_pack_PackUint32(bufferPtr, (uint32_t)refAsInt);
1032 uint8_t** bufferPtr,
1034 le_pack_SemanticTag_t tagId
1037 size_t refAsInt = (size_t)ref;
1042 if ((refAsInt <= UINT32_MAX) &&
1043 ((refAsInt & 0x01) ||
1046 return le_pack_PackTaggedUint32(bufferPtr, (uint32_t)refAsInt, tagId);
1061 uint8_t** bufferPtr,
1065 #ifdef LE_CONFIG_RPC 1066 _le_pack_packInteger(bufferPtr, stringLen, _LE_PACK_CBOR_TEXT_STRING);
1069 return le_pack_PackUint32(bufferPtr, stringLen);
1081 uint8_t** bufferPtr,
1082 const char *stringPtr,
1083 uint32_t maxStringCount
1086 #ifdef LE_CONFIG_RPC 1087 return le_pack_PackString_rpc(bufferPtr, stringPtr, maxStringCount);
1094 uint32_t stringLen = strnlen(stringPtr, maxStringCount);
1096 if (stringPtr[stringLen] !=
'\0')
1100 le_pack_PackUint32(bufferPtr, stringLen);
1101 LE_PACK_PACK_SIMPLE_BUFFER(stringPtr, stringLen);
1117 uint8_t** bufferPtr,
1118 const char *stringPtr,
1119 uint32_t maxStringCount,
1120 le_pack_SemanticTag_t tagId
1123 #ifdef LE_CONFIG_RPC 1124 le_pack_PackSemanticTag(bufferPtr, tagId);
1128 return le_pack_PackString(bufferPtr, stringPtr, maxStringCount);
1141 uint8_t **bufferPtr,
1142 const void *arrayPtr,
1145 size_t arrayMaxCount
1151 if (arrayCount > arrayMaxCount)
1156 #ifdef LE_CONFIG_RPC 1157 _le_pack_packInteger(bufferPtr, arrayCount, _LE_PACK_CBOR_ITEM_ARRAY);
1159 LE_ASSERT(le_pack_PackSize(bufferPtr, arrayCount));
1174 #ifdef LE_CONFIG_RPC 1175 return le_pack_PackIndefArrayHeader_rpc(bufferPtr);
1192 #ifdef LE_CONFIG_RPC 1193 return le_pack_PackEndOfIndefArray_rpc(bufferPtr);
1207 uint8_t** bufferPtr,
1211 #ifdef LE_CONFIG_RPC 1212 _le_pack_packInteger(bufferPtr, length, _LE_PACK_CBOR_BYTE_STRING);
1215 return le_pack_PackUint32(bufferPtr, length);
1226 uint8_t** bufferPtr,
1227 const void* byteStringPtr,
1228 uint32_t byteStringCount
1231 #ifdef LE_CONFIG_RPC 1232 _le_pack_packInteger(bufferPtr, byteStringCount, _LE_PACK_CBOR_BYTE_STRING);
1234 le_pack_PackUint32(bufferPtr, byteStringCount);
1236 LE_PACK_PACK_SIMPLE_BUFFER(byteStringPtr, byteStringCount);
1247 uint8_t** bufferPtr,
1248 le_pack_SemanticTag_t tagId
1251 #ifdef LE_CONFIG_RPC 1252 le_pack_PackSemanticTag(bufferPtr, tagId);
1256 return le_pack_PackIndefArrayHeader(bufferPtr);
1270 uint8_t **bufferPtr,
1271 const void *arrayPtr,
1274 size_t arrayMaxCount,
1275 le_pack_SemanticTag_t tagId
1281 if (arrayCount > arrayMaxCount)
1285 #ifdef LE_CONFIG_RPC 1286 le_pack_PackSemanticTag(bufferPtr, tagId);
1290 LE_ASSERT(le_pack_PackArrayHeader(bufferPtr,arrayPtr, elementSize, arrayCount, arrayMaxCount));
1302 uint8_t** bufferPtr,
1303 void* byteStringPtr,
1304 uint32_t byteStringCount
1307 #ifdef LE_CONFIG_RPC 1308 _le_pack_packInteger(bufferPtr, byteStringCount, _LE_PACK_CBOR_BYTE_STRING);
1310 le_pack_PackUint32(bufferPtr, byteStringCount);
1312 LE_PACK_PACK_SIMPLE_BUFFER(byteStringPtr, byteStringCount);
1323 #define LE_PACK_PACKARRAY(bufferPtr, \ 1330 *(resultPtr) = le_pack_PackArrayHeader((bufferPtr), \ 1331 (arrayPtr), sizeof((arrayPtr)[0]), \ 1332 (arrayCount), (arrayMaxCount)); \ 1336 for (i = 0; i < (arrayCount); ++i) \ 1338 LE_ASSERT(packFunc((bufferPtr), (arrayPtr)[i])); \ 1340 *(resultPtr) = true; \ 1352 #define LE_PACK_PACKTAGGEDARRAY(bufferPtr, \ 1360 *(resultPtr) = le_pack_PackTaggedArrayHeader((bufferPtr), \ 1361 (arrayPtr), sizeof((arrayPtr)[0]), \ 1362 (arrayCount), (arrayMaxCount), tagId); \ 1366 for (i = 0; i < (arrayCount); ++i) \ 1368 LE_ASSERT(packFunc((bufferPtr), (arrayPtr)[i])); \ 1370 *(resultPtr) = true; \ 1381 #define LE_PACK_PACKSTRUCTARRAY(bufferPtr, \ 1388 *(resultPtr) = le_pack_PackArrayHeader((bufferPtr), \ 1389 (arrayPtr), sizeof((arrayPtr)[0]), \ 1390 (arrayCount), (arrayMaxCount)); \ 1394 for (i = 0; i < (arrayCount); ++i) \ 1396 LE_ASSERT(packFunc((bufferPtr), &((arrayPtr)[i]))); \ 1398 *(resultPtr) = true; \ 1406 #define LE_PACK_UNPACK_SIMPLE_VALUE(valuePtr) \ 1408 memcpy((valuePtr), *bufferPtr, sizeof(*(valuePtr))); \ 1409 *bufferPtr = (*bufferPtr) + sizeof(*(valuePtr)); \ 1418 #define LE_PACK_UNPACK_SIMPLE_BUFFER(srcPtr, length) \ 1420 memcpy((void*)(srcPtr), *bufferPtr, length); \ 1421 *bufferPtr += length; \ 1432 le_pack_Type_t le_pack_GetType
1435 ssize_t* additionalBytes
1443 #define LE_PACK_UNPACK_TINY_ITEM() \ 1445 uint8_t* buffer = *bufferPtr; \ 1446 major = (buffer[0] >> 5) & 0x7; \ 1447 additional = buffer[0] & 0x1F; \ 1456 bool _le_pack_unpackPositiveInteger(
1457 uint8_t** bufferPtr,
1459 unsigned int expectedMajor
1468 bool _le_pack_unpackInteger
1470 uint8_t** bufferPtr,
1474 #ifdef LE_CONFIG_RPC 1480 bool le_pack_UnpackUint8_rpc(uint8_t** bufferPtr, uint8_t* valuePtr);
1481 bool le_pack_UnpackUint16_rpc(uint8_t** bufferPtr, uint16_t* valuePtr);
1482 bool le_pack_UnpackUint32_rpc(uint8_t** bufferPtr, uint32_t* valuePtr);
1483 bool le_pack_UnpackUint64_rpc(uint8_t** bufferPtr, uint64_t* valuePtr);
1484 bool le_pack_UnpackInt8_rpc(uint8_t** bufferPtr, int8_t* valuePtr);
1485 bool le_pack_UnpackInt16_rpc(uint8_t** bufferPtr, int16_t* valuePtr);
1486 bool le_pack_UnpackInt32_rpc(uint8_t** bufferPtr, int32_t* valuePtr);
1487 bool le_pack_UnpackInt64_rpc(uint8_t** bufferPtr, int64_t* valuePtr);
1488 bool le_pack_UnpackBool_rpc(uint8_t** bufferPtr,
bool* valuePtr);
1489 bool le_pack_UnpackChar_rpc(uint8_t** bufferPtr,
char* valuePtr);
1490 bool le_pack_UnpackDouble_rpc(uint8_t** bufferPtr,
double* valuePtr);
1491 bool le_pack_UnpackResult_rpc(uint8_t** bufferPtr,
le_result_t* valuePtr);
1492 bool le_pack_UnpackOnOff_rpc(uint8_t** bufferPtr,
le_onoff_t* valuePtr);
1493 bool le_pack_UnpackStringHeader_rpc(uint8_t** bufferPtr,
size_t* stringSizePtr);
1494 bool le_pack_UnpackIndefArrayHeader_rpc(uint8_t** bufferPtr);
1495 bool le_pack_UnpackEndOfIndefArray_rpc(uint8_t** bufferPtr);
1496 bool le_pack_UnpackByteStringHeader_rpc(uint8_t** bufferPtr,
size_t* lengthPtr);
1497 bool le_pack_UnpackSizeUint32Tuple_rpc(uint8_t** bufferPtr,
size_t* sizePtr, uint32_t* valuePtr,
1498 le_pack_SemanticTag_t* semanticTagPtr);
1499 bool le_pack_UnpackSizeUint64Tuple_rpc(uint8_t** bufferPtr,
size_t* sizePtr, uint64_t* valuePtr,
1500 le_pack_SemanticTag_t* semanticTagPtr);
1501 bool le_pack_UnpackReference_rpc(uint8_t** bufferPtr,
void* refPtr,
1502 le_pack_SemanticTag_t* semanticTagPtr);
1503 bool le_pack_UnpackString_rpc(uint8_t** bufferPtr,
char *stringPtr, uint32_t bufferSize,
1504 uint32_t maxStringCount);
1505 bool le_pack_UnpackStringHeader_rpc(uint8_t** bufferPtr,
size_t* stringSizePtr);
1506 bool le_pack_UnpackArrayHeader_rpc(uint8_t **bufferPtr,
const void *arrayPtr,
size_t elementSize,
1507 size_t *arrayCountPtr,
size_t arrayMaxCount);
1508 bool le_pack_UnpackIndefArrayHeader_rpc(uint8_t** bufferPtr);
1509 bool le_pack_UnpackEndOfIndefArray_rpc(uint8_t** bufferPtr);
1510 bool le_pack_UnpackByteStringHeader_rpc(uint8_t** bufferPtr,
size_t* lengthPtr);
1511 bool le_pack_UnpackByteString_rpc(uint8_t** bufferPtr,
void *arrayPtr,
size_t *arrayCountPtr,
1512 size_t arrayMaxCount);
1522 bool le_pack_UnpackSemanticTag
1524 uint8_t** bufferPtr,
1525 le_pack_SemanticTag_t* tagIdPtr
1530 uint8_t** bufferPtr,
1531 le_pack_SemanticTag_t *tagIdPtr
1556 uint8_t** bufferPtr,
1557 le_pack_SemanticTag_t expectedTagId
1561 le_pack_SemanticTag_t tagId;
1562 return le_pack_UnpackSemanticTag(bufferPtr, &tagId) && (tagId == expectedTagId);
1579 uint8_t** bufferPtr,
1583 #ifdef LE_CONFIG_RPC 1584 return le_pack_UnpackUint8_rpc(bufferPtr, valuePtr);
1586 LE_PACK_UNPACK_SIMPLE_VALUE(valuePtr);
1598 uint8_t** bufferPtr,
1602 #ifdef LE_CONFIG_RPC 1603 return le_pack_UnpackUint16_rpc(bufferPtr, valuePtr);
1605 LE_PACK_UNPACK_SIMPLE_VALUE(valuePtr);
1617 uint8_t** bufferPtr,
1621 #ifdef LE_CONFIG_RPC 1622 return le_pack_UnpackUint32_rpc(bufferPtr, valuePtr);
1624 LE_PACK_UNPACK_SIMPLE_VALUE(valuePtr);
1636 uint8_t** bufferPtr,
1640 #ifdef LE_CONFIG_RPC 1641 return le_pack_UnpackUint64_rpc(bufferPtr, valuePtr);
1643 LE_PACK_UNPACK_SIMPLE_VALUE(valuePtr);
1655 uint8_t** bufferPtr,
1659 #ifdef LE_CONFIG_RPC 1660 return le_pack_UnpackInt8_rpc(bufferPtr, valuePtr);
1662 LE_PACK_UNPACK_SIMPLE_VALUE(valuePtr);
1674 uint8_t** bufferPtr,
1678 #ifdef LE_CONFIG_RPC 1679 return le_pack_UnpackInt16_rpc(bufferPtr, valuePtr);
1681 LE_PACK_UNPACK_SIMPLE_VALUE(valuePtr);
1693 uint8_t** bufferPtr,
1697 #ifdef LE_CONFIG_RPC 1698 return le_pack_UnpackInt32_rpc(bufferPtr, valuePtr);
1700 LE_PACK_UNPACK_SIMPLE_VALUE(valuePtr);
1712 uint8_t** bufferPtr,
1716 #ifdef LE_CONFIG_RPC 1717 return le_pack_UnpackInt64_rpc(bufferPtr, valuePtr);
1719 LE_PACK_UNPACK_SIMPLE_VALUE(valuePtr);
1734 uint8_t **bufferPtr,
1740 if (!le_pack_UnpackUint32(bufferPtr, &rawValue))
1745 *valuePtr = rawValue;
1758 uint8_t** bufferPtr,
1760 le_pack_SemanticTag_t tagId
1763 #ifdef LE_CONFIG_RPC 1764 if (!le_pack_CheckSemanticTag(bufferPtr, tagId))
1769 return le_pack_UnpackUint8_rpc(bufferPtr, valuePtr);
1773 LE_PACK_UNPACK_SIMPLE_VALUE(valuePtr);
1786 uint8_t** bufferPtr,
1788 le_pack_SemanticTag_t tagId
1791 #ifdef LE_CONFIG_RPC 1792 if (!le_pack_CheckSemanticTag(bufferPtr, tagId))
1797 return le_pack_UnpackUint16_rpc(bufferPtr, valuePtr);
1801 LE_PACK_UNPACK_SIMPLE_VALUE(valuePtr);
1814 uint8_t** bufferPtr,
1816 le_pack_SemanticTag_t tagId
1819 #ifdef LE_CONFIG_RPC 1820 if (!le_pack_CheckSemanticTag(bufferPtr, tagId))
1825 return le_pack_UnpackUint32_rpc(bufferPtr, valuePtr);
1829 LE_PACK_UNPACK_SIMPLE_VALUE(valuePtr);
1842 uint8_t** bufferPtr,
1844 le_pack_SemanticTag_t tagId
1847 #ifdef LE_CONFIG_RPC 1848 if (!le_pack_CheckSemanticTag(bufferPtr, tagId))
1853 return le_pack_UnpackUint64_rpc(bufferPtr, valuePtr);
1857 LE_PACK_UNPACK_SIMPLE_VALUE(valuePtr);
1870 uint8_t** bufferPtr,
1872 le_pack_SemanticTag_t tagId
1875 #ifdef LE_CONFIG_RPC 1876 if (!le_pack_CheckSemanticTag(bufferPtr, tagId))
1881 return le_pack_UnpackInt8_rpc(bufferPtr, valuePtr);
1885 LE_PACK_UNPACK_SIMPLE_VALUE(valuePtr);
1898 uint8_t** bufferPtr,
1900 le_pack_SemanticTag_t tagId
1903 #ifdef LE_CONFIG_RPC 1904 if (!le_pack_CheckSemanticTag(bufferPtr, tagId))
1909 return le_pack_UnpackInt16_rpc(bufferPtr, valuePtr);
1913 LE_PACK_UNPACK_SIMPLE_VALUE(valuePtr);
1926 uint8_t** bufferPtr,
1928 le_pack_SemanticTag_t tagId
1931 #ifdef LE_CONFIG_RPC 1932 if (!le_pack_CheckSemanticTag(bufferPtr, tagId))
1937 return le_pack_UnpackInt32_rpc(bufferPtr, valuePtr);
1941 LE_PACK_UNPACK_SIMPLE_VALUE(valuePtr);
1954 uint8_t** bufferPtr,
1956 le_pack_SemanticTag_t tagId
1959 #ifdef LE_CONFIG_RPC 1960 if (!le_pack_CheckSemanticTag(bufferPtr, tagId))
1965 return le_pack_UnpackInt64_rpc(bufferPtr, valuePtr);
1969 LE_PACK_UNPACK_SIMPLE_VALUE(valuePtr);
1985 uint8_t **bufferPtr,
1987 le_pack_SemanticTag_t tagId
1992 if (!le_pack_CheckSemanticTag(bufferPtr, tagId))
1997 if (!le_pack_UnpackUint32(bufferPtr, &rawValue))
2002 *valuePtr = rawValue;
2015 uint8_t** bufferPtr,
2018 le_pack_SemanticTag_t* semanticTagPtr
2021 #ifdef LE_CONFIG_RPC 2022 return le_pack_UnpackSizeUint32Tuple_rpc(bufferPtr, sizePtr, valuePtr, semanticTagPtr);
2026 result = le_pack_UnpackSize(bufferPtr, sizePtr);
2029 result = le_pack_UnpackUint32(bufferPtr, valuePtr);
2044 uint8_t** bufferPtr,
2047 le_pack_SemanticTag_t* semanticTagPtr
2050 #ifdef LE_CONFIG_RPC 2051 return le_pack_UnpackSizeUint64Tuple_rpc(bufferPtr, sizePtr, valuePtr, semanticTagPtr);
2055 result = le_pack_UnpackSize(bufferPtr, sizePtr);
2058 result = le_pack_UnpackUint64(bufferPtr, valuePtr);
2071 uint8_t** bufferPtr,
2074 le_pack_SemanticTag_t* semanticTagPtr
2078 uint32_t* rawValuePtr = (uint32_t*)valuePtr;
2079 return le_pack_UnpackSizeUint32Tuple(bufferPtr, sizePtr, rawValuePtr, semanticTagPtr);
2081 uint64_t* rawValuePtr = (uint64_t*)valuePtr;
2082 return le_pack_UnpackSizeUint64Tuple(bufferPtr, sizePtr, rawValuePtr, semanticTagPtr);
2084 # error "Unsupported pointer size -- only 32- and 64-bit are supported for local services." 2098 uint8_t** bufferPtr,
2103 #ifdef LE_CONFIG_RPC 2104 return le_pack_UnpackBool_rpc(bufferPtr, valuePtr);
2108 uint8_t simpleValue;
2110 memcpy(&simpleValue, *bufferPtr,
sizeof(simpleValue));
2112 *bufferPtr = ((uint8_t* )*bufferPtr) +
sizeof(simpleValue);
2115 *valuePtr = !!simpleValue;
2127 uint8_t** bufferPtr,
2131 #ifdef LE_CONFIG_RPC 2132 return le_pack_UnpackChar_rpc(bufferPtr, valuePtr);
2134 LE_PACK_UNPACK_SIMPLE_VALUE(valuePtr);
2146 uint8_t** bufferPtr,
2150 #ifdef LE_CONFIG_RPC 2151 return le_pack_UnpackDouble_rpc(bufferPtr, valuePtr);
2153 LE_PACK_UNPACK_SIMPLE_VALUE(valuePtr);
2165 uint8_t** bufferPtr,
2169 #ifdef LE_CONFIG_RPC 2170 return le_pack_UnpackResult_rpc(bufferPtr, valuePtr);
2172 LE_PACK_UNPACK_SIMPLE_VALUE(valuePtr);
2184 uint8_t** bufferPtr,
2188 #ifdef LE_CONFIG_RPC 2189 return le_pack_UnpackOnOff_rpc(bufferPtr, valuePtr);
2191 LE_PACK_UNPACK_SIMPLE_VALUE(valuePtr);
2196 #undef LE_PACK_UNPACK_SIMPLE_VALUE 2205 uint8_t** bufferPtr,
2207 le_pack_SemanticTag_t* semanticTagPtr
2210 #ifdef LE_CONFIG_RPC 2211 return le_pack_UnpackReference_rpc(bufferPtr, refPtr, semanticTagPtr);
2215 if (!le_pack_UnpackUint32(bufferPtr, &refAsInt))
2222 if ((refAsInt & 0x01) ||
2226 *(
void **)refPtr = (
void *)(size_t)refAsInt;
2243 uint8_t** bufferPtr,
2244 size_t* stringSizePtr
2247 #ifdef LE_CONFIG_RPC 2248 return le_pack_UnpackStringHeader_rpc(bufferPtr, stringSizePtr);
2250 if (!le_pack_UnpackSize(bufferPtr, stringSizePtr))
2265 uint8_t** bufferPtr,
2267 uint32_t bufferSize,
2268 uint32_t maxStringCount
2271 #ifdef LE_CONFIG_RPC 2272 return le_pack_UnpackString_rpc(bufferPtr, stringPtr, bufferSize, maxStringCount);
2275 uint32_t stringSize;
2276 if (!le_pack_UnpackUint32(bufferPtr, &stringSize))
2280 if ((stringSize > maxStringCount) ||
2281 (stringSize > bufferSize))
2300 memcpy(stringPtr, *bufferPtr, stringSize);
2301 stringPtr[stringSize] =
'\0';
2303 *bufferPtr = *bufferPtr + stringSize;
2319 uint8_t **bufferPtr,
2320 const void *arrayPtr,
2322 size_t *arrayCountPtr,
2323 size_t arrayMaxCount
2326 #ifdef LE_CONFIG_RPC 2327 return le_pack_UnpackArrayHeader_rpc(bufferPtr, arrayPtr, elementSize, arrayCountPtr,
2331 LE_ASSERT(le_pack_UnpackSize(bufferPtr, arrayCountPtr));
2332 if (*arrayCountPtr > arrayMaxCount)
2339 return (*arrayCountPtr == 0);
2356 #ifdef LE_CONFIG_RPC 2357 return le_pack_UnpackIndefArrayHeader_rpc(bufferPtr);
2374 #ifdef LE_CONFIG_RPC 2375 return le_pack_UnpackEndOfIndefArray_rpc(bufferPtr);
2389 uint8_t** bufferPtr,
2393 #ifdef LE_CONFIG_RPC 2394 return le_pack_UnpackByteStringHeader_rpc(bufferPtr, lengthPtr);
2396 if (!le_pack_UnpackSize(bufferPtr, lengthPtr))
2411 uint8_t** bufferPtr,
2413 size_t *arrayCountPtr,
2414 size_t arrayMaxCount
2417 #ifdef LE_CONFIG_RPC 2418 return le_pack_UnpackByteString_rpc(bufferPtr, arrayPtr, arrayCountPtr, arrayMaxCount);
2420 le_pack_UnpackSize(bufferPtr, arrayCountPtr);
2421 if (*arrayCountPtr > arrayMaxCount)
2428 return (*arrayCountPtr == 0);
2432 LE_PACK_UNPACK_SIMPLE_BUFFER(arrayPtr, *arrayCountPtr);
2447 #define LE_PACK_UNPACKARRAY(bufferPtr, \ 2454 if (!le_pack_UnpackArrayHeader((bufferPtr), \ 2455 (arrayPtr), sizeof((arrayPtr)[0]), \ 2456 (arrayCountPtr), (arrayMaxCount))) \ 2458 *(resultPtr) = false; \ 2463 for (i = 0; i < *(arrayCountPtr); ++i) \ 2465 LE_ASSERT(unpackFunc((bufferPtr), &(arrayPtr)[i])); \ 2467 *(resultPtr) = true; \ 2481 #define LE_PACK_UNPACKTAGGEDARRAY(bufferPtr, \ 2488 if (!le_pack_UnpackArrayHeader((bufferPtr), \ 2489 (arrayPtr), sizeof((arrayPtr)[0]), \ 2490 (arrayCountPtr), (arrayMaxCount))) \ 2492 *(resultPtr) = false; \ 2497 for (i = 0; i < *(arrayCountPtr); ++i) \ 2499 LE_ASSERT(unpackFunc((bufferPtr), &(arrayPtr)[i]), NULL); \ 2501 *(resultPtr) = true; \ 2512 #define LE_PACK_UNPACKSTRUCTARRAY(bufferPtr, \ 2518 LE_PACK_UNPACKARRAY((bufferPtr), (arrayPtr), (arrayCountPtr), \ 2519 (arrayMaxCount), (unpackFunc), (resultPtr)) le_result_t
Definition: le_basics.h:46
#define LE_UNUSED(v)
Definition: le_basics.h:369
#define LE_ASSERT(condition)
Definition: le_log.h:991
#define LE_DECLARE_INLINE
Definition: le_basics.h:320
le_onoff_t
Definition: le_basics.h:85