Skip to content

Minimal Zero-Footprint CBOR Decoder in C

License

Notifications You must be signed in to change notification settings

All-Your-Locks-Are-Belong-To-Us/cb0r

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cb0r - Minimal Zero-Footprint CBOR Decoder in C

A one-pass minimal malloc-free walk of the raw bytes using a fast jump table to determine state transitions and decode a result.

  • public domain, single cb0r.c file with one ~200 line function
  • easy to use, just returns a given type, value, and offset locations in the bytes
  • no dependencies, designed for embedded use
  • requires no memory/malloc or copying, uses only what is passed in
  • safely stops on anything invalid

For other CBOR implementations check http://cbor.io/impls.html.

Usage

uint8_t *cb0r(uint8_t *start, uint8_t *stop, uint32_t skip, cb0r_t result)

  • processes one item by default into result (if provided)
  • returns end pointer to byte following the item value (may be == stop for complete, > stop for item value length overflow)
  • can very efficiently skip any number of leading items of any type
  • see header for result structure and types
  • fully supports maps, arrays, and indefinite length types

About

Minimal Zero-Footprint CBOR Decoder in C

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 97.6%
  • Makefile 1.5%
  • CMake 0.9%