head 1.1; branch 1.1.1; access; symbols netbsd-11-0-RC4:1.1.1.1 netbsd-11-0-RC3:1.1.1.1 netbsd-11-0-RC2:1.1.1.1 netbsd-11-0-RC1:1.1.1.1 perseant-exfatfs-base-20250801:1.1.1.1 netbsd-11:1.1.1.1.0.12 netbsd-11-base:1.1.1.1 netbsd-10-1-RELEASE:1.1.1.1 perseant-exfatfs-base-20240630:1.1.1.1 perseant-exfatfs:1.1.1.1.0.10 perseant-exfatfs-base:1.1.1.1 netbsd-10-0-RELEASE:1.1.1.1 netbsd-10-0-RC6:1.1.1.1 netbsd-10-0-RC5:1.1.1.1 netbsd-10-0-RC4:1.1.1.1 netbsd-10-0-RC3:1.1.1.1 netbsd-10-0-RC2:1.1.1.1 netbsd-10-0-RC1:1.1.1.1 netbsd-10:1.1.1.1.0.8 netbsd-10-base:1.1.1.1 cjep_sun2x-base1:1.1.1.1 cjep_sun2x:1.1.1.1.0.6 cjep_sun2x-base:1.1.1.1 cjep_staticlib_x-base1:1.1.1.1 cjep_staticlib_x:1.1.1.1.0.4 cjep_staticlib_x-base:1.1.1.1 phil-wifi-20200421:1.1.1.1 phil-wifi:1.1.1.1.0.2 phil-wifi-20200411:1.1.1.1 phil-wifi-20200406:1.1.1.1 libcbor-3b41770ab0ca408d242041dddb3b75811345573f:1.1.1.1 PJK:1.1.1; locks; strict; comment @# @; 1.1 date 2020.03.03.00.34.30; author christos; state Exp; branches 1.1.1.1; next ; commitid CsDukytrNgtSbTYB; 1.1.1.1 date 2020.03.03.00.34.30; author christos; state Exp; branches 1.1.1.1.2.1; next ; commitid CsDukytrNgtSbTYB; 1.1.1.1.2.1 date 2020.03.03.00.34.30; author martin; state dead; branches; next 1.1.1.1.2.2; commitid X01YhRUPVUDaec4C; 1.1.1.1.2.2 date 2020.04.13.08.02.26; author martin; state Exp; branches; next ; commitid X01YhRUPVUDaec4C; desc @@ 1.1 log @Initial revision @ text @ libcbor: src/cbor/encoding.h File Reference
libcbor  0.5.0
libcbor is a C library for parsing and generating CBOR, the general-purpose schema-less binary data format.
Functions
encoding.h File Reference
#include "cbor/common.h"

Go to the source code of this file.

Functions

size_t cbor_encode_uint8 (uint8_t, unsigned char *, size_t)
 
size_t cbor_encode_uint16 (uint16_t, unsigned char *, size_t)
 
size_t cbor_encode_uint32 (uint32_t, unsigned char *, size_t)
 
size_t cbor_encode_uint64 (uint64_t, unsigned char *, size_t)
 
size_t cbor_encode_uint (uint64_t, unsigned char *, size_t)
 
size_t cbor_encode_negint8 (uint8_t, unsigned char *, size_t)
 
size_t cbor_encode_negint16 (uint16_t, unsigned char *, size_t)
 
size_t cbor_encode_negint32 (uint32_t, unsigned char *, size_t)
 
size_t cbor_encode_negint64 (uint64_t, unsigned char *, size_t)
 
size_t cbor_encode_negint (uint64_t, unsigned char *, size_t)
 
size_t cbor_encode_bytestring_start (size_t, unsigned char *, size_t)
 
size_t cbor_encode_indef_bytestring_start (unsigned char *, size_t)
 
size_t cbor_encode_string_start (size_t, unsigned char *, size_t)
 
size_t cbor_encode_indef_string_start (unsigned char *, size_t)
 
size_t cbor_encode_array_start (size_t, unsigned char *, size_t)
 
size_t cbor_encode_indef_array_start (unsigned char *, size_t)
 
size_t cbor_encode_map_start (size_t, unsigned char *, size_t)
 
size_t cbor_encode_indef_map_start (unsigned char *, size_t)
 
size_t cbor_encode_tag (uint64_t, unsigned char *, size_t)
 
size_t cbor_encode_bool (bool, unsigned char *, size_t)
 
size_t cbor_encode_null (unsigned char *, size_t)
 
size_t cbor_encode_undef (unsigned char *, size_t)
 
size_t cbor_encode_half (float, unsigned char *, size_t)
 Encodes a half-precision float. More...
 
size_t cbor_encode_single (float, unsigned char *, size_t)
 
