pax_global_header00006660000000000000000000000064147641620370014524gustar00rootroot0000000000000052 comment=c0aad2fb2137a31b9845fbaae3653540c410f215 tinycbor-0.6.1/000077500000000000000000000000001476416203700133615ustar00rootroot00000000000000tinycbor-0.6.1/.appveyor.yml000066400000000000000000000015461476416203700160350ustar00rootroot00000000000000version: 0.6-build-{build} pull_requests: do_not_increment_build_number: true image: - Visual Studio 2017 - Visual Studio 2019 install: - cmd: >- if /i "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2017" (call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" x86) & (set QTDIR=C:\Qt\5.13\msvc2017) if /i "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2019" (call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" x64) & (set QTDIR=C:\Qt\6.5\msvc2019_64) set path=%PATH%;%QTDIR%\bin build_script: - cmd: >- nmake -f Makefile.nmake -nologo CFLAGS="-W3 -Os -MDd" cd tests qmake CONFIG-=release CONFIG+=debug nmake -nologo -s test_script: - cmd: >- nmake -s -nologo TESTARGS=-silent check artifacts: - path: lib\tinycbor.lib deploy: off tinycbor-0.6.1/.github/000077500000000000000000000000001476416203700147215ustar00rootroot00000000000000tinycbor-0.6.1/.github/dependabot.yml000066400000000000000000000002031476416203700175440ustar00rootroot00000000000000version: 2 updates: - package-ecosystem: github-actions directory: "/" schedule: interval: "daily" target-branch: "main" tinycbor-0.6.1/.github/workflows/000077500000000000000000000000001476416203700167565ustar00rootroot00000000000000tinycbor-0.6.1/.github/workflows/build.yml000066400000000000000000000115571476416203700206110ustar00rootroot00000000000000name: CI permissions: read-all on: push: branches: [ main, dev ] pull_request: branches: [ main, dev ] # When a PR is updated, cancel the jobs from the previous version. Merges # do not define head_ref, so use run_id to never cancel those jobs. concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} cancel-in-progress: true jobs: TinyCBOR: timeout-minutes: 45 # Common environment variables env: HOMEBREW_NO_INSTALL_CLEANUP: 1 HOMEBREW_NO_ANALYTICS: 1 strategy: # Always run all jobs in the matrix, even if one fails. fail-fast: false matrix: os: [ ubuntu-latest ] build_cfg: [ { "name": "gcc-no-math", "flags": '{ "QMAKESPEC": "linux-gcc-no-math", "EVAL": "export CXX=false && touch math.h float.h", "CFLAGS": "-ffreestanding -DCBOR_NO_FLOATING_POINT -Os", "LDFLAGS": "-Wl,--no-undefined", "LDLIBS": "" }', }, { "name": "gcc-freestanding", "flags": '{ "QMAKESPEC": "linux-gcc-freestanding", "EVAL": "export CXX=false", "CFLAGS": "-ffreestanding -Os", "LDFLAGS": "-Wl,--no-undefined -lm" }', }, { "name": "clang", "flags": '{ "QMAKESPEC": "linux-clang", "EVAL": "export CC=clang && export CXX=clang++", "CFLAGS": "-Oz", "LDFLAGS": "-Wl,--no-undefined -lm", "QMAKEFLAGS": "-config release", "MAKEFLAGS": "-s", "TESTARGS": "-silent" }', }, { "name": "linux-g++", "flags": '{ "QMAKESPEC": "linux-g++", "EVAL": "export CC=gcc && export CXX=g++", "CFLAGS": "-Os", "LDFLAGS": "-Wl,--no-undefined -lm", "QMAKEFLAGS": "-config release", "QT_NO_CPU_FEATURE": "rdrnd" }' } ] include: - os: macos-13 build_cfg: { "name": "clang", "flags": '{ "QMAKESPEC": "macx-clang", "EVAL": "export CC=clang && export CXX=clang++", "CFLAGS": "-Oz", "QMAKEFLAGS": "-config debug", "MAKEFLAGS": "-s", "TESTARGS": "-silent", "PATH": "/usr/local/opt/qt/bin:$PATH" }' } # Default job name is too long to be visible in the "Checks" tab. name: ${{ matrix.os }}/${{ matrix.build_cfg.name }} # The type of runner that the job will run on runs-on: ${{ matrix.os }} steps: - name: Clone tinycbor uses: actions/checkout@v4 - name: install Linux software if: matrix.os == 'ubuntu-latest' run: | # Need a recent Valgrind, otherwise debug info cannot be read. sudo snap install valgrind --classic sudo apt-get update sudo apt-get install -y --no-install-recommends \ doxygen \ jq \ libc6-dbg \ libcjson-dev \ libfuntools-dev \ qtbase5-dev - name: install macOS software if: runner.os == 'macOS' run: | # Doxygen 1.9.7 is broken with ifdefs again, install 1.9.4 which works. wget https://raw.githubusercontent.com/Homebrew/homebrew-core/41828ee36b96e35b63b2a4c8cfc2df2c3728944a/Formula/doxygen.rb brew install doxygen.rb rm doxygen.rb brew install qt cjson - name: Execute tests run: | set -x PATH=`echo /opt/qt*/bin`:$PATH eval $(echo '${{ matrix.build_cfg.flags }}' | jq -r 'to_entries[] | "\(.key)=\"\(.value)\""') eval "$EVAL" # FIXME: remove -Wno-error-line below. export CFLAGS="$CFLAGS -Wno-error=implicit-function-declaration" make OUT=.config V=1 -s -f Makefile.configure configure && cat .config make -k \ CFLAGS="$CFLAGS -march=native -g1 -Wall -Wextra -Werror" \ CPPFLAGS="-DNDEBUG -DCBOR_ENCODER_WRITER_CONTROL=-1 -DCBOR_PARSER_READER_CONTROL=-1" \ lib/libtinycbor.a size lib/libtinycbor.a | tee sizes make -s clean make -k \ CFLAGS="$CFLAGS -O0 -g" \ LDFLAGS="$LDFLAGS" ${LDLIBS+LDLIBS="$LDLIBS"} grep -q freestanding-pass .config || make \ QMAKEFLAGS="$QMAKEFLAGS QMAKE_CXX=$CXX" \ tests/Makefile grep -q freestanding-pass .config || \ (cd tests && make TESTARGS=-silent check -k \ TESTRUNNER=`which valgrind 2>/dev/null`) make -s clean ! [ $BUILD_DOCS ] || ./scripts/update-docs.sh tinycbor-0.6.1/.tag000066400000000000000000000000511476416203700141310ustar00rootroot00000000000000c0aad2fb2137a31b9845fbaae3653540c410f215 tinycbor-0.6.1/Doxyfile000066400000000000000000000027411476416203700150730ustar00rootroot00000000000000PROJECT_NAME = "TinyCBOR $(VERSION) API" OUTPUT_DIRECTORY = ../doc ABBREVIATE_BRIEF = SHORT_NAMES = YES JAVADOC_AUTOBRIEF = YES QT_AUTOBRIEF = YES TAB_SIZE = 8 ALIASES = "value=\arg \c" OPTIMIZE_OUTPUT_FOR_C = YES EXTRACT_STATIC = YES EXTRACT_LOCAL_CLASSES = NO HIDE_UNDOC_MEMBERS = YES HIDE_UNDOC_CLASSES = YES GENERATE_TODOLIST = NO GENERATE_TESTLIST = NO GENERATE_BUGLIST = NO GENERATE_DEPRECATEDLIST= NO SHOW_USED_FILES = NO WARN_IF_UNDOCUMENTED = NO WARN_LOGFILE = doxygen.log INPUT = . FILE_PATTERNS = *.h \ *.c \ *.dox EXCLUDE_PATTERNS = *_p.h STRIP_CODE_COMMENTS = NO REFERENCED_BY_RELATION = YES IGNORE_PREFIX = cbor_ \ Cbor HTML_TIMESTAMP = NO GENERATE_HTMLHELP = YES GENERATE_CHI = YES BINARY_TOC = YES TOC_EXPAND = YES MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest SEARCHENGINE = NO GENERATE_LATEX = NO COMPACT_LATEX = YES MACRO_EXPANSION = YES PREDEFINED = DOXYGEN \ CBOR_INLINE_API= CLASS_DIAGRAMS = NO CLASS_GRAPH = NO COLLABORATION_GRAPH = NO GROUP_GRAPHS = NO INCLUDE_GRAPH = NO INCLUDED_BY_GRAPH = NO GRAPHICAL_HIERARCHY = NO DIRECTORY_GRAPH = NO tinycbor-0.6.1/LICENSE000066400000000000000000000020621476416203700143660ustar00rootroot00000000000000MIT License Copyright (c) 2017 Intel Corporation Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. tinycbor-0.6.1/Makefile000066400000000000000000000156561476416203700150360ustar00rootroot00000000000000# Variables: prefix = /usr/local exec_prefix = $(prefix) bindir = $(exec_prefix)/bin libdir = $(exec_prefix)/lib includedir = $(prefix)/include pkgconfigdir = $(libdir)/pkgconfig CFLAGS = -Wall -Wextra LDFLAGS_GCSECTIONS = -Wl,--gc-sections LDFLAGS += $(if $(gc_sections-pass),$(LDFLAGS_GCSECTIONS)) LDLIBS = -lm GIT_ARCHIVE = git archive --prefix="$(PACKAGE)/" -9 INSTALL = install INSTALL_DATA = $(INSTALL) -m 644 INSTALL_PROGRAM = $(INSTALL) -m 755 QMAKE = qmake MKDIR = mkdir -p RMDIR = rmdir SED = sed # Our sources TINYCBOR_HEADERS = src/cbor.h src/cborjson.h src/tinycbor-version.h TINYCBOR_FREESTANDING_SOURCES = \ src/cborerrorstrings.c \ src/cborencoder.c \ src/cborencoder_close_container_checked.c \ src/cborencoder_float.c \ src/cborparser.c \ src/cborparser_float.c \ src/cborpretty.c \ # CBORDUMP_SOURCES = tools/cbordump/cbordump.c BUILD_SHARED = $(shell file -L /bin/sh 2>/dev/null | grep -q ELF && echo 1) BUILD_STATIC = 1 ifneq ($(BUILD_STATIC),1) ifneq ($(BUILD_SHARED),1) $(error error: BUILD_STATIC and BUILD_SHARED can not be both disabled) endif endif INSTALL_TARGETS += $(bindir)/cbordump ifeq ($(BUILD_SHARED),1) BINLIBRARY=lib/libtinycbor.so INSTALL_TARGETS += $(libdir)/libtinycbor.so.$(VERSION) endif ifeq ($(BUILD_STATIC),1) BINLIBRARY=lib/libtinycbor.a INSTALL_TARGETS += $(libdir)/libtinycbor.a endif INSTALL_TARGETS += $(pkgconfigdir)/tinycbor.pc INSTALL_TARGETS += $(TINYCBOR_HEADERS:src/%=$(includedir)/tinycbor/%) # setup VPATH MAKEFILE := $(lastword $(MAKEFILE_LIST)) SRCDIR := $(dir $(MAKEFILE)) VPATH = $(SRCDIR):$(SRCDIR)/src # Our version GIT_DIR := $(strip $(shell git -C $(SRCDIR). rev-parse --git-dir 2> /dev/null)) VERSION = $(shell cat $(SRCDIR)VERSION) SOVERSION = $(shell cut -f1-2 -d. $(SRCDIR)VERSION) PACKAGE = tinycbor-$(VERSION) -include .config ifeq ($(wildcard .config),) $(info .config file not yet created) endif ifeq ($(freestanding-pass),1) TINYCBOR_SOURCES = $(TINYCBOR_FREESTANDING_SOURCES) else TINYCBOR_SOURCES = \ $(TINYCBOR_FREESTANDING_SOURCES) \ src/cborparser_dup_string.c \ src/cborpretty_stdio.c \ src/cbortojson.c \ src/cborvalidation.c \ # # if open_memstream is unavailable on the system, try to implement our own # version using funopen or fopencookie ifeq ($(open_memstream-pass),) ifeq ($(funopen-pass)$(fopencookie-pass),) CFLAGS += -DWITHOUT_OPEN_MEMSTREAM ifeq ($(wildcard .config),.config) $(warning warning: funopen and fopencookie unavailable, open_memstream can not be implemented and conversion to JSON will not work properly!) endif else TINYCBOR_SOURCES += src/open_memstream.c endif endif endif # json2cbor depends on an external library (cjson) ifneq ($(cjson-pass)$(system-cjson-pass),) JSON2CBOR_SOURCES = tools/json2cbor/json2cbor.c INSTALL_TARGETS += $(bindir)/json2cbor ifeq ($(system-cjson-pass),1) LDFLAGS_CJSON = -lcjson else JSON2CBOR_SOURCES += src/cjson/cJSON.c json2cbor_CCFLAGS = -I$(SRCDIR)src/cjson endif endif # Rules all: .config \ $(if $(subst 0,,$(BUILD_STATIC)),lib/libtinycbor.a) \ $(if $(subst 0,,$(BUILD_SHARED)),lib/libtinycbor.so) \ $(if $(freestanding-pass),,bin/cbordump) \ tinycbor.pc all: $(if $(JSON2CBOR_SOURCES),bin/json2cbor) check: tests/Makefile | $(BINLIBRARY) $(MAKE) -C tests check silentcheck: | $(BINLIBRARY) TESTARGS=-silent $(MAKE) -f $(MAKEFILE) -s check configure: .config .config: Makefile.configure $(MAKE) -f $(SRCDIR)Makefile.configure OUT='$@' configure lib/libtinycbor-freestanding.a: $(TINYCBOR_FREESTANDING_SOURCES:.c=.o) @$(MKDIR) -p lib $(AR) cqs $@ $^ lib/libtinycbor.a: $(TINYCBOR_SOURCES:.c=.o) @$(MKDIR) -p lib $(AR) cqs $@ $^ lib/libtinycbor.so: $(TINYCBOR_SOURCES:.c=.pic.o) @$(MKDIR) -p lib $(CC) -shared -Wl,-soname,libtinycbor.so.$(SOVERSION) -o lib/libtinycbor.so.$(VERSION) $(LDFLAGS) $^ $(LDLIBS) cd lib ; ln -sf libtinycbor.so.$(VERSION) libtinycbor.so ; ln -sf libtinycbor.so.$(VERSION) libtinycbor.so.$(SOVERSION) bin/cbordump: $(CBORDUMP_SOURCES:.c=.o) $(BINLIBRARY) @$(MKDIR) -p bin $(CC) -o $@ $(LDFLAGS) $^ $(LDLIBS) bin/json2cbor: $(JSON2CBOR_SOURCES:.c=.o) $(BINLIBRARY) @$(MKDIR) -p bin $(CC) -o $@ $(LDFLAGS) $^ $(LDFLAGS_CJSON) $(LDLIBS) tinycbor.pc: tinycbor.pc.in $(SED) > $@ < $< \ -e 's,@prefix@,$(prefix),' \ -e 's,@exec_prefix@,$(exec_prefix),' \ -e 's,@libdir@,$(libdir),' \ -e 's,@includedir@,$(includedir),' \ -e 's,@version@,$(VERSION),' tests/Makefile: tests/tests.pro $(QMAKE) $(QMAKEFLAGS) -o $@ $< $(PACKAGE).tar.gz: | .git GIT_DIR=$(SRCDIR).git $(GIT_ARCHIVE) --format=tar.gz -o "$(PACKAGE).tar.gz" HEAD $(PACKAGE).zip: | .git GIT_DIR=$(SRCDIR).git $(GIT_ARCHIVE) --format=zip -o "$(PACKAGE).zip" HEAD $(DESTDIR)$(libdir)/%: lib/% $(INSTALL) -d $(@D) $(INSTALL_DATA) $< $@ $(DESTDIR)$(bindir)/%: bin/% $(INSTALL) -d $(@D) $(INSTALL_PROGRAM) $< $@ $(DESTDIR)$(pkgconfigdir)/%: % $(INSTALL) -d $(@D) $(INSTALL_DATA) $< $@ $(DESTDIR)$(includedir)/tinycbor/%: src/% $(INSTALL) -d $(@D) $(INSTALL_DATA) $< $@ install-strip: $(MAKE) -f $(MAKEFILE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' install install: $(INSTALL_TARGETS:%=$(DESTDIR)%) ifeq ($(BUILD_SHARED),1) ln -sf libtinycbor.so.$(VERSION) $(DESTDIR)$(libdir)/libtinycbor.so ln -sf libtinycbor.so.$(VERSION) $(DESTDIR)$(libdir)/libtinycbor.so.$(SOVERSION) endif uninstall: $(RM) $(INSTALL_TARGETS:%=$(DESTDIR)%) $(RM) $(DESTDIR)$(libdir)/libtinycbor.so $(RM) $(DESTDIR)$(libdir)/libtinycbor.so.$(SOVERSION) mostlyclean: $(RM) $(TINYCBOR_SOURCES:.c=.o) $(RM) $(TINYCBOR_SOURCES:.c=.pic.o) $(RM) $(CBORDUMP_SOURCES:.c=.o) clean: mostlyclean $(RM) bin/cbordump $(RM) bin/json2cbor $(RM) lib/libtinycbor.a $(RM) lib/libtinycbor-freestanding.a $(RM) tinycbor.pc $(RM) lib/libtinycbor.so* test -e tests/Makefile && $(MAKE) -C tests clean || : distclean: clean test -e tests/Makefile && $(MAKE) -C tests distclean || : docs: cd $(SRCDIR)src && VERSION=$(VERSION) doxygen $(SRCDIR)/../Doxyfile dist: $(PACKAGE).tar.gz $(PACKAGE).zip distcheck: .git -$(RM) -r $${TMPDIR-/tmp}/tinycbor-distcheck GIT_DIR=$(SRCDIR).git git archive --prefix=tinycbor-distcheck/ --format=tar HEAD | tar -xf - -C $${TMPDIR-/tmp} cd $${TMPDIR-/tmp}/tinycbor-distcheck && $(MAKE) silentcheck $(RM) -r $${TMPDIR-/tmp}/tinycbor-distcheck tag: distcheck @cd $(SRCDIR). && perl scripts/maketag.pl .PHONY: all check silentcheck configure install uninstall .PHONY: mostlyclean clean distclean .PHONY: docs dist distcheck release .SECONDARY: cflags := $(CPPFLAGS) -I$(SRCDIR)src cflags += -std=gnu99 $(CFLAGS) ifneq ($(DISABLE_WERROR),1) cflags += \ $(shell $(CC) -S -Werror -Wdiscarded-qualifiers -o - -xc /dev/null >/dev/null 2>&1 && echo -Werror=discarded-qualifiers) \ -Werror=incompatible-pointer-types \ -Werror=implicit-function-declaration \ -Werror=int-conversion endif %.o: %.c @test -d $(@D) || $(MKDIR) $(@D) $(CC) $(cflags) $($(basename $(notdir $@))_CCFLAGS) -c -o $@ $< %.pic.o: %.c @test -d $(@D) || $(MKDIR) $(@D) $(CC) $(cflags) -fPIC $($(basename $(notdir $@))_CCFLAGS) -c -o $@ $< -include src/*.d tinycbor-0.6.1/Makefile.configure000066400000000000000000000026031476416203700170020ustar00rootroot00000000000000ALLTESTS = open_memstream funopen fopencookie gc_sections \ system-cjson cjson freestanding MAKEFILE := $(lastword $(MAKEFILE_LIST)) OUT := PROGRAM-open_memstream = extern int open_memstream(); int main() { return open_memstream(); } PROGRAM-funopen = extern int funopen(); int main() { return funopen(); } PROGRAM-fopencookie = extern int fopencookie(); int main() { return fopencookie(); } PROGRAM-gc_sections = int main() {} CCFLAGS-gc_sections = -Wl,--gc-sections PROGRAM-freestanding = \#if !defined(__STDC_HOSTED__) || __STDC_HOSTED__-0 == 1\n PROGRAM-freestanding += \#error Hosted implementation\n PROGRAM-freestanding += \#endif\n PROGRAM-freestanding += int main() {} CCFLAGS-freestanding = $(CFLAGS) PROGRAM-cjson = \#include \n PROGRAM-cjson += \#include \n PROGRAM-cjson += \#include \n PROGRAM-cjson += int main() { double d = NAN; return cJSON_False; } CCFLAGS-cjson = -I. -I$(dir $(MAKEFILE))src PROGRAM-system-cjson = $(PROGRAM-cjson) CCFLAGS-system-cjson = -I. -lcjson sink: @echo >&2 Please run from the top-level Makefile. configure: $(foreach it,$(ALLTESTS),check-$(it)) check-%: @echo $(subst check-,,$@)-tested := 1 >>$(OUT) $(if $(V),,@)if printf "$($(subst check-,PROGRAM-,$@))" | \ $(CC) -xc $($(subst check-,CCFLAGS-,$@)) -o /dev/null - $(if $(V),,>/dev/null 2>&1); \ then \ echo $(subst check-,,$@)-pass := 1 >>$(OUT); \ fi tinycbor-0.6.1/Makefile.nmake000066400000000000000000000023171476416203700161160ustar00rootroot00000000000000CFLAGS = -W3 TINYCBOR_HEADERS = src\cbor.h src\cborjson.h TINYCBOR_SOURCES = \ src\cborerrorstrings.c \ src\cborencoder.c \ src\cborencoder_close_container_checked.c \ src\cborencoder_float.c \ src\cborparser.c \ src\cborparser_dup_string.c \ src\cborparser_float.c \ src\cborpretty.c \ src\cborpretty_stdio.c \ src\cborvalidation.c TINYCBOR_OBJS = \ src\cborerrorstrings.obj \ src\cborencoder.obj \ src\cborencoder_close_container_checked.obj \ src\cborencoder_float.obj \ src\cborparser.obj \ src\cborparser_dup_string.obj \ src\cborparser_float.obj \ src\cborpretty.obj \ src\cborpretty_stdio.obj \ src\cborvalidation.obj all: lib\tinycbor.lib check: tests\Makefile lib\tinycbor.lib cd tests & $(MAKE) check silentcheck: cd tests & set TESTARGS=-silent & $(MAKE) -s check tests\Makefile: tests\tests.pro qmake -o $@ $** lib\tinycbor.lib: $(TINYCBOR_OBJS) -if not exist lib\NUL md lib lib -nologo /out:$@ $** mostlyclean: -del $(TINYCBOR_OBJS) clean: mostlyclean -del lib\tinycbor.lib if exist tests\Makefile (cd tests & $(MAKE) clean) distclean: clean if exist tests\Makefile (cd tests & $(MAKE) distclean) tag: @perl maketag.pl {src\}.c{src\}.obj: $(CC) -nologo $(CFLAGS) -Isrc -c -Fo$@ $< tinycbor-0.6.1/README000066400000000000000000000004631476416203700142440ustar00rootroot00000000000000Concise Binary Object Representation (CBOR) Library --------------------------------------------------- To build TinyCBOR: make If you want to change the compiler or pass extra compiler flags: make CC=clang CFLAGS="-m32 -Oz" LDFLAGS="-m32" Documentation: https://intel.github.io/tinycbor/current/ tinycbor-0.6.1/SECURITY.md000066400000000000000000000006251476416203700151550ustar00rootroot00000000000000# Security Policy Intel is committed to rapidly addressing security vulnerabilities affecting our customers and providing clear guidance on the solution, impact, severity and mitigation. ## Reporting a Vulnerability Please report any security vulnerabilities in this project utilizing the guidelines [here](https://www.intel.com/content/www/us/en/security-center/vulnerability-handling-guidelines.html). tinycbor-0.6.1/TODO000066400000000000000000000015131476416203700140510ustar00rootroot00000000000000==== To Do list for libcbor ==== === General === * API review * Benchmark * Write examples ** Simple decoder ** Decoder to JSON ** Windowed encoding/decoding (limited memory) === Encoder === * Write API docs * Add API for creating indeterminate-length arrays and maps * Add API for creating indeterminate-length strings * Add API for relaxing doubles to floats and to integers * Add length-checking of the sub-containers (#ifndef CBOR_ENCODER_NO_USER_CHECK) * Decide how to indicate number of bytes needed ** Suggestion: return negative number from the functions === Decoder === * Write functions not yet implemented * Add API for stream-decoding strings * Add API for checking known tags and simple types * (unlikely) Add API for checking the pairing of a tag and the tagged type * Write tests for error conditions * Fuzzy-test the decoder tinycbor-0.6.1/VERSION000066400000000000000000000000061476416203700144250ustar00rootroot000000000000000.6.0 tinycbor-0.6.1/examples/000077500000000000000000000000001476416203700151775ustar00rootroot00000000000000tinycbor-0.6.1/examples/examples.pro000066400000000000000000000000561476416203700175400ustar00rootroot00000000000000TEMPLATE = subdirs SUBDIRS = simplereader.pro tinycbor-0.6.1/examples/simplereader.c000066400000000000000000000110461476416203700200210ustar00rootroot00000000000000#include "../src/cbor.h" #include #include #include #include #include static uint8_t *readfile(const char *fname, size_t *size) { struct stat st; FILE *f = fopen(fname, "rb"); if (!f) return NULL; if (fstat(fileno(f), &st) == -1) return NULL; uint8_t *buf = malloc(st.st_size); if (buf == NULL) return NULL; *size = fread(buf, st.st_size, 1, f) == 1 ? st.st_size : 0; fclose(f); return buf; } static void indent(int nestingLevel) { while (nestingLevel--) printf(" "); } static void dumpbytes(const uint8_t *buf, size_t len) { printf("\""); while (len--) printf("\\x%02X", *buf++); printf("\""); } static CborError dumprecursive(CborValue *it, int nestingLevel) { while (!cbor_value_at_end(it)) { CborError err; CborType type = cbor_value_get_type(it); indent(nestingLevel); switch (type) { case CborArrayType: case CborMapType: { // recursive type CborValue recursed; assert(cbor_value_is_container(it)); puts(type == CborArrayType ? "Array[" : "Map["); err = cbor_value_enter_container(it, &recursed); if (err) return err; // parse error err = dumprecursive(&recursed, nestingLevel + 1); if (err) return err; // parse error err = cbor_value_leave_container(it, &recursed); if (err) return err; // parse error indent(nestingLevel); puts("]"); continue; } case CborIntegerType: { int64_t val; cbor_value_get_int64(it, &val); // can't fail printf("%lld\n", (long long)val); break; } case CborByteStringType: { uint8_t *buf; size_t n; err = cbor_value_dup_byte_string(it, &buf, &n, it); if (err) return err; // parse error dumpbytes(buf, n); puts(""); free(buf); continue; } case CborTextStringType: { char *buf; size_t n; err = cbor_value_dup_text_string(it, &buf, &n, it); if (err) return err; // parse error printf("\"%s\"\n", buf); free(buf); continue; } case CborTagType: { CborTag tag; cbor_value_get_tag(it, &tag); // can't fail printf("Tag(%lld)\n", (long long)tag); break; } case CborSimpleType: { uint8_t type; cbor_value_get_simple_type(it, &type); // can't fail printf("simple(%u)\n", type); break; } case CborNullType: puts("null"); break; case CborUndefinedType: puts("undefined"); break; case CborBooleanType: { bool val; cbor_value_get_boolean(it, &val); // can't fail puts(val ? "true" : "false"); break; } case CborDoubleType: { double val; if (false) { float f; case CborFloatType: cbor_value_get_float(it, &f); val = f; } else { cbor_value_get_double(it, &val); } printf("%g\n", val); break; } case CborHalfFloatType: { uint16_t val; cbor_value_get_half_float(it, &val); printf("__f16(%04x)\n", val); break; } case CborInvalidType: assert(false); // can't happen break; } err = cbor_value_advance_fixed(it); if (err) return err; } return CborNoError; } int main(int argc, char **argv) { if (argc != 2) { puts("simplereader "); return 1; } size_t length; uint8_t *buf = readfile(argv[1], &length); if (!buf) { perror("readfile"); return 1; } CborParser parser; CborValue it; CborError err = cbor_parser_init(buf, length, 0, &parser, &it); if (!err) err = dumprecursive(&it, 0); free(buf); if (err) { fprintf(stderr, "CBOR parsing failure at offset %ld: %s\n", cbor_value_get_next_byte(&it) - buf, cbor_error_string(err)); return 1; } return 0; } tinycbor-0.6.1/examples/simplereader.pro000066400000000000000000000000761476416203700204000ustar00rootroot00000000000000CONFIG -= qt SOURCES = simplereader.c include(../src/src.pri) tinycbor-0.6.1/scripts/000077500000000000000000000000001476416203700150505ustar00rootroot00000000000000tinycbor-0.6.1/scripts/maketag.pl000066400000000000000000000046361476416203700170270ustar00rootroot00000000000000#!perl use strict; sub run(@) { open PROC, "-|", @_ or die("Cannot run $_[0]: $!"); my @out; while () { chomp; push @out, $_; } close PROC; return @out; } my @tags = run("git", "tag"); my @v = run("git", "show", "HEAD:VERSION"); my $v = $v[0]; my $tagfile = ".git/TAG_EDITMSG"; open TAGFILE, ">", $tagfile or die("Cannot create file for editing tag message: $!"); select TAGFILE; print "TinyCBOR release $v\n"; print "\n"; print "# Write something nice about this release here\n"; # Do we have a commit template? my @result = run("git", "config", "--get", "commit.template"); if (scalar @result) { open TEMPLATE, "<", $result[0]; map { print $_; }