├── debian ├── compat ├── docs ├── source │ └── format ├── libmsgpuck-dev.manpages ├── .gitignore ├── rules ├── changelog ├── control └── copyright ├── test ├── .gitignore ├── CMakeLists.txt ├── test.c ├── test.h └── msgpuck.cc ├── AUTHORS ├── Jenkinsfile ├── .gitignore ├── perf ├── CMakeLists.txt └── msgpuck.cc ├── LICENSE ├── .build.mk ├── CMakeLists.txt ├── .travis.yml ├── README.md ├── rpm └── msgpuck.spec ├── msgpuck.c ├── hints.c └── Doxyfile.in /debian/compat: -------------------------------------------------------------------------------- 1 | 9 2 | -------------------------------------------------------------------------------- /debian/docs: -------------------------------------------------------------------------------- 1 | README.md 2 | -------------------------------------------------------------------------------- /test/.gitignore: -------------------------------------------------------------------------------- 1 | *.test 2 | -------------------------------------------------------------------------------- /debian/source/format: -------------------------------------------------------------------------------- 1 | 3.0 (quilt) 2 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Roman Tsisyk - initial author 2 | -------------------------------------------------------------------------------- /debian/libmsgpuck-dev.manpages: -------------------------------------------------------------------------------- 1 | obj-*/doc/man/man3/msgpuck.h.3 2 | -------------------------------------------------------------------------------- /debian/.gitignore: -------------------------------------------------------------------------------- 1 | libmsgpuck-dev/ 2 | libmsgpuck-doc/ 3 | tmp/ 4 | files 5 | stamp-* 6 | *.substvars 7 | -------------------------------------------------------------------------------- /Jenkinsfile: -------------------------------------------------------------------------------- 1 | stage('Build'){ 2 | packpack = new org.tarantool.packpack() 3 | node { 4 | checkout scm 5 | packpack.prepareSources() 6 | } 7 | packpack.packpackBuildMatrix('result') 8 | } 9 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | *.a 3 | *.o 4 | *.so* 5 | *.dynlib* 6 | *.user 7 | *.cbp 8 | *.log 9 | obj-*/ 10 | doc/ 11 | CMakeFiles/ 12 | CMakeCache.txt 13 | cmake_install.cmake 14 | install_manifest.txt 15 | Makefile 16 | Doxyfile.html 17 | Doxyfile.man 18 | debian/* 19 | VERSION 20 | ./build 21 | /build 22 | ./test_build 23 | /test_build 24 | -------------------------------------------------------------------------------- /debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | 3 | DEB_CMAKE_EXTRA_FLAGS := -DCMAKE_BUILD_TYPE=RelWithDebInfo 4 | DEB_MAKE_CHECK_TARGET := test 5 | 6 | VERSION := $(shell dpkg-parsechangelog|grep ^Version|awk '{print $$2}') 7 | UVERSION := $(shell echo $(VERSION)|sed 's/-[[:digit:]]\+$$//') 8 | 9 | include /usr/share/cdbs/1/rules/debhelper.mk 10 | include /usr/share/cdbs/1/class/cmake.mk 11 | 12 | build-indep: 13 | cd $(DEB_BUILDDIR) && $(MAKE) doc 14 | 15 | tarball: clean 16 | tar --exclude=.git --exclude=debian \ 17 | --transform='s,^\.,msgpuck_$(UVERSION),S' \ 18 | -czf ../msgpuck_$(UVERSION).orig.tar.gz . 19 | -------------------------------------------------------------------------------- /test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if(POLICY CMP0037) 2 | cmake_policy(SET CMP0037 OLD) # don't blame custom target names 3 | endif(POLICY CMP0037) 4 | 5 | include_directories("../") 6 | 7 | #find_program(PROVE prove) 8 | if (PROVE) 9 | set(TEST_RUNNER prove) 10 | else() 11 | set(TEST_RUNNER) 12 | endif() 13 | 14 | set(alltests) 15 | foreach (test msgpuck) 16 | add_executable(${test}.test ${test}.cc test.c) 17 | target_link_libraries(${test}.test msgpuck) 18 | 19 | list(APPEND alltests ${test}.test_run) 20 | add_custom_target(${test}.test_run 21 | DEPENDS ${test}.test 22 | COMMAND ${TEST_RUNNER} ${PROJECT_BINARY_DIR}/test/${test}.test) 23 | endforeach() 24 | 25 | add_custom_target(test DEPENDS ${alltests}) 26 | -------------------------------------------------------------------------------- /perf/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_CXX_STANDARD 11) 2 | 3 | if (CMAKE_BUILD_TYPE STREQUAL "Debug") 4 | message(AUTHOR_WARNING "Benchmark available only in release build") 5 | return() 6 | endif() 7 | 8 | # Handle a case when BENCHMARK_LIBRARIES, BENCHMARK_INCLUDE_DIRS 9 | # and benchmark_FOUND are defined in the parent project, like in 10 | # the Tarantool, that uses the bundled Benchmark library. 11 | if (NOT benchmark_FOUND) 12 | find_package(benchmark QUIET) 13 | if (NOT benchmark_FOUND) 14 | message(AUTHOR_WARNING "Google Benchmark library not found") 15 | return() 16 | endif() 17 | set(BENCHMARK_LIBRARIES benchmark::benchmark) 18 | endif() 19 | 20 | include_directories("${PROJECT_SOURCE_DIR}") 21 | 22 | add_executable(msgpuck.perftest msgpuck.cc) 23 | target_link_libraries(msgpuck.perftest msgpuck ${BENCHMARK_LIBRARIES} pthread) 24 | target_include_directories(msgpuck.perftest PUBLIC ${BENCHMARK_INCLUDE_DIRS}) 25 | -------------------------------------------------------------------------------- /debian/changelog: -------------------------------------------------------------------------------- 1 | msgpuck (2.0.0-1) unstable; urgency=medium 2 | 3 | * Drop MP_SOURCE support and make libmsgpuck.a to be mandatory 4 | * Add helpers to decode any number to int64/double 5 | * Add -fPIC to libmsgpuck.a 6 | 7 | -- Roman Tsisyk Tue, 07 Feb 2017 13:57:10 +0300 8 | 9 | msgpuck (1.1.3-1) unstable; urgency=medium 10 | 11 | * Add mp_snprint() function. 12 | * Change mp_fprint() to return the number of bytes printed instead of 0. 13 | * Fix CVE-2016-9036. 14 | 15 | -- Roman Tsisyk Fri, 16 Dec 2016 17:53:40 +0300 16 | 17 | msgpuck (1.0.3-1) unstable; urgency=medium 18 | 19 | * Fix GCC 6.0 and Doxygen warnings 20 | * Fix out-of-bounds access in the test suite (failed on hppa) 21 | * Add mp_decode_strbin() and mp_decode_strbinl() 22 | * Add mp_fprint() for debug output 23 | 24 | -- Roman Tsisyk Tue, 09 Aug 2016 22:14:15 +0300 25 | 26 | msgpuck (1.0.1-1) unstable; urgency=medium 27 | 28 | * Initial release. (Closes: #811167) 29 | 30 | -- Roman Tsisyk Sat, 16 Jan 2016 18:20:30 +0300 31 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013-2016 MsgPuck Authors 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or 5 | without modification, are permitted provided that the following 6 | conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above 9 | copyright notice, this list of conditions and the 10 | following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above 13 | copyright notice, this list of conditions and the following 14 | disclaimer in the documentation and/or other materials 15 | provided with the distribution. 16 | 17 | THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 19 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 21 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 22 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 25 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 28 | THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /debian/control: -------------------------------------------------------------------------------- 1 | Source: msgpuck 2 | Priority: optional 3 | Section: libdevel 4 | Maintainer: Roman Tsisyk 5 | Uploaders: Dmitry E. Oboukhov 6 | Build-Depends: debhelper (>= 9), cdbs, 7 | cmake (>= 2.8), 8 | doxygen (>= 1.6) 9 | Standards-Version: 3.9.8 10 | Homepage: https://github.com/rtsisyk/msgpuck 11 | Vcs-Git: git://github.com/rtsisyk/msgpuck.git 12 | Vcs-Browser: https://github.com/rtsisyk/msgpuck 13 | 14 | Package: libmsgpuck-dev 15 | Architecture: any 16 | Depends: ${misc:Depends} 17 | Pre-Depends: ${misc:Pre-Depends} 18 | Description: Lightweight MessagePack library 19 | MsgPuck is a compact and efficient MessagePack serialization library 20 | designed with zero-cost abstractions in mind. Almost all encoding/decoding 21 | functions can be fully inlined into your application by C/C++ compiler 22 | to reach the maximum performance. 23 | . 24 | MessagePack is an efficient binary serialization format. 25 | It lets you exchange data among multiple languages like JSON. 26 | But it's faster and smaller. Small integers are encoded into a single byte, 27 | and typical short strings require only one extra byte in addition to the 28 | strings themselves. 29 | . 30 | This package provides a header file and a static library. 31 | The static library contains fallback code for inline functions and 32 | globals tables needed by library functions. 33 | -------------------------------------------------------------------------------- /.build.mk: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2015 MsgPuck Authors 2 | # All rights reserved. 3 | # 4 | # Redistribution and use in source and binary forms, with or 5 | # without modification, are permitted provided that the following 6 | # conditions are met: 7 | # 8 | # 1. Redistributions of source code must retain the above 9 | # copyright notice, this list of conditions and the 10 | # following disclaimer. 11 | # 12 | # 2. Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following 14 | # disclaimer in the documentation and/or other materials 15 | # provided with the distribution. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND 18 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 19 | # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 21 | # OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 22 | # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 25 | # BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 28 | # THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | # SUCH DAMAGE. 30 | 31 | test: 32 | rm -rf ./test_build 33 | mkdir ./test_build && cd ./test_build && cmake .. -DCMAKE_BUILD_TYPE=RelWithDebugInfo 34 | cd test_build && $(MAKE) test 35 | 36 | .PHONY: test 37 | -------------------------------------------------------------------------------- /test/test.c: -------------------------------------------------------------------------------- 1 | #include "test.h" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | enum { MAX_LEVELS = 10 }; 8 | static int tests_done[MAX_LEVELS]; 9 | static int tests_failed[MAX_LEVELS]; 10 | static int plan_test[MAX_LEVELS]; 11 | static int level = -1; 12 | 13 | void 14 | _space(FILE *stream) 15 | { 16 | for (int i = 0 ; i < level; i++) { 17 | fprintf(stream, " "); 18 | } 19 | } 20 | 21 | void 22 | _plan(int count, bool tap) 23 | { 24 | ++level; 25 | plan_test[level] = count; 26 | tests_done[level] = 0; 27 | tests_failed[level] = 0; 28 | 29 | if (tap && level == 0) 30 | printf("TAP version 13\n"); 31 | 32 | _space(stdout); 33 | printf("%d..%d\n", 1, plan_test[level]); 34 | } 35 | 36 | int 37 | check_plan(void) 38 | { 39 | int r = 0; 40 | if (tests_done[level] != plan_test[level]) { 41 | _space(stderr); 42 | fprintf(stderr, 43 | "# Looks like you planned %d tests but ran %d.\n", 44 | plan_test[level], tests_done[level]); 45 | r = -1; 46 | } 47 | 48 | if (tests_failed[level]) { 49 | _space(stderr); 50 | fprintf(stderr, 51 | "# Looks like you failed %d test of %d run.\n", 52 | tests_failed[level], tests_done[level]); 53 | r = tests_failed[level]; 54 | } 55 | --level; 56 | if (level >= 0) { 57 | is(r, 0, "subtests"); 58 | } 59 | return r; 60 | } 61 | 62 | void 63 | _ok(int condition, const char *expr, const char *file, int line, 64 | const char *fmt, ...) 65 | { 66 | va_list ap; 67 | 68 | _space(stdout); 69 | printf("%s %d - ", condition ? "ok" : "not ok", ++tests_done[level]); 70 | va_start(ap, fmt); 71 | vprintf(fmt, ap); 72 | printf("\n"); 73 | va_end(ap); 74 | if (!condition) { 75 | tests_failed[level]++; 76 | _space(stderr); 77 | fprintf(stderr, "# Failed test `%s'\n", expr); 78 | _space(stderr); 79 | fprintf(stderr, "# in %s at line %d\n", file, line); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /debian/copyright: -------------------------------------------------------------------------------- 1 | Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ 2 | Debianized-By: Roman Tsisyk 3 | Upstream-Name: msgpuck 4 | Upstream-Contact: roman@tarantool.org 5 | Source: https://github.com/rtsisyk/msgpuck 6 | 7 | Files: test/test.h test/test.c 8 | Copyright: 2010-2015 by Aleksandr Lyapunov, Aleksey Demakov, Aleksey Mashanov, 9 | Alexandre Kalendarev, Andrey Drozdov, Anton Barabanov, Damien Lefortier, 10 | Dmitry E. Oboukhov, Dmitry Simonenko, Eugene Blikh, Eugene Shadrin, 11 | Konstantin Knizhnik, Konstantin Osipov, Konstantin Shulgin, Mons Anderson, 12 | Marko Kevac, Oleg Tsarev, Pavel Cherenkov, Roman Antipin, Roman Tokarev, 13 | Roman Tsisyk, Teodor Sigaev, Timofey Khryukin, Veniamin Gvozdikov, 14 | Vassiliy Soshnikov, Vladimir Rudnyh, Yuriy Nevinitsin, Yuriy Vostrikov 15 | License: BSD-2-Clause 16 | 17 | Files: * 18 | Copyright: 2014-2015 by Roman Tsisyk 19 | License: BSD-2-Clause 20 | 21 | License: BSD-2-Clause 22 | Redistribution and use in source and binary forms, with or 23 | without modification, are permitted provided that the following 24 | conditions are met: 25 | . 26 | 1. Redistributions of source code must retain the above 27 | copyright notice, this list of conditions and the 28 | following disclaimer. 29 | . 30 | 2. Redistributions in binary form must reproduce the above 31 | copyright notice, this list of conditions and the following 32 | disclaimer in the documentation and/or other materials 33 | provided with the distribution. 34 | . 35 | THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND 36 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 37 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 38 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 39 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 40 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 41 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 42 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 43 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 44 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 45 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 46 | THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 47 | SUCH DAMAGE. 48 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(msgpuck C CXX) 2 | cmake_minimum_required(VERSION 3.5) 3 | 4 | if(CMAKE_C_COMPILER_ID MATCHES "GNU|Clang") 5 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -fPIC -fstrict-aliasing") 6 | set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wall -Wextra -Werror") 7 | endif() 8 | 9 | if(NOT CMAKE_BUILD_TYPE) 10 | set(CMAKE_BUILD_TYPE Debug CACHE STRING 11 | "Build type, options are: Debug Release." FORCE) 12 | endif() 13 | 14 | include(CheckCCompilerFlag) 15 | check_c_compiler_flag("-mno-unaligned-access" CC_HAS_MNO_UNALIGNED_ACCESS) 16 | 17 | add_library(msgpuck STATIC msgpuck.c hints.c) 18 | set_target_properties(msgpuck PROPERTIES VERSION 1.0 SOVERSION 1) 19 | set_target_properties(msgpuck PROPERTIES OUTPUT_NAME "msgpuck") 20 | 21 | add_subdirectory(perf) 22 | 23 | if (NOT ${PROJECT_SOURCE_DIR} STREQUAL ${CMAKE_SOURCE_DIR}) 24 | # Embedded mode, skip tests, documentation and the install targets 25 | return() 26 | endif() 27 | 28 | option(ENABLE_GCOV "Enable integration with gcov, a code coverage program" OFF) 29 | if (ENABLE_GCOV) 30 | set(_flags "-fprofile-arcs -ftest-coverage") 31 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_flags}") 32 | set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${_flags}") 33 | set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${_flags}") 34 | endif() 35 | 36 | add_subdirectory(test) 37 | 38 | include(GNUInstallDirs) 39 | install(TARGETS msgpuck 40 | ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} 41 | LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} 42 | COMPONENT library) 43 | install(FILES msgpuck.h DESTINATION include) 44 | 45 | find_package(Doxygen) 46 | if(NOT DOXYGEN_FOUND) 47 | return() 48 | endif() 49 | 50 | set(GENERATE_HTML "NO") 51 | set(GENERATE_MAN "YES") 52 | configure_file("${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in" 53 | "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile.man") 54 | add_custom_command(OUTPUT doc/man/man3/msgpuck.h.3 55 | COMMAND ${CMAKE_COMMAND} -E make_directory doc/man 56 | COMMAND ${DOXYGEN_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile.man" 57 | WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" 58 | DEPENDS msgpuck.h 59 | COMMENT "Generating man pages" VERBATIM) 60 | add_custom_target(man DEPENDS doc/man/man3/msgpuck.h.3) 61 | 62 | set(GENERATE_HTML "YES") 63 | set(GENERATE_MAN "NO") 64 | configure_file("${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in" 65 | "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile.html") 66 | add_custom_command(OUTPUT doc/html/index.html 67 | COMMAND ${CMAKE_COMMAND} -E make_directory doc/html 68 | COMMAND ${DOXYGEN_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile.html" 69 | COMMAND ${CMAKE_COMMAND} -E rename doc/html/msgpuck_8h.html 70 | doc/html/index.html 71 | COMMAND sed s/msgpuck_8h\\.html/index\\.html/ -i doc/html/index.html 72 | WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" 73 | DEPENDS msgpuck.h 74 | COMMENT "Generating html documentation" VERBATIM) 75 | add_custom_target(html DEPENDS doc/html/index.html) 76 | 77 | add_custom_target(doc DEPENDS man html) 78 | -------------------------------------------------------------------------------- /perf/msgpuck.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "msgpuck.h" 6 | 7 | #define DATA_SIZE (128 * 1024 * 1024) 8 | 9 | static auto generator = std::mt19937_64{}; 10 | 11 | struct data_set { 12 | char *data; 13 | char *end; 14 | char *buf_end; 15 | int count; 16 | }; 17 | 18 | static void 19 | data_set_create(struct data_set *set) 20 | { 21 | set->data = (char *)malloc(DATA_SIZE); 22 | set->buf_end = set->data + DATA_SIZE; 23 | /* No any data on creation. */ 24 | set->end = set->data; 25 | set->count = 0; 26 | } 27 | 28 | static void 29 | data_set_destroy(struct data_set *set) 30 | { 31 | free(set->data); 32 | } 33 | 34 | template 35 | static void 36 | data_set_reset(struct data_set *set, Generator gen) 37 | { 38 | set->count = 0; 39 | set->end = set->data; 40 | while (true) { 41 | size_t size = gen(set->end, set->buf_end); 42 | if (size == 0) 43 | break; 44 | set->end += size; 45 | set->count++; 46 | } 47 | } 48 | 49 | static uint64_t 50 | uint_max(int bits) 51 | { 52 | if (bits == 64) 53 | return UINT64_MAX; 54 | else 55 | return (1ULL << bits) - 1; 56 | } 57 | 58 | template 59 | static size_t 60 | mp_uint_generate(char *buf, char *buf_end, UintDist dist) 61 | { 62 | uint64_t v = dist(generator); 63 | size_t size = mp_sizeof_uint(v); 64 | if (buf + size > buf_end) 65 | return 0; 66 | mp_encode_uint(buf, v); 67 | return size; 68 | } 69 | 70 | static void 71 | bench_mp_next_uint(benchmark::State& state) 72 | { 73 | using namespace std::placeholders; 74 | struct data_set set; 75 | data_set_create(&set); 76 | 77 | /** The test parametrized by number of bits in UINT. */ 78 | int bits = state.range(0); 79 | auto dist = std::uniform_int_distribution(0, uint_max(bits)); 80 | data_set_reset(&set, 81 | std::bind(mp_uint_generate, _1, _2, 82 | dist)); 83 | 84 | for (auto _ : state) { 85 | const char *d = set.data; 86 | for (int i = 0; i < set.count; i++) 87 | mp_next(&d); 88 | } 89 | state.SetItemsProcessed(state.iterations() * set.count); 90 | 91 | data_set_destroy(&set); 92 | } 93 | 94 | static void 95 | bench_mp_check_uint(benchmark::State& state) 96 | { 97 | using namespace std::placeholders; 98 | struct data_set set; 99 | data_set_create(&set); 100 | 101 | /** The test parametrized by number of bits in UINT. */ 102 | int bits = state.range(0); 103 | auto dist = std::uniform_int_distribution(0, uint_max(bits)); 104 | data_set_reset(&set, 105 | std::bind(mp_uint_generate, _1, _2, 106 | dist)); 107 | 108 | for (auto _ : state) { 109 | const char *d = set.data; 110 | for (int i = 0; i < set.count; i++) { 111 | if (mp_check(&d, set.end) != 0) 112 | abort(); 113 | } 114 | } 115 | state.SetItemsProcessed(state.iterations() * set.count); 116 | 117 | data_set_destroy(&set); 118 | } 119 | 120 | BENCHMARK(bench_mp_next_uint)->Arg(7)->Arg(16)->Arg(32)->Arg(64); 121 | BENCHMARK(bench_mp_check_uint)->Arg(7)->Arg(16)->Arg(32)->Arg(64); 122 | 123 | BENCHMARK_MAIN(); 124 | -------------------------------------------------------------------------------- /test/test.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include /* exit() */ 6 | 7 | #define fail(expr, result) do { \ 8 | fprintf(stderr, "Test failed: %s is %s at %s:%d, in function '%s'\n",\ 9 | expr, result, __FILE__, __LINE__, __func__); \ 10 | exit(-1); \ 11 | } while (0) 12 | 13 | #define fail_if(expr) do { if (expr) fail(#expr, "true"); } while (0) 14 | #define fail_unless(expr) do { if (!(expr)) fail(#expr, "false"); } while (0) 15 | 16 | #define note(...) msg(stdout, __VA_ARGS__) 17 | #define diag(...) msg(stderr, __VA_ARGS__) 18 | 19 | #define msg(stream, ...) ({ _space(stream); fprintf(stream, "# "); \ 20 | fprintf(stream, __VA_ARGS__); fprintf(stream, "\n"); }) 21 | 22 | #if defined(__cplusplus) 23 | extern "C" { 24 | #endif /* defined(__cplusplus) */ 25 | 26 | /** 27 | @brief example 28 | 29 | @code 30 | #include "test.h" 31 | 32 | int main(void) { 33 | plan(3); // count of test You planned to check 34 | ok(1, "Test name 1"); 35 | is(4, 2 * 2, "2 * 2 == 4"); 36 | isnt(5, 2 * 2, "2 * 2 != 5); 37 | return check_plan(); // print resume 38 | } 39 | @endcode 40 | */ 41 | 42 | /* private function, use ok(...) instead */ 43 | void 44 | _ok(int condition, const char *expr, const char *file, int line, 45 | const char *fmt, ...); 46 | 47 | /* private function, use note(...) or diag(...) instead */ 48 | void _space(FILE *stream); 49 | 50 | /** 51 | @brief set and print plan 52 | @param count 53 | Before anything else, you need a testing plan. This basically declares 54 | how many tests your program is going to run to protect against premature 55 | failure. 56 | */ 57 | void 58 | _plan(int count, bool tap); 59 | 60 | /** 61 | @brief check if plan is reached and print report 62 | */ 63 | int check_plan(void); 64 | 65 | /* 66 | * The ok macro is defined so that it can be called without a message: 67 | * 68 | * ok(true); 69 | * ok(true, "message"); 70 | * ok(true, "message %d", i); 71 | * 72 | * It supports up to 7 format arguments. 73 | */ 74 | #define _select_10th(f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, ...) f10 75 | #define _ok0(cond, expr, ...) \ 76 | _select_10th(, ##__VA_ARGS__, \ 77 | _ok(cond, expr, __FILE__, __LINE__, __VA_ARGS__), \ 78 | _ok(cond, expr, __FILE__, __LINE__, __VA_ARGS__), \ 79 | _ok(cond, expr, __FILE__, __LINE__, __VA_ARGS__), \ 80 | _ok(cond, expr, __FILE__, __LINE__, __VA_ARGS__), \ 81 | _ok(cond, expr, __FILE__, __LINE__, __VA_ARGS__), \ 82 | _ok(cond, expr, __FILE__, __LINE__, __VA_ARGS__), \ 83 | _ok(cond, expr, __FILE__, __LINE__, __VA_ARGS__), \ 84 | _ok(cond, expr, __FILE__, __LINE__, __VA_ARGS__), \ 85 | _ok(cond, expr, __FILE__, __LINE__, "line %d", __LINE__)) 86 | 87 | #define ok(cond, ...) _ok0(cond, #cond, ##__VA_ARGS__) 88 | #define is(a, b, ...) _ok0((a) == (b), #a " == " #b, ##__VA_ARGS__) 89 | #define isnt(a, b, ...) _ok0((a) != (b), #a " != " #b, ##__VA_ARGS__) 90 | 91 | #define is_str(a, b, fmt, args...) ok(strcmp(a, b) == 0, fmt, ##args) 92 | 93 | #if UNIT_TAP_COMPATIBLE 94 | 95 | #define header() \ 96 | do { \ 97 | _space(stdout); \ 98 | printf("# *** %s ***\n", __func__); \ 99 | } while (0) 100 | 101 | #define footer() \ 102 | do { \ 103 | _space(stdout); \ 104 | printf("# *** %s: done ***\n", __func__); \ 105 | } while (0) 106 | 107 | #define plan(count) _plan(count, true) 108 | 109 | #else /* !UNIT_TAP_COMPATIBLE */ 110 | 111 | #define header() printf("\t*** %s ***\n", __func__) 112 | #define footer() printf("\t*** %s: done ***\n", __func__) 113 | #define plan(count) _plan(count, false) 114 | 115 | #endif /* !UNIT_TAP_COMPATIBLE */ 116 | 117 | #if defined(__cplusplus) 118 | } 119 | #endif /* defined(__cplusplus) */ 120 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: C 3 | services: 4 | - docker 5 | 6 | cache: 7 | directories: 8 | - $HOME/.cache 9 | 10 | env: 11 | matrix: 12 | - OS=el DIST=6 13 | - OS=el DIST=7 14 | - OS=el DIST=8 15 | - OS=fedora DIST=26 16 | - OS=fedora DIST=27 17 | - OS=fedora DIST=28 18 | - OS=fedora DIST=29 19 | - OS=fedora DIST=30 20 | - OS=fedora DIST=31 21 | - OS=ubuntu DIST=trusty 22 | - OS=ubuntu DIST=xenial 23 | - OS=ubuntu DIST=bionic 24 | - OS=ubuntu DIST=eoan 25 | - OS=ubuntu DIST=focal 26 | - OS=debian DIST=jessie 27 | - OS=debian DIST=stretch 28 | - OS=debian DIST=buster 29 | 30 | script: 31 | - git describe --long 32 | - git clone https://github.com/packpack/packpack.git packpack 33 | - packpack/packpack 34 | 35 | before_deploy: 36 | - ls -l build/ 37 | 38 | deploy: 39 | # Deploy packages to PackageCloud 40 | - provider: packagecloud 41 | username: tarantool 42 | repository: "1_6" 43 | token: ${PACKAGECLOUD_TOKEN} 44 | dist: ${OS}/${DIST} 45 | package_glob: build/*.{deb,dsc,rpm} 46 | skip_cleanup: true 47 | on: 48 | branch: master 49 | condition: -n "${OS}" && -n "${DIST}" && -n "${PACKAGECLOUD_TOKEN}" 50 | - provider: packagecloud 51 | username: tarantool 52 | repository: "1_7" 53 | token: ${PACKAGECLOUD_TOKEN} 54 | dist: ${OS}/${DIST} 55 | package_glob: build/*.{deb,dsc,rpm} 56 | skip_cleanup: true 57 | on: 58 | branch: master 59 | condition: -n "${OS}" && -n "${DIST}" && -n "${PACKAGECLOUD_TOKEN}" 60 | - provider: packagecloud 61 | username: tarantool 62 | repository: "1_9" 63 | token: ${PACKAGECLOUD_TOKEN} 64 | dist: ${OS}/${DIST} 65 | package_glob: build/*.{deb,dsc,rpm} 66 | skip_cleanup: true 67 | on: 68 | branch: master 69 | condition: -n "${OS}" && -n "${DIST}" && -n "${PACKAGECLOUD_TOKEN}" 70 | - provider: packagecloud 71 | username: tarantool 72 | repository: "1_10" 73 | token: ${PACKAGECLOUD_TOKEN} 74 | dist: ${OS}/${DIST} 75 | package_glob: build/*.{deb,dsc,rpm} 76 | skip_cleanup: true 77 | on: 78 | branch: master 79 | condition: -n "${OS}" && -n "${DIST}" && -n "${PACKAGECLOUD_TOKEN}" 80 | - provider: packagecloud 81 | username: tarantool 82 | repository: "2x" 83 | token: ${PACKAGECLOUD_TOKEN} 84 | dist: ${OS}/${DIST} 85 | package_glob: build/*.{deb,dsc,rpm} 86 | skip_cleanup: true 87 | on: 88 | branch: master 89 | condition: -n "${OS}" && -n "${DIST}" && -n "${PACKAGECLOUD_TOKEN}" 90 | - provider: packagecloud 91 | username: tarantool 92 | repository: "2_2" 93 | token: ${PACKAGECLOUD_TOKEN} 94 | dist: ${OS}/${DIST} 95 | package_glob: build/*.{deb,dsc,rpm} 96 | skip_cleanup: true 97 | on: 98 | branch: master 99 | condition: -n "${OS}" && -n "${DIST}" && -n "${PACKAGECLOUD_TOKEN}" 100 | - provider: packagecloud 101 | username: tarantool 102 | repository: "2_3" 103 | token: ${PACKAGECLOUD_TOKEN} 104 | dist: ${OS}/${DIST} 105 | package_glob: build/*.{deb,dsc,rpm} 106 | skip_cleanup: true 107 | on: 108 | branch: master 109 | condition: -n "${OS}" && -n "${DIST}" && -n "${PACKAGECLOUD_TOKEN}" 110 | - provider: packagecloud 111 | username: tarantool 112 | repository: "2_4" 113 | token: ${PACKAGECLOUD_TOKEN} 114 | dist: ${OS}/${DIST} 115 | package_glob: build/*.{deb,dsc,rpm} 116 | skip_cleanup: true 117 | on: 118 | branch: master 119 | condition: -n "${OS}" && -n "${DIST}" && -n "${PACKAGECLOUD_TOKEN}" 120 | 121 | notifications: 122 | email: 123 | recipients: 124 | - build@tarantool.org 125 | on_success: change 126 | on_failure: always 127 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | MsgPuck 2 | ======= 3 | 4 | [![Travis][travis-badge]][travis-url] 5 | [![License][license-badge]][license-url] 6 | [![RPM Packages][rpm-badge]][rpm-url] 7 | [![Debian Packages][deb-badge]][deb-url] 8 | [![Telegram][telegram-badge]][telegram-url] 9 | [![Maillist][groups-badge]][groups-url] 10 | 11 | MsgPuck is a compact and efficient [MessagePack] serialization library: 12 | 13 | * Zero-cost abstractions and zero overhead 14 | * Clean and readable C code ready to use 15 | * Easy to incorporate into your project 16 | * Fully documented and covered by unit tests 17 | * Liberal license (BSD-2) 18 | 19 | Status 20 | ------ 21 | 22 | MsgPuck is stable, which means it have been used in production without 23 | serious bugs for quite a while now. The library is fully documented and 24 | covered by unit tests. 25 | 26 | Please feel free to file a ticket if your have a problem or a question. 27 | 28 | Examples 29 | -------- 30 | 31 | **Encoding:** 32 | 33 | char buf[1024]; 34 | 35 | char *w = buf; 36 | w = mp_encode_array(w, 4); 37 | w = mp_encode_uint(w, 10); 38 | w = mp_encode_str(w, "hello world", strlen("hello world")); 39 | w = mp_encode_bool(w, true); 40 | w = mp_encode_double(w, 3.1415); 41 | 42 | **Validating:** 43 | 44 | const char *end = buf + xx; 45 | const char *b = buf; 46 | int rc = mp_check(&b, end); 47 | assert(rc == 0); 48 | assert(b == end); 49 | 50 | **Decoding:** 51 | 52 | uint32_t size; 53 | uint64_t ival; 54 | const char *sval; 55 | uint32_t sval_len; 56 | bool bval; 57 | double dval; 58 | 59 | const char *r = buf; 60 | size = mp_decode_array(&r); 61 | /* size is 4 */ 62 | 63 | ival = mp_decode_uint(&r); 64 | /* ival is 10; */ 65 | 66 | sval = mp_decode_str(&r, &sval_len); 67 | /* sval is "hello world", sval_len is strlen("hello world") */ 68 | 69 | bval = mp_decode_bool(&r); 70 | /* bval is true */ 71 | 72 | dval = mp_decode_double(&r); 73 | /* dval is 3.1415 */ 74 | 75 | assert(r == w); 76 | 77 | Usage 78 | ----- 79 | 80 | You need a C89+ or C++03+ compatible compiler to use msgpuck. 81 | Add this project as a submodule or just use libmsgpuck-dev package. 82 | 83 | MsgPuck is designed to be fully embedded to your application by a C/C++ 84 | compiler. However, some functions require auxiliary static tables which 85 | should be expanded somewhere in a compilation unit (`*.c` or `*.cc` file). 86 | Please link libmsgpuck.a to your binary to avoid problems with unresolved 87 | symbols. 88 | 89 | See Also 90 | -------- 91 | 92 | * [API Documentation](http://rtsisyk.github.io/msgpuck/) 93 | * [Specification](https://github.com/msgpack/msgpack/blob/master/spec.md) 94 | * [Tests](test) 95 | * [Packages](https://tarantool.org/download.html) 96 | * [Maillist](https://groups.google.com/forum/#!forum/tarantool) 97 | * [Facebook](http://facebook.com/TarantoolDatabase/) 98 | * [Telegram Chat][telegram-url] 99 | * [Maillist][groups-url] 100 | 101 | API documentation can be also generated using `make doc` (Doxygen is required). 102 | 103 | MsgPuck was written to use within [Tarantool](http://tarantool.org) - 104 | the world's first full-featured MsgPack-based database. 105 | 106 | [MessagePack]: https://msgpack.org/ 107 | [travis-badge]: https://api.travis-ci.org/rtsisyk/msgpuck.svg?branch=master 108 | [travis-url]: https://travis-ci.org/rtsisyk/msgpuck 109 | [license-badge]: https://img.shields.io/badge/License-BSD--2-lightgray.svg?style=flat 110 | [license-url]: LICENSE 111 | [deb-badge]: https://img.shields.io/badge/Packages-Debian-red.svg?style=flat 112 | [deb-url]: https://packagecloud.io/tarantool/1\_7?filter=debs 113 | [rpm-badge]: https://img.shields.io/badge/Packages-RPM-blue.svg?style=flat 114 | [rpm-url]: https://packagecloud.io/tarantool/1\_7?filter=rpms 115 | [telegram-badge]: https://img.shields.io/badge/Telegram-join%20chat-blue.svg 116 | [telegram-url]: http://telegram.me/tarantool 117 | [groups-badge]: https://img.shields.io/badge/Google-Groups-orange.svg 118 | [groups-url]: https://groups.google.com/forum/#!forum/tarantool 119 | -------------------------------------------------------------------------------- /rpm/msgpuck.spec: -------------------------------------------------------------------------------- 1 | Name: msgpuck 2 | Version: 2.0.0 3 | Release: 1%{?dist} 4 | Summary: MsgPack binary serialization library in a self-contained header 5 | Group: Development/Libraries 6 | License: BSD 7 | URL: https://github.com/rtsisyk/msgpuck 8 | Source0: https://github.com/rtsisyk/msgpuck/archive/%{version}/msgpuck-%{version}.tar.gz 9 | BuildRequires: gcc 10 | BuildRequires: coreutils 11 | BuildRequires: cmake >= 2.8 12 | BuildRequires: doxygen >= 1.6.0 13 | 14 | # https://fedoraproject.org/wiki/Packaging:Guidelines#Packaging_Header_Only_Libraries 15 | # Nothing to add to -debuginfo package - this library is header-only 16 | %global debug_package %{nil} 17 | 18 | # Use strip from devtoolset instead of /usr/bin/strip to avoid 'invalid 19 | # relocation type 42' error on CentOS 6. 20 | # https://bugzilla.redhat.com/show_bug.cgi?id=1545386#c5 21 | # https://stackoverflow.com/a/48801417 22 | %if 0%{?rhel} == 6 23 | %global __strip /opt/rh/devtoolset-6/root/usr/bin/strip 24 | %endif 25 | 26 | %package devel 27 | Summary: Lightweight MessagePack library 28 | Provides: msgpuck-static = %{version}-%{release} 29 | 30 | %description 31 | MsgPuck is a compact and efficient MessagePack serialization library 32 | designed with zero-cost abstractions in mind. Almost all encoding/decoding 33 | functions can be fully inlined into your application by C/C++ compiler 34 | to reach the maximum performance. 35 | 36 | MessagePack is an efficient binary serialization format. 37 | It lets you exchange data among multiple languages like JSON. 38 | But it's faster and smaller. Small integers are encoded into a single byte, 39 | and typical short strings require only one extra byte in addition to the 40 | strings themselves. 41 | 42 | %description devel 43 | MsgPack is a binary-based efficient object serialization library. 44 | It enables to exchange structured objects between many languages like JSON. 45 | But unlike JSON, it is very fast and small. 46 | 47 | msgpuck is very lightweight header-only library designed to be embedded to 48 | your application by the C/C++ compiler. The library is fully documented and 49 | covered by unit tests. 50 | 51 | This package provides a self-contained header file and a static library. 52 | The static library contains generated code for inline functions and 53 | global tables needed by the some library functions. 54 | 55 | %prep 56 | %setup -q -n %{name}-%{version} 57 | 58 | %build 59 | %cmake . -DCMAKE_BUILD_TYPE=RelWithDebInfo 60 | make %{?_smp_mflags} 61 | make man 62 | 63 | %check 64 | make test 65 | 66 | %install 67 | %make_install 68 | mkdir -p %{buildroot}%{_mandir}/man3 69 | install -Dpm 0644 doc/man/man3/msgpuck.h.3* %{buildroot}%{_mandir}/man3/ 70 | 71 | %files devel 72 | %{_libdir}/libmsgpuck.a 73 | %{_includedir}/msgpuck.h 74 | %{_mandir}/man3/msgpuck.h.3* 75 | %doc README.md 76 | %{!?_licensedir:%global license %doc} 77 | %license LICENSE AUTHORS 78 | 79 | %changelog 80 | * Tue Feb 07 2017 Roman Tsisyk 2.0.0-1 81 | - Drop MP_SOURCE support and make libmsgpuck.a to be mandatory 82 | - Add helpers to decode any number to int64/double 83 | - Add -fPIC to libmsgpuck.a 84 | 85 | * Fri Dec 16 2016 Roman Tsisyk 1.1.3-1 86 | - Add mp_snprint() function. 87 | - Change mp_fprint() to return the number of bytes printed instead of 0. 88 | - Fix CVE-2016-9036. 89 | 90 | * Tue Aug 09 2016 Roman Tsisyk 1.0.3-1 91 | - Add mp_decode_strbin() and mp_decode_strbinl() 92 | - Add mp_fprint() for debug output 93 | 94 | * Tue Feb 02 2016 Roman Tsisyk 1.0.2-1 95 | - Add coreutils and make to BuildRequires (#1295217) 96 | - Use `install -Dpm` instead of `cp -p` 97 | - Fix GCC 6.0 and Doxygen warnings 98 | 99 | * Mon Jan 25 2016 Roman Tsisyk 1.0.1-3 100 | - Add `BuildRequires: gcc` (#1295217) 101 | 102 | * Sun Jan 24 2016 Roman Tsisyk 1.0.1-2 103 | - Fix msgpuck-devel dependencies after removing empty msgpuck package 104 | 105 | * Fri Jan 22 2016 Roman Tsisyk 1.0.1-1 106 | - Changes according to Fedora review #1295217 107 | - Fix SIGBUS on processesor without HW support for unaligned access 108 | 109 | * Thu Jul 09 2015 Roman Tsisyk 1.0.0-1 110 | - Initial version of the RPM spec 111 | -------------------------------------------------------------------------------- /msgpuck.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2017 MsgPuck Authors 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or 6 | * without modification, are permitted provided that the following 7 | * conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above 10 | * copyright notice, this list of conditions and the 11 | * following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above 14 | * copyright notice, this list of conditions and the following 15 | * disclaimer in the documentation and/or other materials 16 | * provided with the distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND 19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 22 | * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 23 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 26 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 29 | * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 | * SUCH DAMAGE. 31 | */ 32 | 33 | #define MP_LIBRARY 1 34 | #include "msgpuck.h" 35 | 36 | int 37 | mp_fprint_ext_default(FILE *file, const char **data, int depth) 38 | { 39 | (void) depth; 40 | int8_t type; 41 | uint32_t len; 42 | mp_decode_ext(data, &type, &len); 43 | return fprintf(file, "(extension: type %d, len %u)", (int)type, 44 | (unsigned)len); 45 | } 46 | 47 | int 48 | mp_snprint_ext_default(char *buf, int size, const char **data, int depth) 49 | { 50 | (void) depth; 51 | int8_t type; 52 | uint32_t len; 53 | mp_decode_ext(data, &type, &len); 54 | return snprintf(buf, size, "(extension: type %d, len %u)", (int)type, 55 | (unsigned)len); 56 | } 57 | 58 | mp_fprint_ext_f mp_fprint_ext = mp_fprint_ext_default; 59 | 60 | mp_snprint_ext_f mp_snprint_ext = mp_snprint_ext_default; 61 | 62 | int 63 | mp_check_ext_data_default(int8_t type, const char *data, uint32_t len) 64 | { 65 | (void)data; 66 | (void)type; 67 | (void)len; 68 | return 0; 69 | } 70 | 71 | mp_check_ext_data_f mp_check_ext_data = mp_check_ext_data_default; 72 | 73 | static void 74 | mp_check_on_error_default(const struct mp_check_error *err) 75 | { 76 | (void)err; 77 | } 78 | 79 | mp_check_on_error_f mp_check_on_error = mp_check_on_error_default; 80 | 81 | size_t 82 | mp_vformat(char *data, size_t data_size, const char *format, va_list vl) 83 | { 84 | size_t result = 0; 85 | const char *f = NULL; 86 | 87 | for (f = format; *f; f++) { 88 | if (f[0] == '[') { 89 | uint32_t size = 0; 90 | int level = 1; 91 | const char *e = NULL; 92 | 93 | for (e = f + 1; level && *e; e++) { 94 | if (*e == '[' || *e == '{') { 95 | if (level == 1) 96 | size++; 97 | level++; 98 | } else if (*e == ']' || *e == '}') { 99 | level--; 100 | /* opened '[' must be closed by ']' */ 101 | assert(level || *e == ']'); 102 | } else if (*e == '%') { 103 | if (e[1] == '%') 104 | e++; 105 | else if (level == 1) 106 | size++; 107 | } else if (*e == 'N' && e[1] == 'I' 108 | && e[2] == 'L' && level == 1) { 109 | size++; 110 | } 111 | } 112 | /* opened '[' must be closed */ 113 | assert(level == 0); 114 | result += mp_sizeof_array(size); 115 | if (result <= data_size) 116 | data = mp_encode_array(data, size); 117 | } else if (f[0] == '{') { 118 | uint32_t count = 0; 119 | int level = 1; 120 | const char *e = NULL; 121 | 122 | for (e = f + 1; level && *e; e++) { 123 | if (*e == '[' || *e == '{') { 124 | if (level == 1) 125 | count++; 126 | level++; 127 | } else if (*e == ']' || *e == '}') { 128 | level--; 129 | /* opened '{' must be closed by '}' */ 130 | assert(level || *e == '}'); 131 | } else if (*e == '%') { 132 | if (e[1] == '%') 133 | e++; 134 | else if (level == 1) 135 | count++; 136 | } else if (*e == 'N' && e[1] == 'I' 137 | && e[2] == 'L' && level == 1) { 138 | count++; 139 | } 140 | } 141 | /* opened '{' must be closed */ 142 | assert(level == 0); 143 | /* since map is a pair list, count must be even */ 144 | assert(count % 2 == 0); 145 | uint32_t size = count / 2; 146 | result += mp_sizeof_map(size); 147 | if (result <= data_size) 148 | data = mp_encode_map(data, size); 149 | } else if (f[0] == '%') { 150 | f++; 151 | assert(f[0]); 152 | int64_t int_value = 0; 153 | int int_status = 0; /* 1 - signed, 2 - unsigned */ 154 | 155 | if (f[0] == 'd' || f[0] == 'i') { 156 | int_value = va_arg(vl, int); 157 | int_status = 1; 158 | } else if (f[0] == 'u') { 159 | int_value = va_arg(vl, unsigned int); 160 | int_status = 2; 161 | } else if (f[0] == 's') { 162 | const char *str = va_arg(vl, const char *); 163 | uint32_t len = (uint32_t)strlen(str); 164 | result += mp_sizeof_str(len); 165 | if (result <= data_size) 166 | data = mp_encode_str(data, str, len); 167 | } else if (f[0] == '.' && f[1] == '*' && f[2] == 's') { 168 | uint32_t len = va_arg(vl, uint32_t); 169 | const char *str = va_arg(vl, const char *); 170 | result += mp_sizeof_str(len); 171 | if (result <= data_size) 172 | data = mp_encode_str(data, str, len); 173 | f += 2; 174 | } else if (f[0] == 'p') { 175 | const char *p = va_arg(vl, const char *); 176 | const char *end = p; 177 | mp_next(&end); 178 | uint32_t len = (uint32_t)(end - p); 179 | result += len; 180 | if (result <= data_size) { 181 | memcpy(data, p, len); 182 | data += len; 183 | } 184 | } else if (f[0] == '.' && f[1] == '*' && f[2] == 'p') { 185 | uint32_t len = va_arg(vl, uint32_t); 186 | const char *p = va_arg(vl, const char *); 187 | assert(len > 0); 188 | result += len; 189 | if (result <= data_size) { 190 | memcpy(data, p, len); 191 | data += len; 192 | } 193 | f += 2; 194 | } else if(f[0] == 'f') { 195 | float v = (float)va_arg(vl, double); 196 | result += mp_sizeof_float(v); 197 | if (result <= data_size) 198 | data = mp_encode_float(data, v); 199 | } else if(f[0] == 'l' && f[1] == 'f') { 200 | double v = va_arg(vl, double); 201 | result += mp_sizeof_double(v); 202 | if (result <= data_size) 203 | data = mp_encode_double(data, v); 204 | f++; 205 | } else if(f[0] == 'b') { 206 | bool v = (bool)va_arg(vl, int); 207 | result += mp_sizeof_bool(v); 208 | if (result <= data_size) 209 | data = mp_encode_bool(data, v); 210 | } else if (f[0] == 'l' 211 | && (f[1] == 'd' || f[1] == 'i')) { 212 | int_value = va_arg(vl, long); 213 | int_status = 1; 214 | f++; 215 | } else if (f[0] == 'l' && f[1] == 'u') { 216 | int_value = va_arg(vl, unsigned long); 217 | int_status = 2; 218 | f++; 219 | } else if (f[0] == 'l' && f[1] == 'l' 220 | && (f[2] == 'd' || f[2] == 'i')) { 221 | int_value = va_arg(vl, long long); 222 | int_status = 1; 223 | f += 2; 224 | } else if (f[0] == 'l' && f[1] == 'l' && f[2] == 'u') { 225 | int_value = va_arg(vl, unsigned long long); 226 | int_status = 2; 227 | f += 2; 228 | } else if (f[0] == 'h' 229 | && (f[1] == 'd' || f[1] == 'i')) { 230 | int_value = va_arg(vl, int); 231 | int_status = 1; 232 | f++; 233 | } else if (f[0] == 'h' && f[1] == 'u') { 234 | int_value = va_arg(vl, unsigned int); 235 | int_status = 2; 236 | f++; 237 | } else if (f[0] == 'h' && f[1] == 'h' 238 | && (f[2] == 'd' || f[2] == 'i')) { 239 | int_value = va_arg(vl, int); 240 | int_status = 1; 241 | f += 2; 242 | } else if (f[0] == 'h' && f[1] == 'h' && f[2] == 'u') { 243 | int_value = va_arg(vl, unsigned int); 244 | int_status = 2; 245 | f += 2; 246 | } else if (f[0] != '%') { 247 | /* unexpected format specifier */ 248 | assert(false); 249 | } 250 | 251 | if (int_status == 1 && int_value < 0) { 252 | result += mp_sizeof_int(int_value); 253 | if (result <= data_size) 254 | data = mp_encode_int(data, int_value); 255 | } else if(int_status) { 256 | result += mp_sizeof_uint(int_value); 257 | if (result <= data_size) 258 | data = mp_encode_uint(data, int_value); 259 | } 260 | } else if (f[0] == 'N' && f[1] == 'I' && f[2] == 'L') { 261 | result += mp_sizeof_nil(); 262 | if (result <= data_size) 263 | data = mp_encode_nil(data); 264 | f += 2; 265 | } 266 | } 267 | return result; 268 | } 269 | 270 | size_t 271 | mp_format(char *data, size_t data_size, const char *format, ...) 272 | { 273 | va_list args; 274 | va_start(args, format); 275 | size_t res = mp_vformat(data, data_size, format, args); 276 | va_end(args); 277 | return res; 278 | } 279 | 280 | #define MP_PRINT(SELF, PRINTF) \ 281 | { \ 282 | switch (mp_typeof(**data)) { \ 283 | case MP_NIL: \ 284 | mp_decode_nil(data); \ 285 | PRINTF("null"); \ 286 | break; \ 287 | case MP_UINT: \ 288 | PRINTF("%llu", (unsigned long long) mp_decode_uint(data)); \ 289 | break; \ 290 | case MP_INT: \ 291 | PRINTF("%lld", (long long) mp_decode_int(data)); \ 292 | break; \ 293 | case MP_STR: \ 294 | case MP_BIN: \ 295 | { \ 296 | uint32_t len = mp_typeof(**data) == MP_STR ? \ 297 | mp_decode_strl(data) : mp_decode_binl(data); \ 298 | PRINTF("\""); \ 299 | const char *s; \ 300 | const char *end = *data + len; \ 301 | for (s = *data; s < end; s++) { \ 302 | unsigned char c = (unsigned char ) *s; \ 303 | if (c < 128 && mp_char2escape[c] != NULL) { \ 304 | /* Escape character */ \ 305 | PRINTF("%s", mp_char2escape[c]); \ 306 | } else { \ 307 | PRINTF("%c", c); \ 308 | } \ 309 | } \ 310 | PRINTF("\""); \ 311 | *data = end; \ 312 | break; \ 313 | } \ 314 | case MP_ARRAY: \ 315 | { \ 316 | PRINTF("["); \ 317 | if (depth <= 0) { \ 318 | PRINTF("..."); \ 319 | mp_next(data); \ 320 | } else { \ 321 | --depth; \ 322 | uint32_t count = mp_decode_array(data); \ 323 | for (uint32_t i = 0; i < count; i++) { \ 324 | if (i) \ 325 | PRINTF(", "); \ 326 | SELF(data); \ 327 | } \ 328 | ++depth; \ 329 | } \ 330 | PRINTF("]"); \ 331 | break; \ 332 | } \ 333 | case MP_MAP: \ 334 | { \ 335 | PRINTF("{"); \ 336 | if (depth <= 0) { \ 337 | PRINTF("..."); \ 338 | mp_next(data); \ 339 | } else { \ 340 | --depth; \ 341 | uint32_t count = mp_decode_map(data); \ 342 | for (uint32_t i = 0; i < count; i++) { \ 343 | if (i) \ 344 | PRINTF(", "); \ 345 | SELF(data); \ 346 | PRINTF(": "); \ 347 | SELF(data); \ 348 | } \ 349 | ++depth; \ 350 | } \ 351 | PRINTF("}"); \ 352 | break; \ 353 | } \ 354 | case MP_BOOL: \ 355 | PRINTF(mp_decode_bool(data) ? "true" : "false"); \ 356 | break; \ 357 | case MP_FLOAT: \ 358 | PRINTF("%g", mp_decode_float(data)); \ 359 | break; \ 360 | case MP_DOUBLE: \ 361 | PRINTF("%lg", mp_decode_double(data)); \ 362 | break; \ 363 | case MP_EXT: \ 364 | PRINT_EXT(data); \ 365 | break; \ 366 | default: \ 367 | mp_unreachable(); \ 368 | return -1; \ 369 | } \ 370 | } 371 | 372 | int 373 | mp_fprint_recursion(FILE *file, const char **data, int depth) 374 | { 375 | int total_bytes = 0; 376 | #define HANDLE(FUN, ...) do { \ 377 | int bytes = FUN(file, __VA_ARGS__); \ 378 | if (mp_unlikely(bytes < 0)) \ 379 | return -1; \ 380 | total_bytes += bytes; \ 381 | } while (0) 382 | #define PRINT_EXT(...) HANDLE(mp_fprint_ext, __VA_ARGS__, depth) 383 | #define PRINT(...) HANDLE(fprintf, __VA_ARGS__) 384 | #define SELF(...) HANDLE(mp_fprint_recursion, __VA_ARGS__, depth) 385 | MP_PRINT(SELF, PRINT) 386 | #undef HANDLE 387 | #undef SELF 388 | #undef PRINT 389 | #undef PRINT_EXT 390 | return total_bytes; 391 | } 392 | 393 | int 394 | mp_fprint(FILE *file, const char *data) 395 | { 396 | if (!file) 397 | file = stdout; 398 | int res = mp_fprint_recursion(file, &data, MP_PRINT_MAX_DEPTH); 399 | return res; 400 | } 401 | 402 | int 403 | mp_snprint_recursion(char *buf, int size, const char **data, int depth) 404 | { 405 | int total_bytes = 0; 406 | #define HANDLE(FUN, ...) do { \ 407 | int bytes = FUN(buf, size, __VA_ARGS__); \ 408 | if (mp_unlikely(bytes < 0)) \ 409 | return -1; \ 410 | total_bytes += bytes; \ 411 | if (bytes < size) { \ 412 | buf += bytes; \ 413 | size -= bytes; \ 414 | } else { \ 415 | /* Calculate the number of bytes needed */ \ 416 | buf = NULL; \ 417 | size = 0; \ 418 | } \ 419 | } while (0) 420 | #define PRINT_EXT(...) HANDLE(mp_snprint_ext, __VA_ARGS__, depth) 421 | #define PRINT(...) HANDLE(snprintf, __VA_ARGS__) 422 | #define SELF(...) HANDLE(mp_snprint_recursion, __VA_ARGS__, depth) 423 | MP_PRINT(SELF, PRINT) 424 | #undef HANDLE 425 | #undef SELF 426 | #undef PRINT 427 | #undef PRINT_EXT 428 | return total_bytes; 429 | } 430 | #undef MP_PRINT 431 | 432 | int 433 | mp_snprint(char *buf, int size, const char *data) 434 | { 435 | return mp_snprint_recursion(buf, size, &data, MP_PRINT_MAX_DEPTH); 436 | } 437 | -------------------------------------------------------------------------------- /hints.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2017 MsgPuck Authors 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or 6 | * without modification, are permitted provided that the following 7 | * conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above 10 | * copyright notice, this list of conditions and the 11 | * following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above 14 | * copyright notice, this list of conditions and the following 15 | * disclaimer in the documentation and/or other materials 16 | * provided with the distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND 19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 22 | * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 23 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 26 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 29 | * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 | * SUCH DAMAGE. 31 | */ 32 | 33 | #include "msgpuck.h" 34 | 35 | /** 36 | * This lookup table used by mp_sizeof() to determine enum mp_type by the first 37 | * byte of MsgPack element. 38 | */ 39 | const enum mp_type mp_type_hint[256]= { 40 | /* {{{ MP_UINT (fixed) */ 41 | /* 0x00 */ MP_UINT, 42 | /* 0x01 */ MP_UINT, 43 | /* 0x02 */ MP_UINT, 44 | /* 0x03 */ MP_UINT, 45 | /* 0x04 */ MP_UINT, 46 | /* 0x05 */ MP_UINT, 47 | /* 0x06 */ MP_UINT, 48 | /* 0x07 */ MP_UINT, 49 | /* 0x08 */ MP_UINT, 50 | /* 0x09 */ MP_UINT, 51 | /* 0x0a */ MP_UINT, 52 | /* 0x0b */ MP_UINT, 53 | /* 0x0c */ MP_UINT, 54 | /* 0x0d */ MP_UINT, 55 | /* 0x0e */ MP_UINT, 56 | /* 0x0f */ MP_UINT, 57 | /* 0x10 */ MP_UINT, 58 | /* 0x11 */ MP_UINT, 59 | /* 0x12 */ MP_UINT, 60 | /* 0x13 */ MP_UINT, 61 | /* 0x14 */ MP_UINT, 62 | /* 0x15 */ MP_UINT, 63 | /* 0x16 */ MP_UINT, 64 | /* 0x17 */ MP_UINT, 65 | /* 0x18 */ MP_UINT, 66 | /* 0x19 */ MP_UINT, 67 | /* 0x1a */ MP_UINT, 68 | /* 0x1b */ MP_UINT, 69 | /* 0x1c */ MP_UINT, 70 | /* 0x1d */ MP_UINT, 71 | /* 0x1e */ MP_UINT, 72 | /* 0x1f */ MP_UINT, 73 | /* 0x20 */ MP_UINT, 74 | /* 0x21 */ MP_UINT, 75 | /* 0x22 */ MP_UINT, 76 | /* 0x23 */ MP_UINT, 77 | /* 0x24 */ MP_UINT, 78 | /* 0x25 */ MP_UINT, 79 | /* 0x26 */ MP_UINT, 80 | /* 0x27 */ MP_UINT, 81 | /* 0x28 */ MP_UINT, 82 | /* 0x29 */ MP_UINT, 83 | /* 0x2a */ MP_UINT, 84 | /* 0x2b */ MP_UINT, 85 | /* 0x2c */ MP_UINT, 86 | /* 0x2d */ MP_UINT, 87 | /* 0x2e */ MP_UINT, 88 | /* 0x2f */ MP_UINT, 89 | /* 0x30 */ MP_UINT, 90 | /* 0x31 */ MP_UINT, 91 | /* 0x32 */ MP_UINT, 92 | /* 0x33 */ MP_UINT, 93 | /* 0x34 */ MP_UINT, 94 | /* 0x35 */ MP_UINT, 95 | /* 0x36 */ MP_UINT, 96 | /* 0x37 */ MP_UINT, 97 | /* 0x38 */ MP_UINT, 98 | /* 0x39 */ MP_UINT, 99 | /* 0x3a */ MP_UINT, 100 | /* 0x3b */ MP_UINT, 101 | /* 0x3c */ MP_UINT, 102 | /* 0x3d */ MP_UINT, 103 | /* 0x3e */ MP_UINT, 104 | /* 0x3f */ MP_UINT, 105 | /* 0x40 */ MP_UINT, 106 | /* 0x41 */ MP_UINT, 107 | /* 0x42 */ MP_UINT, 108 | /* 0x43 */ MP_UINT, 109 | /* 0x44 */ MP_UINT, 110 | /* 0x45 */ MP_UINT, 111 | /* 0x46 */ MP_UINT, 112 | /* 0x47 */ MP_UINT, 113 | /* 0x48 */ MP_UINT, 114 | /* 0x49 */ MP_UINT, 115 | /* 0x4a */ MP_UINT, 116 | /* 0x4b */ MP_UINT, 117 | /* 0x4c */ MP_UINT, 118 | /* 0x4d */ MP_UINT, 119 | /* 0x4e */ MP_UINT, 120 | /* 0x4f */ MP_UINT, 121 | /* 0x50 */ MP_UINT, 122 | /* 0x51 */ MP_UINT, 123 | /* 0x52 */ MP_UINT, 124 | /* 0x53 */ MP_UINT, 125 | /* 0x54 */ MP_UINT, 126 | /* 0x55 */ MP_UINT, 127 | /* 0x56 */ MP_UINT, 128 | /* 0x57 */ MP_UINT, 129 | /* 0x58 */ MP_UINT, 130 | /* 0x59 */ MP_UINT, 131 | /* 0x5a */ MP_UINT, 132 | /* 0x5b */ MP_UINT, 133 | /* 0x5c */ MP_UINT, 134 | /* 0x5d */ MP_UINT, 135 | /* 0x5e */ MP_UINT, 136 | /* 0x5f */ MP_UINT, 137 | /* 0x60 */ MP_UINT, 138 | /* 0x61 */ MP_UINT, 139 | /* 0x62 */ MP_UINT, 140 | /* 0x63 */ MP_UINT, 141 | /* 0x64 */ MP_UINT, 142 | /* 0x65 */ MP_UINT, 143 | /* 0x66 */ MP_UINT, 144 | /* 0x67 */ MP_UINT, 145 | /* 0x68 */ MP_UINT, 146 | /* 0x69 */ MP_UINT, 147 | /* 0x6a */ MP_UINT, 148 | /* 0x6b */ MP_UINT, 149 | /* 0x6c */ MP_UINT, 150 | /* 0x6d */ MP_UINT, 151 | /* 0x6e */ MP_UINT, 152 | /* 0x6f */ MP_UINT, 153 | /* 0x70 */ MP_UINT, 154 | /* 0x71 */ MP_UINT, 155 | /* 0x72 */ MP_UINT, 156 | /* 0x73 */ MP_UINT, 157 | /* 0x74 */ MP_UINT, 158 | /* 0x75 */ MP_UINT, 159 | /* 0x76 */ MP_UINT, 160 | /* 0x77 */ MP_UINT, 161 | /* 0x78 */ MP_UINT, 162 | /* 0x79 */ MP_UINT, 163 | /* 0x7a */ MP_UINT, 164 | /* 0x7b */ MP_UINT, 165 | /* 0x7c */ MP_UINT, 166 | /* 0x7d */ MP_UINT, 167 | /* 0x7e */ MP_UINT, 168 | /* 0x7f */ MP_UINT, 169 | /* }}} */ 170 | 171 | /* {{{ MP_MAP (fixed) */ 172 | /* 0x80 */ MP_MAP, 173 | /* 0x81 */ MP_MAP, 174 | /* 0x82 */ MP_MAP, 175 | /* 0x83 */ MP_MAP, 176 | /* 0x84 */ MP_MAP, 177 | /* 0x85 */ MP_MAP, 178 | /* 0x86 */ MP_MAP, 179 | /* 0x87 */ MP_MAP, 180 | /* 0x88 */ MP_MAP, 181 | /* 0x89 */ MP_MAP, 182 | /* 0x8a */ MP_MAP, 183 | /* 0x8b */ MP_MAP, 184 | /* 0x8c */ MP_MAP, 185 | /* 0x8d */ MP_MAP, 186 | /* 0x8e */ MP_MAP, 187 | /* 0x8f */ MP_MAP, 188 | /* }}} */ 189 | 190 | /* {{{ MP_ARRAY (fixed) */ 191 | /* 0x90 */ MP_ARRAY, 192 | /* 0x91 */ MP_ARRAY, 193 | /* 0x92 */ MP_ARRAY, 194 | /* 0x93 */ MP_ARRAY, 195 | /* 0x94 */ MP_ARRAY, 196 | /* 0x95 */ MP_ARRAY, 197 | /* 0x96 */ MP_ARRAY, 198 | /* 0x97 */ MP_ARRAY, 199 | /* 0x98 */ MP_ARRAY, 200 | /* 0x99 */ MP_ARRAY, 201 | /* 0x9a */ MP_ARRAY, 202 | /* 0x9b */ MP_ARRAY, 203 | /* 0x9c */ MP_ARRAY, 204 | /* 0x9d */ MP_ARRAY, 205 | /* 0x9e */ MP_ARRAY, 206 | /* 0x9f */ MP_ARRAY, 207 | /* }}} */ 208 | 209 | /* {{{ MP_STR (fixed) */ 210 | /* 0xa0 */ MP_STR, 211 | /* 0xa1 */ MP_STR, 212 | /* 0xa2 */ MP_STR, 213 | /* 0xa3 */ MP_STR, 214 | /* 0xa4 */ MP_STR, 215 | /* 0xa5 */ MP_STR, 216 | /* 0xa6 */ MP_STR, 217 | /* 0xa7 */ MP_STR, 218 | /* 0xa8 */ MP_STR, 219 | /* 0xa9 */ MP_STR, 220 | /* 0xaa */ MP_STR, 221 | /* 0xab */ MP_STR, 222 | /* 0xac */ MP_STR, 223 | /* 0xad */ MP_STR, 224 | /* 0xae */ MP_STR, 225 | /* 0xaf */ MP_STR, 226 | /* 0xb0 */ MP_STR, 227 | /* 0xb1 */ MP_STR, 228 | /* 0xb2 */ MP_STR, 229 | /* 0xb3 */ MP_STR, 230 | /* 0xb4 */ MP_STR, 231 | /* 0xb5 */ MP_STR, 232 | /* 0xb6 */ MP_STR, 233 | /* 0xb7 */ MP_STR, 234 | /* 0xb8 */ MP_STR, 235 | /* 0xb9 */ MP_STR, 236 | /* 0xba */ MP_STR, 237 | /* 0xbb */ MP_STR, 238 | /* 0xbc */ MP_STR, 239 | /* 0xbd */ MP_STR, 240 | /* 0xbe */ MP_STR, 241 | /* 0xbf */ MP_STR, 242 | /* }}} */ 243 | 244 | /* {{{ MP_NIL, MP_BOOL */ 245 | /* 0xc0 */ MP_NIL, 246 | /* 0xc1 */ MP_EXT, /* never used */ 247 | /* 0xc2 */ MP_BOOL, 248 | /* 0xc3 */ MP_BOOL, 249 | /* }}} */ 250 | 251 | /* {{{ MP_BIN */ 252 | /* 0xc4 */ MP_BIN, /* MP_BIN(8) */ 253 | /* 0xc5 */ MP_BIN, /* MP_BIN(16) */ 254 | /* 0xc6 */ MP_BIN, /* MP_BIN(32) */ 255 | /* }}} */ 256 | 257 | /* {{{ MP_EXT */ 258 | /* 0xc7 */ MP_EXT, 259 | /* 0xc8 */ MP_EXT, 260 | /* 0xc9 */ MP_EXT, 261 | /* }}} */ 262 | 263 | /* {{{ MP_FLOAT, MP_DOUBLE */ 264 | /* 0xca */ MP_FLOAT, 265 | /* 0xcb */ MP_DOUBLE, 266 | /* }}} */ 267 | 268 | /* {{{ MP_UINT */ 269 | /* 0xcc */ MP_UINT, 270 | /* 0xcd */ MP_UINT, 271 | /* 0xce */ MP_UINT, 272 | /* 0xcf */ MP_UINT, 273 | /* }}} */ 274 | 275 | /* {{{ MP_INT */ 276 | /* 0xd0 */ MP_INT, /* MP_INT (8) */ 277 | /* 0xd1 */ MP_INT, /* MP_INT (16) */ 278 | /* 0xd2 */ MP_INT, /* MP_INT (32) */ 279 | /* 0xd3 */ MP_INT, /* MP_INT (64) */ 280 | /* }}} */ 281 | 282 | /* {{{ MP_EXT */ 283 | /* 0xd4 */ MP_EXT, /* MP_INT (8) */ 284 | /* 0xd5 */ MP_EXT, /* MP_INT (16) */ 285 | /* 0xd6 */ MP_EXT, /* MP_INT (32) */ 286 | /* 0xd7 */ MP_EXT, /* MP_INT (64) */ 287 | /* 0xd8 */ MP_EXT, /* MP_INT (127) */ 288 | /* }}} */ 289 | 290 | /* {{{ MP_STR */ 291 | /* 0xd9 */ MP_STR, /* MP_STR(8) */ 292 | /* 0xda */ MP_STR, /* MP_STR(16) */ 293 | /* 0xdb */ MP_STR, /* MP_STR(32) */ 294 | /* }}} */ 295 | 296 | /* {{{ MP_ARRAY */ 297 | /* 0xdc */ MP_ARRAY, /* MP_ARRAY(16) */ 298 | /* 0xdd */ MP_ARRAY, /* MP_ARRAY(32) */ 299 | /* }}} */ 300 | 301 | /* {{{ MP_MAP */ 302 | /* 0xde */ MP_MAP, /* MP_MAP (16) */ 303 | /* 0xdf */ MP_MAP, /* MP_MAP (32) */ 304 | /* }}} */ 305 | 306 | /* {{{ MP_INT */ 307 | /* 0xe0 */ MP_INT, 308 | /* 0xe1 */ MP_INT, 309 | /* 0xe2 */ MP_INT, 310 | /* 0xe3 */ MP_INT, 311 | /* 0xe4 */ MP_INT, 312 | /* 0xe5 */ MP_INT, 313 | /* 0xe6 */ MP_INT, 314 | /* 0xe7 */ MP_INT, 315 | /* 0xe8 */ MP_INT, 316 | /* 0xe9 */ MP_INT, 317 | /* 0xea */ MP_INT, 318 | /* 0xeb */ MP_INT, 319 | /* 0xec */ MP_INT, 320 | /* 0xed */ MP_INT, 321 | /* 0xee */ MP_INT, 322 | /* 0xef */ MP_INT, 323 | /* 0xf0 */ MP_INT, 324 | /* 0xf1 */ MP_INT, 325 | /* 0xf2 */ MP_INT, 326 | /* 0xf3 */ MP_INT, 327 | /* 0xf4 */ MP_INT, 328 | /* 0xf5 */ MP_INT, 329 | /* 0xf6 */ MP_INT, 330 | /* 0xf7 */ MP_INT, 331 | /* 0xf8 */ MP_INT, 332 | /* 0xf9 */ MP_INT, 333 | /* 0xfa */ MP_INT, 334 | /* 0xfb */ MP_INT, 335 | /* 0xfc */ MP_INT, 336 | /* 0xfd */ MP_INT, 337 | /* 0xfe */ MP_INT, 338 | /* 0xff */ MP_INT 339 | /* }}} */ 340 | }; 341 | 342 | /** 343 | * This lookup table used by mp_next() and mp_check() to determine 344 | * size of MsgPack element by its first byte. 345 | * A positive value contains size of the element (excluding the first byte). 346 | * A negative value means the element is compound (e.g. array or map) 347 | * of size (-n). 348 | * MP_HINT_* values used for special cases handled by switch() statement. 349 | */ 350 | const int8_t mp_parser_hint[256] = { 351 | /* {{{ MP_UINT(fixed) **/ 352 | /* 0x00 */ 0, 353 | /* 0x01 */ 0, 354 | /* 0x02 */ 0, 355 | /* 0x03 */ 0, 356 | /* 0x04 */ 0, 357 | /* 0x05 */ 0, 358 | /* 0x06 */ 0, 359 | /* 0x07 */ 0, 360 | /* 0x08 */ 0, 361 | /* 0x09 */ 0, 362 | /* 0x0a */ 0, 363 | /* 0x0b */ 0, 364 | /* 0x0c */ 0, 365 | /* 0x0d */ 0, 366 | /* 0x0e */ 0, 367 | /* 0x0f */ 0, 368 | /* 0x10 */ 0, 369 | /* 0x11 */ 0, 370 | /* 0x12 */ 0, 371 | /* 0x13 */ 0, 372 | /* 0x14 */ 0, 373 | /* 0x15 */ 0, 374 | /* 0x16 */ 0, 375 | /* 0x17 */ 0, 376 | /* 0x18 */ 0, 377 | /* 0x19 */ 0, 378 | /* 0x1a */ 0, 379 | /* 0x1b */ 0, 380 | /* 0x1c */ 0, 381 | /* 0x1d */ 0, 382 | /* 0x1e */ 0, 383 | /* 0x1f */ 0, 384 | /* 0x20 */ 0, 385 | /* 0x21 */ 0, 386 | /* 0x22 */ 0, 387 | /* 0x23 */ 0, 388 | /* 0x24 */ 0, 389 | /* 0x25 */ 0, 390 | /* 0x26 */ 0, 391 | /* 0x27 */ 0, 392 | /* 0x28 */ 0, 393 | /* 0x29 */ 0, 394 | /* 0x2a */ 0, 395 | /* 0x2b */ 0, 396 | /* 0x2c */ 0, 397 | /* 0x2d */ 0, 398 | /* 0x2e */ 0, 399 | /* 0x2f */ 0, 400 | /* 0x30 */ 0, 401 | /* 0x31 */ 0, 402 | /* 0x32 */ 0, 403 | /* 0x33 */ 0, 404 | /* 0x34 */ 0, 405 | /* 0x35 */ 0, 406 | /* 0x36 */ 0, 407 | /* 0x37 */ 0, 408 | /* 0x38 */ 0, 409 | /* 0x39 */ 0, 410 | /* 0x3a */ 0, 411 | /* 0x3b */ 0, 412 | /* 0x3c */ 0, 413 | /* 0x3d */ 0, 414 | /* 0x3e */ 0, 415 | /* 0x3f */ 0, 416 | /* 0x40 */ 0, 417 | /* 0x41 */ 0, 418 | /* 0x42 */ 0, 419 | /* 0x43 */ 0, 420 | /* 0x44 */ 0, 421 | /* 0x45 */ 0, 422 | /* 0x46 */ 0, 423 | /* 0x47 */ 0, 424 | /* 0x48 */ 0, 425 | /* 0x49 */ 0, 426 | /* 0x4a */ 0, 427 | /* 0x4b */ 0, 428 | /* 0x4c */ 0, 429 | /* 0x4d */ 0, 430 | /* 0x4e */ 0, 431 | /* 0x4f */ 0, 432 | /* 0x50 */ 0, 433 | /* 0x51 */ 0, 434 | /* 0x52 */ 0, 435 | /* 0x53 */ 0, 436 | /* 0x54 */ 0, 437 | /* 0x55 */ 0, 438 | /* 0x56 */ 0, 439 | /* 0x57 */ 0, 440 | /* 0x58 */ 0, 441 | /* 0x59 */ 0, 442 | /* 0x5a */ 0, 443 | /* 0x5b */ 0, 444 | /* 0x5c */ 0, 445 | /* 0x5d */ 0, 446 | /* 0x5e */ 0, 447 | /* 0x5f */ 0, 448 | /* 0x60 */ 0, 449 | /* 0x61 */ 0, 450 | /* 0x62 */ 0, 451 | /* 0x63 */ 0, 452 | /* 0x64 */ 0, 453 | /* 0x65 */ 0, 454 | /* 0x66 */ 0, 455 | /* 0x67 */ 0, 456 | /* 0x68 */ 0, 457 | /* 0x69 */ 0, 458 | /* 0x6a */ 0, 459 | /* 0x6b */ 0, 460 | /* 0x6c */ 0, 461 | /* 0x6d */ 0, 462 | /* 0x6e */ 0, 463 | /* 0x6f */ 0, 464 | /* 0x70 */ 0, 465 | /* 0x71 */ 0, 466 | /* 0x72 */ 0, 467 | /* 0x73 */ 0, 468 | /* 0x74 */ 0, 469 | /* 0x75 */ 0, 470 | /* 0x76 */ 0, 471 | /* 0x77 */ 0, 472 | /* 0x78 */ 0, 473 | /* 0x79 */ 0, 474 | /* 0x7a */ 0, 475 | /* 0x7b */ 0, 476 | /* 0x7c */ 0, 477 | /* 0x7d */ 0, 478 | /* 0x7e */ 0, 479 | /* 0x7f */ 0, 480 | /* }}} */ 481 | 482 | /* {{{ MP_MAP (fixed) */ 483 | /* 0x80 */ 0, /* empty map - just skip one byte */ 484 | /* 0x81 */ -2, /* 2 elements follow */ 485 | /* 0x82 */ -4, 486 | /* 0x83 */ -6, 487 | /* 0x84 */ -8, 488 | /* 0x85 */ -10, 489 | /* 0x86 */ -12, 490 | /* 0x87 */ -14, 491 | /* 0x88 */ -16, 492 | /* 0x89 */ -18, 493 | /* 0x8a */ -20, 494 | /* 0x8b */ -22, 495 | /* 0x8c */ -24, 496 | /* 0x8d */ -26, 497 | /* 0x8e */ -28, 498 | /* 0x8f */ -30, 499 | /* }}} */ 500 | 501 | /* {{{ MP_ARRAY (fixed) */ 502 | /* 0x90 */ 0, /* empty array - just skip one byte */ 503 | /* 0x91 */ -1, /* 1 element follows */ 504 | /* 0x92 */ -2, 505 | /* 0x93 */ -3, 506 | /* 0x94 */ -4, 507 | /* 0x95 */ -5, 508 | /* 0x96 */ -6, 509 | /* 0x97 */ -7, 510 | /* 0x98 */ -8, 511 | /* 0x99 */ -9, 512 | /* 0x9a */ -10, 513 | /* 0x9b */ -11, 514 | /* 0x9c */ -12, 515 | /* 0x9d */ -13, 516 | /* 0x9e */ -14, 517 | /* 0x9f */ -15, 518 | /* }}} */ 519 | 520 | /* {{{ MP_STR (fixed) */ 521 | /* 0xa0 */ 0, 522 | /* 0xa1 */ 1, 523 | /* 0xa2 */ 2, 524 | /* 0xa3 */ 3, 525 | /* 0xa4 */ 4, 526 | /* 0xa5 */ 5, 527 | /* 0xa6 */ 6, 528 | /* 0xa7 */ 7, 529 | /* 0xa8 */ 8, 530 | /* 0xa9 */ 9, 531 | /* 0xaa */ 10, 532 | /* 0xab */ 11, 533 | /* 0xac */ 12, 534 | /* 0xad */ 13, 535 | /* 0xae */ 14, 536 | /* 0xaf */ 15, 537 | /* 0xb0 */ 16, 538 | /* 0xb1 */ 17, 539 | /* 0xb2 */ 18, 540 | /* 0xb3 */ 19, 541 | /* 0xb4 */ 20, 542 | /* 0xb5 */ 21, 543 | /* 0xb6 */ 22, 544 | /* 0xb7 */ 23, 545 | /* 0xb8 */ 24, 546 | /* 0xb9 */ 25, 547 | /* 0xba */ 26, 548 | /* 0xbb */ 27, 549 | /* 0xbc */ 28, 550 | /* 0xbd */ 29, 551 | /* 0xbe */ 30, 552 | /* 0xbf */ 31, 553 | /* }}} */ 554 | 555 | /* {{{ MP_NIL, MP_BOOL */ 556 | /* 0xc0 */ 0, /* MP_NIL */ 557 | /* 0xc1 */ MP_HINT_INVALID, /* never used */ 558 | /* 0xc2 */ 0, /* MP_BOOL*/ 559 | /* 0xc3 */ 0, /* MP_BOOL*/ 560 | /* }}} */ 561 | 562 | /* {{{ MP_BIN */ 563 | /* 0xc4 */ MP_HINT_STR_8, /* MP_BIN (8) */ 564 | /* 0xc5 */ MP_HINT_STR_16, /* MP_BIN (16) */ 565 | /* 0xc6 */ MP_HINT_STR_32, /* MP_BIN (32) */ 566 | /* }}} */ 567 | 568 | /* {{{ MP_EXT */ 569 | /* 0xc7 */ MP_HINT_EXT_8, /* MP_EXT (8) */ 570 | /* 0xc8 */ MP_HINT_EXT_16, /* MP_EXT (16) */ 571 | /* 0xc9 */ MP_HINT_EXT_32, /* MP_EXT (32) */ 572 | /* }}} */ 573 | 574 | /* {{{ MP_FLOAT, MP_DOUBLE */ 575 | /* 0xca */ sizeof(float), /* MP_FLOAT */ 576 | /* 0xcb */ sizeof(double), /* MP_DOUBLE */ 577 | /* }}} */ 578 | 579 | /* {{{ MP_UINT */ 580 | /* 0xcc */ sizeof(uint8_t), /* MP_UINT (8) */ 581 | /* 0xcd */ sizeof(uint16_t), /* MP_UINT (16) */ 582 | /* 0xce */ sizeof(uint32_t), /* MP_UINT (32) */ 583 | /* 0xcf */ sizeof(uint64_t), /* MP_UINT (64) */ 584 | /* }}} */ 585 | 586 | /* {{{ MP_INT */ 587 | /* 0xd0 */ sizeof(uint8_t), /* MP_INT (8) */ 588 | /* 0xd1 */ sizeof(uint16_t), /* MP_INT (8) */ 589 | /* 0xd2 */ sizeof(uint32_t), /* MP_INT (8) */ 590 | /* 0xd3 */ sizeof(uint64_t), /* MP_INT (8) */ 591 | /* }}} */ 592 | 593 | /* {{{ MP_EXT (fixext) */ 594 | /* 0xd4 */ 2, /* MP_EXT (fixext 8) */ 595 | /* 0xd5 */ 3, /* MP_EXT (fixext 16) */ 596 | /* 0xd6 */ 5, /* MP_EXT (fixext 32) */ 597 | /* 0xd7 */ 9, /* MP_EXT (fixext 64) */ 598 | /* 0xd8 */ 17, /* MP_EXT (fixext 128) */ 599 | /* }}} */ 600 | 601 | /* {{{ MP_STR */ 602 | /* 0xd9 */ MP_HINT_STR_8, /* MP_STR (8) */ 603 | /* 0xda */ MP_HINT_STR_16, /* MP_STR (16) */ 604 | /* 0xdb */ MP_HINT_STR_32, /* MP_STR (32) */ 605 | /* }}} */ 606 | 607 | /* {{{ MP_ARRAY */ 608 | /* 0xdc */ MP_HINT_ARRAY_16, /* MP_ARRAY (16) */ 609 | /* 0xdd */ MP_HINT_ARRAY_32, /* MP_ARRAY (32) */ 610 | /* }}} */ 611 | 612 | /* {{{ MP_MAP */ 613 | /* 0xde */ MP_HINT_MAP_16, /* MP_MAP (16) */ 614 | /* 0xdf */ MP_HINT_MAP_32, /* MP_MAP (32) */ 615 | /* }}} */ 616 | 617 | /* {{{ MP_INT (fixed) */ 618 | /* 0xe0 */ 0, 619 | /* 0xe1 */ 0, 620 | /* 0xe2 */ 0, 621 | /* 0xe3 */ 0, 622 | /* 0xe4 */ 0, 623 | /* 0xe5 */ 0, 624 | /* 0xe6 */ 0, 625 | /* 0xe7 */ 0, 626 | /* 0xe8 */ 0, 627 | /* 0xe9 */ 0, 628 | /* 0xea */ 0, 629 | /* 0xeb */ 0, 630 | /* 0xec */ 0, 631 | /* 0xed */ 0, 632 | /* 0xee */ 0, 633 | /* 0xef */ 0, 634 | /* 0xf0 */ 0, 635 | /* 0xf1 */ 0, 636 | /* 0xf2 */ 0, 637 | /* 0xf3 */ 0, 638 | /* 0xf4 */ 0, 639 | /* 0xf5 */ 0, 640 | /* 0xf6 */ 0, 641 | /* 0xf7 */ 0, 642 | /* 0xf8 */ 0, 643 | /* 0xf9 */ 0, 644 | /* 0xfa */ 0, 645 | /* 0xfb */ 0, 646 | /* 0xfc */ 0, 647 | /* 0xfd */ 0, 648 | /* 0xfe */ 0, 649 | /* 0xff */ 0 650 | /* }}} */ 651 | }; 652 | 653 | const char *const mp_char2escape[128] = { 654 | "\\u0000", "\\u0001", "\\u0002", "\\u0003", 655 | "\\u0004", "\\u0005", "\\u0006", "\\u0007", 656 | "\\b", "\\t", "\\n", "\\u000b", 657 | "\\f", "\\r", "\\u000e", "\\u000f", 658 | "\\u0010", "\\u0011", "\\u0012", "\\u0013", 659 | "\\u0014", "\\u0015", "\\u0016", "\\u0017", 660 | "\\u0018", "\\u0019", "\\u001a", "\\u001b", 661 | "\\u001c", "\\u001d", "\\u001e", "\\u001f", 662 | NULL, NULL, "\\\"", NULL, NULL, NULL, NULL, NULL, 663 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 664 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 665 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 666 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 667 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 668 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 669 | NULL, NULL, NULL, NULL, "\\\\", NULL, NULL, NULL, 670 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 671 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 672 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 673 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, "\\u007f" 674 | }; 675 | 676 | /* 677 | * This lookup table is used by mp_encode_ext() to 678 | * determine ext code (fixext 1, fixext 2, fixext 4, fixext 8, 679 | * fixext 16) to encode using size. 680 | */ 681 | const uint8_t mp_ext_hint[16] = { 682 | 0xd4, /* 1 */ 683 | 0xd5, /* 2 */ 684 | 0, /* 3 */ 685 | 0xd6, /* 4 */ 686 | 0, /* 5 */ 687 | 0, /* 6 */ 688 | 0, /* 7 */ 689 | 0xd7, /* 8 */ 690 | 0, /* 9 */ 691 | 0, /* 10 */ 692 | 0, /* 11 */ 693 | 0, /* 12 */ 694 | 0, /* 13 */ 695 | 0, /* 14 */ 696 | 0, /* 15 */ 697 | 0xd8 /* 16 */ 698 | }; 699 | -------------------------------------------------------------------------------- /test/msgpuck.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016 MsgPuck Authors 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or 6 | * without modification, are permitted provided that the following 7 | * conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above 10 | * copyright notice, this list of conditions and the 11 | * following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above 14 | * copyright notice, this list of conditions and the following 15 | * disclaimer in the documentation and/or other materials 16 | * provided with the distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND 19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 22 | * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 23 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 26 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 29 | * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 | * SUCH DAMAGE. 31 | */ 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | 39 | #define UNIT_TAP_COMPATIBLE 1 40 | #include "msgpuck.h" 41 | #include "test.h" 42 | 43 | #include 44 | 45 | #define BUF_MAXLEN ((1L << 18) - 1) 46 | #define STRBIN_MAXLEN (BUF_MAXLEN - 10) 47 | #define MP_NUMBER_MAX_LEN 16 48 | #define MP_NUMBER_CODEC_COUNT 16 49 | 50 | #ifndef lengthof 51 | #define lengthof(array) (sizeof(array) / sizeof((array)[0])) 52 | #endif 53 | 54 | #ifndef __has_attribute 55 | # define __has_attribute(x) 0 56 | #endif 57 | 58 | #if __has_attribute(noinline) || defined(__GNUC__) 59 | # define NOINLINE __attribute__((noinline)) 60 | #else 61 | # define NOINLINE 62 | #endif 63 | 64 | static char buf[BUF_MAXLEN + 1]; 65 | static char str[STRBIN_MAXLEN]; 66 | static char *data = buf + 1; /* use unaligned address to fail early */ 67 | 68 | #define SCALAR(x) x 69 | #define COMPLEX(x) 70 | 71 | #define COMMA , 72 | 73 | #define DEFINE_TEST(_type, _complex, _ext, _v, _r, _rl) ({ \ 74 | _ext(int8_t ext_type = 0); \ 75 | const char *d1 = mp_encode_##_type(data, _ext(ext_type COMMA) (_v)); \ 76 | const char *d2 = data; \ 77 | _complex(const char *d3 = data); \ 78 | _complex(const char *d4 = data); \ 79 | note(""#_type" "#_v""); \ 80 | is(mp_check_##_type(data, d1), 0, "mp_check_"#_type"("#_v") == 0"); \ 81 | is(mp_decode_##_type(&d2 _ext(COMMA &ext_type)), (_v), "mp_decode(mp_encode("#_v")) == "#_v);\ 82 | _complex(mp_next(&d3)); \ 83 | _complex(ok(!mp_check(&d4, d3 + _rl), "mp_check("#_v")")); \ 84 | is((d1 - data), (_rl), "len(mp_encode_"#_type"("#_v")"); \ 85 | is(d1, d2, "len(mp_decode_"#_type"("#_v"))"); \ 86 | _complex(is(d1, d3, "len(mp_next_"#_type"("#_v"))")); \ 87 | _complex(is(d1, d4, "len(mp_check_"#_type"("#_v"))")); \ 88 | is(mp_sizeof_##_type(_v), _rl, "mp_sizeof_"#_type"("#_v")"); \ 89 | is(memcmp(data, (_r), (_rl)), 0, "mp_encode("#_v") == "#_r); \ 90 | }) 91 | 92 | 93 | #define DEFINE_TEST_STRBINEXT(_type, _not_ext, _ext, _vl) ({ \ 94 | note(""#_type" len="#_vl""); \ 95 | char *s1 = str; \ 96 | for (uint32_t i = 0; i < _vl; i++) { \ 97 | s1[i] = 'a' + i % 26; \ 98 | } \ 99 | _ext(int8_t ext_type = 0); \ 100 | const char *d1 = mp_encode_##_type(data, _ext(ext_type COMMA) s1, _vl);\ 101 | const char *d2; \ 102 | uint32_t len2; \ 103 | d2 = data; \ 104 | const char *s2 = mp_decode_##_type(&d2, _ext(&ext_type COMMA) &len2); \ 105 | is(_vl, len2, "len(mp_decode_"#_type"(x, %u))", _vl); \ 106 | _ext(is(ext_type, 0, "type(mp_decode_"#_type"(x))")); \ 107 | d2 = data; \ 108 | _not_ext((void) mp_decode_strbin(&d2, &len2)); \ 109 | _ext((void) mp_decode_ext(&d2, &ext_type, &len2)); \ 110 | is(_vl, len2, "len(mp_decode_strbin(x, %u))", _vl); \ 111 | const char *d3 = data; \ 112 | mp_next(&d3); \ 113 | const char *d4 = data; \ 114 | ok(!mp_check(&d4, d3 + _vl), \ 115 | "mp_check_"#_type"(mp_encode_"#_type"(x, "#_vl"))"); \ 116 | is(d1, d2, "len(mp_decode_"#_type"(x, "#_vl")"); \ 117 | is(d1, d3, "len(mp_next_"#_type"(x, "#_vl")"); \ 118 | is(d1, d4, "len(mp_check_"#_type"(x, "#_vl")"); \ 119 | is(mp_sizeof_##_type(_vl), (uint32_t) (d1 - data), \ 120 | "mp_sizeof_"#_type"("#_vl")"); \ 121 | is(memcmp(s1, s2, _vl), 0, "mp_encode_"#_type"(x, "#_vl") == x"); \ 122 | }) 123 | 124 | #define test_uint(...) DEFINE_TEST(uint, SCALAR, COMPLEX, __VA_ARGS__) 125 | #define test_int(...) DEFINE_TEST(int, SCALAR, COMPLEX, __VA_ARGS__) 126 | #define test_bool(...) DEFINE_TEST(bool, SCALAR, COMPLEX, __VA_ARGS__) 127 | #define test_float(...) DEFINE_TEST(float, SCALAR, COMPLEX, __VA_ARGS__) 128 | #define test_double(...) DEFINE_TEST(double, SCALAR, COMPLEX, __VA_ARGS__) 129 | #define test_strl(...) DEFINE_TEST(strl, COMPLEX, COMPLEX, __VA_ARGS__) 130 | #define test_binl(...) DEFINE_TEST(binl, COMPLEX, COMPLEX, __VA_ARGS__) 131 | #define test_extl(...) DEFINE_TEST(extl, COMPLEX, SCALAR, __VA_ARGS__) 132 | #define test_array(...) DEFINE_TEST(array, COMPLEX, COMPLEX, __VA_ARGS__) 133 | #define test_map(...) DEFINE_TEST(map, COMPLEX, COMPLEX, __VA_ARGS__) 134 | #define test_str(...) DEFINE_TEST_STRBINEXT(str, SCALAR, COMPLEX, __VA_ARGS__) 135 | #define test_bin(...) DEFINE_TEST_STRBINEXT(bin, SCALAR, COMPLEX, __VA_ARGS__) 136 | #define test_ext(...) DEFINE_TEST_STRBINEXT(ext, COMPLEX, SCALAR, __VA_ARGS__) 137 | 138 | #define DEFINE_TEST_SAFE(_type, _complex, _ext, _v, _r, _rl) ({ \ 139 | note(""#_type"_safe"); \ 140 | _ext(int8_t ext_type = 0); \ 141 | ptrdiff_t sz; \ 142 | const char *d; \ 143 | /* Test calculating size. */ \ 144 | sz = 0; \ 145 | d = mp_encode_##_type##_safe(NULL, &sz, _ext(ext_type COMMA) (_v)); \ 146 | is(-sz, (_rl), "size after mp_encode_"#_type"_safe(NULL, &sz)"); \ 147 | is(d, NULL, "mp_encode_"#_type"_safe(NULL, &sz)"); \ 148 | /* Test encoding with no overflow. */ \ 149 | sz = _rl; \ 150 | d = mp_encode_##_type##_safe(data, &sz, _ext(ext_type COMMA) (_v)); \ 151 | is(sz, 0, "size after mp_encode_"#_type"_safe(buf, &sz)"); \ 152 | is((d - data), (_rl), "len of mp_encode_"#_type"_safe(buf, &sz)"); \ 153 | is(memcmp(data, (_r), (_rl)), 0, "mp_encode_"#_type"_safe(buf, &sz)"); \ 154 | /* Test encoding with with overflow. */ \ 155 | sz = _rl - 1; \ 156 | d = mp_encode_##_type##_safe(data, &sz, _ext(ext_type COMMA) (_v)); \ 157 | is(sz, -1, "size after mp_encode_"#_type"_safe(buf, &sz) overflow"); \ 158 | is(d, data, "mp_encode_"#_type"_safe(buf, &sz) overflow"); \ 159 | /* Test encoding with sz == NULL. */ \ 160 | d = mp_encode_##_type##_safe(data, NULL, _ext(ext_type COMMA) (_v)); \ 161 | is((d - data), (_rl), "len of mp_encode_"#_type"_safe(buf, NULL)"); \ 162 | is(memcmp(data, (_r), (_rl)), 0, "mp_encode_"#_type"_safe(buf, NULL)");\ 163 | }) 164 | 165 | #define DEFINE_TEST_STRBINEXT_SAFE(_type, _not_ext, _ext, _vl) ({ \ 166 | note(""#_type"_safe"); \ 167 | _ext(int8_t ext_type = 0); \ 168 | ptrdiff_t sz; \ 169 | const ptrdiff_t hl = mp_sizeof_##_type##l(_vl); \ 170 | const ptrdiff_t rl = hl + _vl; \ 171 | char head[5]; \ 172 | const char *d; \ 173 | for (uint32_t i = 0; i < _vl; i++) { \ 174 | str[i] = 'a' + i % 26; \ 175 | } \ 176 | mp_encode_##_type##l(head,_ext(ext_type COMMA) _vl); \ 177 | /* Test calculating size. */ \ 178 | sz = 0; \ 179 | d = mp_encode_##_type##_safe(NULL, &sz, _ext(ext_type COMMA) str, _vl);\ 180 | is(-sz, rl, "size after mp_encode_"#_type"_safe(NULL, &sz)"); \ 181 | is(d, NULL, "mp_encode_"#_type"_safe(NULL, &sz)"); \ 182 | /* Test encoding with no overflow. */ \ 183 | sz = rl; \ 184 | d = mp_encode_##_type##_safe(data, &sz, _ext(ext_type COMMA) str, _vl);\ 185 | is(sz, 0, "size after mp_encode_"#_type"_safe(buf, &sz)"); \ 186 | is((d - data), rl, "len of mp_encode_"#_type"_safe(buf, &sz)"); \ 187 | is(memcmp(data, head, hl), 0, \ 188 | "head of mp_encode_"#_type"_safe(buf, &sz)"); \ 189 | is(memcmp(data + hl, str, (_vl)), 0, \ 190 | "payload of mp_encode_"#_type"_safe(buf, &sz)"); \ 191 | /* Test encoding with with overflow. */ \ 192 | sz = rl - 1; \ 193 | d = mp_encode_##_type##_safe(data, &sz, _ext(ext_type COMMA) str, _vl);\ 194 | is(sz, -1, "size after mp_encode_"#_type"_safe(buf, &sz) overflow"); \ 195 | is(d, data, "mp_encode_"#_type"_safe(buf, &sz) overflow"); \ 196 | /* Test encoding with sz == NULL. */ \ 197 | d = mp_encode_##_type##_safe(data, NULL, _ext(ext_type COMMA)str, _vl);\ 198 | is((d - data), rl, "len of mp_encode_"#_type"_safe(buf, NULL)"); \ 199 | is(memcmp(data, head, hl), 0, \ 200 | "head of mp_encode_"#_type"_safe(buf, NULL)"); \ 201 | is(memcmp(data + hl, str, (_vl)), 0, \ 202 | "payload of mp_encode_"#_type"_safe(buf, NULL)"); \ 203 | }) 204 | 205 | #define test_uint_safe(...) DEFINE_TEST_SAFE(uint, SCALAR, COMPLEX, __VA_ARGS__) 206 | #define test_int_safe(...) DEFINE_TEST_SAFE(int, SCALAR, COMPLEX, __VA_ARGS__) 207 | #define test_bool_safe(...) DEFINE_TEST_SAFE(bool, SCALAR, COMPLEX, __VA_ARGS__) 208 | #define test_float_safe(...) DEFINE_TEST_SAFE(float, SCALAR, COMPLEX, __VA_ARGS__) 209 | #define test_double_safe(...) DEFINE_TEST_SAFE(double, SCALAR, COMPLEX, __VA_ARGS__) 210 | #define test_strl_safe(...) DEFINE_TEST_SAFE(strl, COMPLEX, COMPLEX, __VA_ARGS__) 211 | #define test_binl_safe(...) DEFINE_TEST_SAFE(binl, COMPLEX, COMPLEX, __VA_ARGS__) 212 | #define test_extl_safe(...) DEFINE_TEST_SAFE(extl, COMPLEX, SCALAR, __VA_ARGS__) 213 | #define test_array_safe(...) DEFINE_TEST_SAFE(array, COMPLEX, COMPLEX, __VA_ARGS__) 214 | #define test_map_safe(...) DEFINE_TEST_SAFE(map, COMPLEX, COMPLEX, __VA_ARGS__) 215 | #define test_str_safe(...) DEFINE_TEST_STRBINEXT_SAFE(str, SCALAR, COMPLEX, __VA_ARGS__) 216 | #define test_bin_safe(...) DEFINE_TEST_STRBINEXT_SAFE(bin, SCALAR, COMPLEX, __VA_ARGS__) 217 | #define test_ext_safe(...) DEFINE_TEST_STRBINEXT_SAFE(ext, COMPLEX, SCALAR, __VA_ARGS__) 218 | 219 | static int 220 | test_uints(void) 221 | { 222 | plan(15*9 + 9); 223 | header(); 224 | 225 | test_uint(0U, "\x00", 1); 226 | test_uint(1U, "\x01", 1); 227 | test_uint(0x7eU, "\x7e", 1); 228 | test_uint(0x7fU, "\x7f", 1); 229 | 230 | test_uint(0x80U, "\xcc\x80", 2); 231 | test_uint(0xfeU, "\xcc\xfe", 2); 232 | test_uint(0xffU, "\xcc\xff", 2); 233 | 234 | test_uint(0xfffeU, "\xcd\xff\xfe", 3); 235 | test_uint(0xffffU, "\xcd\xff\xff", 3); 236 | 237 | test_uint(0x10000U, "\xce\x00\x01\x00\x00", 5); 238 | test_uint(0xfffffffeU, "\xce\xff\xff\xff\xfe", 5); 239 | test_uint(0xffffffffU, "\xce\xff\xff\xff\xff", 5); 240 | 241 | test_uint(0x100000000ULL, 242 | "\xcf\x00\x00\x00\x01\x00\x00\x00\x00", 9); 243 | test_uint(0xfffffffffffffffeULL, 244 | "\xcf\xff\xff\xff\xff\xff\xff\xff\xfe", 9); 245 | test_uint(0xffffffffffffffffULL, 246 | "\xcf\xff\xff\xff\xff\xff\xff\xff\xff", 9); 247 | 248 | test_uint_safe(0xfffeU, "\xcd\xff\xfe", 3); 249 | 250 | footer(); 251 | return check_plan(); 252 | } 253 | 254 | static int 255 | test_ints(void) 256 | { 257 | plan(17*9 + 9); 258 | header(); 259 | 260 | test_int(-0x01, "\xff", 1); 261 | test_int(-0x1e, "\xe2", 1); 262 | test_int(-0x1f, "\xe1", 1); 263 | test_int(-0x20, "\xe0", 1); 264 | test_int(-0x21, "\xd0\xdf", 2); 265 | 266 | test_int(-0x7f, "\xd0\x81", 2); 267 | test_int(-0x80, "\xd0\x80", 2); 268 | 269 | test_int(-0x81, "\xd1\xff\x7f", 3); 270 | test_int(-0x7fff, "\xd1\x80\x01", 3); 271 | test_int(-0x8000, "\xd1\x80\x00", 3); 272 | 273 | test_int(-0x8001, "\xd2\xff\xff\x7f\xff", 5); 274 | test_int(-0x7fffffff, "\xd2\x80\x00\x00\x01", 5); 275 | test_int(-0x80000000LL, "\xd2\x80\x00\x00\x00", 5); 276 | 277 | test_int(-0x80000001LL, 278 | "\xd3\xff\xff\xff\xff\x7f\xff\xff\xff", 9); 279 | test_int(-0x80000001LL, 280 | "\xd3\xff\xff\xff\xff\x7f\xff\xff\xff", 9); 281 | test_int(-0x7fffffffffffffffLL, 282 | "\xd3\x80\x00\x00\x00\x00\x00\x00\x01", 9); 283 | test_int((int64_t)-0x8000000000000000LL, 284 | "\xd3\x80\x00\x00\x00\x00\x00\x00\x00", 9); 285 | 286 | test_int_safe(-0x80000000LL, "\xd2\x80\x00\x00\x00", 5); 287 | 288 | footer(); 289 | return check_plan(); 290 | } 291 | 292 | static int 293 | test_bools(void) 294 | { 295 | plan(2*9 + 9); 296 | header(); 297 | 298 | test_bool(true, "\xc3", 1); 299 | test_bool(false, "\xc2", 1); 300 | 301 | test_bool_safe(true, "\xc3", 1); 302 | 303 | footer(); 304 | return check_plan(); 305 | } 306 | 307 | static int 308 | test_floats(void) 309 | { 310 | plan(3*9 + 9); 311 | header(); 312 | 313 | test_float((float) 1.0, "\xca\x3f\x80\x00\x00", 5); 314 | test_float((float) 3.141593, "\xca\x40\x49\x0f\xdc", 5); 315 | test_float((float) -1e38f, "\xca\xfe\x96\x76\x99", 5); 316 | 317 | test_float_safe((float) 3.141593, "\xca\x40\x49\x0f\xdc", 5); 318 | 319 | footer(); 320 | return check_plan(); 321 | } 322 | 323 | static int 324 | test_doubles(void) 325 | { 326 | plan(3*9 + 9); 327 | header(); 328 | 329 | test_double((double) 1.0, 330 | "\xcb\x3f\xf0\x00\x00\x00\x00\x00\x00", 9); 331 | test_double((double) 3.141592653589793, 332 | "\xcb\x40\x09\x21\xfb\x54\x44\x2d\x18", 9); 333 | test_double((double) -1e99, 334 | "\xcb\xd4\x7d\x42\xae\xa2\x87\x9f\x2e", 9); 335 | 336 | test_double_safe((double) 3.141592653589793, 337 | "\xcb\x40\x09\x21\xfb\x54\x44\x2d\x18", 9); 338 | 339 | footer(); 340 | return check_plan(); 341 | } 342 | 343 | static int 344 | test_nils(void) 345 | { 346 | plan(15); 347 | header(); 348 | 349 | const char *d1 = mp_encode_nil(data); 350 | const char *d2 = data; 351 | const char *d3 = data; 352 | const char *d4 = data; 353 | note("nil"); 354 | mp_decode_nil(&d2); 355 | mp_next(&d3); 356 | ok(!mp_check(&d4, d3 + 1), "mp_check_nil()"); 357 | is((d1 - data), 1, "len(mp_encode_nil() == 1"); 358 | is(d1, d2, "len(mp_decode_nil()) == 1"); 359 | is(d1, d3, "len(mp_next_nil()) == 1"); 360 | is(d1, d4, "len(mp_check_nil()) == 1"); 361 | is(mp_sizeof_nil(), 1, "mp_sizeof_nil() == 1"); 362 | 363 | ptrdiff_t sz = 0; 364 | d1 = mp_encode_nil_safe(NULL, &sz); 365 | is(-sz, 1, "size after mp_encode_nil_safe(NULL, &sz)"); 366 | is(d1, NULL, "mp_encode_nil_safe(NULL, &sz)"); 367 | 368 | sz = 1; 369 | d1 = mp_encode_nil_safe(data, &sz); 370 | is(sz, 0, "size after mp_encode_nil_safe(buf, &sz)"); 371 | is(d1 - data, 1, "len of mp_encode_nil_safe(buf, &sz)"); 372 | is((unsigned char)data[0], 0xc0, "mp_encode_nil_safe(buf, &sz)"); 373 | 374 | sz = 0; 375 | d1 = mp_encode_nil_safe(data, &sz); 376 | is(sz, -1, "size after mp_encode_nil_safe(buf, &sz) overflow"); 377 | is(d1, data, "mp_encode_nil_safe(buf, &sz) overflow"); 378 | 379 | d1 = mp_encode_nil_safe(data, NULL); 380 | is(d1 - data, 1, "len of mp_encode_nil_safe(buf, NULL)"); 381 | is((unsigned char)data[0], 0xc0, "mp_encode_nil_safe(buf, NULL)"); 382 | 383 | footer(); 384 | return check_plan(); 385 | } 386 | 387 | static int 388 | test_arrays(void) 389 | { 390 | plan(9*6 + 9); 391 | header(); 392 | 393 | test_array(0, "\x90", 1); 394 | test_array(1, "\x91", 1); 395 | test_array(15, "\x9f", 1); 396 | test_array(16, "\xdc\x00\x10", 3); 397 | test_array(0xfffe, "\xdc\xff\xfe", 3); 398 | test_array(0xffff, "\xdc\xff\xff", 3); 399 | test_array(0x10000, "\xdd\x00\x01\x00\x00", 5); 400 | test_array(0xfffffffeU, "\xdd\xff\xff\xff\xfe", 5); 401 | test_array(0xffffffffU, "\xdd\xff\xff\xff\xff", 5); 402 | 403 | test_array_safe(0xffff, "\xdc\xff\xff", 3); 404 | 405 | footer(); 406 | return check_plan(); 407 | } 408 | 409 | static int 410 | test_maps(void) 411 | { 412 | plan(9*6 + 9); 413 | header(); 414 | 415 | test_map(0, "\x80", 1); 416 | test_map(1, "\x81", 1); 417 | test_map(15, "\x8f", 1); 418 | test_map(16, "\xde\x00\x10", 3); 419 | test_map(0xfffe, "\xde\xff\xfe", 3); 420 | test_map(0xffff, "\xde\xff\xff", 3); 421 | test_map(0x10000, "\xdf\x00\x01\x00\x00", 5); 422 | test_map(0xfffffffeU, "\xdf\xff\xff\xff\xfe", 5); 423 | test_map(0xffffffffU, "\xdf\xff\xff\xff\xff", 5); 424 | 425 | test_map_safe(0xfffffffeU, "\xdf\xff\xff\xff\xfe", 5); 426 | 427 | footer(); 428 | return check_plan(); 429 | } 430 | 431 | static int 432 | test_strls(void) 433 | { 434 | plan(13*6 + 9); 435 | header(); 436 | 437 | test_strl(0x00U, "\xa0", 1); 438 | test_strl(0x01U, "\xa1", 1); 439 | test_strl(0x1eU, "\xbe", 1); 440 | test_strl(0x1fU, "\xbf", 1); 441 | 442 | test_strl(0x20U, "\xd9\x20", 2); 443 | test_strl(0xfeU, "\xd9\xfe", 2); 444 | test_strl(0xffU, "\xd9\xff", 2); 445 | 446 | test_strl(0x0100U, "\xda\x01\x00", 3); 447 | test_strl(0xfffeU, "\xda\xff\xfe", 3); 448 | test_strl(0xffffU, "\xda\xff\xff", 3); 449 | 450 | test_strl(0x00010000U, "\xdb\x00\x01\x00\x00", 5); 451 | test_strl(0xfffffffeU, "\xdb\xff\xff\xff\xfe", 5); 452 | test_strl(0xffffffffU, "\xdb\xff\xff\xff\xff", 5); 453 | 454 | test_strl_safe(0x20U, "\xd9\x20", 2); 455 | 456 | footer(); 457 | return check_plan(); 458 | } 459 | 460 | static int 461 | test_binls(void) 462 | { 463 | plan(13*6 + 9); 464 | header(); 465 | 466 | test_binl(0x00U, "\xc4\x00", 2); 467 | test_binl(0x01U, "\xc4\x01", 2); 468 | test_binl(0x1eU, "\xc4\x1e", 2); 469 | test_binl(0x1fU, "\xc4\x1f", 2); 470 | 471 | test_binl(0x20U, "\xc4\x20", 2); 472 | test_binl(0xfeU, "\xc4\xfe", 2); 473 | test_binl(0xffU, "\xc4\xff", 2); 474 | 475 | test_binl(0x0100U, "\xc5\x01\x00", 3); 476 | test_binl(0xfffeU, "\xc5\xff\xfe", 3); 477 | test_binl(0xffffU, "\xc5\xff\xff", 3); 478 | 479 | test_binl(0x00010000U, "\xc6\x00\x01\x00\x00", 5); 480 | test_binl(0xfffffffeU, "\xc6\xff\xff\xff\xfe", 5); 481 | test_binl(0xffffffffU, "\xc6\xff\xff\xff\xff", 5); 482 | 483 | test_binl_safe(0x00010000U, "\xc6\x00\x01\x00\x00", 5); 484 | 485 | footer(); 486 | return check_plan(); 487 | } 488 | 489 | static int 490 | test_extls(void) 491 | { 492 | plan(28*6 + 9); 493 | header(); 494 | 495 | /* fixext 1,2,4,8,16 */ 496 | test_extl(0x01U, "\xd4\x00", 2); 497 | test_extl(0x02U, "\xd5\x00", 2); 498 | test_extl(0x04U, "\xd6\x00", 2); 499 | test_extl(0x08U, "\xd7\x00", 2); 500 | test_extl(0x10U, "\xd8\x00", 2); 501 | 502 | /* ext 8 */ 503 | test_extl(0x11U, "\xc7\x11\x00", 3); 504 | test_extl(0xfeU, "\xc7\xfe\x00", 3); 505 | test_extl(0xffU, "\xc7\xff\x00", 3); 506 | 507 | test_extl(0x00U, "\xc7\x00\x00", 3); 508 | test_extl(0x03U, "\xc7\x03\x00", 3); 509 | test_extl(0x05U, "\xc7\x05\x00", 3); 510 | test_extl(0x06U, "\xc7\x06\x00", 3); 511 | test_extl(0x07U, "\xc7\x07\x00", 3); 512 | test_extl(0x09U, "\xc7\x09\x00", 3); 513 | test_extl(0x0aU, "\xc7\x0a\x00", 3); 514 | test_extl(0x0bU, "\xc7\x0b\x00", 3); 515 | test_extl(0x0cU, "\xc7\x0c\x00", 3); 516 | test_extl(0x0dU, "\xc7\x0d\x00", 3); 517 | test_extl(0x0eU, "\xc7\x0e\x00", 3); 518 | test_extl(0x0fU, "\xc7\x0f\x00", 3); 519 | 520 | /* ext 16 */ 521 | test_extl(0x0100U, "\xc8\x01\x00\x00", 4); 522 | test_extl(0x0101U, "\xc8\x01\x01\x00", 4); 523 | test_extl(0xfffeU, "\xc8\xff\xfe\x00", 4); 524 | test_extl(0xffffU, "\xc8\xff\xff\x00", 4); 525 | 526 | /* ext 32 */ 527 | test_extl(0x00010000U, "\xc9\x00\x01\x00\x00\x00", 6); 528 | test_extl(0x00010001U, "\xc9\x00\x01\x00\x01\x00", 6); 529 | test_extl(0xfffffffeU, "\xc9\xff\xff\xff\xfe\x00", 6); 530 | test_extl(0xffffffffU, "\xc9\xff\xff\xff\xff\x00", 6); 531 | 532 | test_extl_safe(0x0aU, "\xc7\x0a\x00", 3); 533 | 534 | footer(); 535 | return check_plan(); 536 | } 537 | 538 | static int 539 | test_strs(void) 540 | { 541 | plan(12*8 + 11); 542 | header(); 543 | 544 | test_str(0x01); 545 | test_str(0x1e); 546 | test_str(0x1f); 547 | test_str(0x20); 548 | test_str(0xfe); 549 | test_str(0xff); 550 | test_str(0x100); 551 | test_str(0x101); 552 | test_str(0xfffe); 553 | test_str(0xffff); 554 | test_str(0x10000); 555 | test_str(0x10001); 556 | 557 | test_str_safe(0xfffe); 558 | 559 | footer(); 560 | return check_plan(); 561 | } 562 | 563 | static int 564 | test_bins(void) 565 | { 566 | plan(12*8 + 11); 567 | header(); 568 | 569 | test_bin(0x01); 570 | test_bin(0x1e); 571 | test_bin(0x1f); 572 | test_bin(0x20); 573 | test_bin(0xfe); 574 | test_bin(0xff); 575 | test_bin(0x100); 576 | test_bin(0x101); 577 | test_bin(0xfffe); 578 | test_bin(0xffff); 579 | test_bin(0x10000); 580 | test_bin(0x10001); 581 | 582 | test_bin_safe(0x10001); 583 | 584 | footer(); 585 | return check_plan(); 586 | } 587 | 588 | static int 589 | test_exts(void) 590 | { 591 | plan(25*9 + 11); 592 | header(); 593 | 594 | test_ext(0x01); 595 | test_ext(0x02); 596 | test_ext(0x03); 597 | test_ext(0x04); 598 | test_ext(0x05); 599 | test_ext(0x06); 600 | test_ext(0x07); 601 | test_ext(0x08); 602 | test_ext(0x09); 603 | test_ext(0x0a); 604 | test_ext(0x0b); 605 | test_ext(0x0c); 606 | test_ext(0x0d); 607 | test_ext(0x0e); 608 | test_ext(0x0f); 609 | test_ext(0x10); 610 | 611 | test_ext(0x11); 612 | test_ext(0xfe); 613 | test_ext(0xff); 614 | 615 | test_ext(0x0100); 616 | test_ext(0x0101); 617 | test_ext(0xfffe); 618 | test_ext(0xffff); 619 | 620 | test_ext(0x00010000); 621 | test_ext(0x00010001); 622 | 623 | test_ext_safe(0xfe); 624 | 625 | footer(); 626 | return check_plan(); 627 | } 628 | 629 | static int 630 | test_memcpy() 631 | { 632 | plan(11); 633 | header(); 634 | 635 | int len = 27; 636 | char *d; 637 | 638 | for (int i = 0; i < len; i++) 639 | str[i] = 'a' + i % 26; 640 | 641 | d = mp_memcpy(data, str, len); 642 | is(d - data, len, "len of mp_memcpy()"); 643 | is(memcmp(data, str, len), 0, "payload of mp_memcpy()"); 644 | 645 | ptrdiff_t sz = 0; 646 | d = mp_memcpy_safe(NULL, &sz, str, len); 647 | is(-sz, len, "size after mp_memcpy_safe(NULL, &sz)"); 648 | is(d, NULL, "mp_memcpy_safe(NULL, &sz)"); 649 | 650 | sz = len; 651 | d = mp_memcpy_safe(data, &sz, str, len); 652 | is(sz, 0, "size after mp_memcpy_safe(buf, &sz)"); 653 | is(d - data, len, "len of mp_memcpy_safe(buf, &sz)"); 654 | is(memcmp(data, str, len), 0, "mp_memcpy_safe(buf, &sz)"); 655 | 656 | sz = len - 1; 657 | d = mp_memcpy_safe(data, &sz, str, len); 658 | is(sz, -1, "size after mp_memcpy_safe(buf, &sz) overflow"); 659 | is(d, data, "mp_memcpy_safe(buf, &sz) overflow"); 660 | 661 | d = mp_memcpy_safe(data, NULL, str, len); 662 | is(d - data, len, "len of (buf, NULL)"); 663 | is(memcmp(data, str, len), 0, "mp_memcpy_safe(buf, NULL)"); 664 | 665 | footer(); 666 | return check_plan(); 667 | } 668 | 669 | static void 670 | test_next_on_array(uint32_t count) 671 | { 672 | note("next/check on array(%u)", count); 673 | char *d1 = data; 674 | d1 = mp_encode_array(d1, count); 675 | for (uint32_t i = 0; i < count; i++) { 676 | d1 = mp_encode_uint(d1, i % 0x7f); /* one byte */ 677 | } 678 | uint32_t len = count + mp_sizeof_array(count); 679 | const char *d2 = data; 680 | const char *d3 = data; 681 | ok(!mp_check(&d2, data + BUF_MAXLEN), "mp_check(array %u))", count); 682 | is((d1 - data), (ptrdiff_t)len, "len(array %u) == %u", count, len); 683 | is((d2 - data), (ptrdiff_t)len, "len(mp_check(array %u)) == %u", count, len); 684 | mp_next(&d3); 685 | is((d3 - data), (ptrdiff_t)len, "len(mp_next(array %u)) == %u", count, len); 686 | } 687 | 688 | static int 689 | test_next_on_arrays(void) 690 | { 691 | plan(52); 692 | header(); 693 | 694 | test_next_on_array(0x00); 695 | test_next_on_array(0x01); 696 | test_next_on_array(0x0f); 697 | test_next_on_array(0x10); 698 | test_next_on_array(0x11); 699 | test_next_on_array(0xfe); 700 | test_next_on_array(0xff); 701 | test_next_on_array(0x100); 702 | test_next_on_array(0x101); 703 | test_next_on_array(0xfffe); 704 | test_next_on_array(0xffff); 705 | test_next_on_array(0x10000); 706 | test_next_on_array(0x10001); 707 | 708 | footer(); 709 | return check_plan(); 710 | } 711 | 712 | static void 713 | test_next_on_map(uint32_t count) 714 | { 715 | note("next/check on map(%u)", count); 716 | char *d1 = data; 717 | d1 = mp_encode_map(d1, count); 718 | for (uint32_t i = 0; i < 2 * count; i++) { 719 | d1 = mp_encode_uint(d1, i % 0x7f); /* one byte */ 720 | } 721 | uint32_t len = 2 * count + mp_sizeof_map(count); 722 | const char *d2 = data; 723 | const char *d3 = data; 724 | ok(!mp_check(&d2, data + BUF_MAXLEN), "mp_check(map %u))", count); 725 | is((d1 - data), (ptrdiff_t)len, "len(map %u) == %u", count, len); 726 | is((d2 - data), (ptrdiff_t)len, "len(mp_check(map %u)) == %u", count, len); 727 | mp_next(&d3); 728 | is((d3 - data), (ptrdiff_t)len, "len(mp_next(map %u)) == %u", count, len); 729 | } 730 | 731 | static int 732 | test_next_on_maps(void) 733 | { 734 | plan(52); 735 | header(); 736 | 737 | test_next_on_map(0x00); 738 | test_next_on_map(0x01); 739 | test_next_on_map(0x0f); 740 | test_next_on_map(0x10); 741 | test_next_on_map(0x11); 742 | test_next_on_map(0xfe); 743 | test_next_on_map(0xff); 744 | test_next_on_map(0x100); 745 | test_next_on_map(0x101); 746 | test_next_on_map(0xfffe); 747 | test_next_on_map(0xffff); 748 | test_next_on_map(0x10000); 749 | test_next_on_map(0x10001); 750 | 751 | footer(); 752 | return check_plan(); 753 | } 754 | 755 | /** 756 | * When inlined in Release in clang, this function behaves weird. Looking 757 | * sometimes like if its call had no effect even though it did encoding. 758 | */ 759 | static NOINLINE bool 760 | test_encode_uint_custom_size(char *buf, uint64_t val, int size) 761 | { 762 | char *pos; 763 | switch (size) { 764 | case 1: 765 | if (val > 0x7f) 766 | return false; 767 | mp_store_u8(buf, val); 768 | return true; 769 | case 2: 770 | if (val > UINT8_MAX) 771 | return false; 772 | pos = mp_store_u8(buf, 0xcc); 773 | mp_store_u8(pos, (uint8_t)val); 774 | return true; 775 | case 3: 776 | if (val > UINT16_MAX) 777 | return false; 778 | pos = mp_store_u8(buf, 0xcd); 779 | mp_store_u16(pos, (uint16_t)val); 780 | return true; 781 | case 5: 782 | if (val > UINT32_MAX) 783 | return false; 784 | pos = mp_store_u8(buf, 0xce); 785 | mp_store_u32(pos, (uint32_t)val); 786 | return true; 787 | case 9: 788 | pos = mp_store_u8(buf, 0xcf); 789 | mp_store_u64(pos, val); 790 | return true; 791 | } 792 | abort(); 793 | return false; 794 | } 795 | 796 | /** 797 | * Unlike test_encode_uint_custom_size(), this one doesn't seem to behave 798 | * strange when inlined, but perhaps it just wasn't used in all the same ways as 799 | * the former. 800 | */ 801 | static NOINLINE bool 802 | test_encode_int_custom_size(char *buf, int64_t val, int size) 803 | { 804 | char *pos; 805 | switch (size) { 806 | case 1: 807 | if (val > 0x7f || val < -0x20) 808 | return false; 809 | if (val >= 0) 810 | mp_store_u8(buf, val); 811 | else 812 | mp_store_u8(buf, (uint8_t)(0xe0 | val)); 813 | return true; 814 | case 2: 815 | if (val < INT8_MIN || val > INT8_MAX) 816 | return false; 817 | pos = mp_store_u8(buf, 0xd0); 818 | mp_store_u8(pos, (uint8_t)val); 819 | return true; 820 | case 3: 821 | if (val < INT16_MIN || val > INT16_MAX) 822 | return false; 823 | pos = mp_store_u8(buf, 0xd1); 824 | mp_store_u16(pos, (uint16_t)val); 825 | return true; 826 | case 5: 827 | if (val < INT32_MIN || val > INT32_MAX) 828 | return false; 829 | pos = mp_store_u8(buf, 0xd2); 830 | mp_store_u32(pos, (uint32_t)val); 831 | return true; 832 | case 9: 833 | pos = mp_store_u8(buf, 0xd3); 834 | mp_store_u64(pos, val); 835 | return true; 836 | } 837 | abort(); 838 | return false; 839 | } 840 | 841 | static int 842 | test_encode_uint_all_sizes(char mp_nums[][MP_NUMBER_MAX_LEN], uint64_t val) 843 | { 844 | int sizes[] = {1, 2, 3, 5, 9}; 845 | int count = lengthof(sizes); 846 | int used = 0; 847 | for (int i = 0; i < count; ++i) { 848 | assert(used < MP_NUMBER_CODEC_COUNT); 849 | if (test_encode_uint_custom_size(mp_nums[used], val, sizes[i])) 850 | ++used; 851 | } 852 | return used; 853 | } 854 | 855 | static int 856 | test_encode_int_all_sizes(char mp_nums[][MP_NUMBER_MAX_LEN], int64_t val) 857 | { 858 | int sizes[] = {1, 2, 3, 5, 9}; 859 | int count = lengthof(sizes); 860 | int used = 0; 861 | for (int i = 0; i < count; ++i) { 862 | assert(used < MP_NUMBER_CODEC_COUNT); 863 | if (test_encode_int_custom_size(mp_nums[used], val, sizes[i])) 864 | ++used; 865 | } 866 | return used; 867 | } 868 | 869 | static void 870 | test_compare_uint(uint64_t a, uint64_t b) 871 | { 872 | char mp_nums_a[MP_NUMBER_CODEC_COUNT][MP_NUMBER_MAX_LEN]; 873 | int count_a = test_encode_uint_all_sizes(mp_nums_a, a); 874 | 875 | char mp_nums_b[MP_NUMBER_CODEC_COUNT][MP_NUMBER_MAX_LEN]; 876 | int count_b = test_encode_uint_all_sizes(mp_nums_b, b); 877 | 878 | for (int ai = 0; ai < count_a; ++ai) { 879 | for (int bi = 0; bi < count_b; ++bi) { 880 | int r = mp_compare_uint(mp_nums_a[ai], mp_nums_b[bi]); 881 | if (a < b) { 882 | ok(r < 0, "mp_compare_uint(%" PRIu64 ", " 883 | "%" PRIu64 ") < 0", a, b); 884 | } else if (a > b) { 885 | ok(r > 0, "mp_compare_uint(%" PRIu64 ", " 886 | "%" PRIu64 ") > 0", a, b); 887 | } else { 888 | ok(r == 0, "mp_compare_uint(%" PRIu64 ", " 889 | "%" PRIu64 ") == 0", a, b); 890 | } 891 | } 892 | } 893 | } 894 | 895 | static int 896 | test_compare_uints(void) 897 | { 898 | plan(2209); 899 | header(); 900 | 901 | uint64_t nums[] = { 902 | 0, 1, 0x7eU, 0x7fU, 0x80U, 0xfeU, 0xffU, 0xfffeU, 0xffffU, 903 | 0x10000U, 0xfffffffeU, 0xffffffffU, 0x100000000ULL, 904 | 0xfffffffffffffffeULL, 0xffffffffffffffffULL 905 | }; 906 | int count = sizeof(nums) / sizeof(*nums); 907 | for (int i = 0; i < count; i++) { 908 | for (int j = 0; j < count; j++) { 909 | test_compare_uint(nums[i], nums[j]); 910 | } 911 | } 912 | 913 | footer(); 914 | return check_plan(); 915 | } 916 | 917 | static bool 918 | fequal(float a, float b) 919 | { 920 | return a > b ? a - b < 1e-5f : b - a < 1e-5f; 921 | } 922 | 923 | static bool 924 | dequal(double a, double b) 925 | { 926 | return a > b ? a - b < 1e-10 : b - a < 1e-10; 927 | } 928 | 929 | static int 930 | test_format(void) 931 | { 932 | plan(282); 933 | header(); 934 | 935 | const size_t buf_size = 1024; 936 | char buf[buf_size]; 937 | size_t sz; 938 | const char *fmt; 939 | const char *p, *c, *e; 940 | uint32_t len = 0; 941 | 942 | fmt = "%d %u %i %ld %lu %li %lld %llu %lli" 943 | "%hd %hu %hi %hhd %hhu %hhi"; 944 | sz = mp_format(buf, buf_size, fmt, 1, 2, 3, 945 | (long)4, (long)5, (long)6, 946 | (long long)7, (long long)8, (long long)9, 947 | (short)10, (short)11, (short)12, 948 | (char)13, (char)14, (char)15); 949 | p = buf; 950 | for (unsigned i = 0; i < 15; i++) { 951 | ok(mp_typeof(*p) == MP_UINT, "Test type on step %d", i); 952 | ok(mp_decode_uint(&p) == i + 1, "Test value on step %d", i); 953 | } 954 | sz = mp_format(buf, buf_size, fmt, -1, -2, -3, 955 | (long)-4, (long)-5, (long)-6, 956 | (long long)-7, (long long)-8, (long long)-9, 957 | (short)-10, (unsigned short)-11, (short)-12, 958 | (signed char)-13, (unsigned char)-14, (signed char)-15); 959 | p = buf; 960 | for (int i = 0; i < 15; i++) { 961 | uint64_t expects[5] = { UINT_MAX - 1, 962 | ULONG_MAX - 4, 963 | ULLONG_MAX - 7, 964 | USHRT_MAX - 10, 965 | UCHAR_MAX - 13 }; 966 | if (i % 3 == 1) { 967 | ok(mp_typeof(*p) == MP_UINT, "Test type on step %d", i); 968 | ok(mp_decode_uint(&p) == expects[i / 3], 969 | "Test value on step %d", i); 970 | } else { 971 | ok(mp_typeof(*p) == MP_INT, "Test type on step %d", i); 972 | ok(mp_decode_int(&p) == - i - 1, 973 | "Test value on step %d", i); 974 | } 975 | } 976 | 977 | char data1[32]; 978 | char *data1_end = data1; 979 | data1_end = mp_encode_array(data1_end, 2); 980 | data1_end = mp_encode_str(data1_end, "ABC", 3); 981 | data1_end = mp_encode_uint(data1_end, 11); 982 | size_t data1_len = data1_end - data1; 983 | assert(data1_len <= sizeof(data1)); 984 | 985 | char data2[32]; 986 | char *data2_end = data2; 987 | data2_end = mp_encode_int(data2_end, -1234567890); 988 | data2_end = mp_encode_str(data2_end, "DEFGHIJKLMN", 11); 989 | data2_end = mp_encode_uint(data2_end, 321); 990 | size_t data2_len = data2_end - data2; 991 | assert(data2_len <= sizeof(data2)); 992 | 993 | fmt = "%d NIL [%d %b %b] this is test" 994 | "[%d %%%% [[ %d {%s %f %% %.*s %lf %.*s NIL}" 995 | "%p %d %.*p ]] %d%d%d]"; 996 | #define TEST_PARAMS 0, 1, true, false, -1, 2, \ 997 | "flt", 0.1, 6, "double#ignored", 0.2, 0, "ignore", \ 998 | data1, 3, data2_len, data2, 4, 5, 6 999 | sz = mp_format(buf, buf_size, fmt, TEST_PARAMS); 1000 | p = buf; 1001 | e = buf + sz; 1002 | 1003 | c = p; 1004 | ok(mp_check(&c, e) == 0, "check"); 1005 | ok(mp_typeof(*p) == MP_UINT, "type"); 1006 | ok(mp_decode_uint(&p) == 0, "decode"); 1007 | 1008 | c = p; 1009 | ok(mp_check(&c, e) == 0, "check"); 1010 | ok(mp_typeof(*p) == MP_NIL, "type"); 1011 | mp_decode_nil(&p); 1012 | 1013 | c = p; 1014 | ok(mp_check(&c, e) == 0, "check"); 1015 | ok(mp_typeof(*p) == MP_ARRAY, "type"); 1016 | ok(mp_decode_array(&p) == 3, "decode"); 1017 | 1018 | c = p; 1019 | ok(mp_check(&c, e) == 0, "check"); 1020 | ok(mp_typeof(*p) == MP_UINT, "type"); 1021 | ok(mp_decode_uint(&p) == 1, "decode"); 1022 | 1023 | c = p; 1024 | ok(mp_check(&c, e) == 0, "check"); 1025 | ok(mp_typeof(*p) == MP_BOOL, "type"); 1026 | ok(mp_decode_bool(&p) == true, "decode"); 1027 | 1028 | c = p; 1029 | ok(mp_check(&c, e) == 0, "check"); 1030 | ok(mp_typeof(*p) == MP_BOOL, "type"); 1031 | ok(mp_decode_bool(&p) == false, "decode"); 1032 | 1033 | c = p; 1034 | ok(mp_check(&c, e) == 0, "check"); 1035 | ok(mp_typeof(*p) == MP_ARRAY, "type"); 1036 | ok(mp_decode_array(&p) == 5, "decode"); 1037 | 1038 | c = p; 1039 | ok(mp_check(&c, e) == 0, "check"); 1040 | ok(mp_typeof(*p) == MP_INT, "type"); 1041 | ok(mp_decode_int(&p) == -1, "decode"); 1042 | 1043 | c = p; 1044 | ok(mp_check(&c, e) == 0, "check"); 1045 | ok(mp_typeof(*p) == MP_ARRAY, "type"); 1046 | ok(mp_decode_array(&p) == 1, "decode"); 1047 | 1048 | c = p; 1049 | ok(mp_check(&c, e) == 0, "check"); 1050 | ok(mp_typeof(*p) == MP_ARRAY, "type"); 1051 | ok(mp_decode_array(&p) == 5, "decode"); 1052 | 1053 | c = p; 1054 | ok(mp_check(&c, e) == 0, "check"); 1055 | ok(mp_typeof(*p) == MP_UINT, "type"); 1056 | ok(mp_decode_uint(&p) == 2, "decode"); 1057 | 1058 | c = p; 1059 | ok(mp_check(&c, e) == 0, "check"); 1060 | ok(mp_typeof(*p) == MP_MAP, "type"); 1061 | ok(mp_decode_map(&p) == 3, "decode"); 1062 | 1063 | c = p; 1064 | ok(mp_check(&c, e) == 0, "check"); 1065 | ok(mp_typeof(*p) == MP_STR, "type"); 1066 | c = mp_decode_str(&p, &len); 1067 | ok(len == 3, "decode"); 1068 | ok(memcmp(c, "flt", 3) == 0, "compare"); 1069 | 1070 | c = p; 1071 | ok(mp_check(&c, e) == 0, "check"); 1072 | ok(mp_typeof(*p) == MP_FLOAT, "type"); 1073 | ok(fequal(mp_decode_float(&p), 0.1), "decode"); 1074 | 1075 | c = p; 1076 | ok(mp_check(&c, e) == 0, "check"); 1077 | ok(mp_typeof(*p) == MP_STR, "type"); 1078 | c = mp_decode_str(&p, &len); 1079 | ok(len == 6, "decode"); 1080 | ok(memcmp(c, "double", 6) == 0, "compare"); 1081 | 1082 | c = p; 1083 | ok(mp_check(&c, e) == 0, "check"); 1084 | ok(mp_typeof(*p) == MP_DOUBLE, "type"); 1085 | ok(dequal(mp_decode_double(&p), 0.2), "decode"); 1086 | 1087 | c = p; 1088 | ok(mp_check(&c, e) == 0, "check"); 1089 | ok(mp_typeof(*p) == MP_STR, "type"); 1090 | c = mp_decode_str(&p, &len); 1091 | ok(len == 0, "decode"); 1092 | 1093 | c = p; 1094 | ok(mp_check(&c, e) == 0, "check"); 1095 | ok(mp_typeof(*p) == MP_NIL, "type"); 1096 | mp_decode_nil(&p); 1097 | 1098 | c = p; 1099 | ok(mp_check(&c, e) == 0, "check"); 1100 | ok(((size_t)(c - p) == data1_len) && 1101 | memcmp(p, data1, data1_len) == 0, "compare"); 1102 | p = c; 1103 | 1104 | c = p; 1105 | ok(mp_check(&c, e) == 0, "check"); 1106 | ok(mp_typeof(*p) == MP_UINT, "type"); 1107 | ok(mp_decode_uint(&p) == 3, "decode"); 1108 | 1109 | c = p; 1110 | ok(mp_check(&c, e) == 0, "check"); 1111 | ok(mp_typeof(*p) == MP_INT, "type"); 1112 | ok(mp_decode_int(&p) == -1234567890, "decode"); 1113 | 1114 | c = p; 1115 | ok(mp_check(&c, e) == 0, "check"); 1116 | ok(mp_typeof(*p) == MP_STR, "type"); 1117 | c = mp_decode_str(&p, &len); 1118 | ok(len == 11, "decode"); 1119 | ok(memcmp(c, "DEFGHIJKLMN", 11) == 0, "compare"); 1120 | 1121 | c = p; 1122 | ok(mp_check(&c, e) == 0, "check"); 1123 | ok(mp_typeof(*p) == MP_UINT, "type"); 1124 | ok(mp_decode_uint(&p) == 321, "decode"); 1125 | 1126 | c = p; 1127 | ok(mp_check(&c, e) == 0, "check"); 1128 | ok(mp_typeof(*p) == MP_UINT, "type"); 1129 | ok(mp_decode_uint(&p) == 4, "decode"); 1130 | 1131 | c = p; 1132 | ok(mp_check(&c, e) == 0, "check"); 1133 | ok(mp_typeof(*p) == MP_UINT, "type"); 1134 | ok(mp_decode_uint(&p) == 5, "decode"); 1135 | 1136 | c = p; 1137 | ok(mp_check(&c, e) == 0, "check"); 1138 | ok(mp_typeof(*p) == MP_UINT, "type"); 1139 | ok(mp_decode_uint(&p) == 6, "decode"); 1140 | 1141 | ok(p == e, "nothing more"); 1142 | 1143 | ok(sz < 70, "no magic detected"); 1144 | 1145 | for (size_t lim = 0; lim <= 70; lim++) { 1146 | memset(buf, 0, buf_size); 1147 | size_t test_sz = mp_format(buf, lim, fmt, TEST_PARAMS); 1148 | ok(test_sz == sz, "return value on step %d", (int)lim); 1149 | bool all_zero = true; 1150 | for(size_t z = lim; z < buf_size; z++) 1151 | all_zero = all_zero && (buf[z] == 0); 1152 | ok(all_zero, "buffer overflow on step %d", (int)lim); 1153 | 1154 | } 1155 | 1156 | #undef TEST_PARAMS 1157 | 1158 | footer(); 1159 | return check_plan(); 1160 | } 1161 | 1162 | int 1163 | test_mp_print() 1164 | { 1165 | plan(12); 1166 | header(); 1167 | 1168 | char msgpack[128]; 1169 | char *d = msgpack; 1170 | d = mp_encode_array(d, 8); 1171 | d = mp_encode_int(d, -5); 1172 | d = mp_encode_uint(d, 42); 1173 | d = mp_encode_str(d, "kill/bill", 9); 1174 | d = mp_encode_array(d, 0); 1175 | d = mp_encode_map(d, 6); 1176 | d = mp_encode_str(d, "bool true", 9); 1177 | d = mp_encode_bool(d, true); 1178 | d = mp_encode_str(d, "bool false", 10); 1179 | d = mp_encode_bool(d, false); 1180 | d = mp_encode_str(d, "null", 4); 1181 | d = mp_encode_nil(d); 1182 | d = mp_encode_str(d, "float", 5); 1183 | d = mp_encode_float(d, 3.14); 1184 | d = mp_encode_str(d, "double", 6); 1185 | d = mp_encode_double(d, 3.14); 1186 | d = mp_encode_uint(d, 100); 1187 | d = mp_encode_uint(d, 500); 1188 | /* MP_EXT with type 123 and of size 3 bytes. */ 1189 | d = mp_encode_extl(d, 123, 3); 1190 | memcpy(d, "str", 3); 1191 | d += 3; 1192 | char bin[] = "\x12test\x34\b\t\n\"bla\\-bla\"\f\r"; 1193 | d = mp_encode_bin(d, bin, sizeof(bin)); 1194 | d = mp_encode_map(d, 0); 1195 | assert(d <= msgpack + sizeof(msgpack)); 1196 | 1197 | const char *expected = 1198 | "[-5, 42, \"kill/bill\", [], " 1199 | "{\"bool true\": true, \"bool false\": false, \"null\": null, " 1200 | "\"float\": 3.14, \"double\": 3.14, 100: 500}, " 1201 | "(extension: type 123, len 3), " 1202 | "\"\\u0012test4\\b\\t\\n\\\"bla\\\\-bla\\\"\\f\\r\\u0000\", {}]"; 1203 | int esize = strlen(expected); 1204 | 1205 | char result[256]; 1206 | 1207 | int fsize = mp_snprint(result, sizeof(result), msgpack); 1208 | ok(fsize == esize, "mp_snprint return value"); 1209 | ok(strcmp(result, expected) == 0, "mp_snprint result"); 1210 | 1211 | fsize = mp_snprint(NULL, 0, msgpack); 1212 | ok(fsize == esize, "mp_snprint limit = 0"); 1213 | 1214 | fsize = mp_snprint(result, 1, msgpack); 1215 | ok(fsize == esize && result[0] == '\0', "mp_snprint limit = 1"); 1216 | 1217 | fsize = mp_snprint(result, 2, msgpack); 1218 | ok(fsize == esize && result[1] == '\0', "mp_snprint limit = 2"); 1219 | 1220 | fsize = mp_snprint(result, esize, msgpack); 1221 | ok(fsize == esize && result[esize - 1] == '\0', 1222 | "mp_snprint limit = expected"); 1223 | 1224 | fsize = mp_snprint(result, esize + 1, msgpack); 1225 | ok(fsize == esize && result[esize] == '\0', 1226 | "mp_snprint limit = expected + 1"); 1227 | 1228 | FILE *tmpf = tmpfile(); 1229 | if (tmpf != NULL) { 1230 | int fsize = mp_fprint(tmpf, msgpack); 1231 | ok(fsize == esize, "mp_fprint return value"); 1232 | (void) rewind(tmpf); 1233 | int rsize = fread(result, 1, sizeof(result), tmpf); 1234 | ok(rsize == esize && memcmp(result, expected, esize) == 0, 1235 | "mp_fprint result"); 1236 | fclose(tmpf); 1237 | } 1238 | 1239 | /* stdin is read-only */ 1240 | int rc = mp_fprint(stdin, msgpack); 1241 | is(rc, -1, "mp_fprint I/O error"); 1242 | 1243 | /* Test mp_snprint max nesting depth. */ 1244 | int mp_buff_sz = (MP_PRINT_MAX_DEPTH + 1) * mp_sizeof_array(1) + 1245 | mp_sizeof_uint(1); 1246 | int exp_str_sz = 2 * (MP_PRINT_MAX_DEPTH + 1) + 3 + 1; 1247 | char *mp_buff = (char *)malloc(mp_buff_sz); 1248 | char *exp_str = (char *)malloc(exp_str_sz); 1249 | char *decoded = (char *)malloc(exp_str_sz); 1250 | char *buff_wptr = mp_buff; 1251 | char *exp_str_wptr = exp_str; 1252 | for (int i = 0; i <= 2 * (MP_PRINT_MAX_DEPTH + 1); i++) { 1253 | int exp_str_rest = exp_str_sz - (exp_str_wptr - exp_str); 1254 | assert(exp_str_rest > 0); 1255 | if (i < MP_PRINT_MAX_DEPTH + 1) { 1256 | buff_wptr = mp_encode_array(buff_wptr, 1); 1257 | rc = snprintf(exp_str_wptr, exp_str_rest, "["); 1258 | } else if (i == MP_PRINT_MAX_DEPTH + 1) { 1259 | buff_wptr = mp_encode_uint(buff_wptr, 1); 1260 | rc = snprintf(exp_str_wptr, exp_str_rest, "..."); 1261 | } else { 1262 | rc = snprintf(exp_str_wptr, exp_str_rest, "]"); 1263 | } 1264 | exp_str_wptr += rc; 1265 | } 1266 | assert(exp_str_wptr + 1 == exp_str + exp_str_sz); 1267 | rc = mp_snprint(decoded, exp_str_sz, mp_buff); 1268 | ok(rc == exp_str_sz - 1, "mp_snprint max nesting depth return value"); 1269 | ok(strcmp(decoded, exp_str) == 0, "mp_snprint max nesting depth result"); 1270 | free(decoded); 1271 | free(exp_str); 1272 | free(mp_buff); 1273 | footer(); 1274 | return check_plan(); 1275 | } 1276 | 1277 | enum mp_ext_test_type { 1278 | MP_EXT_TEST_PLAIN, 1279 | MP_EXT_TEST_MSGPACK, 1280 | }; 1281 | 1282 | static int 1283 | mp_fprint_ext_test(FILE *file, const char **data, int depth) 1284 | { 1285 | int8_t type; 1286 | uint32_t len = mp_decode_extl(data, &type); 1287 | const char *ext = *data; 1288 | *data += len; 1289 | switch(type) { 1290 | case MP_EXT_TEST_PLAIN: 1291 | return fprintf(file, "%.*s", len, ext); 1292 | case MP_EXT_TEST_MSGPACK: 1293 | return mp_fprint_recursion(file, &ext, depth); 1294 | } 1295 | return fprintf(file, "undefined"); 1296 | } 1297 | 1298 | static int 1299 | mp_snprint_ext_test(char *buf, int size, const char **data, int depth) 1300 | { 1301 | int8_t type; 1302 | uint32_t len = mp_decode_extl(data, &type); 1303 | const char *ext = *data; 1304 | *data += len; 1305 | switch(type) { 1306 | case MP_EXT_TEST_PLAIN: 1307 | return snprintf(buf, size, "%.*s", len, ext); 1308 | case MP_EXT_TEST_MSGPACK: 1309 | return mp_snprint_recursion(buf, size, &ext, depth); 1310 | } 1311 | return snprintf(buf, size, "undefined"); 1312 | } 1313 | 1314 | static int 1315 | test_mp_print_ext(void) 1316 | { 1317 | plan(5); 1318 | header(); 1319 | mp_snprint_ext = mp_snprint_ext_test; 1320 | mp_fprint_ext = mp_fprint_ext_test; 1321 | 1322 | char *pos = buf; 1323 | const char *plain = "plain-str"; 1324 | size_t plain_len = strlen(plain); 1325 | pos = mp_encode_array(pos, 4); 1326 | pos = mp_encode_uint(pos, 100); 1327 | pos = mp_encode_ext(pos, MP_EXT_TEST_PLAIN, plain, plain_len); 1328 | pos = mp_encode_extl(pos, MP_EXT_TEST_MSGPACK, 1329 | mp_sizeof_str(plain_len)); 1330 | pos = mp_encode_str(pos, plain, plain_len); 1331 | pos = mp_encode_uint(pos, 200); 1332 | 1333 | int size = mp_snprint(NULL, 0, buf); 1334 | int real_size = mp_snprint(str, sizeof(str), buf); 1335 | is(size, real_size, "mp_snrpint size match"); 1336 | const char *expected = "[100, plain-str, \"plain-str\", 200]"; 1337 | is(strcmp(str, expected), 0, "str is correct"); 1338 | 1339 | FILE *tmpf = tmpfile(); 1340 | if (tmpf == NULL) 1341 | abort(); 1342 | real_size = mp_fprint(tmpf, buf); 1343 | is(size, real_size, "mp_fprint size match"); 1344 | rewind(tmpf); 1345 | real_size = (int) fread(str, 1, sizeof(str), tmpf); 1346 | is(real_size, size, "mp_fprint written correct number of bytes"); 1347 | str[real_size] = 0; 1348 | is(strcmp(str, expected), 0, "str is correct"); 1349 | fclose(tmpf); 1350 | 1351 | mp_snprint_ext = mp_snprint_ext_default; 1352 | mp_fprint_ext = mp_fprint_ext_default; 1353 | footer(); 1354 | return check_plan(); 1355 | } 1356 | 1357 | int 1358 | test_mp_check() 1359 | { 1360 | plan(71); 1361 | header(); 1362 | 1363 | #define invalid(data, fmt, ...) ({ \ 1364 | const char *p = data; \ 1365 | isnt(mp_check(&p, p + sizeof(data) - 1), 0, fmt, ## __VA_ARGS__); \ 1366 | }) 1367 | 1368 | /* fixmap */ 1369 | invalid("\x81", "invalid fixmap 1"); 1370 | invalid("\x81\x01", "invalid fixmap 2"); 1371 | invalid("\x8f\x01", "invalid fixmap 3"); 1372 | 1373 | /* fixarray */ 1374 | invalid("\x91", "invalid fixarray 1"); 1375 | invalid("\x92\x01", "invalid fixarray 2"); 1376 | invalid("\x9f\x01", "invalid fixarray 3"); 1377 | 1378 | /* fixstr */ 1379 | invalid("\xa1", "invalid fixstr 1"); 1380 | invalid("\xa2\x00", "invalid fixstr 2"); 1381 | invalid("\xbf\x00", "invalid fixstr 3"); 1382 | 1383 | /* bin8 */ 1384 | invalid("\xc4", "invalid bin8 1"); 1385 | invalid("\xc4\x01", "invalid bin8 2"); 1386 | 1387 | /* bin16 */ 1388 | invalid("\xc5", "invalid bin16 1"); 1389 | invalid("\xc5\x00\x01", "invalid bin16 2"); 1390 | 1391 | /* bin32 */ 1392 | invalid("\xc6", "invalid bin32 1"); 1393 | invalid("\xc6\x00\x00\x00\x01", "invalid bin32 2"); 1394 | 1395 | /* ext8 */ 1396 | invalid("\xc7", "invalid ext8 1"); 1397 | invalid("\xc7\x00", "invalid ext8 2"); 1398 | invalid("\xc7\x01\xff", "invalid ext8 3"); 1399 | invalid("\xc7\x02\xff\x00", "invalid ext8 4"); 1400 | 1401 | /* ext16 */ 1402 | invalid("\xc8", "invalid ext16 1"); 1403 | invalid("\xc8\x00\x00", "invalid ext16 2"); 1404 | invalid("\xc8\x00\x01\xff", "invalid ext16 3"); 1405 | invalid("\xc8\x00\x02\xff\x00", "invalid ext16 4"); 1406 | 1407 | /* ext32 */ 1408 | invalid("\xc9", "invalid ext32 1"); 1409 | invalid("\xc9\x00\x00\x00\x00", "invalid ext32 2"); 1410 | invalid("\xc9\x00\x00\x00\x01\xff", "invalid ext32 3"); 1411 | invalid("\xc9\x00\x00\x00\x02\xff\x00", "invalid ext32 4"); 1412 | 1413 | /* float32 */ 1414 | invalid("\xca", "invalid float32 1"); 1415 | invalid("\xca\x00\x00\x00", "invalid float32 2"); 1416 | 1417 | /* float64 */ 1418 | invalid("\xcb", "invalid float64 1"); 1419 | invalid("\xcb\x00\x00\x00\x00\x00\x00\x00", "invalid float64 2"); 1420 | 1421 | /* uint8 */ 1422 | invalid("\xcc", "invalid uint8 1"); 1423 | 1424 | /* uint16 */ 1425 | invalid("\xcd\x00", "invalid uint16 1"); 1426 | 1427 | /* uint32 */ 1428 | invalid("\xce\x00\x00\x00", "invalid uint32 1"); 1429 | 1430 | /* uint64 */ 1431 | invalid("\xcf\x00\x00\x00\x00\x00\x00\x00", "invalid uint64 1"); 1432 | 1433 | /* int8 */ 1434 | invalid("\xd0", "invalid int8 1"); 1435 | 1436 | /* int16 */ 1437 | invalid("\xd1\x00", "invalid int16 1"); 1438 | 1439 | /* int32 */ 1440 | invalid("\xd2\x00\x00\x00", "invalid int32 1"); 1441 | 1442 | /* int64 */ 1443 | invalid("\xd3\x00\x00\x00\x00\x00\x00\x00", "invalid int64 1"); 1444 | 1445 | /* fixext8 */ 1446 | invalid("\xd4", "invalid fixext8 1"); 1447 | invalid("\xd4\x05", "invalid fixext8 2"); 1448 | 1449 | /* fixext16 */ 1450 | invalid("\xd5", "invalid fixext16 1"); 1451 | invalid("\xd5\x05\x05", "invalid fixext16 2"); 1452 | 1453 | /* fixext32 */ 1454 | invalid("\xd6", "invalid fixext32 1"); 1455 | invalid("\xd6\x00\x00\x05\x05", "invalid fixext32 2"); 1456 | 1457 | /* fixext64 */ 1458 | invalid("\xd7", "invalid fixext64 1"); 1459 | invalid("\xd7\x00\x00\x00\x00\x00\x00\x05\x05", "invalid fixext64 2"); 1460 | 1461 | /* fixext128 */ 1462 | invalid("\xd8", "invalid fixext128 1"); 1463 | invalid("\xd8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" 1464 | "\x00\x05\x05", "invalid fixext128 2"); 1465 | 1466 | /* str8 */ 1467 | invalid("\xd9", "invalid str8 1"); 1468 | invalid("\xd9\x01", "invalid str8 2"); 1469 | 1470 | /* str16 */ 1471 | invalid("\xda", "invalid str16 1"); 1472 | invalid("\xda\x00\x01", "invalid str16 2"); 1473 | 1474 | /* str32 */ 1475 | invalid("\xdb", "invalid str32 1"); 1476 | invalid("\xdb\x00\x00\x00\x01", "invalid str32 2"); 1477 | 1478 | /* array16 */ 1479 | invalid("\xdc", "invalid array16 1"); 1480 | invalid("\xdc\x00\x01", "invalid array16 2"); 1481 | 1482 | /* array32 */ 1483 | invalid("\xdd", "invalid array32 1"); 1484 | invalid("\xdd\x00\x00\x00\x01", "invalid array32 2"); 1485 | 1486 | /* map16 */ 1487 | invalid("\xde", "invalid map16 1"); 1488 | invalid("\xde\x00\x01", "invalid map16 2"); 1489 | invalid("\xde\x00\x01\x5", "invalid map16 3"); 1490 | invalid("\xde\x80\x00", "invalid map16 4"); 1491 | 1492 | /* map32 */ 1493 | invalid("\xdf", "invalid map32 1"); 1494 | invalid("\xdf\x00\x00\x00\x01", "invalid map32 2"); 1495 | invalid("\xdf\x00\x00\x00\x01\x5", "invalid map32 3"); 1496 | invalid("\xdf\x80\x00\x00\x00", "invalid map32 4"); 1497 | 1498 | /* 0xc1 is never used */ 1499 | invalid("\xc1", "invalid header 1"); 1500 | invalid("\x91\xc1", "invalid header 2"); 1501 | invalid("\x93\xff\xc1\xff", "invalid header 3"); 1502 | invalid("\x82\xff\xc1\xff\xff", "invalid header 4"); 1503 | 1504 | #undef invalid 1505 | 1506 | footer(); 1507 | 1508 | return check_plan(); 1509 | } 1510 | 1511 | static int 1512 | test_mp_check_exact(void) 1513 | { 1514 | plan(11); 1515 | header(); 1516 | 1517 | #define invalid(data, fmt, ...) ({ \ 1518 | const char *p = data; \ 1519 | isnt(mp_check_exact(&p, p + sizeof(data) - 1), 0, fmt, ## __VA_ARGS__); \ 1520 | }) 1521 | #define valid(data, fmt, ...) ({ \ 1522 | const char *p = data; \ 1523 | is(mp_check_exact(&p, p + sizeof(data) - 1), 0, fmt, ## __VA_ARGS__); \ 1524 | }) 1525 | 1526 | invalid("", "empty"); 1527 | invalid("\x92\xc0\xc1", "ill"); 1528 | 1529 | invalid("\x92", "trunc 1"); 1530 | invalid("\x92\xc0", "trunc 2"); 1531 | invalid("\x93\xc0\xc0", "trunc 3"); 1532 | 1533 | invalid("\xc0\xc0", "junk 1"); 1534 | invalid("\x92\xc0\xc0\xc0", "junk 2"); 1535 | invalid("\x92\xc0\x91\xc0\xc0", "junk 3"); 1536 | 1537 | valid("\xc0", "valid 1"); 1538 | valid("\x91\xc0", "valid 2"); 1539 | valid("\x92\xc0\x91\xc0", "valid 3"); 1540 | 1541 | #undef valid 1542 | #undef invalid 1543 | 1544 | footer(); 1545 | return check_plan(); 1546 | } 1547 | 1548 | /** 1549 | * Check validity of a simple extension type. 1550 | * Its type is 0x42 and payload is a byte string where i-th byte value is its 1551 | * position from the end of the string. 1552 | */ 1553 | int 1554 | mp_check_ext_data_test(int8_t type, const char *data, uint32_t len) 1555 | { 1556 | if (type != 0x42) 1557 | return 1; 1558 | for (uint32_t i = 0; i < len; i++) { 1559 | if ((unsigned char)data[i] != len - i) 1560 | return 1; 1561 | } 1562 | return 0; 1563 | } 1564 | 1565 | int 1566 | test_mp_check_ext_data() 1567 | { 1568 | plan(24); 1569 | header(); 1570 | 1571 | #define invalid(data, fmt, ...) ({ \ 1572 | const char *p = data; \ 1573 | isnt(mp_check(&p, p + sizeof(data) - 1), 0, fmt, ## __VA_ARGS__); \ 1574 | }) 1575 | #define valid(data, fmt, ...) ({ \ 1576 | const char *p = data; \ 1577 | is(mp_check(&p, p + sizeof(data) - 1), 0, fmt, ## __VA_ARGS__); \ 1578 | }) 1579 | 1580 | mp_check_ext_data_f mp_check_ext_data_svp = mp_check_ext_data; 1581 | mp_check_ext_data = mp_check_ext_data_test; 1582 | 1583 | /* ext8 */ 1584 | invalid("\xc7\x00\x13", "invalid ext8 - bad type"); 1585 | invalid("\xc7\x01\x42\x13", "invalid ext8 - bad data"); 1586 | valid("\xc7\x01\x42\x01", "valid ext8"); 1587 | 1588 | /* ext16 */ 1589 | invalid("\xc8\x00\x00\x13", "invalid ext16 - bad type"); 1590 | invalid("\xc8\x00\x01\x42\x13", "invalid ext16 - bad data"); 1591 | valid("\xc8\x00\x01\x42\x01", "valid ext16"); 1592 | 1593 | /* ext32 */ 1594 | invalid("\xc9\x00\x00\x00\x00\x13", "invalid ext32 - bad type"); 1595 | invalid("\xc9\x00\x00\x00\x01\x42\x13", "invalid ext32 - bad data"); 1596 | valid("\xc9\x00\x00\x00\x01\x42\x01", "valid ext32"); 1597 | 1598 | /* fixext8 */ 1599 | invalid("\xd4\x13\x01", "invalid fixext8 - bad type"); 1600 | invalid("\xd4\x42\x13", "invalid fixext8 - bad data"); 1601 | valid("\xd4\x42\x01", "valid fixext8"); 1602 | 1603 | /* fixext16 */ 1604 | invalid("\xd5\x13\x02\x01", "invalid fixext16 - bad type"); 1605 | invalid("\xd5\x42\x13\x13", "invalid fixext16 - bad data"); 1606 | valid("\xd5\x42\x02\x01", "valid fixext16"); 1607 | 1608 | /* fixext32 */ 1609 | invalid("\xd6\x13\x04\x03\x02\x01", "invalid fixext32 - bad type"); 1610 | invalid("\xd6\x42\x13\x13\x13\x13", "invalid fixext32 - bad data"); 1611 | valid("\xd6\x42\x04\x03\x02\x01", "valid fixext32"); 1612 | 1613 | /* fixext64 */ 1614 | invalid("\xd7\x13\x08\x07\x06\x05\x04\x03\x02\x01", 1615 | "invalid fixext64 - bad type"); 1616 | invalid("\xd7\x42\x13\x13\x13\x13\x13\x13\x13\x13", 1617 | "invalid fixext64 - bad data"); 1618 | valid("\xd7\x42\x08\x07\x06\x05\x04\x03\x02\x01", 1619 | "valid fixext64"); 1620 | 1621 | /* fixext128 */ 1622 | invalid("\xd8\x13\x10\x0f\x0e\x0d\x0c\x0b\x0a\x09\x08\x07\x06\x05\x04" 1623 | "\x03\x02\x01", "invalid fixext128 - bad type"); 1624 | invalid("\xd8\x42\x13\x13\x13\x13\x13\x13\x13\x13\x13\x13\x13\x13\x13" 1625 | "\x13\x13\x13", "invalid fixext128 - bad data"); 1626 | valid("\xd8\x42\x10\x0f\x0e\x0d\x0c\x0b\x0a\x09\x08\x07\x06\x05\x04" 1627 | "\x03\x02\x01", "valid fixext128"); 1628 | 1629 | mp_check_ext_data = mp_check_ext_data_svp; 1630 | 1631 | #undef valid 1632 | #undef invalid 1633 | 1634 | footer(); 1635 | return check_plan(); 1636 | } 1637 | 1638 | static struct mp_check_error last_error; 1639 | 1640 | static void 1641 | mp_check_on_error_test(const struct mp_check_error *err) 1642 | { 1643 | last_error = *err; 1644 | } 1645 | 1646 | static int 1647 | test_mp_check_error(void) 1648 | { 1649 | const int trunc_error_count = 30; 1650 | const int ill_error_count = 3; 1651 | const int ext_error_count = 4; 1652 | const int junk_error_count = 3; 1653 | plan(6 * trunc_error_count + 1654 | 5 * ill_error_count + 1655 | 7 * ext_error_count + 1656 | 5 * junk_error_count); 1657 | header(); 1658 | 1659 | mp_check_ext_data_f mp_check_ext_data_svp = mp_check_ext_data; 1660 | mp_check_ext_data = mp_check_ext_data_test; 1661 | mp_check_on_error_f mp_check_on_error_svp = mp_check_on_error; 1662 | mp_check_on_error = mp_check_on_error_test; 1663 | 1664 | #define check_error(check_, data_, offset_, type_, trunc_count_, \ 1665 | ext_type_, ext_len_, msg_) \ 1666 | do { \ 1667 | const char *data = data_; \ 1668 | const char *end = data + sizeof(data_) - 1; \ 1669 | const char *p = data; \ 1670 | isnt(check_(&p, end), 0, msg_); \ 1671 | is(last_error.type, type_, msg_ " - error type"); \ 1672 | is(last_error.data, data, msg_ " - error data"); \ 1673 | is(last_error.end, end, msg_ " - error data end"); \ 1674 | is(last_error.pos - last_error.data, (ptrdiff_t)offset_,\ 1675 | msg_ " - error data pos"); \ 1676 | if (last_error.type == MP_CHECK_ERROR_TRUNC) { \ 1677 | is(last_error.trunc_count, trunc_count_, \ 1678 | msg_ " - error trunc count"); \ 1679 | } \ 1680 | if (last_error.type == MP_CHECK_ERROR_EXT) { \ 1681 | is(last_error.ext_type, ext_type_, \ 1682 | msg_ " - error ext type"); \ 1683 | is(last_error.ext_len, ext_len_, \ 1684 | msg_ " - error ext len"); \ 1685 | } \ 1686 | } while (0) 1687 | 1688 | #define check_error_trunc(data_, offset_, trunc_count_, msg_) \ 1689 | check_error(mp_check, data_, offset_, MP_CHECK_ERROR_TRUNC, \ 1690 | trunc_count_, 0, 0, msg_) 1691 | 1692 | #define check_error_ill(data_, offset_, msg_) \ 1693 | check_error(mp_check, data_, offset_, MP_CHECK_ERROR_ILL, \ 1694 | 0, 0, 0, msg_) 1695 | 1696 | #define check_error_ext(data_, offset_, ext_type_, ext_len_, msg_) \ 1697 | check_error(mp_check, data_, offset_, MP_CHECK_ERROR_EXT, \ 1698 | 0, ext_type_, ext_len_, msg_) 1699 | 1700 | #define check_error_junk(data_, offset_, msg_) \ 1701 | check_error(mp_check_exact, data_, offset_, MP_CHECK_ERROR_JUNK,\ 1702 | 0, 0, 0, msg_) 1703 | 1704 | check_error_trunc("", 0, 1, "empty"); 1705 | 1706 | check_error_trunc("\xa2", 0, 1, "trunc fixstr"); 1707 | check_error_trunc("\xd9", 0, 1, "trunc str8 header"); 1708 | check_error_trunc("\xd9\x10", 0, 1, "trunc str8 data"); 1709 | check_error_trunc("\xda\x00", 0, 1, "trunc str16 header"); 1710 | check_error_trunc("\xda\x00\x10", 0, 1, "trunc str16 data"); 1711 | check_error_trunc("\xdb\x00\x00\x00", 0, 1, "trunc str32 header"); 1712 | check_error_trunc("\xdb\x00\x00\x00\x10", 0, 1, "trunc str32 data"); 1713 | 1714 | check_error_trunc("\x92", 1, 2, "trunc fixarray"); 1715 | check_error_trunc("\xdc\x00", 0, 1, "trunc array16 header"); 1716 | check_error_trunc("\xdc\x00\x10", 3, 16, "trunc array16 data"); 1717 | check_error_trunc("\xdd\x00\x00\x00", 0, 1, "trunc array32 header"); 1718 | check_error_trunc("\xdd\x00\x00\x00\x10", 5, 16, "trunc array32 data"); 1719 | 1720 | check_error_trunc("\x82", 1, 4, "trunc fixmap"); 1721 | check_error_trunc("\xde\x00", 0, 1, "trunc map16 header"); 1722 | check_error_trunc("\xde\x00\x10", 3, 32, "trunc map16 data"); 1723 | check_error_trunc("\xdf\x00\x00\x00", 0, 1, "trunc map32 header"); 1724 | check_error_trunc("\xdf\x00\x00\x00\x10", 5, 32, "trunc map32 data"); 1725 | 1726 | check_error_trunc("\xd4", 0, 1, "trunc fixext header"); 1727 | check_error_trunc("\xd4\x42", 0, 1, "trunc fixext data"); 1728 | check_error_trunc("\xc7\x10", 0, 1, "trunc ext8 header"); 1729 | check_error_trunc("\xc7\x10\x42", 0, 1, "trunc ext8 data"); 1730 | check_error_trunc("\xc8\x00\x10", 0, 1, "trunc ext16 header"); 1731 | check_error_trunc("\xc8\x00\x10\x42", 0, 1, "trunc ext16 data"); 1732 | check_error_trunc("\xc9\x00\x00\x00\x10", 0, 1, "trunc ext32 header"); 1733 | check_error_trunc("\xc9\x00\x00\x00\x10\x42", 0, 1, "trunc ext32 data"); 1734 | 1735 | check_error_trunc("\x92\x82", 2, 5, "trunc nested 1"); 1736 | check_error_trunc("\x92\x82\xc0", 3, 4, "trunc nested 2"); 1737 | check_error_trunc("\x92\x82\xc0\x92", 4, 5, "trunc nested 3"); 1738 | check_error_trunc("\x92\x82\xc0\x92\x82", 5, 8, "trunc nested 4"); 1739 | 1740 | check_error_ill("\xc1", 0, "ill 1"); 1741 | check_error_ill("\x92\xc1", 1, "ill 2"); 1742 | check_error_ill("\x92\xc0\xc1", 2, "ill 3"); 1743 | 1744 | check_error_ext("\xd4\x42\x00", 2, 0x42, 1, "bad fixext"); 1745 | check_error_ext("\xc7\x01\x42\x00", 3, 0x42, 1, "bad ext8"); 1746 | check_error_ext("\xc8\x00\x01\x42\x00", 4, 0x42, 1, "bad ext16"); 1747 | check_error_ext("\xc9\x00\x00\x00\x01\x42\x00", 6, 0x42, 1, "bad ext32"); 1748 | 1749 | check_error_junk("\xc0\xc0", 1, "junk 1"); 1750 | check_error_junk("\xc0\x91\xc1", 1, "junk 2"); 1751 | check_error_junk("\x92\xc0\xc0\xc0", 3, "junk 3"); 1752 | 1753 | #undef check_error_junk 1754 | #undef check_error_ext 1755 | #undef check_error_ill 1756 | #undef check_error_trunc 1757 | #undef check_error 1758 | 1759 | mp_check_ext_data = mp_check_ext_data_svp; 1760 | mp_check_on_error = mp_check_on_error_svp; 1761 | 1762 | footer(); 1763 | return check_plan(); 1764 | } 1765 | 1766 | #define double_eq(a, b) (fabs((a) - (b)) < 1e-15) 1767 | 1768 | template 1769 | static void 1770 | test_read_num(ValueT num1, ReadF read_f, bool is_ok) 1771 | { 1772 | /* 1773 | * Build the header message. 1774 | */ 1775 | const int str_cap = 256; 1776 | char str[str_cap]; 1777 | char *end = str + str_cap; 1778 | char *pos = str + snprintf(str, str_cap, "typed read of "); 1779 | if (std::is_same::value) 1780 | pos += snprintf(pos, end - pos, "%f", (float)num1); 1781 | else if (std::is_same::value) 1782 | pos += snprintf(pos, end - pos, "%lf", (double)num1); 1783 | else if (num1 >= 0) 1784 | pos += snprintf(pos, end - pos, "%llu", (long long)num1); 1785 | else 1786 | pos += snprintf(pos, end - pos, "%lld", (long long)num1); 1787 | pos += snprintf(pos, end - pos, " into "); 1788 | 1789 | static_assert(!std::is_same::value, 1790 | "no float reading"); 1791 | if (std::is_integral::value) { 1792 | pos += snprintf(pos, end - pos, "int%zu_t", 1793 | sizeof(TargetT) * 8); 1794 | } else { 1795 | pos += snprintf(pos, end - pos, "double"); 1796 | } 1797 | note("%s", str); 1798 | /* 1799 | * Perform the actual tests. 1800 | */ 1801 | char mp_nums[MP_NUMBER_CODEC_COUNT][MP_NUMBER_MAX_LEN]; 1802 | int count = 0; 1803 | if (std::is_integral::value) { 1804 | if (num1 >= 0) { 1805 | count += test_encode_uint_all_sizes( 1806 | &mp_nums[count], num1); 1807 | } 1808 | if (num1 <= INT64_MAX) { 1809 | count += test_encode_int_all_sizes( 1810 | &mp_nums[count], num1); 1811 | } 1812 | } else if (!std::is_integral::value || !is_ok) { 1813 | /* 1814 | * Only encode floating point types when 1815 | * 1) expect to also decode them back successfully. 1816 | * 2) want to fail to decode an integer. 1817 | * 1818 | * Encoding integers as floats for decoding them back into 1819 | * integers won't work. 1820 | */ 1821 | if (std::is_same::value) 1822 | mp_encode_float(mp_nums[count++], (float)num1); 1823 | mp_encode_double(mp_nums[count++], (double)num1); 1824 | } 1825 | for (int i = 0; i < count; ++i) { 1826 | const char *mp_num_pos1 = mp_nums[i]; 1827 | char code = *mp_num_pos1; 1828 | /* Sanity check of the test encoding. */ 1829 | if (mp_typeof(*mp_num_pos1) == MP_INT) { 1830 | fail_unless(mp_decode_int(&mp_num_pos1) == 1831 | (int64_t)num1); 1832 | } else if (mp_typeof(*mp_num_pos1) == MP_UINT) { 1833 | fail_unless(mp_decode_uint(&mp_num_pos1) == 1834 | (uint64_t)num1); 1835 | } else if (mp_typeof(*mp_num_pos1) == MP_FLOAT) { 1836 | fail_unless(mp_decode_float(&mp_num_pos1) == 1837 | (float)num1); 1838 | } else { 1839 | fail_unless(mp_decode_double(&mp_num_pos1) == 1840 | (double)num1); 1841 | } 1842 | 1843 | const char *mp_num_pos2 = mp_nums[i]; 1844 | TargetT num2 = 0; 1845 | int rc = read_f(&mp_num_pos2, &num2); 1846 | if (!is_ok) { 1847 | is(rc, -1, "check failure for code 0x%02X", code); 1848 | is(mp_num_pos2, mp_nums[i], "check position"); 1849 | continue; 1850 | } 1851 | is(rc, 0, "check success for code 0x%02X", code); 1852 | is(mp_num_pos1, mp_num_pos2, "check position"); 1853 | if (!std::is_integral::value) { 1854 | ok(double_eq(num1, num2), "check float number"); 1855 | continue; 1856 | } 1857 | if (num1 >= 0) { 1858 | fail_unless(num2 >= 0); 1859 | is((uint64_t)num1, (uint64_t)num2, "check int number"); 1860 | } else { 1861 | fail_unless(num2 < 0); 1862 | is((int64_t)num1, (int64_t)num2, "check int number"); 1863 | } 1864 | } 1865 | } 1866 | 1867 | template 1868 | static void 1869 | test_read_num_from_non_numeric_mp(ReadF read_f) 1870 | { 1871 | const int str_cap = 256; 1872 | char str[str_cap]; 1873 | char *end = str + str_cap; 1874 | char *pos = str + snprintf(str, str_cap, "ensure failure of reading "); 1875 | if (std::is_integral::value) { 1876 | pos += snprintf(pos, end - pos, "int%zu_t", 1877 | sizeof(TargetT) * 8); 1878 | } else if (read_f == (void *)mp_read_double) { 1879 | pos += snprintf(pos, end - pos, "double"); 1880 | } else if (read_f == (void *)mp_read_double_lossy) { 1881 | pos += snprintf(pos, end - pos, "double with precision loss"); 1882 | } else { 1883 | abort(); 1884 | } 1885 | note("%s", str); 1886 | 1887 | char bad_types[16][16]; 1888 | int bad_count = 0; 1889 | mp_encode_array(bad_types[bad_count++], 1); 1890 | mp_encode_map(bad_types[bad_count++], 1); 1891 | mp_encode_str0(bad_types[bad_count++], "abc"); 1892 | mp_encode_bool(bad_types[bad_count++], true); 1893 | mp_encode_ext(bad_types[bad_count++], 1, "abc", 3); 1894 | mp_encode_bin(bad_types[bad_count++], "abc", 3); 1895 | mp_encode_nil(bad_types[bad_count++]); 1896 | for (int i = 0; i < bad_count; ++i) { 1897 | TargetT val; 1898 | const char *pos = bad_types[i]; 1899 | char code = *pos; 1900 | int rc = read_f(&pos, &val); 1901 | is(rc, -1, "check fail for code 0x%02X", code); 1902 | is(pos, bad_types[i], "check position for code 0x%02X", code); 1903 | } 1904 | } 1905 | 1906 | #define test_read_int8(num, success) \ 1907 | test_read_num(num, mp_read_int8, success) 1908 | #define test_read_int16(num, success) \ 1909 | test_read_num(num, mp_read_int16, success) 1910 | #define test_read_int32(num, success) \ 1911 | test_read_num(num, mp_read_int32, success) 1912 | #define test_read_int64(num, success) \ 1913 | test_read_num(num, mp_read_int64, success) 1914 | #define test_read_double(num, success) \ 1915 | test_read_num(num, mp_read_double, success) 1916 | #define test_read_double_lossy(num, success) \ 1917 | test_read_num(num, mp_read_double_lossy, success) 1918 | 1919 | static int 1920 | test_mp_read_typed() 1921 | { 1922 | plan(716); 1923 | header(); 1924 | 1925 | test_read_int8(12, true); 1926 | test_read_int8(127, true); 1927 | test_read_int8(128, false); 1928 | test_read_int8(-12, true); 1929 | test_read_int8(-128, true); 1930 | test_read_int8(-129, false); 1931 | test_read_int8(-3e-4f, false); 1932 | test_read_int8(123.45, false); 1933 | test_read_num_from_non_numeric_mp(mp_read_int8); 1934 | 1935 | test_read_int16(123, true); 1936 | test_read_int16(32767, true); 1937 | test_read_int16(32768, false); 1938 | test_read_int16(-123, true); 1939 | test_read_int16(-32768, true); 1940 | test_read_int16(-32769, false); 1941 | test_read_int16(-2e-3f, false); 1942 | test_read_int16(12.345, false); 1943 | test_read_num_from_non_numeric_mp(mp_read_int16); 1944 | 1945 | test_read_int32(123, true); 1946 | test_read_int32(12345, true); 1947 | test_read_int32(2147483647, true); 1948 | test_read_int32(2147483648, false); 1949 | test_read_int32(-123, true); 1950 | test_read_int32(-12345, true); 1951 | test_read_int32(-2147483648, true); 1952 | test_read_int32(-2147483649LL, false); 1953 | test_read_int32(-1e2f, false); 1954 | test_read_int32(1.2345, false); 1955 | test_read_num_from_non_numeric_mp(mp_read_int32); 1956 | 1957 | test_read_int64(123, true); 1958 | test_read_int64(12345, true); 1959 | test_read_int64(123456789, true); 1960 | test_read_int64(9223372036854775807ULL, true); 1961 | test_read_int64(9223372036854775808ULL, false); 1962 | test_read_int64(-123, true); 1963 | test_read_int64(-12345, true); 1964 | test_read_int64(-123456789, true); 1965 | test_read_int64(-9223372036854775807LL, true); 1966 | test_read_int64(100.0f, false); 1967 | test_read_int64(-5.4321, false); 1968 | test_read_num_from_non_numeric_mp(mp_read_int64); 1969 | 1970 | test_read_double(123, true); 1971 | test_read_double(12345, true); 1972 | test_read_double(123456789, true); 1973 | test_read_double(1234567890000ULL, true); 1974 | test_read_double(123456789123456789ULL, false); 1975 | test_read_double(-123, true); 1976 | test_read_double(-12345, true); 1977 | test_read_double(-123456789, true); 1978 | test_read_double(-1234567890000LL, true); 1979 | test_read_double(-123456789123456789LL, false); 1980 | test_read_double(6.565e6f, true); 1981 | test_read_double(-5.555, true); 1982 | test_read_num_from_non_numeric_mp(mp_read_double); 1983 | 1984 | test_read_double_lossy(123, true); 1985 | test_read_double_lossy(12345, true); 1986 | test_read_double_lossy(123456789, true); 1987 | test_read_double_lossy(1234567890000ULL, true); 1988 | test_read_double_lossy(123456789123456789ULL, true); 1989 | test_read_double_lossy(-123, true); 1990 | test_read_double_lossy(-12345, true); 1991 | test_read_double_lossy(-123456789, true); 1992 | test_read_double_lossy(-1234567890000LL, true); 1993 | test_read_double_lossy(-123456789123456789LL, true); 1994 | test_read_double_lossy(6.565e6f, true); 1995 | test_read_double_lossy(-5.555, true); 1996 | test_read_num_from_non_numeric_mp(mp_read_double_lossy); 1997 | 1998 | footer(); 1999 | return check_plan(); 2000 | } 2001 | 2002 | static int 2003 | test_overflow() 2004 | { 2005 | plan(5); 2006 | header(); 2007 | 2008 | const char *chk; 2009 | char *d; 2010 | d = data; 2011 | chk = data; 2012 | d = mp_encode_array(d, 1); 2013 | d = mp_encode_array(d, UINT32_MAX); 2014 | is(mp_check(&chk, d), 1, "mp_check array overflow"); 2015 | 2016 | d = data; 2017 | chk = data; 2018 | d = mp_encode_array(d, 1); 2019 | d = mp_encode_map(d, UINT32_MAX); 2020 | is(mp_check(&chk, d), 1, "mp_check map overflow"); 2021 | 2022 | d = data; 2023 | chk = data; 2024 | d = mp_encode_array(d, 2); 2025 | d = mp_encode_str(d, "", 0); 2026 | d = mp_encode_strl(d, UINT32_MAX); 2027 | is(mp_check(&chk, d), 1, "mp_check str overflow"); 2028 | 2029 | d = data; 2030 | chk = data; 2031 | d = mp_encode_array(d, 2); 2032 | d = mp_encode_bin(d, "", 0); 2033 | d = mp_encode_binl(d, UINT32_MAX); 2034 | is(mp_check(&chk, d), 1, "mp_check bin overflow"); 2035 | 2036 | d = data; 2037 | chk = data; 2038 | d = mp_encode_array(d, 2); 2039 | d = mp_encode_str0(d, ""); 2040 | d = mp_encode_strl(d, UINT32_MAX); 2041 | is(mp_check(&chk, d), 1, "mp_check str overflow"); 2042 | 2043 | footer(); 2044 | return check_plan(); 2045 | } 2046 | 2047 | 2048 | int main() 2049 | { 2050 | plan(27); 2051 | header(); 2052 | 2053 | test_uints(); 2054 | test_ints(); 2055 | test_bools(); 2056 | test_floats(); 2057 | test_doubles(); 2058 | test_nils(); 2059 | test_strls(); 2060 | test_binls(); 2061 | test_extls(); 2062 | test_strs(); 2063 | test_bins(); 2064 | test_exts(); 2065 | test_arrays(); 2066 | test_maps(); 2067 | test_memcpy(); 2068 | test_next_on_arrays(); 2069 | test_next_on_maps(); 2070 | test_compare_uints(); 2071 | test_format(); 2072 | test_mp_print(); 2073 | test_mp_print_ext(); 2074 | test_mp_check(); 2075 | test_mp_check_exact(); 2076 | test_mp_check_ext_data(); 2077 | test_mp_check_error(); 2078 | test_mp_read_typed(); 2079 | test_overflow(); 2080 | 2081 | footer(); 2082 | return check_plan(); 2083 | } 2084 | -------------------------------------------------------------------------------- /Doxyfile.in: -------------------------------------------------------------------------------- 1 | # Doxyfile 1.8.1.2 2 | 3 | # This file describes the settings to be used by the documentation system 4 | # doxygen (www.doxygen.org) for a project. 5 | # 6 | # All text after a hash (#) is considered a comment and will be ignored. 7 | # The format is: 8 | # TAG = value [value, ...] 9 | # For lists items can also be appended using: 10 | # TAG += value [value, ...] 11 | # Values that contain spaces should be placed between quotes (" "). 12 | 13 | #--------------------------------------------------------------------------- 14 | # Project related configuration options 15 | #--------------------------------------------------------------------------- 16 | 17 | # This tag specifies the encoding used for all characters in the config file 18 | # that follow. The default is UTF-8 which is also the encoding used for all 19 | # text before the first occurrence of this tag. Doxygen uses libiconv (or the 20 | # iconv built into libc) for the transcoding. See 21 | # http://www.gnu.org/software/libiconv for the list of possible encodings. 22 | 23 | DOXYFILE_ENCODING = UTF-8 24 | 25 | # The PROJECT_NAME tag is a single word (or sequence of words) that should 26 | # identify the project. Note that if you do not use Doxywizard you need 27 | # to put quotes around the project name if it contains spaces. 28 | 29 | PROJECT_NAME = "MsgPuck" 30 | 31 | # The PROJECT_NUMBER tag can be used to enter a project or revision number. 32 | # This could be handy for archiving the generated documentation or 33 | # if some version control system is used. 34 | 35 | PROJECT_NUMBER = 36 | 37 | # Using the PROJECT_BRIEF tag one can provide an optional one line description 38 | # for a project that appears at the top of each page and should give viewer 39 | # a quick idea about the purpose of the project. Keep the description short. 40 | 41 | PROJECT_BRIEF = 42 | 43 | # With the PROJECT_LOGO tag one can specify an logo or icon that is 44 | # included in the documentation. The maximum height of the logo should not 45 | # exceed 55 pixels and the maximum width should not exceed 200 pixels. 46 | # Doxygen will copy the logo to the output directory. 47 | 48 | PROJECT_LOGO = 49 | 50 | # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) 51 | # base path where the generated documentation will be put. 52 | # If a relative path is entered, it will be relative to the location 53 | # where doxygen was started. If left blank the current directory will be used. 54 | 55 | OUTPUT_DIRECTORY = doc 56 | 57 | # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create 58 | # 4096 sub-directories (in 2 levels) under the output directory of each output 59 | # format and will distribute the generated files over these directories. 60 | # Enabling this option can be useful when feeding doxygen a huge amount of 61 | # source files, where putting all generated files in the same directory would 62 | # otherwise cause performance problems for the file system. 63 | 64 | CREATE_SUBDIRS = NO 65 | 66 | # The OUTPUT_LANGUAGE tag is used to specify the language in which all 67 | # documentation generated by doxygen is written. Doxygen will use this 68 | # information to generate all constant output in the proper language. 69 | # The default language is English, other supported languages are: 70 | # Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, 71 | # Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, 72 | # Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English 73 | # messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, 74 | # Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, 75 | # Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. 76 | 77 | OUTPUT_LANGUAGE = English 78 | 79 | # If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will 80 | # include brief member descriptions after the members that are listed in 81 | # the file and class documentation (similar to JavaDoc). 82 | # Set to NO to disable this. 83 | 84 | BRIEF_MEMBER_DESC = YES 85 | 86 | # If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend 87 | # the brief description of a member or function before the detailed description. 88 | # Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the 89 | # brief descriptions will be completely suppressed. 90 | 91 | REPEAT_BRIEF = YES 92 | 93 | # This tag implements a quasi-intelligent brief description abbreviator 94 | # that is used to form the text in various listings. Each string 95 | # in this list, if found as the leading text of the brief description, will be 96 | # stripped from the text and the result after processing the whole list, is 97 | # used as the annotated text. Otherwise, the brief description is used as-is. 98 | # If left blank, the following values are used ("$name" is automatically 99 | # replaced with the name of the entity): "The $name class" "The $name widget" 100 | # "The $name file" "is" "provides" "specifies" "contains" 101 | # "represents" "a" "an" "the" 102 | 103 | ABBREVIATE_BRIEF = 104 | 105 | # If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then 106 | # Doxygen will generate a detailed section even if there is only a brief 107 | # description. 108 | 109 | ALWAYS_DETAILED_SEC = NO 110 | 111 | # If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all 112 | # inherited members of a class in the documentation of that class as if those 113 | # members were ordinary class members. Constructors, destructors and assignment 114 | # operators of the base classes will not be shown. 115 | 116 | INLINE_INHERITED_MEMB = NO 117 | 118 | # If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full 119 | # path before files name in the file list and in the header files. If set 120 | # to NO the shortest path that makes the file name unique will be used. 121 | 122 | FULL_PATH_NAMES = NO 123 | 124 | # If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag 125 | # can be used to strip a user-defined part of the path. Stripping is 126 | # only done if one of the specified strings matches the left-hand part of 127 | # the path. The tag can be used to show relative paths in the file list. 128 | # If left blank the directory from which doxygen is run is used as the 129 | # path to strip. 130 | 131 | STRIP_FROM_PATH = 132 | 133 | # The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of 134 | # the path mentioned in the documentation of a class, which tells 135 | # the reader which header file to include in order to use a class. 136 | # If left blank only the name of the header file containing the class 137 | # definition is used. Otherwise one should specify the include paths that 138 | # are normally passed to the compiler using the -I flag. 139 | 140 | STRIP_FROM_INC_PATH = 141 | 142 | # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter 143 | # (but less readable) file names. This can be useful if your file system 144 | # doesn't support long names like on DOS, Mac, or CD-ROM. 145 | 146 | SHORT_NAMES = NO 147 | 148 | # If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen 149 | # will interpret the first line (until the first dot) of a JavaDoc-style 150 | # comment as the brief description. If set to NO, the JavaDoc 151 | # comments will behave just like regular Qt-style comments 152 | # (thus requiring an explicit @brief command for a brief description.) 153 | 154 | JAVADOC_AUTOBRIEF = NO 155 | 156 | # If the QT_AUTOBRIEF tag is set to YES then Doxygen will 157 | # interpret the first line (until the first dot) of a Qt-style 158 | # comment as the brief description. If set to NO, the comments 159 | # will behave just like regular Qt-style comments (thus requiring 160 | # an explicit \brief command for a brief description.) 161 | 162 | QT_AUTOBRIEF = NO 163 | 164 | # The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen 165 | # treat a multi-line C++ special comment block (i.e. a block of //! or /// 166 | # comments) as a brief description. This used to be the default behaviour. 167 | # The new default is to treat a multi-line C++ comment block as a detailed 168 | # description. Set this tag to YES if you prefer the old behaviour instead. 169 | 170 | MULTILINE_CPP_IS_BRIEF = NO 171 | 172 | # If the INHERIT_DOCS tag is set to YES (the default) then an undocumented 173 | # member inherits the documentation from any documented member that it 174 | # re-implements. 175 | 176 | INHERIT_DOCS = YES 177 | 178 | # If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce 179 | # a new page for each member. If set to NO, the documentation of a member will 180 | # be part of the file/class/namespace that contains it. 181 | 182 | SEPARATE_MEMBER_PAGES = NO 183 | 184 | # The TAB_SIZE tag can be used to set the number of spaces in a tab. 185 | # Doxygen uses this value to replace tabs by spaces in code fragments. 186 | 187 | TAB_SIZE = 8 188 | 189 | # This tag can be used to specify a number of aliases that acts 190 | # as commands in the documentation. An alias has the form "name=value". 191 | # For example adding "sideeffect=\par Side Effects:\n" will allow you to 192 | # put the command \sideeffect (or @sideeffect) in the documentation, which 193 | # will result in a user-defined paragraph with heading "Side Effects:". 194 | # You can put \n's in the value part of an alias to insert newlines. 195 | 196 | ALIASES = 197 | 198 | # This tag can be used to specify a number of word-keyword mappings (TCL only). 199 | # A mapping has the form "name=value". For example adding 200 | # "class=itcl::class" will allow you to use the command class in the 201 | # itcl::class meaning. 202 | 203 | TCL_SUBST = 204 | 205 | # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C 206 | # sources only. Doxygen will then generate output that is more tailored for C. 207 | # For instance, some of the names that are used will be different. The list 208 | # of all members will be omitted, etc. 209 | 210 | OPTIMIZE_OUTPUT_FOR_C = YES 211 | 212 | # Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java 213 | # sources only. Doxygen will then generate output that is more tailored for 214 | # Java. For instance, namespaces will be presented as packages, qualified 215 | # scopes will look different, etc. 216 | 217 | OPTIMIZE_OUTPUT_JAVA = NO 218 | 219 | # Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran 220 | # sources only. Doxygen will then generate output that is more tailored for 221 | # Fortran. 222 | 223 | OPTIMIZE_FOR_FORTRAN = NO 224 | 225 | # Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL 226 | # sources. Doxygen will then generate output that is tailored for 227 | # VHDL. 228 | 229 | OPTIMIZE_OUTPUT_VHDL = NO 230 | 231 | # Doxygen selects the parser to use depending on the extension of the files it 232 | # parses. With this tag you can assign which parser to use for a given extension. 233 | # Doxygen has a built-in mapping, but you can override or extend it using this 234 | # tag. The format is ext=language, where ext is a file extension, and language 235 | # is one of the parsers supported by doxygen: IDL, Java, Javascript, CSharp, C, 236 | # C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, C++. For instance to make 237 | # doxygen treat .inc files as Fortran files (default is PHP), and .f files as C 238 | # (default is Fortran), use: inc=Fortran f=C. Note that for custom extensions 239 | # you also need to set FILE_PATTERNS otherwise the files are not read by doxygen. 240 | 241 | EXTENSION_MAPPING = 242 | 243 | # If MARKDOWN_SUPPORT is enabled (the default) then doxygen pre-processes all 244 | # comments according to the Markdown format, which allows for more readable 245 | # documentation. See http://daringfireball.net/projects/markdown/ for details. 246 | # The output of markdown processing is further processed by doxygen, so you 247 | # can mix doxygen, HTML, and XML commands with Markdown formatting. 248 | # Disable only in case of backward compatibilities issues. 249 | 250 | MARKDOWN_SUPPORT = YES 251 | 252 | # If you use STL classes (i.e. std::string, std::vector, etc.) but do not want 253 | # to include (a tag file for) the STL sources as input, then you should 254 | # set this tag to YES in order to let doxygen match functions declarations and 255 | # definitions whose arguments contain STL classes (e.g. func(std::string); v.s. 256 | # func(std::string) {}). This also makes the inheritance and collaboration 257 | # diagrams that involve STL classes more complete and accurate. 258 | 259 | BUILTIN_STL_SUPPORT = NO 260 | 261 | # If you use Microsoft's C++/CLI language, you should set this option to YES to 262 | # enable parsing support. 263 | 264 | CPP_CLI_SUPPORT = NO 265 | 266 | # Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. 267 | # Doxygen will parse them like normal C++ but will assume all classes use public 268 | # instead of private inheritance when no explicit protection keyword is present. 269 | 270 | SIP_SUPPORT = NO 271 | 272 | # For Microsoft's IDL there are propget and propput attributes to indicate getter 273 | # and setter methods for a property. Setting this option to YES (the default) 274 | # will make doxygen replace the get and set methods by a property in the 275 | # documentation. This will only work if the methods are indeed getting or 276 | # setting a simple type. If this is not the case, or you want to show the 277 | # methods anyway, you should set this option to NO. 278 | 279 | IDL_PROPERTY_SUPPORT = YES 280 | 281 | # If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC 282 | # tag is set to YES, then doxygen will reuse the documentation of the first 283 | # member in the group (if any) for the other members of the group. By default 284 | # all members of a group must be documented explicitly. 285 | 286 | DISTRIBUTE_GROUP_DOC = NO 287 | 288 | # Set the SUBGROUPING tag to YES (the default) to allow class member groups of 289 | # the same type (for instance a group of public functions) to be put as a 290 | # subgroup of that type (e.g. under the Public Functions section). Set it to 291 | # NO to prevent subgrouping. Alternatively, this can be done per class using 292 | # the \nosubgrouping command. 293 | 294 | SUBGROUPING = YES 295 | 296 | # When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and 297 | # unions are shown inside the group in which they are included (e.g. using 298 | # @ingroup) instead of on a separate page (for HTML and Man pages) or 299 | # section (for LaTeX and RTF). 300 | 301 | INLINE_GROUPED_CLASSES = NO 302 | 303 | # When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and 304 | # unions with only public data fields will be shown inline in the documentation 305 | # of the scope in which they are defined (i.e. file, namespace, or group 306 | # documentation), provided this scope is documented. If set to NO (the default), 307 | # structs, classes, and unions are shown on a separate page (for HTML and Man 308 | # pages) or section (for LaTeX and RTF). 309 | 310 | INLINE_SIMPLE_STRUCTS = NO 311 | 312 | # When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum 313 | # is documented as struct, union, or enum with the name of the typedef. So 314 | # typedef struct TypeS {} TypeT, will appear in the documentation as a struct 315 | # with name TypeT. When disabled the typedef will appear as a member of a file, 316 | # namespace, or class. And the struct will be named TypeS. This can typically 317 | # be useful for C code in case the coding convention dictates that all compound 318 | # types are typedef'ed and only the typedef is referenced, never the tag name. 319 | 320 | TYPEDEF_HIDES_STRUCT = NO 321 | 322 | # Similar to the SYMBOL_CACHE_SIZE the size of the symbol lookup cache can be 323 | # set using LOOKUP_CACHE_SIZE. This cache is used to resolve symbols given 324 | # their name and scope. Since this can be an expensive process and often the 325 | # same symbol appear multiple times in the code, doxygen keeps a cache of 326 | # pre-resolved symbols. If the cache is too small doxygen will become slower. 327 | # If the cache is too large, memory is wasted. The cache size is given by this 328 | # formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range is 0..9, the default is 0, 329 | # corresponding to a cache size of 2^16 = 65536 symbols. 330 | 331 | LOOKUP_CACHE_SIZE = 0 332 | 333 | #--------------------------------------------------------------------------- 334 | # Build related configuration options 335 | #--------------------------------------------------------------------------- 336 | 337 | # If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in 338 | # documentation are documented, even if no documentation was available. 339 | # Private class members and static file members will be hidden unless 340 | # the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES 341 | 342 | EXTRACT_ALL = NO 343 | 344 | # If the EXTRACT_PRIVATE tag is set to YES all private members of a class 345 | # will be included in the documentation. 346 | 347 | EXTRACT_PRIVATE = NO 348 | 349 | # If the EXTRACT_PACKAGE tag is set to YES all members with package or internal scope will be included in the documentation. 350 | 351 | EXTRACT_PACKAGE = NO 352 | 353 | # If the EXTRACT_STATIC tag is set to YES all static members of a file 354 | # will be included in the documentation. 355 | 356 | EXTRACT_STATIC = NO 357 | 358 | # If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) 359 | # defined locally in source files will be included in the documentation. 360 | # If set to NO only classes defined in header files are included. 361 | 362 | EXTRACT_LOCAL_CLASSES = YES 363 | 364 | # This flag is only useful for Objective-C code. When set to YES local 365 | # methods, which are defined in the implementation section but not in 366 | # the interface are included in the documentation. 367 | # If set to NO (the default) only methods in the interface are included. 368 | 369 | EXTRACT_LOCAL_METHODS = NO 370 | 371 | # If this flag is set to YES, the members of anonymous namespaces will be 372 | # extracted and appear in the documentation as a namespace called 373 | # 'anonymous_namespace{file}', where file will be replaced with the base 374 | # name of the file that contains the anonymous namespace. By default 375 | # anonymous namespaces are hidden. 376 | 377 | EXTRACT_ANON_NSPACES = NO 378 | 379 | # If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all 380 | # undocumented members of documented classes, files or namespaces. 381 | # If set to NO (the default) these members will be included in the 382 | # various overviews, but no documentation section is generated. 383 | # This option has no effect if EXTRACT_ALL is enabled. 384 | 385 | HIDE_UNDOC_MEMBERS = NO 386 | 387 | # If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all 388 | # undocumented classes that are normally visible in the class hierarchy. 389 | # If set to NO (the default) these classes will be included in the various 390 | # overviews. This option has no effect if EXTRACT_ALL is enabled. 391 | 392 | HIDE_UNDOC_CLASSES = NO 393 | 394 | # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all 395 | # friend (class|struct|union) declarations. 396 | # If set to NO (the default) these declarations will be included in the 397 | # documentation. 398 | 399 | HIDE_FRIEND_COMPOUNDS = NO 400 | 401 | # If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any 402 | # documentation blocks found inside the body of a function. 403 | # If set to NO (the default) these blocks will be appended to the 404 | # function's detailed documentation block. 405 | 406 | HIDE_IN_BODY_DOCS = NO 407 | 408 | # The INTERNAL_DOCS tag determines if documentation 409 | # that is typed after a \internal command is included. If the tag is set 410 | # to NO (the default) then the documentation will be excluded. 411 | # Set it to YES to include the internal documentation. 412 | 413 | INTERNAL_DOCS = NO 414 | 415 | # If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate 416 | # file names in lower-case letters. If set to YES upper-case letters are also 417 | # allowed. This is useful if you have classes or files whose names only differ 418 | # in case and if your file system supports case sensitive file names. Windows 419 | # and Mac users are advised to set this option to NO. 420 | 421 | CASE_SENSE_NAMES = YES 422 | 423 | # If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen 424 | # will show members with their full class and namespace scopes in the 425 | # documentation. If set to YES the scope will be hidden. 426 | 427 | HIDE_SCOPE_NAMES = NO 428 | 429 | # If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen 430 | # will put a list of the files that are included by a file in the documentation 431 | # of that file. 432 | 433 | SHOW_INCLUDE_FILES = YES 434 | 435 | # If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen 436 | # will list include files with double quotes in the documentation 437 | # rather than with sharp brackets. 438 | 439 | FORCE_LOCAL_INCLUDES = NO 440 | 441 | # If the INLINE_INFO tag is set to YES (the default) then a tag [inline] 442 | # is inserted in the documentation for inline members. 443 | 444 | INLINE_INFO = YES 445 | 446 | # If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen 447 | # will sort the (detailed) documentation of file and class members 448 | # alphabetically by member name. If set to NO the members will appear in 449 | # declaration order. 450 | 451 | SORT_MEMBER_DOCS = YES 452 | 453 | # If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the 454 | # brief documentation of file, namespace and class members alphabetically 455 | # by member name. If set to NO (the default) the members will appear in 456 | # declaration order. 457 | 458 | SORT_BRIEF_DOCS = NO 459 | 460 | # If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen 461 | # will sort the (brief and detailed) documentation of class members so that 462 | # constructors and destructors are listed first. If set to NO (the default) 463 | # the constructors will appear in the respective orders defined by 464 | # SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. 465 | # This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO 466 | # and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. 467 | 468 | SORT_MEMBERS_CTORS_1ST = NO 469 | 470 | # If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the 471 | # hierarchy of group names into alphabetical order. If set to NO (the default) 472 | # the group names will appear in their defined order. 473 | 474 | SORT_GROUP_NAMES = NO 475 | 476 | # If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be 477 | # sorted by fully-qualified names, including namespaces. If set to 478 | # NO (the default), the class list will be sorted only by class name, 479 | # not including the namespace part. 480 | # Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. 481 | # Note: This option applies only to the class list, not to the 482 | # alphabetical list. 483 | 484 | SORT_BY_SCOPE_NAME = NO 485 | 486 | # If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to 487 | # do proper type resolution of all parameters of a function it will reject a 488 | # match between the prototype and the implementation of a member function even 489 | # if there is only one candidate or it is obvious which candidate to choose 490 | # by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen 491 | # will still accept a match between prototype and implementation in such cases. 492 | 493 | STRICT_PROTO_MATCHING = NO 494 | 495 | # The GENERATE_TODOLIST tag can be used to enable (YES) or 496 | # disable (NO) the todo list. This list is created by putting \todo 497 | # commands in the documentation. 498 | 499 | GENERATE_TODOLIST = YES 500 | 501 | # The GENERATE_TESTLIST tag can be used to enable (YES) or 502 | # disable (NO) the test list. This list is created by putting \test 503 | # commands in the documentation. 504 | 505 | GENERATE_TESTLIST = YES 506 | 507 | # The GENERATE_BUGLIST tag can be used to enable (YES) or 508 | # disable (NO) the bug list. This list is created by putting \bug 509 | # commands in the documentation. 510 | 511 | GENERATE_BUGLIST = YES 512 | 513 | # The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or 514 | # disable (NO) the deprecated list. This list is created by putting 515 | # \deprecated commands in the documentation. 516 | 517 | GENERATE_DEPRECATEDLIST= YES 518 | 519 | # The ENABLED_SECTIONS tag can be used to enable conditional 520 | # documentation sections, marked by \if sectionname ... \endif. 521 | 522 | ENABLED_SECTIONS = 523 | 524 | # The MAX_INITIALIZER_LINES tag determines the maximum number of lines 525 | # the initial value of a variable or macro consists of for it to appear in 526 | # the documentation. If the initializer consists of more lines than specified 527 | # here it will be hidden. Use a value of 0 to hide initializers completely. 528 | # The appearance of the initializer of individual variables and macros in the 529 | # documentation can be controlled using \showinitializer or \hideinitializer 530 | # command in the documentation regardless of this setting. 531 | 532 | MAX_INITIALIZER_LINES = 30 533 | 534 | # Set the SHOW_USED_FILES tag to NO to disable the list of files generated 535 | # at the bottom of the documentation of classes and structs. If set to YES the 536 | # list will mention the files that were used to generate the documentation. 537 | 538 | SHOW_USED_FILES = YES 539 | 540 | # Set the SHOW_FILES tag to NO to disable the generation of the Files page. 541 | # This will remove the Files entry from the Quick Index and from the 542 | # Folder Tree View (if specified). The default is YES. 543 | 544 | SHOW_FILES = YES 545 | 546 | # Set the SHOW_NAMESPACES tag to NO to disable the generation of the 547 | # Namespaces page. 548 | # This will remove the Namespaces entry from the Quick Index 549 | # and from the Folder Tree View (if specified). The default is YES. 550 | 551 | SHOW_NAMESPACES = YES 552 | 553 | # The FILE_VERSION_FILTER tag can be used to specify a program or script that 554 | # doxygen should invoke to get the current version for each file (typically from 555 | # the version control system). Doxygen will invoke the program by executing (via 556 | # popen()) the command , where is the value of 557 | # the FILE_VERSION_FILTER tag, and is the name of an input file 558 | # provided by doxygen. Whatever the program writes to standard output 559 | # is used as the file version. See the manual for examples. 560 | 561 | FILE_VERSION_FILTER = 562 | 563 | # The LAYOUT_FILE tag can be used to specify a layout file which will be parsed 564 | # by doxygen. The layout file controls the global structure of the generated 565 | # output files in an output format independent way. To create the layout file 566 | # that represents doxygen's defaults, run doxygen with the -l option. 567 | # You can optionally specify a file name after the option, if omitted 568 | # DoxygenLayout.xml will be used as the name of the layout file. 569 | 570 | LAYOUT_FILE = 571 | 572 | # The CITE_BIB_FILES tag can be used to specify one or more bib files 573 | # containing the references data. This must be a list of .bib files. The 574 | # .bib extension is automatically appended if omitted. Using this command 575 | # requires the bibtex tool to be installed. See also 576 | # http://en.wikipedia.org/wiki/BibTeX for more info. For LaTeX the style 577 | # of the bibliography can be controlled using LATEX_BIB_STYLE. To use this 578 | # feature you need bibtex and perl available in the search path. 579 | 580 | CITE_BIB_FILES = 581 | 582 | #--------------------------------------------------------------------------- 583 | # configuration options related to warning and progress messages 584 | #--------------------------------------------------------------------------- 585 | 586 | # The QUIET tag can be used to turn on/off the messages that are generated 587 | # by doxygen. Possible values are YES and NO. If left blank NO is used. 588 | 589 | QUIET = NO 590 | 591 | # The WARNINGS tag can be used to turn on/off the warning messages that are 592 | # generated by doxygen. Possible values are YES and NO. If left blank 593 | # NO is used. 594 | 595 | WARNINGS = YES 596 | 597 | # If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings 598 | # for undocumented members. If EXTRACT_ALL is set to YES then this flag will 599 | # automatically be disabled. 600 | 601 | WARN_IF_UNDOCUMENTED = YES 602 | 603 | # If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for 604 | # potential errors in the documentation, such as not documenting some 605 | # parameters in a documented function, or documenting parameters that 606 | # don't exist or using markup commands wrongly. 607 | 608 | WARN_IF_DOC_ERROR = YES 609 | 610 | # The WARN_NO_PARAMDOC option can be enabled to get warnings for 611 | # functions that are documented, but have no documentation for their parameters 612 | # or return value. If set to NO (the default) doxygen will only warn about 613 | # wrong or incomplete parameter documentation, but not about the absence of 614 | # documentation. 615 | 616 | WARN_NO_PARAMDOC = NO 617 | 618 | # The WARN_FORMAT tag determines the format of the warning messages that 619 | # doxygen can produce. The string should contain the $file, $line, and $text 620 | # tags, which will be replaced by the file and line number from which the 621 | # warning originated and the warning text. Optionally the format may contain 622 | # $version, which will be replaced by the version of the file (if it could 623 | # be obtained via FILE_VERSION_FILTER) 624 | 625 | WARN_FORMAT = "$file:$line: $text" 626 | 627 | # The WARN_LOGFILE tag can be used to specify a file to which warning 628 | # and error messages should be written. If left blank the output is written 629 | # to stderr. 630 | 631 | WARN_LOGFILE = 632 | 633 | #--------------------------------------------------------------------------- 634 | # configuration options related to the input files 635 | #--------------------------------------------------------------------------- 636 | 637 | # The INPUT tag can be used to specify the files and/or directories that contain 638 | # documented source files. You may enter file names like "myfile.cpp" or 639 | # directories like "/usr/src/myproject". Separate the files or directories 640 | # with spaces. 641 | 642 | INPUT = "@CMAKE_CURRENT_SOURCE_DIR@/msgpuck.h" 643 | 644 | # This tag can be used to specify the character encoding of the source files 645 | # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is 646 | # also the default input encoding. Doxygen uses libiconv (or the iconv built 647 | # into libc) for the transcoding. See http://www.gnu.org/software/libiconv for 648 | # the list of possible encodings. 649 | 650 | INPUT_ENCODING = UTF-8 651 | 652 | # If the value of the INPUT tag contains directories, you can use the 653 | # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp 654 | # and *.h) to filter out the source-files in the directories. If left 655 | # blank the following patterns are tested: 656 | # *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh 657 | # *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py 658 | # *.f90 *.f *.for *.vhd *.vhdl 659 | 660 | FILE_PATTERNS = 661 | 662 | # The RECURSIVE tag can be used to turn specify whether or not subdirectories 663 | # should be searched for input files as well. Possible values are YES and NO. 664 | # If left blank NO is used. 665 | 666 | RECURSIVE = NO 667 | 668 | # The EXCLUDE tag can be used to specify files and/or directories that should be 669 | # excluded from the INPUT source files. This way you can easily exclude a 670 | # subdirectory from a directory tree whose root is specified with the INPUT tag. 671 | # Note that relative paths are relative to the directory from which doxygen is 672 | # run. 673 | 674 | EXCLUDE = 675 | 676 | # The EXCLUDE_SYMLINKS tag can be used to select whether or not files or 677 | # directories that are symbolic links (a Unix file system feature) are excluded 678 | # from the input. 679 | 680 | EXCLUDE_SYMLINKS = NO 681 | 682 | # If the value of the INPUT tag contains directories, you can use the 683 | # EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude 684 | # certain files from those directories. Note that the wildcards are matched 685 | # against the file with absolute path, so to exclude all test directories 686 | # for example use the pattern */test/* 687 | 688 | EXCLUDE_PATTERNS = 689 | 690 | # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names 691 | # (namespaces, classes, functions, etc.) that should be excluded from the 692 | # output. The symbol name can be a fully qualified name, a word, or if the 693 | # wildcard * is used, a substring. Examples: ANamespace, AClass, 694 | # AClass::ANamespace, ANamespace::*Test 695 | 696 | EXCLUDE_SYMBOLS = 697 | 698 | # The EXAMPLE_PATH tag can be used to specify one or more files or 699 | # directories that contain example code fragments that are included (see 700 | # the \include command). 701 | 702 | EXAMPLE_PATH = 703 | 704 | # If the value of the EXAMPLE_PATH tag contains directories, you can use the 705 | # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp 706 | # and *.h) to filter out the source-files in the directories. If left 707 | # blank all files are included. 708 | 709 | EXAMPLE_PATTERNS = 710 | 711 | # If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be 712 | # searched for input files to be used with the \include or \dontinclude 713 | # commands irrespective of the value of the RECURSIVE tag. 714 | # Possible values are YES and NO. If left blank NO is used. 715 | 716 | EXAMPLE_RECURSIVE = NO 717 | 718 | # The IMAGE_PATH tag can be used to specify one or more files or 719 | # directories that contain image that are included in the documentation (see 720 | # the \image command). 721 | 722 | IMAGE_PATH = 723 | 724 | # The INPUT_FILTER tag can be used to specify a program that doxygen should 725 | # invoke to filter for each input file. Doxygen will invoke the filter program 726 | # by executing (via popen()) the command , where 727 | # is the value of the INPUT_FILTER tag, and is the name of an 728 | # input file. Doxygen will then use the output that the filter program writes 729 | # to standard output. 730 | # If FILTER_PATTERNS is specified, this tag will be 731 | # ignored. 732 | 733 | INPUT_FILTER = 734 | 735 | # The FILTER_PATTERNS tag can be used to specify filters on a per file pattern 736 | # basis. 737 | # Doxygen will compare the file name with each pattern and apply the 738 | # filter if there is a match. 739 | # The filters are a list of the form: 740 | # pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further 741 | # info on how filters are used. If FILTER_PATTERNS is empty or if 742 | # non of the patterns match the file name, INPUT_FILTER is applied. 743 | 744 | FILTER_PATTERNS = 745 | 746 | # If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using 747 | # INPUT_FILTER) will be used to filter the input files when producing source 748 | # files to browse (i.e. when SOURCE_BROWSER is set to YES). 749 | 750 | FILTER_SOURCE_FILES = NO 751 | 752 | # The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file 753 | # pattern. A pattern will override the setting for FILTER_PATTERN (if any) 754 | # and it is also possible to disable source filtering for a specific pattern 755 | # using *.ext= (so without naming a filter). This option only has effect when 756 | # FILTER_SOURCE_FILES is enabled. 757 | 758 | FILTER_SOURCE_PATTERNS = 759 | 760 | #--------------------------------------------------------------------------- 761 | # configuration options related to source browsing 762 | #--------------------------------------------------------------------------- 763 | 764 | # If the SOURCE_BROWSER tag is set to YES then a list of source files will 765 | # be generated. Documented entities will be cross-referenced with these sources. 766 | # Note: To get rid of all source code in the generated output, make sure also 767 | # VERBATIM_HEADERS is set to NO. 768 | 769 | SOURCE_BROWSER = NO 770 | 771 | # Setting the INLINE_SOURCES tag to YES will include the body 772 | # of functions and classes directly in the documentation. 773 | 774 | INLINE_SOURCES = NO 775 | 776 | # Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct 777 | # doxygen to hide any special comment blocks from generated source code 778 | # fragments. Normal C, C++ and Fortran comments will always remain visible. 779 | 780 | STRIP_CODE_COMMENTS = YES 781 | 782 | # If the REFERENCED_BY_RELATION tag is set to YES 783 | # then for each documented function all documented 784 | # functions referencing it will be listed. 785 | 786 | REFERENCED_BY_RELATION = NO 787 | 788 | # If the REFERENCES_RELATION tag is set to YES 789 | # then for each documented function all documented entities 790 | # called/used by that function will be listed. 791 | 792 | REFERENCES_RELATION = NO 793 | 794 | # If the REFERENCES_LINK_SOURCE tag is set to YES (the default) 795 | # and SOURCE_BROWSER tag is set to YES, then the hyperlinks from 796 | # functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will 797 | # link to the source code. 798 | # Otherwise they will link to the documentation. 799 | 800 | REFERENCES_LINK_SOURCE = YES 801 | 802 | # If the USE_HTAGS tag is set to YES then the references to source code 803 | # will point to the HTML generated by the htags(1) tool instead of doxygen 804 | # built-in source browser. The htags tool is part of GNU's global source 805 | # tagging system (see http://www.gnu.org/software/global/global.html). You 806 | # will need version 4.8.6 or higher. 807 | 808 | USE_HTAGS = NO 809 | 810 | # If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen 811 | # will generate a verbatim copy of the header file for each class for 812 | # which an include is specified. Set to NO to disable this. 813 | 814 | VERBATIM_HEADERS = NO 815 | 816 | #--------------------------------------------------------------------------- 817 | # configuration options related to the alphabetical class index 818 | #--------------------------------------------------------------------------- 819 | 820 | # If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index 821 | # of all compounds will be generated. Enable this if the project 822 | # contains a lot of classes, structs, unions or interfaces. 823 | 824 | ALPHABETICAL_INDEX = YES 825 | 826 | # If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then 827 | # the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns 828 | # in which this list will be split (can be a number in the range [1..20]) 829 | 830 | COLS_IN_ALPHA_INDEX = 5 831 | 832 | # In case all classes in a project start with a common prefix, all 833 | # classes will be put under the same header in the alphabetical index. 834 | # The IGNORE_PREFIX tag can be used to specify one or more prefixes that 835 | # should be ignored while generating the index headers. 836 | 837 | IGNORE_PREFIX = 838 | 839 | #--------------------------------------------------------------------------- 840 | # configuration options related to the HTML output 841 | #--------------------------------------------------------------------------- 842 | 843 | # If the GENERATE_HTML tag is set to YES (the default) Doxygen will 844 | # generate HTML output. 845 | 846 | GENERATE_HTML = @GENERATE_HTML@ 847 | 848 | # The HTML_OUTPUT tag is used to specify where the HTML docs will be put. 849 | # If a relative path is entered the value of OUTPUT_DIRECTORY will be 850 | # put in front of it. If left blank `html' will be used as the default path. 851 | 852 | HTML_OUTPUT = html 853 | 854 | # The HTML_FILE_EXTENSION tag can be used to specify the file extension for 855 | # each generated HTML page (for example: .htm,.php,.asp). If it is left blank 856 | # doxygen will generate files with .html extension. 857 | 858 | HTML_FILE_EXTENSION = .html 859 | 860 | # The HTML_HEADER tag can be used to specify a personal HTML header for 861 | # each generated HTML page. If it is left blank doxygen will generate a 862 | # standard header. Note that when using a custom header you are responsible 863 | # for the proper inclusion of any scripts and style sheets that doxygen 864 | # needs, which is dependent on the configuration options used. 865 | # It is advised to generate a default header using "doxygen -w html 866 | # header.html footer.html stylesheet.css YourConfigFile" and then modify 867 | # that header. Note that the header is subject to change so you typically 868 | # have to redo this when upgrading to a newer version of doxygen or when 869 | # changing the value of configuration settings such as GENERATE_TREEVIEW! 870 | 871 | HTML_HEADER = 872 | 873 | # The HTML_FOOTER tag can be used to specify a personal HTML footer for 874 | # each generated HTML page. If it is left blank doxygen will generate a 875 | # standard footer. 876 | 877 | HTML_FOOTER = 878 | 879 | # The HTML_STYLESHEET tag can be used to specify a user-defined cascading 880 | # style sheet that is used by each HTML page. It can be used to 881 | # fine-tune the look of the HTML output. If the tag is left blank doxygen 882 | # will generate a default style sheet. Note that doxygen will try to copy 883 | # the style sheet file to the HTML output directory, so don't put your own 884 | # style sheet in the HTML output directory as well, or it will be erased! 885 | 886 | HTML_STYLESHEET = 887 | 888 | # The HTML_EXTRA_FILES tag can be used to specify one or more extra images or 889 | # other source files which should be copied to the HTML output directory. Note 890 | # that these files will be copied to the base HTML output directory. Use the 891 | # $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these 892 | # files. In the HTML_STYLESHEET file, use the file name only. Also note that 893 | # the files will be copied as-is; there are no commands or markers available. 894 | 895 | HTML_EXTRA_FILES = 896 | 897 | # The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. 898 | # Doxygen will adjust the colors in the style sheet and background images 899 | # according to this color. Hue is specified as an angle on a colorwheel, 900 | # see http://en.wikipedia.org/wiki/Hue for more information. 901 | # For instance the value 0 represents red, 60 is yellow, 120 is green, 902 | # 180 is cyan, 240 is blue, 300 purple, and 360 is red again. 903 | # The allowed range is 0 to 359. 904 | 905 | HTML_COLORSTYLE_HUE = 220 906 | 907 | # The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of 908 | # the colors in the HTML output. For a value of 0 the output will use 909 | # grayscales only. A value of 255 will produce the most vivid colors. 910 | 911 | HTML_COLORSTYLE_SAT = 100 912 | 913 | # The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to 914 | # the luminance component of the colors in the HTML output. Values below 915 | # 100 gradually make the output lighter, whereas values above 100 make 916 | # the output darker. The value divided by 100 is the actual gamma applied, 917 | # so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, 918 | # and 100 does not change the gamma. 919 | 920 | HTML_COLORSTYLE_GAMMA = 80 921 | 922 | # If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML 923 | # page will contain the date and time when the page was generated. Setting 924 | # this to NO can help when comparing the output of multiple runs. 925 | 926 | HTML_TIMESTAMP = YES 927 | 928 | # If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML 929 | # documentation will contain sections that can be hidden and shown after the 930 | # page has loaded. 931 | 932 | HTML_DYNAMIC_SECTIONS = NO 933 | 934 | # With HTML_INDEX_NUM_ENTRIES one can control the preferred number of 935 | # entries shown in the various tree structured indices initially; the user 936 | # can expand and collapse entries dynamically later on. Doxygen will expand 937 | # the tree to such a level that at most the specified number of entries are 938 | # visible (unless a fully collapsed tree already exceeds this amount). 939 | # So setting the number of entries 1 will produce a full collapsed tree by 940 | # default. 0 is a special value representing an infinite number of entries 941 | # and will result in a full expanded tree by default. 942 | 943 | HTML_INDEX_NUM_ENTRIES = 100 944 | 945 | # If the GENERATE_DOCSET tag is set to YES, additional index files 946 | # will be generated that can be used as input for Apple's Xcode 3 947 | # integrated development environment, introduced with OSX 10.5 (Leopard). 948 | # To create a documentation set, doxygen will generate a Makefile in the 949 | # HTML output directory. Running make will produce the docset in that 950 | # directory and running "make install" will install the docset in 951 | # ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find 952 | # it at startup. 953 | # See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html 954 | # for more information. 955 | 956 | GENERATE_DOCSET = NO 957 | 958 | # When GENERATE_DOCSET tag is set to YES, this tag determines the name of the 959 | # feed. A documentation feed provides an umbrella under which multiple 960 | # documentation sets from a single provider (such as a company or product suite) 961 | # can be grouped. 962 | 963 | DOCSET_FEEDNAME = "Doxygen generated docs" 964 | 965 | # When GENERATE_DOCSET tag is set to YES, this tag specifies a string that 966 | # should uniquely identify the documentation set bundle. This should be a 967 | # reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen 968 | # will append .docset to the name. 969 | 970 | DOCSET_BUNDLE_ID = org.doxygen.Project 971 | 972 | # When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely identify 973 | # the documentation publisher. This should be a reverse domain-name style 974 | # string, e.g. com.mycompany.MyDocSet.documentation. 975 | 976 | DOCSET_PUBLISHER_ID = org.doxygen.Publisher 977 | 978 | # The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher. 979 | 980 | DOCSET_PUBLISHER_NAME = Publisher 981 | 982 | # If the GENERATE_HTMLHELP tag is set to YES, additional index files 983 | # will be generated that can be used as input for tools like the 984 | # Microsoft HTML help workshop to generate a compiled HTML help file (.chm) 985 | # of the generated HTML documentation. 986 | 987 | GENERATE_HTMLHELP = NO 988 | 989 | # If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can 990 | # be used to specify the file name of the resulting .chm file. You 991 | # can add a path in front of the file if the result should not be 992 | # written to the html output directory. 993 | 994 | CHM_FILE = 995 | 996 | # If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can 997 | # be used to specify the location (absolute path including file name) of 998 | # the HTML help compiler (hhc.exe). If non-empty doxygen will try to run 999 | # the HTML help compiler on the generated index.hhp. 1000 | 1001 | HHC_LOCATION = 1002 | 1003 | # If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag 1004 | # controls if a separate .chi index file is generated (YES) or that 1005 | # it should be included in the master .chm file (NO). 1006 | 1007 | GENERATE_CHI = NO 1008 | 1009 | # If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING 1010 | # is used to encode HtmlHelp index (hhk), content (hhc) and project file 1011 | # content. 1012 | 1013 | CHM_INDEX_ENCODING = 1014 | 1015 | # If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag 1016 | # controls whether a binary table of contents is generated (YES) or a 1017 | # normal table of contents (NO) in the .chm file. 1018 | 1019 | BINARY_TOC = NO 1020 | 1021 | # The TOC_EXPAND flag can be set to YES to add extra items for group members 1022 | # to the contents of the HTML help documentation and to the tree view. 1023 | 1024 | TOC_EXPAND = NO 1025 | 1026 | # If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and 1027 | # QHP_VIRTUAL_FOLDER are set, an additional index file will be generated 1028 | # that can be used as input for Qt's qhelpgenerator to generate a 1029 | # Qt Compressed Help (.qch) of the generated HTML documentation. 1030 | 1031 | GENERATE_QHP = NO 1032 | 1033 | # If the QHG_LOCATION tag is specified, the QCH_FILE tag can 1034 | # be used to specify the file name of the resulting .qch file. 1035 | # The path specified is relative to the HTML output folder. 1036 | 1037 | QCH_FILE = 1038 | 1039 | # The QHP_NAMESPACE tag specifies the namespace to use when generating 1040 | # Qt Help Project output. For more information please see 1041 | # http://doc.trolltech.com/qthelpproject.html#namespace 1042 | 1043 | QHP_NAMESPACE = org.doxygen.Project 1044 | 1045 | # The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating 1046 | # Qt Help Project output. For more information please see 1047 | # http://doc.trolltech.com/qthelpproject.html#virtual-folders 1048 | 1049 | QHP_VIRTUAL_FOLDER = doc 1050 | 1051 | # If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to 1052 | # add. For more information please see 1053 | # http://doc.trolltech.com/qthelpproject.html#custom-filters 1054 | 1055 | QHP_CUST_FILTER_NAME = 1056 | 1057 | # The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the 1058 | # custom filter to add. For more information please see 1059 | # 1060 | # Qt Help Project / Custom Filters. 1061 | 1062 | QHP_CUST_FILTER_ATTRS = 1063 | 1064 | # The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this 1065 | # project's 1066 | # filter section matches. 1067 | # 1068 | # Qt Help Project / Filter Attributes. 1069 | 1070 | QHP_SECT_FILTER_ATTRS = 1071 | 1072 | # If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can 1073 | # be used to specify the location of Qt's qhelpgenerator. 1074 | # If non-empty doxygen will try to run qhelpgenerator on the generated 1075 | # .qhp file. 1076 | 1077 | QHG_LOCATION = 1078 | 1079 | # If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files 1080 | # will be generated, which together with the HTML files, form an Eclipse help 1081 | # plugin. To install this plugin and make it available under the help contents 1082 | # menu in Eclipse, the contents of the directory containing the HTML and XML 1083 | # files needs to be copied into the plugins directory of eclipse. The name of 1084 | # the directory within the plugins directory should be the same as 1085 | # the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before 1086 | # the help appears. 1087 | 1088 | GENERATE_ECLIPSEHELP = NO 1089 | 1090 | # A unique identifier for the eclipse help plugin. When installing the plugin 1091 | # the directory name containing the HTML and XML files should also have 1092 | # this name. 1093 | 1094 | ECLIPSE_DOC_ID = org.tarantool.msgpack 1095 | 1096 | # The DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) 1097 | # at top of each HTML page. The value NO (the default) enables the index and 1098 | # the value YES disables it. Since the tabs have the same information as the 1099 | # navigation tree you can set this option to NO if you already set 1100 | # GENERATE_TREEVIEW to YES. 1101 | 1102 | DISABLE_INDEX = YES 1103 | 1104 | # The GENERATE_TREEVIEW tag is used to specify whether a tree-like index 1105 | # structure should be generated to display hierarchical information. 1106 | # If the tag value is set to YES, a side panel will be generated 1107 | # containing a tree-like index structure (just like the one that 1108 | # is generated for HTML Help). For this to work a browser that supports 1109 | # JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). 1110 | # Windows users are probably better off using the HTML help feature. 1111 | # Since the tree basically has the same information as the tab index you 1112 | # could consider to set DISABLE_INDEX to NO when enabling this option. 1113 | 1114 | GENERATE_TREEVIEW = NO 1115 | 1116 | # The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values 1117 | # (range [0,1..20]) that doxygen will group on one line in the generated HTML 1118 | # documentation. Note that a value of 0 will completely suppress the enum 1119 | # values from appearing in the overview section. 1120 | 1121 | ENUM_VALUES_PER_LINE = 4 1122 | 1123 | # If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be 1124 | # used to set the initial width (in pixels) of the frame in which the tree 1125 | # is shown. 1126 | 1127 | TREEVIEW_WIDTH = 250 1128 | 1129 | # When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open 1130 | # links to external symbols imported via tag files in a separate window. 1131 | 1132 | EXT_LINKS_IN_WINDOW = NO 1133 | 1134 | # Use this tag to change the font size of Latex formulas included 1135 | # as images in the HTML documentation. The default is 10. Note that 1136 | # when you change the font size after a successful doxygen run you need 1137 | # to manually remove any form_*.png images from the HTML output directory 1138 | # to force them to be regenerated. 1139 | 1140 | FORMULA_FONTSIZE = 10 1141 | 1142 | # Use the FORMULA_TRANPARENT tag to determine whether or not the images 1143 | # generated for formulas are transparent PNGs. Transparent PNGs are 1144 | # not supported properly for IE 6.0, but are supported on all modern browsers. 1145 | # Note that when changing this option you need to delete any form_*.png files 1146 | # in the HTML output before the changes have effect. 1147 | 1148 | FORMULA_TRANSPARENT = YES 1149 | 1150 | # Enable the USE_MATHJAX option to render LaTeX formulas using MathJax 1151 | # (see http://www.mathjax.org) which uses client side Javascript for the 1152 | # rendering instead of using prerendered bitmaps. Use this if you do not 1153 | # have LaTeX installed or if you want to formulas look prettier in the HTML 1154 | # output. When enabled you may also need to install MathJax separately and 1155 | # configure the path to it using the MATHJAX_RELPATH option. 1156 | 1157 | USE_MATHJAX = NO 1158 | 1159 | # When MathJax is enabled you need to specify the location relative to the 1160 | # HTML output directory using the MATHJAX_RELPATH option. The destination 1161 | # directory should contain the MathJax.js script. For instance, if the mathjax 1162 | # directory is located at the same level as the HTML output directory, then 1163 | # MATHJAX_RELPATH should be ../mathjax. The default value points to 1164 | # the MathJax Content Delivery Network so you can quickly see the result without 1165 | # installing MathJax. 1166 | # However, it is strongly recommended to install a local 1167 | # copy of MathJax from http://www.mathjax.org before deployment. 1168 | 1169 | MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest 1170 | 1171 | # The MATHJAX_EXTENSIONS tag can be used to specify one or MathJax extension 1172 | # names that should be enabled during MathJax rendering. 1173 | 1174 | MATHJAX_EXTENSIONS = 1175 | 1176 | # When the SEARCHENGINE tag is enabled doxygen will generate a search box 1177 | # for the HTML output. The underlying search engine uses javascript 1178 | # and DHTML and should work on any modern browser. Note that when using 1179 | # HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets 1180 | # (GENERATE_DOCSET) there is already a search function so this one should 1181 | # typically be disabled. For large projects the javascript based search engine 1182 | # can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. 1183 | 1184 | SEARCHENGINE = NO 1185 | 1186 | # When the SERVER_BASED_SEARCH tag is enabled the search engine will be 1187 | # implemented using a PHP enabled web server instead of at the web client 1188 | # using Javascript. Doxygen will generate the search PHP script and index 1189 | # file to put on the web server. The advantage of the server 1190 | # based approach is that it scales better to large projects and allows 1191 | # full text search. The disadvantages are that it is more difficult to setup 1192 | # and does not have live searching capabilities. 1193 | 1194 | SERVER_BASED_SEARCH = NO 1195 | 1196 | #--------------------------------------------------------------------------- 1197 | # configuration options related to the LaTeX output 1198 | #--------------------------------------------------------------------------- 1199 | 1200 | # If the GENERATE_LATEX tag is set to YES (the default) Doxygen will 1201 | # generate Latex output. 1202 | 1203 | GENERATE_LATEX = NO 1204 | 1205 | # The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. 1206 | # If a relative path is entered the value of OUTPUT_DIRECTORY will be 1207 | # put in front of it. If left blank `latex' will be used as the default path. 1208 | 1209 | LATEX_OUTPUT = latex 1210 | 1211 | # The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be 1212 | # invoked. If left blank `latex' will be used as the default command name. 1213 | # Note that when enabling USE_PDFLATEX this option is only used for 1214 | # generating bitmaps for formulas in the HTML output, but not in the 1215 | # Makefile that is written to the output directory. 1216 | 1217 | LATEX_CMD_NAME = latex 1218 | 1219 | # The MAKEINDEX_CMD_NAME tag can be used to specify the command name to 1220 | # generate index for LaTeX. If left blank `makeindex' will be used as the 1221 | # default command name. 1222 | 1223 | MAKEINDEX_CMD_NAME = makeindex 1224 | 1225 | # If the COMPACT_LATEX tag is set to YES Doxygen generates more compact 1226 | # LaTeX documents. This may be useful for small projects and may help to 1227 | # save some trees in general. 1228 | 1229 | COMPACT_LATEX = NO 1230 | 1231 | # The PAPER_TYPE tag can be used to set the paper type that is used 1232 | # by the printer. Possible values are: a4, letter, legal and 1233 | # executive. If left blank a4wide will be used. 1234 | 1235 | PAPER_TYPE = a4 1236 | 1237 | # The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX 1238 | # packages that should be included in the LaTeX output. 1239 | 1240 | EXTRA_PACKAGES = 1241 | 1242 | # The LATEX_HEADER tag can be used to specify a personal LaTeX header for 1243 | # the generated latex document. The header should contain everything until 1244 | # the first chapter. If it is left blank doxygen will generate a 1245 | # standard header. Notice: only use this tag if you know what you are doing! 1246 | 1247 | LATEX_HEADER = 1248 | 1249 | # The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for 1250 | # the generated latex document. The footer should contain everything after 1251 | # the last chapter. If it is left blank doxygen will generate a 1252 | # standard footer. Notice: only use this tag if you know what you are doing! 1253 | 1254 | LATEX_FOOTER = 1255 | 1256 | # If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated 1257 | # is prepared for conversion to pdf (using ps2pdf). The pdf file will 1258 | # contain links (just like the HTML output) instead of page references 1259 | # This makes the output suitable for online browsing using a pdf viewer. 1260 | 1261 | PDF_HYPERLINKS = YES 1262 | 1263 | # If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of 1264 | # plain latex in the generated Makefile. Set this option to YES to get a 1265 | # higher quality PDF documentation. 1266 | 1267 | USE_PDFLATEX = YES 1268 | 1269 | # If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. 1270 | # command to the generated LaTeX files. This will instruct LaTeX to keep 1271 | # running if errors occur, instead of asking the user for help. 1272 | # This option is also used when generating formulas in HTML. 1273 | 1274 | LATEX_BATCHMODE = NO 1275 | 1276 | # If LATEX_HIDE_INDICES is set to YES then doxygen will not 1277 | # include the index chapters (such as File Index, Compound Index, etc.) 1278 | # in the output. 1279 | 1280 | LATEX_HIDE_INDICES = NO 1281 | 1282 | # If LATEX_SOURCE_CODE is set to YES then doxygen will include 1283 | # source code with syntax highlighting in the LaTeX output. 1284 | # Note that which sources are shown also depends on other settings 1285 | # such as SOURCE_BROWSER. 1286 | 1287 | LATEX_SOURCE_CODE = NO 1288 | 1289 | # The LATEX_BIB_STYLE tag can be used to specify the style to use for the 1290 | # bibliography, e.g. plainnat, or ieeetr. The default style is "plain". See 1291 | # http://en.wikipedia.org/wiki/BibTeX for more info. 1292 | 1293 | LATEX_BIB_STYLE = plain 1294 | 1295 | #--------------------------------------------------------------------------- 1296 | # configuration options related to the RTF output 1297 | #--------------------------------------------------------------------------- 1298 | 1299 | # If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output 1300 | # The RTF output is optimized for Word 97 and may not look very pretty with 1301 | # other RTF readers or editors. 1302 | 1303 | GENERATE_RTF = NO 1304 | 1305 | # The RTF_OUTPUT tag is used to specify where the RTF docs will be put. 1306 | # If a relative path is entered the value of OUTPUT_DIRECTORY will be 1307 | # put in front of it. If left blank `rtf' will be used as the default path. 1308 | 1309 | RTF_OUTPUT = rtf 1310 | 1311 | # If the COMPACT_RTF tag is set to YES Doxygen generates more compact 1312 | # RTF documents. This may be useful for small projects and may help to 1313 | # save some trees in general. 1314 | 1315 | COMPACT_RTF = NO 1316 | 1317 | # If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated 1318 | # will contain hyperlink fields. The RTF file will 1319 | # contain links (just like the HTML output) instead of page references. 1320 | # This makes the output suitable for online browsing using WORD or other 1321 | # programs which support those fields. 1322 | # Note: wordpad (write) and others do not support links. 1323 | 1324 | RTF_HYPERLINKS = NO 1325 | 1326 | # Load style sheet definitions from file. Syntax is similar to doxygen's 1327 | # config file, i.e. a series of assignments. You only have to provide 1328 | # replacements, missing definitions are set to their default value. 1329 | 1330 | RTF_STYLESHEET_FILE = 1331 | 1332 | # Set optional variables used in the generation of an rtf document. 1333 | # Syntax is similar to doxygen's config file. 1334 | 1335 | RTF_EXTENSIONS_FILE = 1336 | 1337 | #--------------------------------------------------------------------------- 1338 | # configuration options related to the man page output 1339 | #--------------------------------------------------------------------------- 1340 | 1341 | # If the GENERATE_MAN tag is set to YES (the default) Doxygen will 1342 | # generate man pages 1343 | 1344 | GENERATE_MAN = @GENERATE_MAN@ 1345 | 1346 | # The MAN_OUTPUT tag is used to specify where the man pages will be put. 1347 | # If a relative path is entered the value of OUTPUT_DIRECTORY will be 1348 | # put in front of it. If left blank `man' will be used as the default path. 1349 | 1350 | MAN_OUTPUT = man 1351 | 1352 | # The MAN_EXTENSION tag determines the extension that is added to 1353 | # the generated man pages (default is the subroutine's section .3) 1354 | 1355 | MAN_EXTENSION = .3 1356 | 1357 | # If the MAN_LINKS tag is set to YES and Doxygen generates man output, 1358 | # then it will generate one additional man file for each entity 1359 | # documented in the real man page(s). These additional files 1360 | # only source the real man page, but without them the man command 1361 | # would be unable to find the correct page. The default is NO. 1362 | 1363 | MAN_LINKS = NO 1364 | 1365 | #--------------------------------------------------------------------------- 1366 | # configuration options related to the XML output 1367 | #--------------------------------------------------------------------------- 1368 | 1369 | # If the GENERATE_XML tag is set to YES Doxygen will 1370 | # generate an XML file that captures the structure of 1371 | # the code including all documentation. 1372 | 1373 | GENERATE_XML = NO 1374 | 1375 | # The XML_OUTPUT tag is used to specify where the XML pages will be put. 1376 | # If a relative path is entered the value of OUTPUT_DIRECTORY will be 1377 | # put in front of it. If left blank `xml' will be used as the default path. 1378 | 1379 | XML_OUTPUT = xml 1380 | 1381 | # If the XML_PROGRAMLISTING tag is set to YES Doxygen will 1382 | # dump the program listings (including syntax highlighting 1383 | # and cross-referencing information) to the XML output. Note that 1384 | # enabling this will significantly increase the size of the XML output. 1385 | 1386 | XML_PROGRAMLISTING = YES 1387 | 1388 | #--------------------------------------------------------------------------- 1389 | # configuration options for the AutoGen Definitions output 1390 | #--------------------------------------------------------------------------- 1391 | 1392 | # If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will 1393 | # generate an AutoGen Definitions (see autogen.sf.net) file 1394 | # that captures the structure of the code including all 1395 | # documentation. Note that this feature is still experimental 1396 | # and incomplete at the moment. 1397 | 1398 | GENERATE_AUTOGEN_DEF = NO 1399 | 1400 | #--------------------------------------------------------------------------- 1401 | # configuration options related to the Perl module output 1402 | #--------------------------------------------------------------------------- 1403 | 1404 | # If the GENERATE_PERLMOD tag is set to YES Doxygen will 1405 | # generate a Perl module file that captures the structure of 1406 | # the code including all documentation. Note that this 1407 | # feature is still experimental and incomplete at the 1408 | # moment. 1409 | 1410 | GENERATE_PERLMOD = NO 1411 | 1412 | # If the PERLMOD_LATEX tag is set to YES Doxygen will generate 1413 | # the necessary Makefile rules, Perl scripts and LaTeX code to be able 1414 | # to generate PDF and DVI output from the Perl module output. 1415 | 1416 | PERLMOD_LATEX = NO 1417 | 1418 | # If the PERLMOD_PRETTY tag is set to YES the Perl module output will be 1419 | # nicely formatted so it can be parsed by a human reader. 1420 | # This is useful 1421 | # if you want to understand what is going on. 1422 | # On the other hand, if this 1423 | # tag is set to NO the size of the Perl module output will be much smaller 1424 | # and Perl will parse it just the same. 1425 | 1426 | PERLMOD_PRETTY = YES 1427 | 1428 | # The names of the make variables in the generated doxyrules.make file 1429 | # are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. 1430 | # This is useful so different doxyrules.make files included by the same 1431 | # Makefile don't overwrite each other's variables. 1432 | 1433 | PERLMOD_MAKEVAR_PREFIX = 1434 | 1435 | #--------------------------------------------------------------------------- 1436 | # Configuration options related to the preprocessor 1437 | #--------------------------------------------------------------------------- 1438 | 1439 | # If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will 1440 | # evaluate all C-preprocessor directives found in the sources and include 1441 | # files. 1442 | 1443 | ENABLE_PREPROCESSING = YES 1444 | 1445 | # If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro 1446 | # names in the source code. If set to NO (the default) only conditional 1447 | # compilation will be performed. Macro expansion can be done in a controlled 1448 | # way by setting EXPAND_ONLY_PREDEF to YES. 1449 | 1450 | MACRO_EXPANSION = YES 1451 | 1452 | # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES 1453 | # then the macro expansion is limited to the macros specified with the 1454 | # PREDEFINED and EXPAND_AS_DEFINED tags. 1455 | 1456 | EXPAND_ONLY_PREDEF = YES 1457 | 1458 | # If the SEARCH_INCLUDES tag is set to YES (the default) the includes files 1459 | # pointed to by INCLUDE_PATH will be searched when a #include is found. 1460 | 1461 | SEARCH_INCLUDES = YES 1462 | 1463 | # The INCLUDE_PATH tag can be used to specify one or more directories that 1464 | # contain include files that are not input files but should be processed by 1465 | # the preprocessor. 1466 | 1467 | INCLUDE_PATH = 1468 | 1469 | # You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard 1470 | # patterns (like *.h and *.hpp) to filter out the header-files in the 1471 | # directories. If left blank, the patterns specified with FILE_PATTERNS will 1472 | # be used. 1473 | 1474 | INCLUDE_FILE_PATTERNS = 1475 | 1476 | # The PREDEFINED tag can be used to specify one or more macro names that 1477 | # are defined before the preprocessor is started (similar to the -D option of 1478 | # gcc). The argument of the tag is a list of macros of the form: name 1479 | # or name=definition (no spaces). If the definition and the = are 1480 | # omitted =1 is assumed. To prevent a macro definition from being 1481 | # undefined via #undef or recursively expanded use the := operator 1482 | # instead of the = operator. 1483 | 1484 | PREDEFINED = "MP_PROTO = inline"\ 1485 | "__attribute__(x)=" 1486 | 1487 | # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then 1488 | # this tag can be used to specify a list of macro names that should be expanded. 1489 | # The macro definition that is found in the sources will be used. 1490 | # Use the PREDEFINED tag if you want to use a different macro definition that 1491 | # overrules the definition found in the source code. 1492 | 1493 | EXPAND_AS_DEFINED = 1494 | 1495 | # If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then 1496 | # doxygen's preprocessor will remove all references to function-like macros 1497 | # that are alone on a line, have an all uppercase name, and do not end with a 1498 | # semicolon, because these will confuse the parser if not removed. 1499 | 1500 | SKIP_FUNCTION_MACROS = YES 1501 | 1502 | #--------------------------------------------------------------------------- 1503 | # Configuration::additions related to external references 1504 | #--------------------------------------------------------------------------- 1505 | 1506 | # The TAGFILES option can be used to specify one or more tagfiles. For each 1507 | # tag file the location of the external documentation should be added. The 1508 | # format of a tag file without this location is as follows: 1509 | # 1510 | # TAGFILES = file1 file2 ... 1511 | # Adding location for the tag files is done as follows: 1512 | # 1513 | # TAGFILES = file1=loc1 "file2 = loc2" ... 1514 | # where "loc1" and "loc2" can be relative or absolute paths 1515 | # or URLs. Note that each tag file must have a unique name (where the name does 1516 | # NOT include the path). If a tag file is not located in the directory in which 1517 | # doxygen is run, you must also specify the path to the tagfile here. 1518 | 1519 | TAGFILES = 1520 | 1521 | # When a file name is specified after GENERATE_TAGFILE, doxygen will create 1522 | # a tag file that is based on the input files it reads. 1523 | 1524 | GENERATE_TAGFILE = 1525 | 1526 | # If the ALLEXTERNALS tag is set to YES all external classes will be listed 1527 | # in the class index. If set to NO only the inherited external classes 1528 | # will be listed. 1529 | 1530 | ALLEXTERNALS = NO 1531 | 1532 | # If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed 1533 | # in the modules index. If set to NO, only the current project's groups will 1534 | # be listed. 1535 | 1536 | EXTERNAL_GROUPS = YES 1537 | 1538 | # The PERL_PATH should be the absolute path and name of the perl script 1539 | # interpreter (i.e. the result of `which perl'). 1540 | 1541 | PERL_PATH = /usr/bin/perl 1542 | 1543 | #--------------------------------------------------------------------------- 1544 | # Configuration options related to the dot tool 1545 | #--------------------------------------------------------------------------- 1546 | 1547 | # If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will 1548 | # generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base 1549 | # or super classes. Setting the tag to NO turns the diagrams off. Note that 1550 | # this option also works with HAVE_DOT disabled, but it is recommended to 1551 | # install and use dot, since it yields more powerful graphs. 1552 | 1553 | CLASS_DIAGRAMS = NO 1554 | 1555 | # You can define message sequence charts within doxygen comments using the \msc 1556 | # command. Doxygen will then run the mscgen tool (see 1557 | # http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the 1558 | # documentation. The MSCGEN_PATH tag allows you to specify the directory where 1559 | # the mscgen tool resides. If left empty the tool is assumed to be found in the 1560 | # default search path. 1561 | 1562 | MSCGEN_PATH = 1563 | 1564 | # If set to YES, the inheritance and collaboration graphs will hide 1565 | # inheritance and usage relations if the target is undocumented 1566 | # or is not a class. 1567 | 1568 | HIDE_UNDOC_RELATIONS = YES 1569 | 1570 | # If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is 1571 | # available from the path. This tool is part of Graphviz, a graph visualization 1572 | # toolkit from AT&T and Lucent Bell Labs. The other options in this section 1573 | # have no effect if this option is set to NO (the default) 1574 | 1575 | HAVE_DOT = NO 1576 | 1577 | # The DOT_NUM_THREADS specifies the number of dot invocations doxygen is 1578 | # allowed to run in parallel. When set to 0 (the default) doxygen will 1579 | # base this on the number of processors available in the system. You can set it 1580 | # explicitly to a value larger than 0 to get control over the balance 1581 | # between CPU load and processing speed. 1582 | 1583 | DOT_NUM_THREADS = 0 1584 | 1585 | # By default doxygen will use the Helvetica font for all dot files that 1586 | # doxygen generates. When you want a differently looking font you can specify 1587 | # the font name using DOT_FONTNAME. You need to make sure dot is able to find 1588 | # the font, which can be done by putting it in a standard location or by setting 1589 | # the DOTFONTPATH environment variable or by setting DOT_FONTPATH to the 1590 | # directory containing the font. 1591 | 1592 | DOT_FONTNAME = Helvetica 1593 | 1594 | # The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. 1595 | # The default size is 10pt. 1596 | 1597 | DOT_FONTSIZE = 10 1598 | 1599 | # By default doxygen will tell dot to use the Helvetica font. 1600 | # If you specify a different font using DOT_FONTNAME you can use DOT_FONTPATH to 1601 | # set the path where dot can find it. 1602 | 1603 | DOT_FONTPATH = 1604 | 1605 | # If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen 1606 | # will generate a graph for each documented class showing the direct and 1607 | # indirect inheritance relations. Setting this tag to YES will force the 1608 | # CLASS_DIAGRAMS tag to NO. 1609 | 1610 | CLASS_GRAPH = YES 1611 | 1612 | # If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen 1613 | # will generate a graph for each documented class showing the direct and 1614 | # indirect implementation dependencies (inheritance, containment, and 1615 | # class references variables) of the class with other documented classes. 1616 | 1617 | COLLABORATION_GRAPH = YES 1618 | 1619 | # If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen 1620 | # will generate a graph for groups, showing the direct groups dependencies 1621 | 1622 | GROUP_GRAPHS = YES 1623 | 1624 | # If the UML_LOOK tag is set to YES doxygen will generate inheritance and 1625 | # collaboration diagrams in a style similar to the OMG's Unified Modeling 1626 | # Language. 1627 | 1628 | UML_LOOK = NO 1629 | 1630 | # If the UML_LOOK tag is enabled, the fields and methods are shown inside 1631 | # the class node. If there are many fields or methods and many nodes the 1632 | # graph may become too big to be useful. The UML_LIMIT_NUM_FIELDS 1633 | # threshold limits the number of items for each type to make the size more 1634 | # managable. Set this to 0 for no limit. Note that the threshold may be 1635 | # exceeded by 50% before the limit is enforced. 1636 | 1637 | UML_LIMIT_NUM_FIELDS = 10 1638 | 1639 | # If set to YES, the inheritance and collaboration graphs will show the 1640 | # relations between templates and their instances. 1641 | 1642 | TEMPLATE_RELATIONS = NO 1643 | 1644 | # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT 1645 | # tags are set to YES then doxygen will generate a graph for each documented 1646 | # file showing the direct and indirect include dependencies of the file with 1647 | # other documented files. 1648 | 1649 | INCLUDE_GRAPH = YES 1650 | 1651 | # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and 1652 | # HAVE_DOT tags are set to YES then doxygen will generate a graph for each 1653 | # documented header file showing the documented files that directly or 1654 | # indirectly include this file. 1655 | 1656 | INCLUDED_BY_GRAPH = YES 1657 | 1658 | # If the CALL_GRAPH and HAVE_DOT options are set to YES then 1659 | # doxygen will generate a call dependency graph for every global function 1660 | # or class method. Note that enabling this option will significantly increase 1661 | # the time of a run. So in most cases it will be better to enable call graphs 1662 | # for selected functions only using the \callgraph command. 1663 | 1664 | CALL_GRAPH = NO 1665 | 1666 | # If the CALLER_GRAPH and HAVE_DOT tags are set to YES then 1667 | # doxygen will generate a caller dependency graph for every global function 1668 | # or class method. Note that enabling this option will significantly increase 1669 | # the time of a run. So in most cases it will be better to enable caller 1670 | # graphs for selected functions only using the \callergraph command. 1671 | 1672 | CALLER_GRAPH = NO 1673 | 1674 | # If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen 1675 | # will generate a graphical hierarchy of all classes instead of a textual one. 1676 | 1677 | GRAPHICAL_HIERARCHY = YES 1678 | 1679 | # If the DIRECTORY_GRAPH and HAVE_DOT tags are set to YES 1680 | # then doxygen will show the dependencies a directory has on other directories 1681 | # in a graphical way. The dependency relations are determined by the #include 1682 | # relations between the files in the directories. 1683 | 1684 | DIRECTORY_GRAPH = YES 1685 | 1686 | # The DOT_IMAGE_FORMAT tag can be used to set the image format of the images 1687 | # generated by dot. Possible values are svg, png, jpg, or gif. 1688 | # If left blank png will be used. If you choose svg you need to set 1689 | # HTML_FILE_EXTENSION to xhtml in order to make the SVG files 1690 | # visible in IE 9+ (other browsers do not have this requirement). 1691 | 1692 | DOT_IMAGE_FORMAT = png 1693 | 1694 | # If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to 1695 | # enable generation of interactive SVG images that allow zooming and panning. 1696 | # Note that this requires a modern browser other than Internet Explorer. 1697 | # Tested and working are Firefox, Chrome, Safari, and Opera. For IE 9+ you 1698 | # need to set HTML_FILE_EXTENSION to xhtml in order to make the SVG files 1699 | # visible. Older versions of IE do not have SVG support. 1700 | 1701 | INTERACTIVE_SVG = NO 1702 | 1703 | # The tag DOT_PATH can be used to specify the path where the dot tool can be 1704 | # found. If left blank, it is assumed the dot tool can be found in the path. 1705 | 1706 | DOT_PATH = 1707 | 1708 | # The DOTFILE_DIRS tag can be used to specify one or more directories that 1709 | # contain dot files that are included in the documentation (see the 1710 | # \dotfile command). 1711 | 1712 | DOTFILE_DIRS = 1713 | 1714 | # The MSCFILE_DIRS tag can be used to specify one or more directories that 1715 | # contain msc files that are included in the documentation (see the 1716 | # \mscfile command). 1717 | 1718 | MSCFILE_DIRS = 1719 | 1720 | # The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of 1721 | # nodes that will be shown in the graph. If the number of nodes in a graph 1722 | # becomes larger than this value, doxygen will truncate the graph, which is 1723 | # visualized by representing a node as a red box. Note that doxygen if the 1724 | # number of direct children of the root node in a graph is already larger than 1725 | # DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note 1726 | # that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. 1727 | 1728 | DOT_GRAPH_MAX_NODES = 50 1729 | 1730 | # The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the 1731 | # graphs generated by dot. A depth value of 3 means that only nodes reachable 1732 | # from the root by following a path via at most 3 edges will be shown. Nodes 1733 | # that lay further from the root node will be omitted. Note that setting this 1734 | # option to 1 or 2 may greatly reduce the computation time needed for large 1735 | # code bases. Also note that the size of a graph can be further restricted by 1736 | # DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. 1737 | 1738 | MAX_DOT_GRAPH_DEPTH = 0 1739 | 1740 | # Set the DOT_TRANSPARENT tag to YES to generate images with a transparent 1741 | # background. This is disabled by default, because dot on Windows does not 1742 | # seem to support this out of the box. Warning: Depending on the platform used, 1743 | # enabling this option may lead to badly anti-aliased labels on the edges of 1744 | # a graph (i.e. they become hard to read). 1745 | 1746 | DOT_TRANSPARENT = NO 1747 | 1748 | # Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output 1749 | # files in one run (i.e. multiple -o and -T options on the command line). This 1750 | # makes dot run faster, but since only newer versions of dot (>1.8.10) 1751 | # support this, this feature is disabled by default. 1752 | 1753 | DOT_MULTI_TARGETS = YES 1754 | 1755 | # If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will 1756 | # generate a legend page explaining the meaning of the various boxes and 1757 | # arrows in the dot generated graphs. 1758 | 1759 | GENERATE_LEGEND = YES 1760 | 1761 | # If the DOT_CLEANUP tag is set to YES (the default) Doxygen will 1762 | # remove the intermediate dot files that are used to generate 1763 | # the various graphs. 1764 | 1765 | DOT_CLEANUP = YES 1766 | --------------------------------------------------------------------------------