size_t cbor_encode_double (double, unsigned char *, size_t)
 
size_t cbor_encode_break (unsigned char *, size_t)
 
size_t cbor_encode_ctrl (uint8_t, unsigned char *, size_t)
 

Function Documentation

§ cbor_encode_array_start()

size_t cbor_encode_array_start ( size_t  ,
unsigned char *  ,
size_t   
)

Definition at line 91 of file encoding.c.

§ cbor_encode_bool()

size_t cbor_encode_bool ( bool  ,
unsigned char *  ,
size_t   
)

Definition at line 116 of file encoding.c.

§ cbor_encode_break()

size_t cbor_encode_break ( unsigned char *  ,
size_t   
)

Definition at line 178 of file encoding.c.

§ cbor_encode_bytestring_start()

size_t cbor_encode_bytestring_start ( size_t  ,
unsigned char *  ,
size_t   
)

Definition at line 62 of file encoding.c.

§ cbor_encode_ctrl()

size_t cbor_encode_ctrl ( uint8_t  ,
unsigned char *  ,
size_t   
)

Definition at line 183 of file encoding.c.

§ cbor_encode_double()

size_t cbor_encode_double ( double  ,
unsigned char *  ,
size_t   
)

Definition at line 173 of file encoding.c.

§ cbor_encode_half()

size_t cbor_encode_half ( float  ,
unsigned char *  ,
size_t   
)

Encodes a half-precision float.

Since there is no native representation or semantics for half floats in the language, we use single-precision floats, as every value that can be expressed as a half-float can also be expressed as a float.

This however means that not all floats passed to this function can be unambiguously encoded. The behavior is as follows:

  • Infinity, NaN are preserved
  • Zero is preserved
  • Denormalized numbers keep their sign bit and 10 most significant bit of the significand
  • All other numbers
    • If the logical value of the exponent is < -24, the output is zero
    • If the logical value of the exponent is between -23 and -14, the output is cut off to represent the 'magnitude' of the input, by which we mean (-1)^{signbit} x 1.0e{exponent}. The value in the significand is lost.
    • In all other cases, the sign bit, the exponent, and 10 most significant bits of the significand are kept
Parameters
value
bufferTarget buffer
buffer_sizeAvailable space in the buffer
Returns
number of bytes written

Definition at line 131 of file encoding.c.

§ cbor_encode_indef_array_start()

size_t cbor_encode_indef_array_start ( unsigned char *  ,
size_t   
)

Definition at line 96 of file encoding.c.

§ cbor_encode_indef_bytestring_start()

size_t cbor_encode_indef_bytestring_start ( unsigned char *  ,
size_t   
)

Definition at line 76 of file encoding.c.

§ cbor_encode_indef_map_start()

size_t cbor_encode_indef_map_start ( unsigned char *  ,
size_t   
)

Definition at line 106 of file encoding.c.

§ cbor_encode_indef_string_start()

size_t cbor_encode_indef_string_start ( unsigned char *  ,
size_t   
)

Definition at line 86 of file encoding.c.

§ cbor_encode_map_start()

size_t cbor_encode_map_start ( size_t  ,
unsigned char *  ,
size_t   
)

Definition at line 101 of file encoding.c.

§ cbor_encode_negint()

size_t cbor_encode_negint ( uint64_t  ,
unsigned char *  ,
size_t   
)

Definition at line 57 of file encoding.c.

§ cbor_encode_negint16()

size_t cbor_encode_negint16 ( uint16_t  ,
unsigned char *  ,
size_t   
)

Definition at line 42 of file encoding.c.

§ cbor_encode_negint32()

size_t cbor_encode_negint32 ( uint32_t  ,
unsigned char *  ,
size_t   
)

Definition at line 47 of file encoding.c.

§ cbor_encode_negint64()

size_t cbor_encode_negint64 ( uint64_t  ,
unsigned char *  ,
size_t   
)

Definition at line 52 of file encoding.c.

§ cbor_encode_negint8()

size_t cbor_encode_negint8 ( uint8_t  ,
unsigned char *  ,
size_t   
)

Definition at line 37 of file encoding.c.

§ cbor_encode_null()

size_t cbor_encode_null ( unsigned char *  ,
size_t   
)

Definition at line 121 of file encoding.c.

§ cbor_encode_single()

size_t cbor_encode_single ( float  ,
unsigned char *  ,
size_t   
)

Definition at line 167 of file encoding.c.

§ cbor_encode_string_start()

size_t cbor_encode_string_start ( size_t  ,
unsigned char *  ,
size_t   
)

Definition at line 81 of file encoding.c.

§ cbor_encode_tag()

size_t cbor_encode_tag ( uint64_t  ,
unsigned char *  ,
size_t   
)

Definition at line 111 of file encoding.c.

§ cbor_encode_uint()

