\n
\n-
\n+
\n
\n
\n
\n
\n
\n
\n
\n@@ -66,754 +66,21 @@\n
\n
\n
\n
\n
\n
\n
\n-
\n-
\n-
\n-
\n-
\n-
\n-
\n-
\n-
\n-
\n-
\n-
\n-
37#ifdef CBOR_EXTERNAL_CFG \n-
\n-
\n-
\n-
41#include "tinycbor-version.h" \n-
\n-
43#define TINYCBOR_VERSION ((TINYCBOR_VERSION_MAJOR << 16) | (TINYCBOR_VERSION_MINOR << 8) | TINYCBOR_VERSION_PATCH) \n-
\n-
\n-
\n-
\n-
\n-
\n-
\n-
\n-
\n-
\n-
\n-
\n-
\n-
\n-
\n-
59# define SIZE_MAX ((size_t)-1) \n-
\n-
\n-
\n-
\n-
\n-
65#ifndef CBOR_PRIVATE_API \n-
66# define CBOR_PRIVATE_API \n-
\n-
68#ifndef CBOR_INLINE_API \n-
69# if defined(__cplusplus) \n-
70# define CBOR_INLINE inline \n-
71# define CBOR_INLINE_API inline \n-
\n-
73# define CBOR_INLINE_API static CBOR_INLINE \n-
\n-
75# define CBOR_INLINE __inline \n-
76# elif defined(__GNUC__) \n-
77# define CBOR_INLINE __inline__ \n-
78# elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L \n-
79# define CBOR_INLINE inline \n-
\n-
\n-
\n-
\n-
\n-
\n-
86typedef enum CborType {
\n-
87 CborIntegerType = 0x00,
\n-
88 CborByteStringType = 0x40,
\n-
89 CborTextStringType = 0x60,
\n-
\n-
\n-
\n-
93 CborSimpleType = 0xe0,
\n-
94 CborBooleanType = 0xf5,
\n-
\n-
96 CborUndefinedType = 0xf7,
\n-
97 CborHalfFloatType = 0xf9,
\n-
\n-
99 CborDoubleType = 0xfb,
\n-
\n-
101 CborInvalidType = 0xff
\n-
\n-
\n-
104typedef uint64_t CborTag;
\n-
105typedef enum CborKnownTags {
\n-
106 CborDateTimeStringTag = 0,
\n-
107 CborUnixTime_tTag = 1,
\n-
108 CborPositiveBignumTag = 2,
\n-
109 CborNegativeBignumTag = 3,
\n-
\n-
\n-
112 CborCOSE_Encrypt0Tag = 16,
\n-
113 CborCOSE_Mac0Tag = 17,
\n-
114 CborCOSE_Sign1Tag = 18,
\n-
115 CborExpectedBase64urlTag = 21,
\n-
116 CborExpectedBase64Tag = 22,
\n-
117 CborExpectedBase16Tag = 23,
\n-
118 CborEncodedCborTag = 24,
\n-
\n-
120 CborBase64urlTag = 33,
\n-
\n-
122 CborRegularExpressionTag = 35,
\n-
123 CborMimeMessageTag = 36,
\n-
124 CborCOSE_EncryptTag = 96,
\n-
125 CborCOSE_MacTag = 97,
\n-
126 CborCOSE_SignTag = 98,
\n-
127 CborSignatureTag = 55799
\n-
\n-
\n-
\n-
131#define CborDateTimeStringTag CborDateTimeStringTag \n-
132#define CborUnixTime_tTag CborUnixTime_tTag \n-
133#define CborPositiveBignumTag CborPositiveBignumTag \n-
134#define CborNegativeBignumTag CborNegativeBignumTag \n-
135#define CborDecimalTag CborDecimalTag \n-
136#define CborBigfloatTag CborBigfloatTag \n-
137#define CborCOSE_Encrypt0Tag CborCOSE_Encrypt0Tag \n-
138#define CborCOSE_Mac0Tag CborCOSE_Mac0Tag \n-
139#define CborCOSE_Sign1Tag CborCOSE_Sign1Tag \n-
140#define CborExpectedBase64urlTag CborExpectedBase64urlTag \n-
141#define CborExpectedBase64Tag CborExpectedBase64Tag \n-
142#define CborExpectedBase16Tag CborExpectedBase16Tag \n-
143#define CborEncodedCborTag CborEncodedCborTag \n-
144#define CborUrlTag CborUrlTag \n-
145#define CborBase64urlTag CborBase64urlTag \n-
146#define CborBase64Tag CborBase64Tag \n-
147#define CborRegularExpressionTag CborRegularExpressionTag \n-
148#define CborMimeMessageTag CborMimeMessageTag \n-
149#define CborCOSE_EncryptTag CborCOSE_EncryptTag \n-
150#define CborCOSE_MacTag CborCOSE_MacTag \n-
151#define CborCOSE_SignTag CborCOSE_SignTag \n-
152#define CborSignatureTag CborSignatureTag \n-
\n-
\n-
\n-
156typedef enum CborError {
\n-
\n-
\n-
\n-
\n-
161 CborErrorUnknownLength,
\n-
162 CborErrorAdvancePastEOF,
\n-
\n-
\n-
\n-
166 CborErrorGarbageAtEnd = 256,
\n-
167 CborErrorUnexpectedEOF,
\n-
168 CborErrorUnexpectedBreak,
\n-
169 CborErrorUnknownType,
\n-
170 CborErrorIllegalType,
\n-
171 CborErrorIllegalNumber,
\n-
172 CborErrorIllegalSimpleType,
\n-
173 CborErrorNoMoreStringChunks,
\n-
\n-
\n-
176 CborErrorUnknownSimpleType = 512,
\n-
\n-
178 CborErrorInappropriateTagForType,
\n-
179 CborErrorDuplicateObjectKeys,
\n-
180 CborErrorInvalidUtf8TextString,
\n-
181 CborErrorExcludedType,
\n-
182 CborErrorExcludedValue,
\n-
183 CborErrorImproperValue,
\n-
184 CborErrorOverlongEncoding,
\n-
185 CborErrorMapKeyNotString,
\n-
186 CborErrorMapNotSorted,
\n-
187 CborErrorMapKeysNotUnique,
\n-
\n-
\n-
190 CborErrorTooManyItems = 768,
\n-
191 CborErrorTooFewItems,
\n-
\n-
\n-
194 CborErrorDataTooLarge = 1024,
\n-
195 CborErrorNestingTooDeep,
\n-
196 CborErrorUnsupportedType,
\n-
197 CborErrorUnimplementedValidation,
\n-
\n-
\n-
200 CborErrorJsonObjectKeyIsAggregate = 1280,
\n-
201 CborErrorJsonObjectKeyNotString,
\n-
202 CborErrorJsonNotImplemented,
\n-
\n-
204 CborErrorOutOfMemory = (int) (~0U / 2 + 1),
\n-
205 CborErrorInternalError = (int) (~0U / 2)
\n-
\n-
\n-
\n-
\n-
\n-
\n-
212typedef enum CborEncoderAppendType
\n-
\n-
214 CborEncoderAppendCborData = 0,
\n-
215 CborEncoderAppendStringData = 1
\n-
216} CborEncoderAppendType;
\n-
\n-
218typedef CborError (*CborEncoderWriteFunction)(
void *,
const void *, size_t, CborEncoderAppendType);
\n-
\n-
\n-
\n-
222 CborIteratorFlag_WriterFunction = 0x01,
\n-
223 CborIteratorFlag_ContainerIsMap_ = 0x20
\n-
\n-
\n-
\n-
\n-
\n-
\n-
230 ptrdiff_t bytes_needed;
\n-
231 CborEncoderWriteFunction writer;
\n-
\n-
\n-
\n-
\n-
\n-
\n-
\n-
239static const size_t CborIndefiniteLength = SIZE_MAX;
\n-
\n-
241#ifndef CBOR_NO_ENCODER_API \n-
\n-
243CBOR_API
void cbor_encoder_init_writer(
CborEncoder *encoder, CborEncoderWriteFunction writer,
void *);
\n-
\n-
\n-
\n-
\n-
\n-
\n-
250CBOR_INLINE_API CborError cbor_encode_text_stringz(
CborEncoder *encoder,
const char *
string)
\n-
\n-
\n-
\n-
\n-
255CBOR_INLINE_API CborError cbor_encode_boolean(
CborEncoder *encoder,
bool value)
\n-
\n-
257CBOR_INLINE_API CborError cbor_encode_null(
CborEncoder *encoder)
\n-
\n-
259CBOR_INLINE_API CborError cbor_encode_undefined(
CborEncoder *encoder)
\n-
\n-
\n-
262CBOR_INLINE_API CborError cbor_encode_half_float(
CborEncoder *encoder,
const void *value)
\n-
\n-
264CBOR_API CborError cbor_encode_float_as_half_float(
CborEncoder *encoder,
float value);
\n-
265CBOR_INLINE_API CborError cbor_encode_float(
CborEncoder *encoder,
float value)
\n-
\n-
267CBOR_INLINE_API CborError cbor_encode_double(
CborEncoder *encoder,
double value)
\n-
\n-
\n-
\n-
\n-
\n-
\n-
\n-
275CBOR_INLINE_API uint8_t *_cbor_encoder_get_buffer_pointer(
const CborEncoder *encoder)
\n-
\n-
277 return encoder->data.ptr;
\n-
\n-
\n-
280CBOR_INLINE_API
size_t cbor_encoder_get_buffer_size(
const CborEncoder *encoder,
const uint8_t *buffer)
\n-
\n-
282 return (
size_t)(encoder->data.ptr - buffer);
\n-
\n-
\n-
285CBOR_INLINE_API
size_t cbor_encoder_get_extra_bytes_needed(
const CborEncoder *encoder)
\n-
\n-
287 return encoder->end ? 0 : (size_t)encoder->data.bytes_needed;
\n-
\n-
\n-
\n-
\n-
\n-
293enum CborParserGlobalFlags
\n-
\n-
295 CborParserFlag_ExternalSource = 0x01
\n-
\n-
\n-
298enum CborParserIteratorFlags
\n-
\n-
\n-
\n-
302 CborIteratorFlag_IntegerValueIs64Bit = 0x01,
\n-
303 CborIteratorFlag_IntegerValueTooLarge = 0x02,
\n-
\n-
\n-
306 CborIteratorFlag_NegativeInteger = 0x04,
\n-
\n-
\n-
309 CborIteratorFlag_BeforeFirstStringChunk = 0x04,
\n-
310 CborIteratorFlag_IteratingStringChunks = 0x08,
\n-
\n-
\n-
313 CborIteratorFlag_UnknownLength = 0x10,
\n-
\n-
\n-
\n-
317 CborIteratorFlag_ContainerIsMap = 0x20,
\n-
318 CborIteratorFlag_NextIsMapKey = 0x40
\n-
\n-
\n-
\n-
322struct CborParserOperations
\n-
\n-
324 bool (*can_read_bytes)(
void *token,
size_t len);
\n-
325 void *(*read_bytes)(
void *token,
void *dst,
size_t offset,
size_t len);
\n-
326 void (*advance_bytes)(
void *token,
size_t len);
\n-
327 CborError (*transfer_string)(
void *token,
const void **userptr,
size_t offset,
size_t len);
\n-
\n-
\n-
\n-
\n-
\n-
\n-
334 const struct CborParserOperations *ops;
\n-
\n-
336 enum CborParserGlobalFlags flags;
\n-
\n-
338typedef struct CborParser CborParser;
\n-
\n-
\n-
\n-
342 const CborParser *parser;
\n-
\n-
\n-
\n-
\n-
\n-
\n-
\n-
\n-
\n-
\n-
\n-
354#ifndef CBOR_NO_PARSER_API \n-
355CBOR_API CborError
cbor_parser_init(
const uint8_t *buffer,
size_t size, uint32_t flags, CborParser *parser,
CborValue *it);
\n-
356CBOR_API CborError cbor_parser_init_reader(
const struct CborParserOperations *ops, CborParser *parser,
CborValue *it,
void *token);
\n-
\n-
\n-
\n-
360CBOR_INLINE_API
bool cbor_value_at_end(
const CborValue *it)
\n-
361{
return it->remaining == 0; }
\n-
362CBOR_INLINE_API
const uint8_t *cbor_value_get_next_byte(
const CborValue *it)
\n-
363{
return it->source.ptr; }
\n-
364CBOR_API CborError cbor_value_reparse(
CborValue *it);
\n-
\n-
\n-
367CBOR_INLINE_API
bool cbor_value_is_container(
const CborValue *it)
\n-
368{
return it->type == CborArrayType || it->type == CborMapType; }
\n-
\n-
\n-
\n-
372CBOR_PRIVATE_API uint64_t _cbor_value_decode_int64_internal(
const CborValue *value);
\n-
373CBOR_INLINE_API uint64_t _cbor_value_extract_int64_helper(
const CborValue *value)
\n-
\n-
375 return value->flags & CborIteratorFlag_IntegerValueTooLarge ?
\n-
376 _cbor_value_decode_int64_internal(value) : value->extra;
\n-
\n-
\n-
379CBOR_INLINE_API
bool cbor_value_is_valid(
const CborValue *value)
\n-
380{
return value && value->type != CborInvalidType; }
\n-
381CBOR_INLINE_API CborType cbor_value_get_type(
const CborValue *value)
\n-
382{
return (CborType)value->type; }
\n-
\n-
\n-
385CBOR_INLINE_API
bool cbor_value_is_null(
const CborValue *value)
\n-
386{
return value->type == CborNullType; }
\n-
387CBOR_INLINE_API
bool cbor_value_is_undefined(
const CborValue *value)
\n-
388{
return value->type == CborUndefinedType; }
\n-
\n-
\n-
391CBOR_INLINE_API
bool cbor_value_is_boolean(
const CborValue *value)
\n-
392{
return value->type == CborBooleanType; }
\n-
393CBOR_INLINE_API CborError cbor_value_get_boolean(
const CborValue *value,
bool *result)
\n-
\n-
395 assert(cbor_value_is_boolean(value));
\n-
396 *result = !!value->extra;
\n-
\n-
\n-
\n-
\n-
401CBOR_INLINE_API
bool cbor_value_is_simple_type(
const CborValue *value)
\n-
402{
return value->type == CborSimpleType; }
\n-
403CBOR_INLINE_API CborError cbor_value_get_simple_type(
const CborValue *value, uint8_t *result)
\n-
\n-
405 assert(cbor_value_is_simple_type(value));
\n-
406 *result = (uint8_t)value->extra;
\n-
\n-
\n-
\n-
\n-
411CBOR_INLINE_API
bool cbor_value_is_integer(
const CborValue *value)
\n-
412{
return value->type == CborIntegerType; }
\n-
413CBOR_INLINE_API
bool cbor_value_is_unsigned_integer(
const CborValue *value)
\n-
414{
return cbor_value_is_integer(value) && (value->flags & CborIteratorFlag_NegativeInteger) == 0; }
\n-
415CBOR_INLINE_API
bool cbor_value_is_negative_integer(
const CborValue *value)
\n-
416{
return cbor_value_is_integer(value) && (value->flags & CborIteratorFlag_NegativeInteger); }
\n-
\n-
418CBOR_INLINE_API CborError cbor_value_get_raw_integer(
const CborValue *value, uint64_t *result)
\n-
\n-
420 assert(cbor_value_is_integer(value));
\n-
421 *result = _cbor_value_extract_int64_helper(value);
\n-
\n-
\n-
\n-
425CBOR_INLINE_API CborError cbor_value_get_uint64(
const CborValue *value, uint64_t *result)
\n-
\n-
427 assert(cbor_value_is_unsigned_integer(value));
\n-
428 *result = _cbor_value_extract_int64_helper(value);
\n-
\n-
\n-
\n-
432CBOR_INLINE_API CborError cbor_value_get_int64(
const CborValue *value, int64_t *result)
\n-
\n-
434 assert(cbor_value_is_integer(value));
\n-
435 *result = (int64_t) _cbor_value_extract_int64_helper(value);
\n-
436 if (value->flags & CborIteratorFlag_NegativeInteger)
\n-
437 *result = -*result - 1;
\n-
\n-
\n-
\n-
441CBOR_INLINE_API CborError cbor_value_get_int(
const CborValue *value,
int *result)
\n-
\n-
443 assert(cbor_value_is_integer(value));
\n-
444 *result = (int) _cbor_value_extract_int64_helper(value);
\n-
445 if (value->flags & CborIteratorFlag_NegativeInteger)
\n-
446 *result = -*result - 1;
\n-
\n-
\n-
\n-
\n-
\n-
\n-
453CBOR_INLINE_API
bool cbor_value_is_length_known(
const CborValue *value)
\n-
454{
return (value->flags & CborIteratorFlag_UnknownLength) == 0; }
\n-
\n-
\n-
457CBOR_INLINE_API
bool cbor_value_is_tag(
const CborValue *value)
\n-
458{
return value->type == CborTagType; }
\n-
459CBOR_INLINE_API CborError cbor_value_get_tag(
const CborValue *value, CborTag *result)
\n-
\n-
461 assert(cbor_value_is_tag(value));
\n-
462 *result = _cbor_value_extract_int64_helper(value);
\n-
\n-
\n-
\n-
\n-
\n-
468CBOR_INLINE_API
bool cbor_value_is_byte_string(
const CborValue *value)
\n-
469{
return value->type == CborByteStringType; }
\n-
470CBOR_INLINE_API
bool cbor_value_is_text_string(
const CborValue *value)
\n-
471{
return value->type == CborTextStringType; }
\n-
\n-
473CBOR_INLINE_API CborError cbor_value_get_string_length(
const CborValue *value,
size_t *length)
\n-
\n-
\n-
476 assert(cbor_value_is_byte_string(value) || cbor_value_is_text_string(value));
\n-
477 if (!cbor_value_is_length_known(value))
\n-
478 return CborErrorUnknownLength;
\n-
479 v = _cbor_value_extract_int64_helper(value);
\n-
\n-
\n-
482 return CborErrorDataTooLarge;
\n-
\n-
\n-
\n-
486CBOR_PRIVATE_API CborError _cbor_value_copy_string(
const CborValue *value,
void *buffer,
\n-
\n-
488CBOR_PRIVATE_API CborError _cbor_value_dup_string(
const CborValue *value,
void **buffer,
\n-
\n-
\n-
\n-
\n-
493CBOR_INLINE_API CborError cbor_value_copy_text_string(
const CborValue *value,
char *buffer,
\n-
\n-
\n-
496 assert(cbor_value_is_text_string(value));
\n-
497 return _cbor_value_copy_string(value, buffer, buflen, next);
\n-
\n-
499CBOR_INLINE_API CborError cbor_value_copy_byte_string(
const CborValue *value, uint8_t *buffer,
\n-
\n-
\n-
502 assert(cbor_value_is_byte_string(value));
\n-
503 return _cbor_value_copy_string(value, buffer, buflen, next);
\n-
\n-
\n-
\n-
\n-
\n-
509 assert(cbor_value_is_text_string(value));
\n-
510 return _cbor_value_dup_string(value, (
void **)buffer, buflen, next);
\n-
\n-
\n-
\n-
\n-
515 assert(cbor_value_is_byte_string(value));
\n-
516 return _cbor_value_dup_string(value, (
void **)buffer, buflen, next);
\n-
\n-
\n-
519CBOR_PRIVATE_API CborError _cbor_value_get_string_chunk_size(
const CborValue *value,
size_t *len);
\n-
520CBOR_INLINE_API CborError cbor_value_get_string_chunk_size(
const CborValue *value,
size_t *len)
\n-
\n-
522 assert(value->flags & CborIteratorFlag_IteratingStringChunks);
\n-
523 return _cbor_value_get_string_chunk_size(value, len);
\n-
\n-
\n-
526CBOR_INLINE_API
bool cbor_value_string_iteration_at_end(
const CborValue *value)
\n-
\n-
\n-
529 return cbor_value_get_string_chunk_size(value, &dummy) == CborErrorNoMoreStringChunks;
\n-
\n-
\n-
532CBOR_PRIVATE_API CborError _cbor_value_begin_string_iteration(
CborValue *value);
\n-
533CBOR_INLINE_API CborError cbor_value_begin_string_iteration(
CborValue *value)
\n-
\n-
535 assert(cbor_value_is_text_string(value) || cbor_value_is_byte_string(value));
\n-
536 assert(!(value->flags & CborIteratorFlag_IteratingStringChunks));
\n-
537 return _cbor_value_begin_string_iteration(value);
\n-
\n-
\n-
540CBOR_PRIVATE_API CborError _cbor_value_finish_string_iteration(
CborValue *value);
\n-
541CBOR_INLINE_API CborError cbor_value_finish_string_iteration(
CborValue *value)
\n-
\n-
543 assert(cbor_value_string_iteration_at_end(value));
\n-
544 return _cbor_value_finish_string_iteration(value);
\n-
\n-
\n-
547CBOR_PRIVATE_API CborError _cbor_value_get_string_chunk(
const CborValue *value,
const void **bufferptr,
\n-
\n-
549CBOR_INLINE_API CborError cbor_value_get_text_string_chunk(
const CborValue *value,
const char **bufferptr,
\n-
\n-
\n-
552 assert(cbor_value_is_text_string(value));
\n-
553 return _cbor_value_get_string_chunk(value, (
const void **)bufferptr, len, next);
\n-
\n-
555CBOR_INLINE_API CborError cbor_value_get_byte_string_chunk(
const CborValue *value,
const uint8_t **bufferptr,
\n-
\n-
\n-
558 assert(cbor_value_is_byte_string(value));
\n-
559 return _cbor_value_get_string_chunk(value, (
const void **)bufferptr, len, next);
\n-
\n-
\n-
\n-
\n-
\n-
565CBOR_INLINE_API
bool cbor_value_is_array(
const CborValue *value)
\n-
566{
return value->type == CborArrayType; }
\n-
567CBOR_INLINE_API
bool cbor_value_is_map(
const CborValue *value)
\n-
568{
return value->type == CborMapType; }
\n-
\n-
570CBOR_INLINE_API CborError cbor_value_get_array_length(
const CborValue *value,
size_t *length)
\n-
\n-
\n-
573 assert(cbor_value_is_array(value));
\n-
574 if (!cbor_value_is_length_known(value))
\n-
575 return CborErrorUnknownLength;
\n-
576 v = _cbor_value_extract_int64_helper(value);
\n-
\n-
\n-
579 return CborErrorDataTooLarge;
\n-
\n-
\n-
\n-
583CBOR_INLINE_API CborError cbor_value_get_map_length(
const CborValue *value,
size_t *length)
\n-
\n-
\n-
586 assert(cbor_value_is_map(value));
\n-
587 if (!cbor_value_is_length_known(value))
\n-
588 return CborErrorUnknownLength;
\n-
589 v = _cbor_value_extract_int64_helper(value);
\n-
\n-
\n-
592 return CborErrorDataTooLarge;
\n-
\n-
\n-
\n-
\n-
\n-
\n-
599CBOR_INLINE_API
bool cbor_value_is_half_float(
const CborValue *value)
\n-
600{
return value->type == CborHalfFloatType; }
\n-
\n-
602CBOR_INLINE_API CborError cbor_value_get_half_float(
const CborValue *value,
void *result)
\n-
\n-
604 assert(cbor_value_is_half_float(value));
\n-
605 assert((value->flags & CborIteratorFlag_IntegerValueTooLarge) == 0);
\n-
\n-
\n-
608 memcpy(result, &value->extra,
sizeof(value->extra));
\n-
\n-
\n-
\n-
612CBOR_INLINE_API
bool cbor_value_is_float(
const CborValue *value)
\n-
613{
return value->type == CborFloatType; }
\n-
614CBOR_INLINE_API CborError cbor_value_get_float(
const CborValue *value,
float *result)
\n-
\n-
\n-
617 assert(cbor_value_is_float(value));
\n-
618 assert(value->flags & CborIteratorFlag_IntegerValueTooLarge);
\n-
619 data = (uint32_t)_cbor_value_decode_int64_internal(value);
\n-
620 memcpy(result, &data,
sizeof(*result));
\n-
\n-
\n-
\n-
624CBOR_INLINE_API
bool cbor_value_is_double(
const CborValue *value)
\n-
625{
return value->type == CborDoubleType; }
\n-
626CBOR_INLINE_API CborError cbor_value_get_double(
const CborValue *value,
double *result)
\n-
\n-
\n-
629 assert(cbor_value_is_double(value));
\n-
630 assert(value->flags & CborIteratorFlag_IntegerValueTooLarge);
\n-
631 data = _cbor_value_decode_int64_internal(value);
\n-
632 memcpy(result, &data,
sizeof(*result));
\n-
\n-
\n-
\n-
\n-
637#ifndef CBOR_NO_VALIDATION_API \n-
\n-
639enum CborValidationFlags {
\n-
\n-
\n-
\n-
\n-
\n-
\n-
\n-
647 CborValidateShortestIntegrals = 0x0001,
\n-
648 CborValidateShortestFloatingPoint = 0x0002,
\n-
649 CborValidateShortestNumbers = CborValidateShortestIntegrals | CborValidateShortestFloatingPoint,
\n-
650 CborValidateNoIndeterminateLength = 0x0100,
\n-
651 CborValidateMapIsSorted = 0x0200 | CborValidateNoIndeterminateLength,
\n-
\n-
653 CborValidateCanonicalFormat = 0x0fff,
\n-
\n-
655 CborValidateMapKeysAreUnique = 0x1000 | CborValidateMapIsSorted,
\n-
656 CborValidateTagUse = 0x2000,
\n-
657 CborValidateUtf8 = 0x4000,
\n-
\n-
659 CborValidateStrictMode = 0xfff00,
\n-
\n-
661 CborValidateMapKeysAreString = 0x100000,
\n-
662 CborValidateNoUndefined = 0x200000,
\n-
663 CborValidateNoTags = 0x400000,
\n-
664 CborValidateFiniteFloatingPoint = 0x800000,
\n-
\n-
\n-
\n-
668 CborValidateNoUnknownSimpleTypesSA = 0x4000000,
\n-
669 CborValidateNoUnknownSimpleTypes = 0x8000000 | CborValidateNoUnknownSimpleTypesSA,
\n-
670 CborValidateNoUnknownTagsSA = 0x10000000,
\n-
671 CborValidateNoUnknownTagsSR = 0x20000000 | CborValidateNoUnknownTagsSA,
\n-
672 CborValidateNoUnknownTags = 0x40000000 | CborValidateNoUnknownTagsSR,
\n-
\n-
674 CborValidateCompleteData = (int)0x80000000,
\n-
\n-
676 CborValidateStrictest = (
int)~0U,
\n-
677 CborValidateBasic = 0
\n-
\n-
\n-
\n-
\n-
\n-
\n-
684#ifndef CBOR_NO_PRETTY_API \n-
\n-
686enum CborPrettyFlags {
\n-
687 CborPrettyNumericEncodingIndicators = 0x01,
\n-
688 CborPrettyTextualEncodingIndicators = 0,
\n-
\n-
690 CborPrettyIndicateIndeterminateLength = 0x02,
\n-
691 CborPrettyIndicateIndetermineLength = CborPrettyIndicateIndeterminateLength,
\n-
692 CborPrettyIndicateOverlongNumbers = 0x04,
\n-
\n-
694 CborPrettyShowStringFragments = 0x100,
\n-
695 CborPrettyMergeStringFragments = 0,
\n-
\n-
697 CborPrettyDefaultFlags = CborPrettyIndicateIndeterminateLength
\n-
\n-
\n-
700typedef CborError (*CborStreamFunction)(
void *token,
const char *fmt, ...)
\n-
\n-
702 __attribute__((__format__(printf, 2, 3)))
\n-
\n-
\n-
\n-
\n-
\n-
\n-
709#if !defined(__STDC_HOSTED__) || __STDC_HOSTED__-0 == 1 \n-
\n-
\n-
\n-
\n-
\n-
\n-
\n-
\n-
\n-
\n-
\n-
\n-
\n-
\n-
\n-
\n-
\n-
\n-
\n-
CborError cbor_value_to_pretty(FILE *out, const CborValue *value)
Converts the current CBOR type pointed to by value to its textual representation and writes it to the...
Definition cbor.h:712
\n-
CborError cbor_value_dup_text_string(const CborValue *value, char **buffer, size_t *buflen, CborValue *next)
Allocates memory for the string pointed by value and copies it into this buffer.
Definition cbor.h:506
\n-
CBOR_API CborError cbor_value_get_half_float_as_float(const CborValue *value, float *result)
Retrieves the CBOR half-precision floating point (16-bit) value that value points to,...
Definition cborparser_float.c:45
\n-
CBOR_API CborError cbor_value_to_pretty_advance_flags(FILE *out, CborValue *value, int flags)
Converts the current CBOR type pointed to by value to its textual representation and writes it to the...
Definition cborpretty_stdio.c:83
\n-
CborError cbor_value_dup_byte_string(const CborValue *value, uint8_t **buffer, size_t *buflen, CborValue *next)
Allocates memory for the string pointed by value and copies it into this buffer.
Definition cbor.h:512
\n-
CBOR_API CborError cbor_value_to_pretty_advance(FILE *out, CborValue *value)
Converts the current CBOR type pointed to by value to its textual representation and writes it to the...
Definition cborpretty_stdio.c:63
\n-
CBOR_API const char * cbor_error_string(CborError error)
Returns the error string corresponding to the CBOR error condition error.
Definition cborerrorstrings.c:80
\n-
CBOR_API CborError cbor_encode_negative_int(CborEncoder *encoder, uint64_t absolute_value)
Appends the negative 64-bit integer whose absolute value is absolute_value to the CBOR stream provide...
Definition cborencoder.c:369
\n-
CBOR_API CborError cbor_encode_byte_string(CborEncoder *encoder, const uint8_t *string, size_t length)
Appends the byte string string of length length to the CBOR stream provided by encoder.
Definition cborencoder.c:471
\n-
CBOR_API void cbor_encoder_init(CborEncoder *encoder, uint8_t *buffer, size_t size, int flags)
Initializes a CborEncoder structure encoder by pointing it to buffer buffer of size size.
Definition cborencoder.c:204
\n-
CBOR_API CborError cbor_encode_uint(CborEncoder *encoder, uint64_t value)
Appends the unsigned 64-bit integer value to the CBOR stream provided by encoder.
Definition cborencoder.c:356
\n-
CBOR_API CborError cbor_encode_text_string(CborEncoder *encoder, const char *string, size_t length)
Appends the text string string of length length to the CBOR stream provided by encoder.
Definition cborencoder.c:483
\n-
CBOR_API CborError cbor_encoder_close_container(CborEncoder *parentEncoder, const CborEncoder *containerEncoder)
Closes the CBOR container (array or map) provided by containerEncoder and updates the CBOR stream pro...
Definition cborencoder.c:574
\n-
CBOR_API CborError cbor_encode_tag(CborEncoder *encoder, CborTag tag)
Appends the CBOR tag tag to the CBOR stream provided by encoder.
Definition cborencoder.c:440
\n-
CBOR_API CborError cbor_encode_simple_value(CborEncoder *encoder, uint8_t value)
Appends the CBOR Simple Type of value value to the CBOR stream provided by encoder.
Definition cborencoder.c:396
\n-
CBOR_API CborError cbor_encoder_create_array(CborEncoder *parentEncoder, CborEncoder *arrayEncoder, size_t length)
Creates a CBOR array in the CBOR stream provided by parentEncoder and initializes arrayEncoder so tha...
Definition cborencoder.c:531
\n-
CBOR_API CborError cbor_encoder_close_container_checked(CborEncoder *parentEncoder, const CborEncoder *containerEncoder)
Definition cborencoder_close_container_checked.c:53
\n-
CBOR_API CborError cbor_encoder_create_map(CborEncoder *parentEncoder, CborEncoder *mapEncoder, size_t length)
Creates a CBOR map in the CBOR stream provided by parentEncoder and initializes mapEncoder so that it...
Definition cborencoder.c:555
\n-
CBOR_API CborError cbor_encode_int(CborEncoder *encoder, int64_t value)
Appends the signed 64-bit integer value to the CBOR stream provided by encoder.
Definition cborencoder.c:380
\n-
CBOR_API CborError cbor_encode_floating_point(CborEncoder *encoder, CborType fpType, const void *value)
Appends the floating-point value of type fpType and pointed to by value to the CBOR stream provided b...
Definition cborencoder.c:417
\n-
CBOR_API CborError cbor_value_enter_container(const CborValue *it, CborValue *recursed)
Creates a CborValue iterator pointing to the first element of the container represented by it and sav...
Definition cborparser.c:578
\n-
CBOR_API CborError cbor_value_validate_basic(const CborValue *it)
Performs a basic validation of the CBOR stream pointed by it and returns the error it found.
Definition cborparser.c:442
\n-
CBOR_API CborError cbor_value_skip_tag(CborValue *it)
Advances the CBOR value it until it no longer points to a tag.
Definition cborparser.c:551
\n-
CBOR_API CborError cbor_value_validate(const CborValue *it, uint32_t flags)
Performs a full validation, controlled by the flags options, of the CBOR stream pointed by it and ret...
Definition cborvalidation.c:645
\n-
CBOR_API CborError cbor_value_leave_container(CborValue *it, const CborValue *recursed)
Updates it to point to the next element after the container.
Definition cborparser.c:627
\n-
CBOR_API CborError cbor_value_get_int64_checked(const CborValue *value, int64_t *result)
Retrieves the CBOR integer value that value points to and stores it in result.
Definition cborparser.c:812
\n-
CBOR_API CborError cbor_parser_init(const uint8_t *buffer, size_t size, uint32_t flags, CborParser *parser, CborValue *it)
Initializes the CBOR parser for parsing size bytes beginning at buffer.
Definition cborparser.c:345
\n-
CBOR_API CborError cbor_value_advance_fixed(CborValue *it)
Advances the CBOR value it by one fixed-size position.
Definition cborparser.c:463
\n-
CBOR_API CborError cbor_value_text_string_equals(const CborValue *value, const char *string, bool *result)
Compares the entry value with the string string and stores the result in result.
Definition cborparser.c:1323
\n-
CBOR_API CborError cbor_value_calculate_string_length(const CborValue *value, size_t *length)
Calculates the length of the byte or text string that value points to and stores it in len.
Definition cborparser.c:963
\n-
CBOR_API CborError cbor_value_advance(CborValue *it)
Advances the CBOR value it by one element, skipping over containers.
Definition cborparser.c:515
\n-
CBOR_API CborError cbor_value_map_find_value(const CborValue *map, const char *string, CborValue *element)
Attempts to find the value in map map that corresponds to the text string entry string.
Definition cborparser.c:1411
\n-
CBOR_API CborError cbor_value_get_int_checked(const CborValue *value, int *result)
Retrieves the CBOR integer value that value points to and stores it in result.
Definition cborparser.c:852
\n-
CBOR_API CborError cbor_value_to_pretty_stream(CborStreamFunction streamFunction, void *token, CborValue *value, int flags)
Converts the current CBOR type pointed by value to its textual representation and writes it to the st...
Definition cborpretty.c:578
\n-
Structure used to encode to CBOR.
Definition cbor.h:227
\n-
This type contains one value parsed from the CBOR stream.
Definition cbor.h:341
\n+
25#if defined(CBOR_CUSTOM_ALLOC_INCLUDE) \n+
26# include CBOR_CUSTOM_ALLOC_INCLUDE \n+
\n+
\n+
29# define cbor_malloc malloc \n+
30# define cbor_free free \n+
\n