14 size_t _cbor_encode_uint8(uint8_t value,
unsigned char *buffer,
size_t buffer_size, uint8_t offset)
17 if (buffer_size >= 1) {
18 buffer[0] = value + offset;
22 if (buffer_size >= 2) {
23 buffer[0] = 0x18 + offset;
33 if (buffer_size >= 3) {
34 buffer[0] = 0x19 + offset;
37 *(uint16_t *) &buffer[1] = htobe16(value);
40 *(uint16_t *) &buffer[1] = value;
42 buffer[1] = value >> 8;
54 if (buffer_size >= 5) {
55 buffer[0] = 0x1A + offset;
58 *(uint32_t *) &buffer[1] = htobe32(value);
61 *(uint32_t *) &buffer[1] = value;
63 buffer[1] = value >> 24;
64 buffer[2] = value >> 16;
65 buffer[3] = value >> 8;
77 if (buffer_size >= 9) {
78 buffer[0] = 0x1B + offset;
81 *(uint64_t *) &buffer[1] = htobe64(value);
84 *(uint64_t *) &buffer[1] = value;
86 buffer[1] = value >> 56;
87 buffer[2] = value >> 48;
88 buffer[3] = value >> 40;
89 buffer[4] = value >> 32;
90 buffer[5] = value >> 24;
91 buffer[6] = value >> 16;
92 buffer[7] = value >> 8;
102 size_t _cbor_encode_uint(uint64_t value,
unsigned char *buffer,
size_t buffer_size, uint8_t offset)
104 if (value <= UINT16_MAX)
if (value <= UINT8_MAX)
108 else if (value <= UINT32_MAX)
size_t _cbor_encode_uint16(uint16_t value, unsigned char *buffer, size_t buffer_size, uint8_t offset)
size_t _cbor_encode_uint64(uint64_t value, unsigned char *buffer, size_t buffer_size, uint8_t offset)
size_t _cbor_encode_uint32(uint32_t value, unsigned char *buffer, size_t buffer_size, uint8_t offset)
size_t _cbor_encode_uint(uint64_t value, unsigned char *buffer, size_t buffer_size, uint8_t offset)
size_t _cbor_encode_uint8(uint8_t value, unsigned char *buffer, size_t buffer_size, uint8_t offset)