size_t cbor_encode_uint ( uint64_t  ,
unsigned char *  ,
size_t   
)

Definition at line 31 of file encoding.c.

§ cbor_encode_uint16()

size_t cbor_encode_uint16 ( uint16_t  ,
unsigned char *  ,
size_t   
)

Definition at line 16 of file encoding.c.

§ cbor_encode_uint32()

size_t cbor_encode_uint32 ( uint32_t  ,
unsigned char *  ,
size_t   
)

Definition at line 21 of file encoding.c.

§ cbor_encode_uint64()

size_t cbor_encode_uint64 ( uint64_t  ,
unsigned char *  ,
size_t   
)

Definition at line 26 of file encoding.c.

§ cbor_encode_uint8()

size_t cbor_encode_uint8 ( uint8_t  ,
unsigned char *  ,
size_t   
)

Definition at line 11 of file encoding.c.

§ cbor_encode_undef()

size_t cbor_encode_undef ( unsigned char *  ,
size_t   
)

Definition at line 126 of file encoding.c.

@ 1.1.1.1 log @Import libcbor from: https://github.com/PJK/libcbor.git @ text @@ 1.1.1.1.2.1 log @file encoding_8h.html was added on branch phil-wifi on 2020-04-13 08:02:26 +0000 @ text @d1 1098 @ 1.1.1.1.2.2 log @Mostly merge changes from HEAD upto 20200411 @ text @a0 1098 libcbor: src/cbor/encoding.h File Reference
libcbor  0.5.0
libcbor is a C library for parsing and generating CBOR, the general-purpose schema-less binary data format.
Functions
encoding.h File Reference
#include "cbor/common.h"

Go to the source code of this file.

Functions

size_t cbor_encode_uint8 (uint8_t, unsigned char *, size_t)
 
size_t cbor_encode_uint16 (uint16_t, unsigned char *, size_t)
 
size_t cbor_encode_uint32 (uint32_t, unsigned char *, size_t)
 
size_t cbor_encode_uint64 (uint64_t, unsigned char *, size_t)
 
size_t cbor_encode_uint (uint64_t, unsigned char *, size_t)
 
size_t cbor_encode_negint8 (uint8_t, unsigned char *, size_t)
 
size_t cbor_encode_negint16 (uint16_t, unsigned char *, size_t)
 
size_t cbor_encode_negint32 (uint32_t, unsigned char *, size_t)
 
size_t cbor_encode_negint64 (uint64_t, unsigned char *, size_t)
 
size_t cbor_encode_negint (uint64_t, unsigned char *, size_t)
 
size_t cbor_encode_bytestring_start (size_t, unsigned char *, size_t)
 
size_t cbor_encode_indef_bytestring_start (unsigned char *, size_t)
 
size_t cbor_encode_string_start (size_t, unsigned char *, size_t)
 
size_t cbor_encode_indef_string_start (unsigned char *, size_t)
 
size_t cbor_encode_array_start (size_t, unsigned char *, size_t)
 
size_t cbor_encode_indef_array_start (unsigned char *, size_t)
 
size_t cbor_encode_map_start (size_t, unsigned char *, size_t)
 
size_t cbor_encode_indef_map_start (unsigned char *, size_t)
 
size_t cbor_encode_tag (uint64_t, unsigned char *, size_t)
 
size_t cbor_encode_bool (bool, unsigned char *, size_t)
 
size_t cbor_encode_null (unsigned char *, size_t)
 
size_t cbor_encode_undef (unsigned char *, size_t)
 
size_t cbor_encode_half (float, unsigned char *, size_t)
 Encodes a half-precision float. More...
 
size_t cbor_encode_single (float, unsigned char *, size_t)
 
size_t cbor_encode_double (double, unsigned char *, size_t)
 
size_t cbor_encode_break (unsigned char *, size_t)
 
size_t cbor_encode_ctrl (uint8_t, unsigned char *, size_t)
 

Function Documentation

§ cbor_encode_array_start()

size_t cbor_encode_array_start ( size_t  ,
unsigned char *  ,
size_t   
)

Definition at line 91 of file encoding.c.

§ cbor_encode_bool()

size_t cbor_encode_bool ( bool  ,
unsigned char *  ,
size_t   
)

Definition at line 116 of file encoding.c.

§ cbor_encode_break()

size_t cbor_encode_break ( unsigned char *  ,
size_t   
)

Definition at line 178 of file encoding.c.

§ cbor_encode_bytestring_start()

size_t cbor_encode_bytestring_start ( size_t  ,
unsigned char *  ,
size_t   
)

Definition at line 62 of file encoding.c.

§ cbor_encode_ctrl()

size_t cbor_encode_ctrl ( uint8_t  ,
unsigned char *  ,
size_t   
)

Definition at line 183 of file encoding.c.

§ cbor_encode_double()

size_t cbor_encode_double ( double  ,
unsigned char *  ,
size_t   
)

Definition at line 173 of file encoding.c.

§ cbor_encode_half()

size_t cbor_encode_half ( float  ,
unsigned char *  ,
size_t   
)

Encodes a half-precision float.

Since there is no native representation or semantics for half floats in the language, we use single-precision floats, as every value that can be expressed as a half-float can also be expressed as a float.

This however means that not all floats passed to this function can be unambiguously encoded. The behavior is as follows:

  • Infinity, NaN are preserved
  • Zero is preserved
  • Denormalized numbers keep their sign bit and 10 most significant bit of the significand
  • All other numbers
    • If the logical value of the exponent is < -24, the output is zero
    • If the logical value of the exponent is between -23 and -14, the output is cut off to represent the 'magnitude' of the input, by which we mean (-1)^{signbit} x 1.0e{exponent}. The value in the significand is lost.
    • In all other cases, the sign bit, the exponent, and 10 most significant bits of the significand are kept
Parameters
value
bufferTarget buffer
buffer_sizeAvailable space in the buffer
Returns
number of bytes written

Definition at line 131 of file encoding.c.

§ cbor_encode_indef_array_start()

size_t cbor_encode_indef_array_start ( unsigned char *  ,
size_t   
)

Definition at line 96 of file encoding.c.

§ cbor_encode_indef_bytestring_start()

size_t cbor_encode_indef_bytestring_start ( unsigned char *  ,
size_t   
)

Definition at line 76 of file encoding.c.

§ cbor_encode_indef_map_start()

size_t cbor_encode_indef_map_start ( unsigned char *  ,
size_t   
)

Definition at line 106 of file encoding.c.

§ cbor_encode_indef_string_start()

size_t cbor_encode_indef_string_start ( unsigned char *  ,
size_t   
)

Definition at line 86 of file encoding.c.

§ cbor_encode_map_start()

size_t cbor_encode_map_start ( size_t  ,
unsigned char *  ,
size_t   
)

Definition at line 101 of file encoding.c.

§ cbor_encode_negint()

size_t cbor_encode_negint ( uint64_t  ,
unsigned char *  ,
size_t   
)

Definition at line 57 of file encoding.c.

§ cbor_encode_negint16()

size_t cbor_encode_negint16 ( uint16_t  ,
unsigned char *  ,
size_t   
)

Definition at line 42 of file encoding.c.

§ cbor_encode_negint32()

size_t cbor_encode_negint32 ( uint32_t  ,
unsigned char *  ,
size_t   
)

Definition at line 47 of file encoding.c.

§ cbor_encode_negint64()

size_t cbor_encode_negint64 ( uint64_t  ,
unsigned char *  ,
size_t   
)

Definition at line 52 of file encoding.c.

§ cbor_encode_negint8()

size_t cbor_encode_negint8 ( uint8_t  ,
unsigned char *  ,
size_t   
)

Definition at line 37 of file encoding.c.

§ cbor_encode_null()

size_t cbor_encode_null ( unsigned char *  ,
size_t   
)

Definition at line 121 of file encoding.c.

§ cbor_encode_single()

size_t cbor_encode_single ( float  ,
unsigned char *  ,
size_t   
)

Definition at line 167 of file encoding.c.

§ cbor_encode_string_start()

size_t cbor_encode_string_start ( size_t  ,
unsigned char *  ,
size_t   
)

Definition at line 81 of file encoding.c.

§ cbor_encode_tag()

size_t cbor_encode_tag ( uint64_t  ,
unsigned char *  ,
size_t   
)

Definition at line 111 of file encoding.c.

§ cbor_encode_uint()

size_t cbor_encode_uint ( uint64_t  ,
unsigned char *  ,
size_t   
)

Definition at line 31 of file encoding.c.

§ cbor_encode_uint16()

size_t cbor_encode_uint16 ( uint16_t  ,
unsigned char *  ,
size_t   
)

Definition at line 16 of file encoding.c.

§ cbor_encode_uint32()

size_t cbor_encode_uint32 ( uint32_t  ,
unsigned char *  ,
size_t   
)

Definition at line 21 of file encoding.c.

§ cbor_encode_uint64()

size_t cbor_encode_uint64 ( uint64_t  ,
unsigned char *  ,
size_t   
)

Definition at line 26 of file encoding.c.

§ cbor_encode_uint8()

size_t cbor_encode_uint8 ( uint8_t  ,
unsigned char *  ,
size_t   
)

Definition at line 11 of file encoding.c.

§ cbor_encode_undef()

size_t cbor_encode_undef ( unsigned char *  ,
size_t   
)

Definition at line 126 of file encoding.c.

@