pax_global_header00006660000000000000000000000064147230343040014512gustar00rootroot0000000000000052 comment=cad3c18ef15a663e30e3e43e3a752b66378adec1 nanopb-0.4.9.1/000077500000000000000000000000001472303430400131405ustar00rootroot00000000000000nanopb-0.4.9.1/.bazelignore000066400000000000000000000000351472303430400154400ustar00rootroot00000000000000tests/bazel_workspace_supportnanopb-0.4.9.1/.gitattributes000066400000000000000000000002231472303430400160300ustar00rootroot00000000000000# Auto-generated files that don't need human review. MODULE.bazel.lock linguist-generated=true extra/requirements_lock.txt linguist-generated=true nanopb-0.4.9.1/.github/000077500000000000000000000000001472303430400145005ustar00rootroot00000000000000nanopb-0.4.9.1/.github/workflows/000077500000000000000000000000001472303430400165355ustar00rootroot00000000000000nanopb-0.4.9.1/.github/workflows/bazel.yml000066400000000000000000000011271472303430400203560ustar00rootroot00000000000000name: Bazel on: workflow_dispatch: workflow_call: push: paths: - '**bazel**' pull_request: paths: - '**bazel**' jobs: build_embedded: runs-on: ${{ matrix.os }} strategy: matrix: os: [ubuntu-20.04, macos-14] steps: - uses: actions/checkout@v4 - name: Mount bazel cache uses: actions/cache@v2 with: path: "/home/runner/.cache/bazel" key: ${{ runner.os }}-bazel - name: Test run: | bazelisk test //... - name: Build run: | bazelisk build //... nanopb-0.4.9.1/.github/workflows/binary_packages.yml000066400000000000000000000077631472303430400224170ustar00rootroot00000000000000name: Build binary packages on: workflow_dispatch: workflow_call: push: branches: - 'master' tags: - '*' jobs: build_linux: name: Build binary on Ubuntu 20.04 runs-on: ubuntu-20.04 steps: - name: Check out code from GitHub uses: actions/checkout@v4 with: path: nanopb fetch-depth: "0" - name: Setup Python uses: actions/setup-python@v5 with: python-version: '3.8' - name: Install dependencies run: | python3 -m pip install --user --upgrade scons protobuf grpcio-tools pyinstaller python3 -c 'import google.protobuf; print(google.protobuf.__file__)' - name: Build binary package run: | cd nanopb git clean -dxf tools/make_linux_package.sh - name: Fingerprint binary run: | openssl sha256 nanopb/dist/*.tar.gz - name: Upload binary uses: actions/upload-artifact@v4 with: path: nanopb/dist/*.tar.gz name: nanopb-binary-linux - name: Test binary package run: | tar xzf nanopb/dist/*.tar.gz cd nanopb-*/tests python3 -m SCons - name: Test examples run: | cd nanopb-*/examples (cd simple; make; ./simple) (cd network_server; make) (cd using_union_messages; make) (cd cmake_simple; mkdir build; cd build; cmake ..; make) (cd cmake_relpath; mkdir build; cd build; cmake ..; make) - name: Run build tests run: | cd nanopb-*/build-tests (cd cmake_with_components; mkdir build; cd build; cmake ..; make) (cd legacy_cmake_relpath; mkdir build; cd build; cmake ..; make) (cd legacy_cmake_simple; mkdir build; cd build; cmake ..; make) build_windows: name: Build binary on Windows 2019 runs-on: windows-2019 steps: - name: Check out code from GitHub uses: actions/checkout@v4 with: path: nanopb fetch-depth: "0" - name: Install dependencies shell: bash run: | python3 -m pip install --user --upgrade scons protobuf grpcio-tools pyinstaller python3 -c 'import google.protobuf; print(google.protobuf.__file__)' - name: Build binary package shell: bash run: | cd nanopb git clean -dxf tools/make_windows_package.sh - name: Fingerprint binary run: | openssl sha256 nanopb/dist/*.zip - name: Upload binary uses: actions/upload-artifact@v4 with: path: nanopb/dist/*.zip name: nanopb-binary-windows - name: Test binary package shell: bash run: | powershell "Expand-Archive nanopb/dist/*.zip" ls cd nanopb-*/nanopb-*/tests python3 -m SCons build_macos: name: Build binary on Mac OS X 14 runs-on: macos-14 steps: - name: Check out code from GitHub uses: actions/checkout@v4 with: path: nanopb fetch-depth: "0" - name: Install dependencies run: | python3 -m venv venv venv/bin/python3 -m pip install --upgrade scons protobuf grpcio-tools pyinstaller venv/bin/python3 -c 'import google.protobuf; print(google.protobuf.__file__)' - name: Build binary package run: | source venv/bin/activate cd nanopb git clean -dxf tools/make_mac_package.sh - name: Fingerprint binary run: | openssl sha256 nanopb/dist/*.tar.gz - name: Upload binary uses: actions/upload-artifact@v4 with: path: nanopb/dist/*.tar.gz name: nanopb-binary-macos - name: Test binary package run: | tar xzf nanopb/dist/*.tar.gz cd nanopb-*/tests ../../venv/bin/python3 -m SCons cd ../examples/simple make ./simple nanopb-0.4.9.1/.github/workflows/cifuzz.yml000066400000000000000000000014441472303430400205750ustar00rootroot00000000000000name: Run CIFuzz fuzz test for 10 minutes on: workflow_dispatch: workflow_call: jobs: Fuzzing: runs-on: ubuntu-latest steps: - name: Build Fuzzers id: build uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master with: oss-fuzz-project-name: 'nanopb' dry-run: false sanitizer: undefined - name: Run Fuzzers uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master with: oss-fuzz-project-name: 'nanopb' fuzz-seconds: 600 dry-run: false sanitizer: undefined - name: Upload Crash uses: actions/upload-artifact@v4 if: failure() && steps.build.outcome == 'success' with: name: artifacts path: ./out/artifacts nanopb-0.4.9.1/.github/workflows/cmake.yml000066400000000000000000000035241472303430400203440ustar00rootroot00000000000000name: Test CMake-based installation and compilation on: workflow_dispatch: workflow_call: push: paths: - '**CMakeLists**' - '**cmake**' pull_request: paths: - '**CMakeLists**' - '**cmake**' jobs: build_cmake_linux: name: CMake on Ubuntu 22.04 runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 - name: Install dependencies run: | python3 -m pip install protobuf grpcio-tools - name: Build with CMake run: | mkdir build cd build cmake .. cmake --build . sudo cmake --install . - name: Compile example against installed library run: | cd examples/simple nanopb_generator simple.proto gcc -Wall -Werror -osimple simple.pb.c simple.c -lprotobuf-nanopb -I/usr/local/include/nanopb ./simple build_cmake_windows: name: CMake on Windows 2022 runs-on: windows-2022 steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v4 with: python-version: '3.12' - name: Install dependencies run: | pip install protobuf grpcio-tools - name: Build with CMake run: | mkdir build cd build cmake .. cmake --build . --config Release cmake --install . --config Release --prefix C:/nanopb-test - name: Compile example against installed library shell: cmd run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" cd examples/simple call C:\nanopb-test\bin\nanopb_generator simple.proto cl simple.pb.c simple.c /IC:\nanopb-test\include\nanopb C:\nanopb-test\lib\protobuf-nanopb.lib /link /out:simple.exe simple.exe nanopb-0.4.9.1/.github/workflows/codeql-buildscript.sh000066400000000000000000000002261472303430400226620ustar00rootroot00000000000000#!/usr/bin/env bash sudo apt-get -y update sudo apt-get -y install python3-protobuf protobuf-compiler #scons splint valgrind cd examples/simple make nanopb-0.4.9.1/.github/workflows/codeql.yml000066400000000000000000000115671472303430400205410ustar00rootroot00000000000000# For most projects, this workflow file will not need changing; you simply need # to commit it to your repository. # # You may wish to alter this file to override the set of languages analyzed, # or to provide custom queries or build logic. # # ******** NOTE ******** # We have attempted to detect the languages in your repository. Please check # the `language` matrix defined below to confirm you have the correct set of # supported CodeQL languages. # name: "CodeQL" on: push: branches: [ "main", "master" ] schedule: - cron: '0 0 * * *' pull_request: branches: '*' jobs: analyze: name: Analyze # Runner size impacts CodeQL analysis time. To learn more, please see: # - https://gh.io/recommended-hardware-resources-for-running-codeql # - https://gh.io/supported-runners-and-hardware-resources # - https://gh.io/using-larger-runners # Consider using larger runners for possible analysis time improvements. runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-20.04' }} timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }} permissions: actions: read contents: read security-events: write strategy: fail-fast: false matrix: language: [ 'cpp' ] # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby', 'swift' ] # Use only 'java' to analyze code written in Java, Kotlin or both # Use only 'javascript' to analyze code written in JavaScript, TypeScript or both # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support steps: - name: Checkout repository uses: actions/checkout@v4 with: submodules: recursive # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL uses: github/codeql-action/init@v2 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. # By default, queries listed here will override any specified in a config file. # Prefix the list here with "+" to use these queries and those in the config file. # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs # queries: security-extended,security-and-quality queries: security-and-quality # Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift). # If this step fails, then you should remove it and run the build manually (see below) #- name: Autobuild # uses: github/codeql-action/autobuild@v2 # ℹ️ Command-line programs to run using the OS shell. # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun # If the Autobuild fails above, remove it and uncomment the following three lines. # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. - run: | ./.github/workflows/codeql-buildscript.sh - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v2 with: category: "/language:${{matrix.language}}" upload: false id: step1 # Filter out rules with low severity or high false positve rate # Also filter out warnings in third-party code - name: Filter out unwanted errors and warnings uses: advanced-security/filter-sarif@v1 with: patterns: | -**:cpp/path-injection -**:cpp/world-writable-file-creation -**:cpp/poorly-documented-function -**:cpp/potentially-dangerous-function -**:cpp/use-of-goto -**:cpp/integer-multiplication-cast-to-long -**:cpp/comparison-with-wider-type -**:cpp/leap-year/* -**:cpp/ambiguously-signed-bit-field -**:cpp/suspicious-pointer-scaling -**:cpp/suspicious-pointer-scaling-void -**:cpp/unsigned-comparison-zero -**/cmake*/Modules/** input: ${{ steps.step1.outputs.sarif-output }}/cpp.sarif output: ${{ steps.step1.outputs.sarif-output }}/cpp.sarif - name: Upload CodeQL results to code scanning uses: github/codeql-action/upload-sarif@v2 with: sarif_file: ${{ steps.step1.outputs.sarif-output }} category: "/language:${{matrix.language}}" - name: Upload CodeQL results as an artifact if: success() || failure() uses: actions/upload-artifact@v4 with: name: codeql-results path: ${{ steps.step1.outputs.sarif-output }} retention-days: 5 - name: Fail if an error is found run: | ./.github/workflows/fail_on_error.py \ ${{ steps.step1.outputs.sarif-output }}/cpp.sarif nanopb-0.4.9.1/.github/workflows/compiler_tests.yml000066400000000000000000000036641472303430400223250ustar00rootroot00000000000000name: Run tests with various compilers on: workflow_dispatch: workflow_call: jobs: test_linux: name: Test with gcc & clang on Ubuntu runs-on: ubuntu-20.04 steps: - name: Check out code from GitHub uses: actions/checkout@v4 with: path: nanopb fetch-depth: "0" - name: Install dependencies run: | sudo dpkg --add-architecture i386 sudo apt-get update sudo apt-get install python3-protobuf protobuf-compiler scons sudo apt-get install clang valgrind splint cmake sudo apt-get install libstdc++6:i386 libgcc-s1:i386 lib32gcc-9-dev lib32stdc++-9-dev libncurses5:i386 libc6-dbg:i386 libc6-dev:i386 binutils-multiarch - name: Test with 64-bit GCC run: | cd nanopb/tests rm -rf build scons CC=gcc CXX=g++ CCFLAGS="-O3" rm -rf build scons CC=gcc CXX=g++ CCFLAGS="-Os -flto" rm -rf build scons CC=gcc CXX=g++ CCFLAGS="-O1 -DPB_FIELD_32BIT=1" - name: Test with 32-bit GCC run: | cd nanopb/tests rm -rf build scons CC=gcc CXX=g++ CCFLAGS="-O3 -m32" LINKFLAGS="-m32" rm -rf build scons CC=gcc CXX=g++ CCFLAGS="-Os -flto -m32" LINKFLAGS="-m32" rm -rf build scons CC=gcc CXX=g++ CCFLAGS="-O1 -DPB_FIELD_32BIT=1 -m32" LINKFLAGS="-m32" - name: Test with 64-bit clang run: | cd nanopb/tests rm -rf build scons CC=clang CXX=clang++ CCFLAGS="-O3" rm -rf build scons CC=clang CXX=clang++ CCFLAGS="-Os -DPB_FIELD_32BIT=1" - name: Test with 32-bit clang run: | cd nanopb/tests rm -rf build scons CC=clang CXX=clang++ CCFLAGS="-O3 -m32" LINKFLAGS="-m32" rm -rf build scons CC=clang CXX=clang++ CCFLAGS="-Os -DPB_FIELD_32BIT=1 -m32" LINKFLAGS="-m32" nanopb-0.4.9.1/.github/workflows/fail_on_error.py000077500000000000000000000020661472303430400217360ustar00rootroot00000000000000#!/usr/bin/env python3 import json import sys # Return whether SARIF file contains error-level results def codeql_sarif_contain_error(filename): with open(filename, 'r') as f: s = json.load(f) for run in s.get('runs', []): rules_metadata = run['tool']['driver']['rules'] if not rules_metadata: rules_metadata = run['tool']['extensions'][0]['rules'] for res in run.get('results', []): if 'ruleIndex' in res: rule_index = res['ruleIndex'] elif 'rule' in res and 'index' in res['rule']: rule_index = res['rule']['index'] else: continue try: rule_level = rules_metadata[rule_index]['defaultConfiguration']['level'] except IndexError as e: print(e, rule_index, len(rules_metadata)) else: if rule_level == 'error': return True return False if __name__ == "__main__": if codeql_sarif_contain_error(sys.argv[1]): sys.exit(1) nanopb-0.4.9.1/.github/workflows/ios_swift_tests.yml000066400000000000000000000005741472303430400225160ustar00rootroot00000000000000name: Build and test for Apple iOS swift on: workflow_dispatch: workflow_call: push: paths: - '**spm**' - '**swift**' pull_request: paths: - '**spm**' - '**swift**' jobs: swift-build-run: runs-on: macOS-latest steps: - uses: actions/checkout@v4 - name: Build run: swift build - name: Run run: swift test nanopb-0.4.9.1/.github/workflows/platformio_tests.yml000066400000000000000000000045351472303430400226650ustar00rootroot00000000000000name: Build and test using platformio on: workflow_dispatch: workflow_call: push: paths: - '**platformio**' pull_request: paths: - '**platformio**' jobs: platformio: name: Build and run PlatformIO example runs-on: ubuntu-latest steps: - name: Check out code from GitHub uses: actions/checkout@v4 with: path: nanopb - name: Installing dependencies for local act if: ${{ env.ACT }} run: | sudo apt update - name: Installing common dependencies run: | sudo apt install -y python3-pip - name: Install and setup PlatformIO run: | python3 -m venv venv venv/bin/pip3 install -U platformio - name: Build PlatformIO package run: | source venv/bin/activate cd nanopb pio package pack - name: Example - Extract PlatformIO package to example dir run: | source venv/bin/activate cp -R nanopb/examples/platformio example mkdir -p example/lib/nanopb tar -xzf nanopb/Nanopb-*.tar.gz -C example/lib/nanopb - name: Example - Build run: | source venv/bin/activate cd example pio run - name: Example - Run test without options run: example/.pio/build/pio_without_options/program - name: Example - Run test with options run: example/.pio/build/pio_with_options/program - name: Build in subdirectory with space characters run: | source venv/bin/activate cp -R nanopb/examples/platformio "example with spaces" mkdir -p "example with spaces/lib/nanopb" tar -xzf nanopb/Nanopb-*.tar.gz -C "example with spaces/lib/nanopb" cd "example with spaces" pio run -e pio_with_options # ESP32 platform doesn't support spaces currently - name: Build with default platformio.ini run: | source venv/bin/activate mkdir -p test_default_pio_conf cd test_default_pio_conf pio project init ln -s ../nanopb lib/nanopb echo "[env:native]" >> platformio.ini echo "platform = native" >> platformio.ini echo "lib_deps = Nanopb" >> platformio.ini echo "int main(int argc, char *argv[]){}" > src/main.cpp pio run nanopb-0.4.9.1/.github/workflows/pypi_publish.yml000066400000000000000000000042561472303430400217760ustar00rootroot00000000000000name: Publish generator package to PyPI / pip on: workflow_dispatch: workflow_call: secrets: PYPI_API_KEY: required: true jobs: publish_pypi: name: Build and publish pypi package on Ubuntu 20.04 runs-on: ubuntu-20.04 steps: - name: Check out code from GitHub uses: actions/checkout@v4 with: path: nanopb fetch-depth: "0" - name: Install dependencies run: | python3 -m pip install --user --upgrade pyinstaller poetry protobuf grpcio-tools - name: Build PyPI package run: | cd nanopb/extra/poetry ./poetry_build.sh - name: Fingerprint package run: | openssl sha256 nanopb/extra/poetry/dist/*.whl - name: Check for existence of PyPI package run: | VERSION=$(grep "^version =" nanopb/extra/poetry/build/pyproject.toml | cut -d '"' -f 2) if curl --head --silent --fail https://pypi.org/project/nanopb/$VERSION/; then echo "pypi_exists=true" >> $GITHUB_ENV else echo "pypi_exists=false" >> $GITHUB_ENV fi - name: Publish PyPI package if: env.pypi_exists == 'false' env: POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_API_KEY }} POETRY_HTTP_BASIC_PYPI_USERNAME: __token__ POETRY_HTTP_BASIC_PYPI_PASSWORD: ${{ secrets.PYPI_API_KEY }} run: | cd nanopb/extra/poetry/build poetry publish -n -v -u __token__ -p "$POETRY_PYPI_TOKEN_PYPI" test_pypi: name: Test pypi package runs-on: ubuntu-20.04 needs: publish_pypi steps: - name: Check out code from GitHub uses: actions/checkout@v4 with: path: nanopb - name: Wait for package to become visible run: | sleep 60 - name: Install PyPI package run: | python3 -m pip install --user --upgrade protobuf grpcio-tools scons python3 -m pip install --user --upgrade --pre nanopb - name: Test PyPI package run: | cd nanopb/tests/alltypes/ nanopb_generator alltypes.proto gcc -Wall -I ../../ -c alltypes.pb.c nanopb-0.4.9.1/.github/workflows/python2_tests.yml000066400000000000000000000015401472303430400221050ustar00rootroot00000000000000name: Run tests on Python 2 on: workflow_dispatch: workflow_call: push: paths: - '**.py' pull_request: paths: - '**.py' jobs: test_python2: name: Test with Python 2 on Ubuntu 20.04 runs-on: ubuntu-20.04 steps: - name: Check out code from GitHub uses: actions/checkout@v4 with: path: nanopb fetch-depth: "0" - name: Install dependencies run: | sudo apt-get update sudo apt-get install python-protobuf protobuf-compiler scons python-is-python2 - name: Run tests with Python 2 run: | cd nanopb export GENPATH=$(bash -c 'printf %q "$(pwd)/generator/protoc-gen-nanopb-py2"') cd tests scons PYTHON="/usr/bin/python2" PROTOC="/usr/bin/protoc" PROTOCFLAGS="--plugin=protoc-gen-nanopb=$GENPATH" nanopb-0.4.9.1/.github/workflows/simulator_tests.yml000066400000000000000000000043051472303430400225230ustar00rootroot00000000000000name: Run tests in simulator on: workflow_dispatch: workflow_call: jobs: test_avr: name: Test in simavr for ATMega1284 runs-on: ubuntu-20.04 steps: - name: Check out code from GitHub uses: actions/checkout@v4 with: path: nanopb fetch-depth: "0" - name: Install dependencies run: | sudo apt-get update sudo apt-get install python3-protobuf protobuf-compiler scons sudo apt-get install libelf-dev gcc-avr gdb-avr avr-libc - name: Install simavr run: | git clone https://github.com/buserror/simavr.git cd simavr make build-simavr sudo make install-simavr sudo ldconfig - name: Run tests in AVR simulator run: | cd nanopb/tests scons PLATFORM=AVR test_mips: name: Test in qemu for MIPS runs-on: ubuntu-20.04 steps: - name: Check out code from GitHub uses: actions/checkout@v4 with: path: nanopb fetch-depth: "0" - name: Install dependencies run: | sudo apt-get update sudo apt-get install python3-protobuf protobuf-compiler scons sudo apt-get install gcc-mipsel-linux-gnu g++-mipsel-linux-gnu gcc-mips-linux-gnu g++-mips-linux-gnu qemu-user - name: Run tests for big-endian MIPS run: | cd nanopb/tests rm -rf build scons PLATFORM=MIPS - name: Run tests for little-endian MIPS run: | cd nanopb/tests rm -rf build scons PLATFORM=MIPSEL test_riscv: name: Test in qemu for RISCV64 runs-on: ubuntu-20.04 steps: - name: Check out code from GitHub uses: actions/checkout@v4 with: path: nanopb fetch-depth: "0" - name: Install dependencies run: | sudo apt-get update sudo apt-get install python3-protobuf protobuf-compiler scons sudo apt-get install gcc-riscv64-linux-gnu g++-riscv64-linux-gnu qemu-user - name: Run tests for RISCV64 run: | cd nanopb/tests rm -rf build scons PLATFORM=RISCV64 nanopb-0.4.9.1/.github/workflows/trigger_on_code_change.yml000066400000000000000000000025701472303430400237220ustar00rootroot00000000000000name: Test after code changes on: workflow_dispatch: push: paths: - '**.c' - '**.h' - '**.py' - '**.sh' - '**.yml' - '**.proto' - '**.mk' - '**.cmake' pull_request: paths: - '**.c' - '**.h' - '**.py' - '**.sh' - '**.yml' - '**.proto' - '**.mk' - '**.cmake' jobs: smoke_test: name: Run test suite on Ubuntu 20.04 runs-on: ${{ matrix.os }} strategy: matrix: python-version: ['3.8', '3.x'] os: ['ubuntu-20.04', 'ubuntu-24.04'] steps: - name: Check out code from GitHub uses: actions/checkout@v4 with: path: nanopb - name: Setup Python uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | sudo apt-get update sudo apt-get install protobuf-compiler splint valgrind python3 -m pip install --user --upgrade scons protobuf grpcio-tools pyinstaller python3 -c 'import google.protobuf; print(google.protobuf.__file__)' - name: Run tests run: | cd nanopb/tests scons fuzz_tests: needs: smoke_test uses: ./.github/workflows/cifuzz.yml binary_builds: needs: smoke_test uses: ./.github/workflows/binary_packages.yml nanopb-0.4.9.1/.github/workflows/trigger_on_schedule.yml000066400000000000000000000016051472303430400232750ustar00rootroot00000000000000name: Test, build and pre-release weekly on: workflow_dispatch: schedule: - cron: '32 1 * * 1' jobs: compiler_tests: uses: ./.github/workflows/compiler_tests.yml simulator_tests: uses: ./.github/workflows/simulator_tests.yml python2_tests: uses: ./.github/workflows/python2_tests.yml ios_swift_tests: uses: ./.github/workflows/ios_swift_tests.yml platformio_tests: uses: ./.github/workflows/platformio_tests.yml bazel_tests: uses: ./.github/workflows/bazel.yml cifuzz: uses: ./.github/workflows/cifuzz.yml binary_packages: needs: [compiler_tests, simulator_tests, python2_tests, ios_swift_tests, platformio_tests, cifuzz] uses: ./.github/workflows/binary_packages.yml pypi_publish: needs: binary_packages uses: ./.github/workflows/pypi_publish.yml secrets: PYPI_API_KEY: ${{ secrets.PYPI_API_KEY }} nanopb-0.4.9.1/.gitignore000066400000000000000000000010511472303430400151250ustar00rootroot00000000000000*.gcda *.gcno *.gcov *.o *.pb.c *.pb.h *.pb *.pyc *_pb2.py *~ *.tar.gz *.swp .sconsign.dblite config.log .sconf_temp tests/build julkaisu.txt dist docs/*.html docs/generator_flow.png examples/simple/simple examples/network_server/client examples/network_server/server examples/using_double_on_avr/decode_double examples/using_double_on_avr/encode_double examples/using_double_on_avr/test_conversions examples/using_union_messages/decode examples/using_union_messages/encode generator/nanopb_pb2.pyc !generator-bin/**/* bazel-* extra/poetry/build build/ nanopb-0.4.9.1/AUTHORS.txt000066400000000000000000000133121472303430400150260ustar00rootroot00000000000000Petteri Aimonen Michael Poole Daniel Kan Stan Hu David Hotham Steffen Siering Jens Steinhauser Pavel Ilin Kent Ryhorchuk Martin Donath Oliver Lee Michael Haberler Nicolas Colomer Ivan Kravets Kyle Manna Benjamin Kamath Andrew Ruder Kenshi Kawaguchi isotes Maxim Khitrov Yaniv Mordekhay Ming Zhao Google, Inc. Tom Roeder Piotr Sikora Bernhard Krämer Konstantin Podsvirov William A. Kennington III Guillaume Lager Tobias Haegermarck Justin DeMartino Constantine Grantcharov Nick Ewalt Harald Fernengel Alice Wang Kevin Fitch Kamal Marhubi Elco Jacobs Sébastien Morin Dave Flogeras Edward Z. Yang Robbie Shade Andrew Ballinger Hamina, Juha-Pekka Jason Bishop matejcik Tobias Müller Jari Vetoniemi Gabriel Staples Amarnath Michal Rostecki Pei Wang Noah Pendleton <2538614+noahp@users.noreply.github.com> Pavol Rusnak der-imp Mark Hill Torfinn Berset Bo Langgaard Lind Stephane Dorre Phillip Cao Melvin Wang Joshua Salzedo Adam Klama Anton Matosov berni155 David Lin devjoa Evan Fisher Fay Florian Märkl Franck Ilya Averyanov John Ullman Ket3r maciej Marek Zukal Paul Beusterien Rogers Guedes Stefan R. Filipek T. Carl Beery Vitali Lovich Vojtěch Boček Wael Nasreddine wangli28 Gediminas Žukaitis Alex Pacini Cong kurddt otopetrik Psy-Kai a1lu L <46594312+WakandaO2@users.noreply.github.com> Melvin Wang Tim Gates leabut Angel ILIEV Jakub Tymejczyk Matthew Simmons Anthony Pesch Avik De Conrad Wood David Sabatie Sebastian Stockhammer Gil Shapira Ian Frosst Ingo Kresse Ivan Zrno Jonathan Seilkopf Karl Ljungkvist Mathis Logemann Oleg Dolgy <60554929+odolgy@users.noreply.github.com> Pavel Sokolov Slavey Karadzhov Tobias Nießen Christian Balcom Christopher Hughes <67643395+chughes-pika@users.noreply.github.com> Greg Balke Jussi Keränen Krzysztof Rosinski Nathaniel Brough Sean Kahler Valerii Koval Armando Montanez Brian Yuan Hans Binderup Isaac Torres Jerry Chen jheaff1 Joseph Duchesne Josh Strohminger Krishna Ersson <2743723+kersson@users.noreply.github.com> Mark Nick St.Pierre <120039901+nicholas-stpierre-simplisafe@users.noreply.github.com> philippe44 Richard Patel Tilen Majerle Tobias Thiel Adrian Böckenkamp Antony Male Chi-Ju Wu Georgii Surkov Jan Dorniak Joseph Chen Marco Nilsson Nick Cooke Pieter De Gendt Reinis Veips Robin Kastberg Ted Pudlik Zach Deibert Mark Schulte nanopb-0.4.9.1/BUILD.bazel000066400000000000000000000057271472303430400150310ustar00rootroot00000000000000load("@bazel_skylib//rules:copy_file.bzl", "copy_file") # Note: if you are still using WORKSPACE, you will need to patch this file to use the following instead # load("@python_3_11//:defs.bzl", "py_binary") load("@python_versions//3.11:defs.bzl", "py_binary") load("@rules_proto//proto:defs.bzl", "proto_library") load("@rules_proto_grpc//:defs.bzl", "proto_plugin") load("@rules_python//python:proto.bzl", "py_proto_library") load("@rules_python//python/pip_install:requirements.bzl", "compile_pip_requirements") load("//extra/bazel:nanopb_cc_proto_library.bzl", "cc_nanopb_proto_library") package(default_visibility = ["//visibility:public"]) licenses(["notice"]) exports_files(["LICENSE.txt"]) cc_library( name = "nanopb", srcs = [ "pb_common.c", "pb_decode.c", "pb_encode.c", ], hdrs = [ "pb.h", "pb_common.h", "pb_decode.h", "pb_encode.h", ], visibility = ["//visibility:public"], ) copy_file( name = "protoc-gen-nanopb.py", src = "generator/protoc-gen-nanopb", out = "generator/protoc-gen-nanopb.py", allow_symlink = True, ) py_binary( name = "protoc-gen-nanopb", srcs = glob([ "generator/**/*.py", ]) + [ ":protoc-gen-nanopb.py", ], data = glob([ "generator/**/*.proto", ]), env = { "NANOPB_PB2_NO_REBUILD": "1", }, imports = [ "generator", ], deps = [ ":nanopb_py_proto", ], ) proto_plugin( name = "nanopb_plugin", env = { "NANOPB_PB2_NO_REBUILD": "1", }, options = [ "--library-include-format=quote", ], outputs = [ "{protopath}.pb.h", "{protopath}.pb.c", ], separate_options_flag = True, tool = ":protoc-gen-nanopb", use_built_in_shell_environment = False, visibility = ["//visibility:public"], ) proto_library( name = "nanopb_proto", srcs = [ "generator/proto/nanopb.proto", ], strip_import_prefix = "generator/proto/", deps = ["@protobuf//:descriptor_proto"], ) py_proto_library( name = "nanopb_py_proto", deps = [":nanopb_proto"], ) cc_nanopb_proto_library( name = "test_compilation", protos = ["@protobuf//:descriptor_proto"], visibility = ["//visibility:private"], ) proto_library( name = "all_types_proto", srcs = ["tests/alltypes/alltypes.proto"], ) cc_nanopb_proto_library( name = "all_types_nanopb", nanopb_options_files = ["tests/alltypes/alltypes.options"], protos = [":all_types_proto"], visibility = ["//visibility:private"], ) cc_test( name = "bazel_options_support", srcs = ["tests/bazel_options_support/bazel_options_support.cc"], deps = [":all_types_nanopb"], ) # Run `bazel run //:requirements.update` if you want to update the requirements. compile_pip_requirements( name = "requirements", extra_args = ["--allow-unsafe"], requirements_in = "extra/requirements.txt", requirements_txt = "extra/requirements_lock.txt", ) nanopb-0.4.9.1/CHANGELOG.txt000066400000000000000000000724661472303430400152070ustar00rootroot00000000000000nanopb-0.4.9.1 (2024-12-01) Fix memory not released on error return from pb_decode_ex() (GHSA-xwqq-qxmw-hj5r) Fix deprecated MakeClass() call in generator (#1015) Fix compiler error with enums and --c-style (#1014) Fix version conflict with bazel build rules (#1034) nanopb-0.4.9 (2024-09-19) Fix problems with enum intsize introduced in 0.4.8 (#961) Fix Python pkg_resources deprecation (#887) Add option to discard deprecated fields (#997) Use fallback_type when breaking circular dependencies (#996) Discard autogenerated map entry types if the field is skipped (#956) Use pb_byte_t = uint8_t when available (#916) Add enum_validate option (#988, #991) Add check_return attribute for IAR compiler (#965) Add label_override field option (#962, #963) Add Zephyr module specification (#946) Add Apple privacy manifest (#938) Bazel rule improvements, including bzlmod migration (#927, #950) CMake build rule improvements (#936, #939, #942, #958, #968, #971, #974, #978, #1003) Improve C++ descriptors (#931, #933) Test case improvements (#928) Update dependency package versions (#924, #959, #986, #998, #1010) Documentation improvements (#319, #710, #999) nanopb-0.4.8 (2023-11-11) Fix name mangling with dependent proto files (#892, #899) Fix initializer macros for custom callback datatype (#806) Use UTF-8 encoding for generated files irrespective of locale (#868) Add integer size overrides for fixed width types (#897) Add ability to specify size of generated enums (#867) Provide define for largest message in file (#893) Automatically break circular dependencies (#881) Remove pkg_resources import to avoid deprecation warning (#887) Use static_assert keyword on MSVC in C89 mode (#843) platformio: Allow substitutions in custom_nanopb_protos (#882) CMakeLists: Add missing __init__.py to generator install (#841) CMakeLists: Add nanopb_PYTHON_INSTDIR_OVERRIDE (#875) CMakeLists: Rename installation directories (#845, #907) FindNanopb.cmake: Fix regression bug with relative include path (#888) FindNanopb.cmake: Ensure generator files are updated when cached (#847) FindNanopb.cmake: Fix generator call on Windows (#874) Bazel: multiple build rule fixes and updates (#855, #891, #904, #906, #919) nanopb-0.4.7 (2022-12-11) Fix comments generation for submessages (#788) Fix handling of spaces in arguments passed through protoc (#810) Fix problems with multiple files and mangle_names option (#783, #820) Fix generator error when using M_STRIP_PACKAGE without package name (#795) Fix compilation error with fixed size array and FT_POINTER (#630) Fix wrong format in Python Poetry project file (#811) Fix unnecessary generator message when using --quiet (#831) Fix enum_to_string with C++ (#838) Fix /* */ inside .proto file comment Workaround python-protobuf version issues (#787) Safeguard substraction in pb_read() with custom streams (#697) Always include pb_release() as function, instead of macro. (#802) Allow using = instead of : with generator option -s Allow specifying include format without special characters (#810) Allow including headers from inside of extern C (#814) Add option NANOPB_PB2_TEMP_DIR to store nanopb_pb2.py in a temporary dir (#601) Add compile-time error message for when PB_FIELD_32BIT is needed (#680, #827) Add --c-style command line option for naming style (#199, #533, #791) Add --protoc-opt to nanopb_generator.py (#628) Add ENUMTYPE convenience macros (#803) Add Bazel build rules (#360, #500) Generator: keep order of messages when possible Test case improvements (#792) PlatformIO build rule improvements (#808, #809, #819, #834, #839, #840) CMake build rule improvements (#822) CMakeLists: use protoc wrapper script by default (#769) nanopb-0.4.6 (2022-05-30) Fix passing of error message from substream callback (#703) Fix comments going to wrong member variables (#701) Fix regression in 0.4.3 where generator did not find all dependencies (#720) Fix FindNanopb.cmake not finding options file (#659) Fix double-definition errors with size_union (#692) Fix generator error with same inner message name (#746) Fix infinite recursion in generator/protoc script (#762) Fix unicode comment handling for Python 2 (#740) Fix compiler warnings with PB_BUFFER_ONLY (#717) Fix options dependency in nanopb.mk (#666) Fix handling of filenames with dot in them in FindNanopb.cmake (#756) Add fallback_type option (#772, #773) Use C11 static assert mechanism by default (#761, #766) Use 'static_assert' keyword for iar (#679) Explicitly check for pItem == NULL to satisfy Xcode analyzer (#667, #674) Support --proto-path as alias to -I (#749) Refactor name mangling to separate class, improve error messages (#735) Move PB_WT_PACKED definition to the header to fix compiler warnings (#671) FindNanopb.cmake: use --nanopb_opt for option passing by default (#752) FindNanopb.cmake: Add option NANOPB_GENERATE_CPP_STANDALONE (#741) FindNanopb.cmake: Add PROTOC_OPTIONS variable (#768, #771) CMakeLists: add build interface for using as a submodule (#669) CMakeLists: fix error with nanopb_BUILD_GENERATOR=OFF (#764) CMakeLists: make more uniform (#676) CMakeLists: Fix uninitialized PYTHON_INSTDIR (#652) Clean up CMake examples (#741) Rebuild nanopb_pb2.py and print version numbers on import failure (#733, #742) Use memcpy instead of iterating on buf_read/write (#751) Add generator support for PlatformIO (#718) Add clean target to generator/proto/Makefile (#681) Windows .bats: use standard python invocation instead of py.exe launcher (#657) Fix problems running tests with newer SCons version Improve handling of varint overflows Improve optimization for little-endian platforms NOTE: During development, prereleases were published on PlatformIO registry as versions 0.4.6 - 0.4.6.3. The version 0.4.6.4 on PlatformIO corresponds to the real final 0.4.6 release. nanopb-0.4.5 (2021-03-22) Fix invalid free() with oneof (#647, GHSA-7mv5-5mxh-qg88) Fix unordered field numbers inside oneof causing fields to be ignored (#617) Fix pb_decode() not initializing fields inside oneof (#635 Fix compiler errors with complex oneof hierarchy and sizeof() (#610) Fix descriptor width calculation for 64-bit types (#644) Fix compiler error in generated initializer for submessage callback (#631) Fix duplicate union definition in generated file (#637) Fix test case build error on SCons 4.1.0 Pip package: include nanopb_pb2.py (#629) Make generator consider dependencies recursively (#610) Bazel build system updates (#633) Add support for including comments from .proto file (#85, #645) nanopb-0.4.4 (2020-11-25) Fix memory leak with oneofs and PB_ENABLE_MALLOC (#615, GHSA-85rr-4rh9-hhwh) Fix generator error when oneof contains a single unresolved field size (#610) Fix unsigned enums not working correctly inside OneOf (#611) Fix recursion depth exceeded error in generator (#493) Add '--version' option to nanopb_generator.py (#607) Add support for proto3 optional fields introduced in protoc 3.12 (#591) Add better error message when enum type is not found (#592) Allow specifying descriptorsize on field level also (#546) Allow multiple targets to be created by calling NANOPB_GENERATE_CPP() (#596) Conanfile: Add protobuf-nanopb library to cpp_info.libs (#605) Include version number in generator verbose output Convert documentation to markdown format (#587) Remove outdated transitional generator/nanopb/options.proto. Test case improvements Documentation improvements nanopb-0.4.3 (2020-09-21) Fix generator error when output is in current directory (#553) Fix issue with unknown message sizes being referred inside oneof encoded size calculation (#569) Fix problem with [default=xxxx, (nanopb).proto3=true] field option combination (#558) Fix cross compilation with Conan build system (#568) Better support C++ types in generated structs (#577) CMake rule improvements (#554, #555, #556, #561, #564) Generator: fix compatibility bug with Python 3.1 and earlier Make Linux and Mac packages use grpcio protoc Make pb_decode_varint32() reject overlong varint encodings. Performance optimizations Test case improvements Documentation improvements NOTE: version 0.4.3 changes layout of pb_msgdesc_t. It requires recompiling .pb.c files and thus breaks ABI compatibility. In general, ABI compatibility is not currently maintained between any nanopb versions. NOTE: There was an apparent false positive virus identification by Windows Defender of the PyInstaller 3.6 based Windows package nanopb-0.4.3-windows-x86.zip. The package was replaced by nanopb-0.4.3-p1-windows-x86.zip with rebuilt PyInstaller 4.0, which seems to avoid the problem. Actual nanopb code is unchanged between the packages. nanopb-0.4.2 (2020-06-23) Fix buffer overflow when encoding bytes with size set to 65535 (#547, GHSA-3p39-mfxg-hrq4) Fix segfault with pointer fields and proto3_singular_msgs = true. (#504,#505) Fix Windows 10 temp file handling (#486) Fix macro name conflicts (ATMEGA32U4 UENUM and more) (#522) Fix generator error with nested messages and default values (#487) Fix nanopb_generator exception on enums with aliases (#535) Fix compile error when struct members are called X or a (#492) Fix sizeof(union ...) fallback not compiling with C++ (#415, #494) Fix "missing required field" error with submessage callback (#544) Fix field descriptor sizing with submsg_callback option (#545) Fix protoc calling on Python 2 (#503) Fix handling of varying NaN representations in PB_CONVERT_DOUBLE_FLOAT (#543) Fix clang undefined behavior sanitizer errors. Change generator to use Python 3 by default (#441, #509) Binary packages updated to use Python 3 and grpcio-tools Add support for infinity and nan floating-point defaults (#530, #538) Add generator option sort_by_tag (#542) Add type_override option to override type defined in .proto (#497) Set proto2 enum fields to first value when no default is given, even if nonzero (#532,#539) Include protoc-gen-nanopb in path in protoc wrapper script Properly pass error status from protoc wrapper when calling binary protoc Generator: pass --include_imports when calling protoc (#494) Create intermediate directories when writing files to relative path (#512) Add current directory to include path for protoc (#499) Update readme to use nanopb_generator.py directly Regression test for proto3 incorrectly considered empty (#504) CMake: change package name to Nanopb for cmake 3.17 compatibility (#506) CMake: remove find_package(PythonInterp) (#508) CMake: use split --nanopb_opt only on protoc >= 3.6 (#515) CMake: Relax python version spec, allowing Python3. (#534) Swift package manager (#549) Rename BUILD as BUILD.bazel (#537) Note: Windows binary packages in 0.4.2 and later require Windows 7 or newer. nanopb-0.4.1 (2020-02-02) Fix invalid free() after failed realloc() (GHSA-gcx3-7m76-287p) Avoid overflows in allocation for packed fields. Verify stream size before allocating string / bytes. Add workaround for avr-libc realloc() bug (#475) Fix bug with field numbers >255 (#407) Fix compilation error on platforms without uint8_t (#485) Fix warnings on Python3.8 (#399, #467) Make fixed_count option work when combined with FT_POINTER. Add missing #define for submsg callbacks, add regression test (#472) Fix ImportError when using generator/protoc with Python 3 Remove accidental debug code in generator Reduce stack usage (#484) Remove PB_FIELDINFO_WIDTH option (#473) Add nanopb-specific package name option (#422) Add testcase for Any type (#163) Add exclude option also from .proto/.options Set default include path in the grpc_tools protoc wrapper. Add workaround for python-protobuf 3.6.1 bug (#478) Detect invalid wire type when decoding fields. Improved fuzz testing nanopb-0.4.0 (2019-12-20) New field descriptor format. Make nanopb_generator automatically compile .proto files (#462) Allow installing as Python package from pip (#460) Use protoc from grpcio-tools Python package if available (#463) Change proto3 message types to be optional (#308, #452) Add pb_decode_ex(), pb_encode_ex() functions. Automatically rebuild nanopb_pb2.py Use plugin.proto that comes with python-protobuf (#234) Allow specifying a per-message callback. (#175) Improve callback handling inside oneofs. (#175) Introduce new compile time flag: PB_VALIDATE_UTF8 (#437) Add TypenameMangling.M_PACKAGE_INITIALS (#394) Introduce new compile time flag: PB_ENCODE_ARRAYS_UNPACKED (#427) Add default_has option (#423) Add option for including extra files from .pb.h Add generator option to error out on unmatched options (#458) Generator: Allow comma separated options in plugin mode (#343) Allow comma-separated option parsing to handle `#include` (#450) Remove timestamp from generated files by default, add -t to keep it. Make --no-strip-path default (#326) Fix .options file case sensitivity on Windows. Fix generator error with mangle_names option (#380) Take int_size setting into account in calculating message sizes (#373) .gitignore: don't ignore generator-bin files (#419) Cleanup .pb.h header format Make tests run on AVR and STM32 Add PB_CONVERT_DOUBLE_FLOAT setting to convert doubles on AVR. Store field descriptor constants in flash on AVR (#464) Added "f" suffix to const float declarations. (#453) Fix clang-tidy warnings about using signed integers in binary bitwise operations (#451) Add C++ message descriptors helper (#384) Implement conan recipe (#378) CMake: Split nanopb_out command (#454) CMake: install created shared library(dll) in windows to the binary folder (#447) nanopb-0.3.9.9 (2022-04-23) Fix Xcode analyzer warnings (#667, #674) Fix clang sanitizer warnings Note: there are no known functional differences between 0.3.9.8 and 0.3.9.9. The changes are merely to fix warnings introduced by new compiler versions. nanopb-0.3.9.8 (2021-03-22) Fix invalid free() with oneof (#647, GHSA-7mv5-5mxh-qg88) Don't generate lines with trailing spaces (#622) Verify stream size before allocating string / bytes (#620) nanopb-0.3.9.7 (2020-11-25) Fix memory leak with oneofs and PB_ENABLE_MALLOC (#615, GHSA-85rr-4rh9-hhwh) Fix unsigned enums not working correctly inside OneOf (#611) Add '--version' option to nanopb_generator.py (#607) SwiftPM rule updates (#567, #585) nanopb-0.3.9.6 (2020-06-23) Fix buffer overflow when encoding bytes with size set to 65535 (#547, GHSA-3p39-mfxg-hrq4) Fix proto3 submessage improperly considered empty (#504) Fix ImportError when using generator/protoc with Python 3 Add build rules for Swift package manager (#549) nanopb-0.3.9.5 (2020-02-02) Fix invalid free() after failed realloc() (GHSA-gcx3-7m76-287p) Add workaround for avr-libc realloc() bug (#475) Fix empty submessages getting encoded in proto3 mode (#395) Avoid overflows in allocation for packed fields. nanopb-0.3.9.4 (2019-10-13) Fix undefined behavior with bool fields (#434) Fix enum min/max defines when values are not in order (#405) Fix network_server socket example with zero-length strings (#421) Don't call stream read callback with count=0 (#421) Add compile time flag PB_ENCODE_ARRAYS_UNPACKED (#427) nanopb-0.3.9.3 (2019-03-08) NOTE: nanopb-0.3.9.3.tar.gz before 2019-03-21 was accidentally from 0.4 branch (#388) Fix fixed size and callback repeated fields inside proto3 submessages (#376, #382, #386) Fix incorrect PB_STATIC_ASSERT for bytes inside oneof (#363) Fix generator error with mangle_names option (#380) Generator: Allow comma separated options in plugin mode (#343) nanopb-0.3.9.2 (2018-11-10) Erroneous free() when using callbacks combined with PB_ENABLE_MALLOC (#346) Fix possible null-pointer dereference in decode_callback_field (#342) Fix FindNanopb.cmake on Windows (#335) Fix large generator memory usage with oneof fields (#338) Fix error in splint test (#359) Allow cmake to build as a shared library (#352, #353) Add --no-strip-path command line option (#326) Option for flattening nested protobuf names (#333) Documentation fixes (#329, #350, #358) Better error messages (#351) nanopb-0.3.9.1 (2018-04-14) Fix handling of special characters in string/bytes default values (issue #322) Fix encoding of negative numbers with PB_WITHOUT_64BIT (#285) Fix _zero initializer for enums that don't begin at 0. (#295) Multiple CMake fixes (#296, #299, #304, #312, #320) Fix compiler warnings (#305) Fix scons rules for Python 3 Add check for large extension field number (issue #306) Updated included descriptor.proto version (#314) Resolve oneof sizes symbolically when needed (#311) Add fixed_count option (#260) Add some verbose prints in generator (issue #238) Add test/example of using 'map' type. (#289) nanopb-0.3.9 (2017-09-23) Fix bugs in proto3 encoding of submessages (#256) Fix message size calculation for arrays of size 1 (#253) Fix segfault with FT_CALLBACK inside FT_POINTER (#259) Properly detect truncated tags in corrupted messages (#277) Make pb_decode_varint32 overflow checks exact (#258) Add option to build without 64-bit support (#86) Add options to define source and header file extensions (#264) Add pb_en/decode_nullterminated() (part of #278) Add pb_decode_delimited_noinit (#284) CMake: add dependency for .options file (#265) CMake: change use of relative paths (#250,#271,#273) Better error message for missing max_size option (#281) Travis-CI build fixes (#283) Add Bazel build system file (#266) nanopb-0.3.8 (2017-03-05) Fix problems with multiple oneofs in same message (#229) Zero-valued extension fields were mistakenly ignored by encoder (#242) Multiple fixes related to proto3 mode (#242, #245, #247, #249) Fix potential unaligned access (#226, #227) Fix documentation for protoc --plugin argument (#239) Extend inline / fixed length bytes array support (#244) Add new option max_length for strings (#107) Make string substream API more robust (#230) Make pb_decode_varint32 public API (#231) Allow overriding proto3 mode (#228) Add optional enum->string mapping function (#223) Add transitional options.proto file (#241) Add better error message on Python library version incompatibility (#240) Include version number in PlatformIO library.json (#222) CMake build script changes (#236, #237) Change download links to https Improvements to test cases. nanopb-0.3.7 (2016-10-30) Add support for proto3-style singular fields (#182, #206, #216) Updated binary package protoc to version 3.1.0 Add FT_INLINE allocation of bytes fields (#211) Include package name in include guard (#207) Fix missing warning with large bytes fields (issue #220) Added CMake project (#208) Add bazel BUILD file for nanopb (#209) Added an AUTHORS file (#211) Documentation updates Improvements to test cases. nanopb-0.3.6 (2016-06-19) Protect against corrupted _count fields in pb_release (#205) Fix error in STATIC_ASSERT with multiple files (#203) Add -D option to specify output directory (#193) Generate MIN/MAX/ARRAYSIZE defines for enums (#194) Generate comments about uncalculable message sizes (#195) Documentation updates (#196, #201) Improvements to test cases. nanopb-0.3.5 (2016-02-13) NOTE: If you are using pb_syshdr.h, you will need to add uint_least8_t definition. See docs/migration.rst for details. Fix generator crash with Enum inside Oneof (#188) Fix some generator regressions related to .options file path (#172) Add support for platforms without uint8_t (#191) Allow const parameter to pb_istream_from_buffer (#152) Ignore null pointers in pb_release() (#183) Add support for anonymous unions (#184) Add Python3 support to the generator (#169) Add code generator insertion points to generated files (#178) Improvements to CMake script (#181) Improvements to test cases. nanopb-0.3.4 (2015-09-26) Fix handling of unsigned 8- and 16-bit enums (issue 164) Fix generator on systems where python = python3. (issue 155) Fix compiler warning on GCC 5.x (issue 171) Make the generator better handle imported .protos (issue 165) Add packed_enum option to generator. Add syntax= line to .proto files (issue 167) Add PlatformIO registry manifest file. (pr 156) nanopb-0.3.3 (2015-04-10) Fix missing files in Linux binary package (issue 146) Fix generator bug when oneof is first field in a message. (issue 142) Fix generator error when long_names:false is combined with Oneofs. (issue 147) Fix oneof submessage initialization bug. (issue 149) Fix problem with plugin options on Python 2.7.2 and older. (issue 153) Fix crash when callback is inside oneof field. (issue 148) Switch to .tar.gz format for Mac OS X packages. (issue 154) Always define enum long names so that cross-file references work. (issue 118) Add msgid generator option. (issue 151) Improve comment support in .options files. (issue 145) Updates for the CMake rule file, add cmake example. Better error messages for syntax errors in .options file nanopb-0.3.2 (2015-01-24) Fix memory leaks with PB_ENABLE_MALLOC with some submessage hierarchies (issue 138) Implement support for oneofs (C unions). (issues 131, 141) Add int_size option for generator (issue 139) Add compilation option to disable struct packing. (issue 136) Change PB_RETURN_ERROR() macro to avoid compiler warnings (issue 140) Fix build problems with protoc 3.0.0 Add support for POINTER type in extensions Initialize also extension fields to defaults in pb_decode(). Detect too large varint values when decoding. nanopb-0.3.1 (2014-09-11) Fix security issue due to size_t overflows. (issue 132) Fix memory leak with duplicated fields and PB_ENABLE_MALLOC Fix crash if pb_release() is called twice. Fix cyclic message support (issue 130) Fix error in generated initializers for repeated pointer fields. Improve tests (issues 113, 126) nanopb-0.3.0 (2014-08-26) NOTE: See docs/migration.html or online at http://koti.kapsi.fi/~jpa/nanopb/docs/migration.html for changes in this version. Most importantly, you need to add pb_common.c to the list of files to compile. Separated field iterator logic to pb_common.c (issue 128) Change the _count fields to use pb_size_t datatype (issue 82) Added PB_ prefix to macro names (issue 106) Added #if version guard to generated files (issue 129) Added migration document nanopb-0.2.9.5 (2020-06-23) Fix buffer overflow when encoding bytes with size set to 65535 (#547, GHSA-3p39-mfxg-hrq4) Backport Python 3 and protoc 3.x fixes to test cases nanopb-0.2.9.4 (2020-02-02) Fix invalid free() after failed realloc() (GHSA-gcx3-7m76-287p) Add workaround for avr-libc realloc() bug (#475) nanopb-0.2.9.3 (2016-06-19) Protect against corrupted _count fields in pb_release (#205) nanopb-0.2.9.2 (2015-01-24) Fix memory leaks with PB_ENABLE_MALLOC with some submessage hierarchies (issue 138) Fix compilation error with generated initializers for repeated pointer fields nanopb-0.2.9.1 (2014-09-11) Fix security issue due to size_t overflows. (issue 132) Fix memory leak with duplicated fields and PB_ENABLE_MALLOC Fix crash if pb_release() is called twice. nanopb-0.2.9 (2014-08-09) NOTE: If you are using the -e option with the generator, you have to prepend . to the argument to get the same behaviour as before. Do not automatically add a dot with generator -e option. (issue 122) Fix problem with .options file and extension fields. (issue 125) Don't use SIZE_MAX macro, as it is not in C89. (issue 120) Generate #defines for initializing message structures. (issue 79) Add skip_message option to generator. (issue 121) Add PB_PACKED_STRUCT support for Keil MDK-ARM toolchain (issue 119) Give better messages about the .options file path. (issue 124) Improved tests nanopb-0.2.8 (2014-05-20) Fix security issue with PB_ENABLE_MALLOC. (issue 117) Add option to not add timestamps to .pb.h and .pb.c preambles. (issue 115) Documentation updates Improved tests nanopb-0.2.7 (2014-04-07) Fix bug with default values for extension fields (issue 111) Fix some MISRA-C warnings (issue 91) Implemented optional malloc() support (issue 80) Changed pointer-type bytes field datatype Add a "found" field to pb_extension_t (issue 112) Add convenience function pb_get_encoded_size() (issue 16) nanopb-0.2.6 (2014-02-15) Fix generator error with bytes callback fields (issue 99) Fix warnings about large integer constants (issue 102) Add comments to where STATIC_ASSERT is used (issue 96) Add warning about unknown field names on .options (issue 105) Move descriptor.proto to google/protobuf subdirectory (issue 104) Improved tests nanopb-0.2.5 (2014-01-01) Fix a bug with encoding negative values in int32 fields (issue 97) Create binary packages of the generator + dependencies (issue 47) Add support for pointer-type fields to the encoder (part of issue 80) Fixed path in FindNanopb.cmake (issue 94) Improved tests nanopb-0.2.4 (2013-11-07) Remove the deprecated NANOPB_INTERNALS functions from public API. Document the security model. Check array and bytes max sizes when encoding (issue 90) Add #defines for maximum encoded message size (issue 89) Add #define tags for extension fields (issue 93) Fix MISRA C violations (issue 91) Clean up pb_field_t definition with typedefs. nanopb-0.2.3 (2013-09-18) Improve compatibility by removing ternary operator from initializations (issue 88) Fix build error on Visual C++ (issue 84, patch by Markus Schwarzenberg) Don't stop on unsupported extension fields (issue 83) Add an example pb_syshdr.h file for non-C99 compilers Reorganize tests and examples into subfolders (issue 63) Switch from Makefiles to scons for building the tests Make the tests buildable on Windows nanopb-0.2.2 (2013-08-18) Add support for extension fields (issue 17) Fix unknown fields in empty message (issue 78) Include the field tags in the generated .pb.h file. Add pb_decode_delimited and pb_encode_delimited wrapper functions (issue 74) Add a section in top of pb.h for changing compilation settings (issue 76) Documentation improvements (issues 12, 77 and others) Improved tests nanopb-0.2.1 (2013-04-14) NOTE: The default callback function signature has changed. If you don't want to update your code, define PB_OLD_CALLBACK_STYLE. Change the callback function to use void** (issue 69) Add support for defining the nanopb options in a separate file (issue 12) Add support for packed structs in IAR and MSVC (in addition to GCC) (issue 66) Implement error message support for the encoder side (issue 7) Handle unterminated strings when encoding (issue 68) Fix bug with empty strings in repeated string callbacks (issue 73) Fix regression in 0.2.0 with optional callback fields (issue 70) Fix bugs with empty message types (issues 64, 65) Fix some compiler warnings on clang (issue 67) Some portability improvements (issues 60, 62) Various new generator options Improved tests nanopb-0.2.0 (2013-03-02) NOTE: This release requires you to regenerate all .pb.c files. Files generated by older versions will not compile anymore. Reformat generated .pb.c files using macros (issue 58) Rename PB_HTYPE_ARRAY -> PB_HTYPE_REPEATED Separate PB_HTYPE to PB_ATYPE and PB_HTYPE Move STATIC_ASSERTs to .pb.c file Added CMake file (by Pavel Ilin) Add option to give file extension to generator (by Michael Haberler) Documentation updates nanopb-0.1.9 (2013-02-13) Fixed error message bugs (issues 52, 56) Sanitize #ifndef filename (issue 50) Performance improvements Add compile-time option PB_BUFFER_ONLY Add Java package name to nanopb.proto Check for sizeof(double) == 8 (issue 54) Added generator option to ignore some fields. (issue 51) Added generator option to make message structs packed. (issue 49) Add more test cases. nanopb-0.1.8 (2012-12-13) Fix bugs in the enum short names introduced in 0.1.7 (issues 42, 43) Fix STATIC_ASSERT macro when using multiple .proto files. (issue 41) Fix missing initialization of istream.errmsg Make tests/Makefile work for non-gcc compilers (issue 40) nanopb-0.1.7 (2012-11-11) Remove "skip" mode from pb_istream_t callbacks. Example implementation had a bug. (issue 37) Add option to use shorter names for enum values (issue 38) Improve options support in generator (issues 12, 30) Add nanopb version number to generated files (issue 36) Add extern "C" to generated headers (issue 35) Add names for structs to allow forward declaration (issue 39) Add buffer size check in example (issue 34) Fix build warnings on MS compilers (issue 33) nanopb-0.1.6 (2012-09-02) Reorganize the field decoder interface (issue 2) Improve performance in submessage decoding (issue 28) Implement error messages in the decoder side (issue 7) Extended testcases (alltypes test is now complete). Fix some compiler warnings (issues 25, 26, 27, 32). nanopb-0.1.5 (2012-08-04) Fix bug in decoder with packed arrays (issue 23). Extended testcases. Fix some compiler warnings. nanopb-0.1.4 (2012-07-05) Add compile-time options for easy-to-use >255 field support. Improve the detection of missing required fields. Added example on how to handle union messages. Fix generator error with .proto without messages. Fix problems that stopped the code from compiling with some compilers. Fix some compiler warnings. nanopb-0.1.3 (2012-06-12) Refactor the field encoder interface. Improve generator error messages (issue 5) Add descriptor.proto into the #include exclusion list Fix some compiler warnings. nanopb-0.1.2 (2012-02-15) Make the generator to generate include for other .proto files (issue 4). Fixed generator not working on Windows (issue 3) nanopb-0.1.1 (2012-01-14) Fixed bug in encoder with 'bytes' fields (issue 1). Fixed a bug in the generator that caused a compiler error on sfixed32 and sfixed64 fields. Extended testcases. nanopb-0.1.0 (2012-01-06) First stable release. nanopb-0.4.9.1/CMakeLists.txt000066400000000000000000000153451472303430400157100ustar00rootroot00000000000000cmake_minimum_required(VERSION 3.14.0) project(nanopb VERSION 0.4.9.1 LANGUAGES C) set(nanopb_VERSION_STRING ${PROJECT_NAME}-${${PROJECT_NAME}_VERSION}-dev) set(nanopb_SOVERSION 0) string(REPLACE "nanopb-" "" nanopb_VERSION ${nanopb_VERSION_STRING}) option(BUILD_SHARED_LIBS "Build shared libraries" OFF) option(BUILD_STATIC_LIBS "Build static libraries" ON) option(nanopb_BUILD_RUNTIME "Build the headers and libraries needed at runtime" ON) option(nanopb_BUILD_GENERATOR "Build the protoc plugin for code generation" ON) option(nanopb_MSVC_STATIC_RUNTIME "Link static runtime libraries" ON) set(nanopb_PYTHON_INSTDIR_OVERRIDE "" CACHE PATH "Override the default python installation directory with the given path") find_program(nanopb_PROTOC_PATH protoc PATHS generator-bin generator NO_DEFAULT_PATH) find_program(nanopb_PROTOC_PATH protoc) if(NOT EXISTS ${nanopb_PROTOC_PATH}) message(FATAL_ERROR "protoc compiler not found") endif() if(NOT DEFINED CMAKE_DEBUG_POSTFIX) set(CMAKE_DEBUG_POSTFIX "d") endif() include(GNUInstallDirs) if(MSVC AND nanopb_MSVC_STATIC_RUNTIME) foreach(flag_var CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO) if(${flag_var} MATCHES "/MD") string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}") endif(${flag_var} MATCHES "/MD") endforeach(flag_var) endif() if(NOT DEFINED CMAKE_INSTALL_CMAKEDIR) set(CMAKE_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/nanopb") endif() # Determine Python module installation path if (NOT nanopb_PYTHON_INSTDIR_OVERRIDE) find_package(Python REQUIRED COMPONENTS Interpreter) file(TO_CMAKE_PATH "${Python_SITELIB}" PYTHON_INSTDIR) else() set(PYTHON_INSTDIR ${nanopb_PYTHON_INSTDIR_OVERRIDE}) endif() message(STATUS "Python install dir: ${PYTHON_INSTDIR}") # Package nanopb generator as Python module 'nanopb' if(nanopb_BUILD_GENERATOR) # Copy Python code files related to the generator add_custom_target(nanopb_generator ALL COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_BINARY_DIR}/nanopb/generator/proto COMMAND ${CMAKE_COMMAND} -E copy_if_different ${PROJECT_SOURCE_DIR}/generator/proto/_utils.py ${PROJECT_SOURCE_DIR}/generator/proto/__init__.py ${PROJECT_SOURCE_DIR}/generator/proto/nanopb.proto ${PROJECT_BINARY_DIR}/nanopb/generator/proto COMMAND ${CMAKE_COMMAND} -E copy_if_different ${PROJECT_SOURCE_DIR}/generator/nanopb_generator.py ${PROJECT_SOURCE_DIR}/generator/__init__.py ${PROJECT_BINARY_DIR}/nanopb/generator COMMAND ${CMAKE_COMMAND} -E copy_if_different ${PROJECT_SOURCE_DIR}/generator/__init__.py ${PROJECT_BINARY_DIR}/nanopb COMMAND ${nanopb_PROTOC_PATH} --python_out=${PROJECT_BINARY_DIR}/nanopb/generator/proto -I${PROJECT_SOURCE_DIR}/generator/proto ${PROJECT_SOURCE_DIR}/generator/proto/nanopb.proto ) # Install Python module files install( DIRECTORY ${PROJECT_BINARY_DIR}/nanopb DESTINATION ${PYTHON_INSTDIR} FILES_MATCHING PATTERN *.py PATTERN *.proto PATTERN __pycache__ EXCLUDE ) # Generate a wrapper script that calls nanopb.generator Python module when invoked configure_file( extra/script_wrappers/nanopb_generator.py.in ${PROJECT_BINARY_DIR}/nanopb_generator.py ) install( PROGRAMS ${PROJECT_BINARY_DIR}/nanopb_generator.py DESTINATION ${CMAKE_INSTALL_BINDIR} ) # Install shell/bat script wrappers for invoking nanopb_generator.py. # protoc-gen-nanopb is automatically used by protoc when --nanopb_out= option is used. if(WIN32) # Include the full path to Python executable in Windows .bat scripts, as it is not in PATH on all systems file(READ generator/protoc-gen-nanopb.bat FILE_CONTENTS) string(REPLACE "python" ${Python_EXECUTABLE} FILE_CONTENTS "${FILE_CONTENTS}") file(WRITE ${PROJECT_BINARY_DIR}/protoc-gen-nanopb.bat "${FILE_CONTENTS}") file(READ generator/nanopb_generator.bat FILE_CONTENTS) string(REPLACE "python" ${Python_EXECUTABLE} FILE_CONTENTS "${FILE_CONTENTS}") file(WRITE ${PROJECT_BINARY_DIR}/nanopb_generator.bat "${FILE_CONTENTS}") install( PROGRAMS ${PROJECT_BINARY_DIR}/protoc-gen-nanopb.bat ${PROJECT_BINARY_DIR}/nanopb_generator.bat DESTINATION ${CMAKE_INSTALL_BINDIR} ) else() # Linux/Mac scripts currently use python3 from PATH install( PROGRAMS generator/protoc-gen-nanopb generator/nanopb_generator DESTINATION ${CMAKE_INSTALL_BINDIR} ) endif() endif() if(nanopb_BUILD_RUNTIME) if(BUILD_SHARED_LIBS) add_library(protobuf-nanopb SHARED pb.h pb_common.h pb_common.c pb_encode.h pb_encode.c pb_decode.h pb_decode.c) set_target_properties(protobuf-nanopb PROPERTIES SOVERSION ${nanopb_SOVERSION}) install(TARGETS protobuf-nanopb EXPORT nanopb-targets ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) target_include_directories(protobuf-nanopb INTERFACE $ $ ) endif() if(BUILD_STATIC_LIBS) add_library(protobuf-nanopb-static STATIC pb.h pb_common.h pb_common.c pb_encode.h pb_encode.c pb_decode.h pb_decode.c) set_target_properties(protobuf-nanopb-static PROPERTIES OUTPUT_NAME protobuf-nanopb) install(TARGETS protobuf-nanopb-static EXPORT nanopb-targets ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) target_include_directories(protobuf-nanopb-static INTERFACE $ $ ) endif() configure_file(extra/nanopb-config-version.cmake.in nanopb-config-version.cmake @ONLY) install(EXPORT nanopb-targets DESTINATION ${CMAKE_INSTALL_CMAKEDIR} NAMESPACE nanopb::) install(FILES extra/nanopb-config.cmake ${CMAKE_CURRENT_BINARY_DIR}/nanopb-config-version.cmake DESTINATION ${CMAKE_INSTALL_CMAKEDIR}) install(FILES pb.h pb_common.h pb_encode.h pb_decode.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/nanopb) endif() nanopb-0.4.9.1/CONTRIBUTING.md000066400000000000000000000023131472303430400153700ustar00rootroot00000000000000Contributing to Nanopb development ================================== Reporting issues and requesting features ---------------------------------------- Feel free to report any issues you see or features you would like to see in the future to the Github issue tracker. Using the templates below is preferred: * [Report a bug](https://github.com/nanopb/nanopb/issues/new?body=**Steps%20to%20reproduce%20the%20issue**%0a%0a1.%0a2.%0a3.%0a%0a**What%20happens?**%0A%0A**What%20should%20happen?**&labels=Type-Defect) * [Request a feature](https://github.com/nanopb/nanopb/issues/new?body=**What%20should%20the%20feature%20do?**%0A%0A**In%20what%20situation%20would%20the%20feature%20be%20useful?**&labels=Type-Enhancement) Requesting help --------------- If there is something strange going on, but you do not know if it is actually a bug in nanopb, try asking first on the [discussion forum](https://groups.google.com/forum/#!forum/nanopb). Pull requests ------------- Pull requests are welcome! If it is not obvious from the commit message, please indicate the same information as you would for an issue report: * What functionality it fixes/adds. * How can the problem be reproduced / when would the feature be useful. nanopb-0.4.9.1/LICENSE.txt000066400000000000000000000016021472303430400147620ustar00rootroot00000000000000Copyright (c) 2011 Petteri Aimonen This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. nanopb-0.4.9.1/MODULE.bazel000066400000000000000000000015501472303430400151450ustar00rootroot00000000000000module( name = "nanopb", version = "0.4.9", ) bazel_dep(name = "bazel_skylib", version = "1.7.1") bazel_dep(name = "rules_cc", version = "0.0.10") bazel_dep(name = "rules_python", version = "0.35.0") bazel_dep(name = "rules_proto", version = "6.0.2") bazel_dep(name = "protobuf", version = "28.2") bazel_dep(name = "rules_proto_grpc", version = "5.0.0") pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip") python = use_extension("@rules_python//python/extensions:python.bzl", "python") PYTHON_VERSION = "3.11" # No need for this since rules_python already creates our version. # python.toolchain(python_version = PYTHON_VERSION) use_repo(python, "python_versions") use_repo(pip, "nanopb_pypi") pip.parse( hub_name = "nanopb_pypi", python_version = PYTHON_VERSION, requirements_lock = "@nanopb//:extra/requirements_lock.txt", ) nanopb-0.4.9.1/MODULE.bazel.lock000066400000000000000000000340251472303430400160770ustar00rootroot00000000000000{ "lockFileVersion": 11, "registryFileHashes": { "https://bcr.bazel.build/bazel_registry.json": "8a28e4aff06ee60aed2a8c281907fb8bcbf3b753c91fb5a5c57da3215d5b3497", "https://bcr.bazel.build/modules/abseil-cpp/20210324.2/MODULE.bazel": "7cd0312e064fde87c8d1cd79ba06c876bd23630c83466e9500321be55c96ace2", "https://bcr.bazel.build/modules/abseil-cpp/20211102.0/MODULE.bazel": "70390338f7a5106231d20620712f7cccb659cd0e9d073d1991c038eb9fc57589", "https://bcr.bazel.build/modules/abseil-cpp/20230125.1/MODULE.bazel": "89047429cb0207707b2dface14ba7f8df85273d484c2572755be4bab7ce9c3a0", "https://bcr.bazel.build/modules/abseil-cpp/20230802.0.bcr.1/MODULE.bazel": "1c8cec495288dccd14fdae6e3f95f772c1c91857047a098fad772034264cc8cb", "https://bcr.bazel.build/modules/abseil-cpp/20230802.0.bcr.1/source.json": "14892cc698e02ffedf4967546e6bedb7245015906888d3465fcf27c90a26da10", "https://bcr.bazel.build/modules/apple_support/1.5.0/MODULE.bazel": "50341a62efbc483e8a2a6aec30994a58749bd7b885e18dd96aa8c33031e558ef", "https://bcr.bazel.build/modules/apple_support/1.5.0/source.json": "eb98a7627c0bc486b57f598ad8da50f6625d974c8f723e9ea71bd39f709c9862", "https://bcr.bazel.build/modules/bazel_features/1.11.0/MODULE.bazel": "f9382337dd5a474c3b7d334c2f83e50b6eaedc284253334cf823044a26de03e8", "https://bcr.bazel.build/modules/bazel_features/1.11.0/source.json": "c9320aa53cd1c441d24bd6b716da087ad7e4ff0d9742a9884587596edfe53015", "https://bcr.bazel.build/modules/bazel_features/1.4.1/MODULE.bazel": "e45b6bb2350aff3e442ae1111c555e27eac1d915e77775f6fdc4b351b758b5d7", "https://bcr.bazel.build/modules/bazel_features/1.9.0/MODULE.bazel": "885151d58d90d8d9c811eb75e3288c11f850e1d6b481a8c9f766adee4712358b", "https://bcr.bazel.build/modules/bazel_features/1.9.1/MODULE.bazel": "8f679097876a9b609ad1f60249c49d68bfab783dd9be012faf9d82547b14815a", "https://bcr.bazel.build/modules/bazel_skylib/1.0.3/MODULE.bazel": "bcb0fd896384802d1ad283b4e4eb4d718eebd8cb820b0a2c3a347fb971afd9d8", "https://bcr.bazel.build/modules/bazel_skylib/1.2.0/MODULE.bazel": "44fe84260e454ed94ad326352a698422dbe372b21a1ac9f3eab76eb531223686", "https://bcr.bazel.build/modules/bazel_skylib/1.2.1/MODULE.bazel": "f35baf9da0efe45fa3da1696ae906eea3d615ad41e2e3def4aeb4e8bc0ef9a7a", "https://bcr.bazel.build/modules/bazel_skylib/1.3.0/MODULE.bazel": "20228b92868bf5cfc41bda7afc8a8ba2a543201851de39d990ec957b513579c5", "https://bcr.bazel.build/modules/bazel_skylib/1.4.1/MODULE.bazel": "a0dcb779424be33100dcae821e9e27e4f2901d9dfd5333efe5ac6a8d7ab75e1d", "https://bcr.bazel.build/modules/bazel_skylib/1.5.0/MODULE.bazel": "32880f5e2945ce6a03d1fbd588e9198c0a959bb42297b2cfaf1685b7bc32e138", "https://bcr.bazel.build/modules/bazel_skylib/1.6.1/MODULE.bazel": "8fdee2dbaace6c252131c00e1de4b165dc65af02ea278476187765e1a617b917", "https://bcr.bazel.build/modules/bazel_skylib/1.7.1/MODULE.bazel": "3120d80c5861aa616222ec015332e5f8d3171e062e3e804a2a0253e1be26e59b", "https://bcr.bazel.build/modules/bazel_skylib/1.7.1/source.json": "f121b43eeefc7c29efbd51b83d08631e2347297c95aac9764a701f2a6a2bb953", "https://bcr.bazel.build/modules/buildozer/7.1.2/MODULE.bazel": "2e8dd40ede9c454042645fd8d8d0cd1527966aa5c919de86661e62953cd73d84", "https://bcr.bazel.build/modules/buildozer/7.1.2/source.json": "c9028a501d2db85793a6996205c8de120944f50a0d570438fcae0457a5f9d1f8", "https://bcr.bazel.build/modules/googletest/1.11.0/MODULE.bazel": "3a83f095183f66345ca86aa13c58b59f9f94a2f81999c093d4eeaa2d262d12f4", "https://bcr.bazel.build/modules/googletest/1.14.0/MODULE.bazel": "cfbcbf3e6eac06ef9d85900f64424708cc08687d1b527f0ef65aa7517af8118f", "https://bcr.bazel.build/modules/googletest/1.14.0/source.json": "2478949479000fdd7de9a3d0107ba2c85bb5f961c3ecb1aa448f52549ce310b5", "https://bcr.bazel.build/modules/platforms/0.0.10/MODULE.bazel": "8cb8efaf200bdeb2150d93e162c40f388529a25852b332cec879373771e48ed5", "https://bcr.bazel.build/modules/platforms/0.0.10/source.json": "f22828ff4cf021a6b577f1bf6341cb9dcd7965092a439f64fc1bb3b7a5ae4bd5", "https://bcr.bazel.build/modules/platforms/0.0.4/MODULE.bazel": "9b328e31ee156f53f3c416a64f8491f7eb731742655a47c9eec4703a71644aee", "https://bcr.bazel.build/modules/platforms/0.0.5/MODULE.bazel": "5733b54ea419d5eaf7997054bb55f6a1d0b5ff8aedf0176fef9eea44f3acda37", "https://bcr.bazel.build/modules/platforms/0.0.6/MODULE.bazel": "ad6eeef431dc52aefd2d77ed20a4b353f8ebf0f4ecdd26a807d2da5aa8cd0615", "https://bcr.bazel.build/modules/platforms/0.0.7/MODULE.bazel": "72fd4a0ede9ee5c021f6a8dd92b503e089f46c227ba2813ff183b71616034814", "https://bcr.bazel.build/modules/platforms/0.0.8/MODULE.bazel": "9f142c03e348f6d263719f5074b21ef3adf0b139ee4c5133e2aa35664da9eb2d", "https://bcr.bazel.build/modules/platforms/0.0.9/MODULE.bazel": "4a87a60c927b56ddd67db50c89acaa62f4ce2a1d2149ccb63ffd871d5ce29ebc", "https://bcr.bazel.build/modules/protobuf/21.7/MODULE.bazel": "a5a29bb89544f9b97edce05642fac225a808b5b7be74038ea3640fae2f8e66a7", "https://bcr.bazel.build/modules/protobuf/23.1/MODULE.bazel": "88b393b3eb4101d18129e5db51847cd40a5517a53e81216144a8c32dfeeca52a", "https://bcr.bazel.build/modules/protobuf/24.4/MODULE.bazel": "7bc7ce5f2abf36b3b7b7c8218d3acdebb9426aeb35c2257c96445756f970eb12", "https://bcr.bazel.build/modules/protobuf/24.4/source.json": "ace4b8c65d4cfe64efe544f09fc5e5df77faf3a67fbb29c5341e0d755d9b15d6", "https://bcr.bazel.build/modules/protobuf/3.19.0/MODULE.bazel": "6b5fbb433f760a99a22b18b6850ed5784ef0e9928a72668b66e4d7ccd47db9b0", "https://bcr.bazel.build/modules/protobuf/3.19.6/MODULE.bazel": "9233edc5e1f2ee276a60de3eaa47ac4132302ef9643238f23128fea53ea12858", "https://bcr.bazel.build/modules/rules_cc/0.0.1/MODULE.bazel": "cb2aa0747f84c6c3a78dad4e2049c154f08ab9d166b1273835a8174940365647", "https://bcr.bazel.build/modules/rules_cc/0.0.2/MODULE.bazel": "6915987c90970493ab97393024c156ea8fb9f3bea953b2f3ec05c34f19b5695c", "https://bcr.bazel.build/modules/rules_cc/0.0.6/MODULE.bazel": "abf360251023dfe3efcef65ab9d56beefa8394d4176dd29529750e1c57eaa33f", "https://bcr.bazel.build/modules/rules_cc/0.0.8/MODULE.bazel": "964c85c82cfeb6f3855e6a07054fdb159aced38e99a5eecf7bce9d53990afa3e", "https://bcr.bazel.build/modules/rules_cc/0.0.9/MODULE.bazel": "836e76439f354b89afe6a911a7adf59a6b2518fafb174483ad78a2a2fde7b1c5", "https://bcr.bazel.build/modules/rules_cc/0.0.9/source.json": "1f1ba6fea244b616de4a554a0f4983c91a9301640c8fe0dd1d410254115c8430", "https://bcr.bazel.build/modules/rules_java/4.0.0/MODULE.bazel": "5a78a7ae82cd1a33cef56dc578c7d2a46ed0dca12643ee45edbb8417899e6f74", "https://bcr.bazel.build/modules/rules_java/7.1.0/MODULE.bazel": "30d9135a2b6561c761bd67bd4990da591e6bdc128790ce3e7afd6a3558b2fb64", "https://bcr.bazel.build/modules/rules_java/7.6.1/MODULE.bazel": "2f14b7e8a1aa2f67ae92bc69d1ec0fa8d9f827c4e17ff5e5f02e91caa3b2d0fe", "https://bcr.bazel.build/modules/rules_java/7.6.1/source.json": "8f3f3076554e1558e8e468b2232991c510ecbcbed9e6f8c06ac31c93bcf38362", "https://bcr.bazel.build/modules/rules_jvm_external/4.4.2/MODULE.bazel": "a56b85e418c83eb1839819f0b515c431010160383306d13ec21959ac412d2fe7", "https://bcr.bazel.build/modules/rules_jvm_external/5.1/MODULE.bazel": "33f6f999e03183f7d088c9be518a63467dfd0be94a11d0055fe2d210f89aa909", "https://bcr.bazel.build/modules/rules_jvm_external/5.1/source.json": "5abb45cc9beb27b77aec6a65a11855ef2b55d95dfdc358e9f312b78ae0ba32d5", "https://bcr.bazel.build/modules/rules_license/0.0.3/MODULE.bazel": "627e9ab0247f7d1e05736b59dbb1b6871373de5ad31c3011880b4133cafd4bd0", "https://bcr.bazel.build/modules/rules_license/0.0.7/MODULE.bazel": "088fbeb0b6a419005b89cf93fe62d9517c0a2b8bb56af3244af65ecfe37e7d5d", "https://bcr.bazel.build/modules/rules_license/0.0.7/source.json": "355cc5737a0f294e560d52b1b7a6492d4fff2caf0bef1a315df5a298fca2d34a", "https://bcr.bazel.build/modules/rules_pkg/0.7.0/MODULE.bazel": "df99f03fc7934a4737122518bb87e667e62d780b610910f0447665a7e2be62dc", "https://bcr.bazel.build/modules/rules_pkg/0.7.0/source.json": "c2557066e0c0342223ba592510ad3d812d4963b9024831f7f66fd0584dd8c66c", "https://bcr.bazel.build/modules/rules_proto/4.0.0/MODULE.bazel": "a7a7b6ce9bee418c1a760b3d84f83a299ad6952f9903c67f19e4edd964894e06", "https://bcr.bazel.build/modules/rules_proto/5.3.0-21.7/MODULE.bazel": "e8dff86b0971688790ae75528fe1813f71809b5afd57facb44dad9e8eca631b7", "https://bcr.bazel.build/modules/rules_proto/6.0.0-rc1/MODULE.bazel": "1e5b502e2e1a9e825eef74476a5a1ee524a92297085015a052510b09a1a09483", "https://bcr.bazel.build/modules/rules_proto/6.0.0/MODULE.bazel": "b531d7f09f58dce456cd61b4579ce8c86b38544da75184eadaf0a7cb7966453f", "https://bcr.bazel.build/modules/rules_proto/6.0.2/MODULE.bazel": "ce916b775a62b90b61888052a416ccdda405212b6aaeb39522f7dc53431a5e73", "https://bcr.bazel.build/modules/rules_proto/6.0.2/source.json": "17a2e195f56cb28d6bbf763e49973d13890487c6945311ed141e196fb660426d", "https://bcr.bazel.build/modules/rules_proto_grpc/5.0.0/MODULE.bazel": "aad0151be788911f9736f413c423342d781a9dc19f35d3373c8581c828a387f4", "https://bcr.bazel.build/modules/rules_proto_grpc/5.0.0/source.json": "f35378dee74074450e6bb0755febb17879bddb705fe57270a213c8ee9c658a46", "https://bcr.bazel.build/modules/rules_python/0.10.2/MODULE.bazel": "cc82bc96f2997baa545ab3ce73f196d040ffb8756fd2d66125a530031cd90e5f", "https://bcr.bazel.build/modules/rules_python/0.22.1/MODULE.bazel": "26114f0c0b5e93018c0c066d6673f1a2c3737c7e90af95eff30cfee38d0bbac7", "https://bcr.bazel.build/modules/rules_python/0.34.0/MODULE.bazel": "1d623d026e075b78c9fde483a889cda7996f5da4f36dffb24c246ab30f06513a", "https://bcr.bazel.build/modules/rules_python/0.34.0/source.json": "113116e287eec64a7d005a9db44865d810499fdc4f621e352aff58214f5ea2d8", "https://bcr.bazel.build/modules/rules_python/0.4.0/MODULE.bazel": "9208ee05fd48bf09ac60ed269791cf17fb343db56c8226a720fbb1cdf467166c", "https://bcr.bazel.build/modules/stardoc/0.5.1/MODULE.bazel": "1a05d92974d0c122f5ccf09291442580317cdd859f07a8655f1db9a60374f9f8", "https://bcr.bazel.build/modules/stardoc/0.5.3/MODULE.bazel": "c7f6948dae6999bf0db32c1858ae345f112cacf98f174c7a8bb707e41b974f1c", "https://bcr.bazel.build/modules/stardoc/0.5.3/source.json": "cd53fe968dc8cd98197c052db3db6d82562960c87b61e7a90ee96f8e4e0dda97", "https://bcr.bazel.build/modules/toolchains_protoc/0.3.1/MODULE.bazel": "b6574a2a314cbd40cafb5ed87b03d1996e015315f80a7e33116c8b2e209cb5cf", "https://bcr.bazel.build/modules/toolchains_protoc/0.3.1/source.json": "b589ee1faec4c789c680afa9d500b5ccbea25422560b8b9dc4e0e6b26471f13b", "https://bcr.bazel.build/modules/upb/0.0.0-20220923-a547704/MODULE.bazel": "7298990c00040a0e2f121f6c32544bab27d4452f80d9ce51349b1a28f3005c43", "https://bcr.bazel.build/modules/upb/0.0.0-20230516-61a97ef/MODULE.bazel": "c0df5e35ad55e264160417fd0875932ee3c9dda63d9fccace35ac62f45e1b6f9", "https://bcr.bazel.build/modules/upb/0.0.0-20230516-61a97ef/source.json": "b2150404947339e8b947c6b16baa39fa75657f4ddec5e37272c7b11c7ab533bc", "https://bcr.bazel.build/modules/zlib/1.2.11/MODULE.bazel": "07b389abc85fdbca459b69e2ec656ae5622873af3f845e1c9d80fe179f3effa0", "https://bcr.bazel.build/modules/zlib/1.2.12/MODULE.bazel": "3b1a8834ada2a883674be8cbd36ede1b6ec481477ada359cd2d3ddc562340b27", "https://bcr.bazel.build/modules/zlib/1.3/MODULE.bazel": "6a9c02f19a24dcedb05572b2381446e27c272cd383aed11d41d99da9e3167a72", "https://bcr.bazel.build/modules/zlib/1.3/source.json": "b6b43d0737af846022636e6e255fd4a96fee0d34f08f3830e6e0bac51465c37c" }, "selectedYankedVersions": {}, "moduleExtensions": { "@@apple_support~//crosstool:setup.bzl%apple_cc_configure_extension": { "general": { "bzlTransitiveDigest": "PjIds3feoYE8SGbbIq2SFTZy3zmxeO2tQevJZNDo7iY=", "usagesDigest": "aLmqbvowmHkkBPve05yyDNGN7oh7QE9kBADr3QIZTZs=", "recordedFileInputs": {}, "recordedDirentsInputs": {}, "envVariables": {}, "generatedRepoSpecs": { "local_config_apple_cc": { "bzlFile": "@@apple_support~//crosstool:setup.bzl", "ruleClassName": "_apple_cc_autoconf", "attributes": {} }, "local_config_apple_cc_toolchains": { "bzlFile": "@@apple_support~//crosstool:setup.bzl", "ruleClassName": "_apple_cc_autoconf_toolchains", "attributes": {} } }, "recordedRepoMappingEntries": [ [ "apple_support~", "bazel_tools", "bazel_tools" ] ] } }, "@@platforms//host:extension.bzl%host_platform": { "general": { "bzlTransitiveDigest": "xelQcPZH8+tmuOHVjL9vDxMnnQNMlwj0SlvgoqBkm4U=", "usagesDigest": "V1R2Y2oMxKNfx2WCWpSCaUV1WefW1o8HZGm3v1vHgY4=", "recordedFileInputs": {}, "recordedDirentsInputs": {}, "envVariables": {}, "generatedRepoSpecs": { "host_platform": { "bzlFile": "@@platforms//host:extension.bzl", "ruleClassName": "host_platform_repo", "attributes": {} } }, "recordedRepoMappingEntries": [] } }, "@@protobuf~//:non_module_deps.bzl%non_module_deps": { "general": { "bzlTransitiveDigest": "jsbfONl9OksDWiAs7KDFK5chH/tYI3DngdM30NKdk5Y=", "usagesDigest": "eVrT3hFCIZNRuTKpfWDzSIwTi2p6U6PWbt+tNWl/Tqk=", "recordedFileInputs": {}, "recordedDirentsInputs": {}, "envVariables": {}, "generatedRepoSpecs": { "utf8_range": { "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", "ruleClassName": "http_archive", "attributes": { "urls": [ "https://github.com/protocolbuffers/utf8_range/archive/de0b4a8ff9b5d4c98108bdfe723291a33c52c54f.zip" ], "strip_prefix": "utf8_range-de0b4a8ff9b5d4c98108bdfe723291a33c52c54f", "sha256": "5da960e5e5d92394c809629a03af3c7709d2d3d0ca731dacb3a9fb4bf28f7702" } } }, "recordedRepoMappingEntries": [ [ "protobuf~", "bazel_tools", "bazel_tools" ] ] } } } } nanopb-0.4.9.1/Package.swift000066400000000000000000000026771472303430400155650ustar00rootroot00000000000000// swift-tools-version:5.3 // The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription let package = Package( name: "nanopb", products: [ .library( name: "nanopb", targets: ["nanopb"] ) ], targets: [ .target( name: "nanopb", path: ".", sources: [ "pb.h", "pb_common.h", "pb_common.c", "pb_decode.h", "pb_decode.c", "pb_encode.h", "pb_encode.c" ], resources: [.process("spm_resources/PrivacyInfo.xcprivacy")], publicHeadersPath: "spm_headers", cSettings: [ .define("PB_FIELD_32BIT", to: "1"), .define("PB_NO_PACKED_STRUCTS", to: "1"), .define("PB_ENABLE_MALLOC", to: "1"), ] ), .testTarget( name: "swift-test", dependencies: [ "nanopb", ], path: "spm-test/swift", cSettings: [ .headerSearchPath("../"), .define("PB_FIELD_32BIT", to: "1"), .define("PB_NO_PACKED_STRUCTS", to: "1"), .define("PB_ENABLE_MALLOC", to: "1"), ] ), .testTarget( name: "objc-test", dependencies: [ "nanopb", ], path: "spm-test/objc", cSettings: [ .headerSearchPath("../"), .define("PB_FIELD_32BIT", to: "1"), .define("PB_NO_PACKED_STRUCTS", to: "1"), .define("PB_ENABLE_MALLOC", to: "1"), ] ) ] ) nanopb-0.4.9.1/README.md000066400000000000000000000105551472303430400144250ustar00rootroot00000000000000Nanopb - Protocol Buffers for Embedded Systems ============================================== ![Latest change](https://github.com/nanopb/nanopb/actions/workflows/trigger_on_code_change.yml/badge.svg) ![Weekly build](https://github.com/nanopb/nanopb/actions/workflows/trigger_on_schedule.yml/badge.svg) Nanopb is a small code-size Protocol Buffers implementation in ansi C. It is especially suitable for use in microcontrollers, but fits any memory restricted system. * **Homepage:** https://jpa.kapsi.fi/nanopb/ * **Git repository:** https://github.com/nanopb/nanopb/ * **Documentation:** https://jpa.kapsi.fi/nanopb/docs/ * **Forum:** https://groups.google.com/forum/#!forum/nanopb * **Stable version downloads:** https://jpa.kapsi.fi/nanopb/download/ * **Pre-release binary packages:** https://github.com/nanopb/nanopb/actions/workflows/binary_packages.yml Using the nanopb library ------------------------ To use the nanopb library, you need to do two things: 1. Compile your .proto files for nanopb, using `protoc`. 2. Include *pb_encode.c*, *pb_decode.c* and *pb_common.c* in your project. The easiest way to get started is to study the project in "examples/simple". It contains a Makefile, which should work directly under most Linux systems. However, for any other kind of build system, see the manual steps in README.txt in that folder. Generating the headers ---------------------- Protocol Buffers messages are defined in a `.proto` file, which follows a standard format that is compatible with all Protocol Buffers libraries. To use it with nanopb, you need to generate `.pb.c` and `.pb.h` files from it: python generator/nanopb_generator.py myprotocol.proto # For source checkout generator-bin/nanopb_generator myprotocol.proto # For binary package (Note: For instructions for nanopb-0.3.9.x and older, see the documentation of that particular version [here](https://github.com/nanopb/nanopb/blob/maintenance_0.3/README.md)) The binary packages for Windows, Linux and Mac OS X should contain all necessary dependencies, including Python, python-protobuf library and protoc. If you are using a git checkout or a plain source distribution, you will need to install Python separately. Once you have Python, you can install the other dependencies with `pip install --upgrade protobuf grpcio-tools`. You can further customize the header generation by creating an `.options` file. See [documentation](https://jpa.kapsi.fi/nanopb/docs/concepts.html#modifying-generator-behaviour) for details. Running the tests ----------------- If you want to perform further development of the nanopb core, or to verify its functionality using your compiler and platform, you'll want to run the test suite. The build rules for the test suite are implemented using Scons, so you need to have that installed (ex: `sudo apt install scons` or `pip install scons`). To run the tests: cd tests scons This will show the progress of various test cases. If the output does not end in an error, the test cases were successful. Note: Mac OS X by default aliases 'clang' as 'gcc', while not actually supporting the same command line options as gcc does. To run tests on Mac OS X, use: `scons CC=clang CXX=clang++`. Same way can be used to run tests with different compilers on any platform. For embedded platforms, there is currently support for running the tests on STM32 discovery board and [simavr](https://github.com/buserror/simavr) AVR simulator. Use `scons PLATFORM=STM32` and `scons PLATFORM=AVR` to run these tests. Build systems and integration ----------------------------- Nanopb C code itself is designed to be portable and easy to build on any platform. Often the bigger hurdle is running the generator which takes in the `.proto` files and outputs `.pb.c` definitions. There exist build rules for several systems: * **Makefiles**: `extra/nanopb.mk`, see `examples/simple` * **CMake**: `extra/FindNanopb.cmake`, see `examples/cmake` * **SCons**: `tests/site_scons` (generator only) * **Bazel**: `BUILD.bazel` in source root * **Conan**: `conanfile.py` in source root * **PlatformIO**: https://platformio.org/lib/show/431/Nanopb * **PyPI/pip**: https://pypi.org/project/nanopb/ * **vcpkg**: https://vcpkg.info/port/nanopb And also integration to platform interfaces: * **Arduino**: http://platformio.org/lib/show/1385/nanopb-arduino * **Zephyr**: https://docs.zephyrproject.org/latest/services/serialization/nanopb.html nanopb-0.4.9.1/WORKSPACE000066400000000000000000000000001472303430400144070ustar00rootroot00000000000000nanopb-0.4.9.1/build-tests/000077500000000000000000000000001472303430400153775ustar00rootroot00000000000000nanopb-0.4.9.1/build-tests/cmake_with_components/000077500000000000000000000000001472303430400217575ustar00rootroot00000000000000nanopb-0.4.9.1/build-tests/cmake_with_components/CMakeLists.txt000066400000000000000000000005631472303430400245230ustar00rootroot00000000000000cmake_minimum_required(VERSION 2.8) project(NANOPB_CMAKE_SIMPLE C CXX) set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../extra) find_package(Nanopb REQUIRED COMPONENTS cpp-descriptors) nanopb_generate_cpp(TARGET proto simple.proto) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror -g -O0") add_executable(simple simple.cpp) target_link_libraries(simple proto) nanopb-0.4.9.1/build-tests/cmake_with_components/simple.cpp000066400000000000000000000042301472303430400237530ustar00rootroot00000000000000#include #include #include #include "simple.pb.h" int main() { /* This is the buffer where we will store our message. */ uint8_t buffer[128]; size_t message_length; bool status; /* Encode our message */ { /* Allocate space on the stack to store the message data. * * Nanopb generates simple struct definitions for all the messages. * - check out the contents of simple.pb.h! * It is a good idea to always initialize your structures * so that you do not have garbage data from RAM in there. */ SimpleMessage message = SimpleMessage_init_zero; /* Create a stream that will write to our buffer. */ pb_ostream_t stream = pb_ostream_from_buffer(buffer, sizeof(buffer)); /* Fill in the lucky number */ message.lucky_number = 13; /* Now we are ready to encode the message! */ status = pb_encode(&stream, nanopb::MessageDescriptor::fields(), &message); message_length = stream.bytes_written; /* Then just check for any errors.. */ if (!status) { printf("Encoding failed: %s\n", PB_GET_ERROR(&stream)); return 1; } } /* Now we could transmit the message over network, store it in a file or * wrap it to a pigeon's leg. */ /* But because we are lazy, we will just decode it immediately. */ { /* Allocate space for the decoded message. */ SimpleMessage message = SimpleMessage_init_zero; /* Create a stream that reads from the buffer. */ pb_istream_t stream = pb_istream_from_buffer(buffer, message_length); /* Now we are ready to decode the message. */ status = pb_decode(&stream, nanopb::MessageDescriptor::fields(), &message); /* Check for errors... */ if (!status) { printf("Decoding failed: %s\n", PB_GET_ERROR(&stream)); return 1; } /* Print the data contained in the message. */ printf("Your lucky number was %d!\n", message.lucky_number); } return 0; } nanopb-0.4.9.1/build-tests/cmake_with_components/simple.proto000066400000000000000000000002361472303430400243360ustar00rootroot00000000000000// A very simple protocol definition, consisting of only // one message. syntax = "proto2"; message SimpleMessage { required int32 lucky_number = 1; } nanopb-0.4.9.1/build-tests/legacy_cmake_relpath/000077500000000000000000000000001472303430400215225ustar00rootroot00000000000000nanopb-0.4.9.1/build-tests/legacy_cmake_relpath/CMakeLists.txt000066400000000000000000000007361472303430400242700ustar00rootroot00000000000000cmake_minimum_required(VERSION 2.8) project(NANOPB_CMAKE_SIMPLE C) set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../extra) find_package(Nanopb REQUIRED) include_directories(${NANOPB_INCLUDE_DIRS}) nanopb_generate_cpp(PROTO_SRCS PROTO_HDRS RELPATH proto proto/simple.proto proto/sub/unlucky.proto) include_directories(${CMAKE_CURRENT_BINARY_DIR}) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror -g -O0") add_executable(simple simple.c ${PROTO_SRCS} ${PROTO_HDRS}) nanopb-0.4.9.1/build-tests/legacy_cmake_relpath/proto/000077500000000000000000000000001472303430400226655ustar00rootroot00000000000000nanopb-0.4.9.1/build-tests/legacy_cmake_relpath/proto/simple.proto000066400000000000000000000003421472303430400252420ustar00rootroot00000000000000// A very simple protocol definition, consisting of only // one message. syntax = "proto2"; import "sub/unlucky.proto"; message SimpleMessage { required int32 lucky_number = 1; required UnluckyNumber unlucky = 2; } nanopb-0.4.9.1/build-tests/legacy_cmake_relpath/proto/sub/000077500000000000000000000000001472303430400234565ustar00rootroot00000000000000nanopb-0.4.9.1/build-tests/legacy_cmake_relpath/proto/sub/unlucky.proto000066400000000000000000000001131472303430400262300ustar00rootroot00000000000000syntax = "proto2"; message UnluckyNumber { required uint32 number = 1; } nanopb-0.4.9.1/build-tests/legacy_cmake_relpath/simple.c000066400000000000000000000044231472303430400231620ustar00rootroot00000000000000#include #include #include #include "simple.pb.h" int main() { /* This is the buffer where we will store our message. */ uint8_t buffer[128]; size_t message_length; bool status; /* Encode our message */ { /* Allocate space on the stack to store the message data. * * Nanopb generates simple struct definitions for all the messages. * - check out the contents of simple.pb.h! * It is a good idea to always initialize your structures * so that you do not have garbage data from RAM in there. */ SimpleMessage message = SimpleMessage_init_zero; /* Create a stream that will write to our buffer. */ pb_ostream_t stream = pb_ostream_from_buffer(buffer, sizeof(buffer)); /* Fill in the lucky number */ message.lucky_number = 13; message.unlucky.number = 42; /* Now we are ready to encode the message! */ status = pb_encode(&stream, SimpleMessage_fields, &message); message_length = stream.bytes_written; /* Then just check for any errors.. */ if (!status) { printf("Encoding failed: %s\n", PB_GET_ERROR(&stream)); return 1; } } /* Now we could transmit the message over network, store it in a file or * wrap it to a pigeon's leg. */ /* But because we are lazy, we will just decode it immediately. */ { /* Allocate space for the decoded message. */ SimpleMessage message = SimpleMessage_init_zero; /* Create a stream that reads from the buffer. */ pb_istream_t stream = pb_istream_from_buffer(buffer, message_length); /* Now we are ready to decode the message. */ status = pb_decode(&stream, SimpleMessage_fields, &message); /* Check for errors... */ if (!status) { printf("Decoding failed: %s\n", PB_GET_ERROR(&stream)); return 1; } /* Print the data contained in the message. */ printf("Your lucky number was %d!\n", message.lucky_number); printf("Your unlucky number was %u!\n", message.unlucky.number); } return 0; } nanopb-0.4.9.1/build-tests/legacy_cmake_simple/000077500000000000000000000000001472303430400213545ustar00rootroot00000000000000nanopb-0.4.9.1/build-tests/legacy_cmake_simple/CMakeLists.txt000066400000000000000000000006601472303430400241160ustar00rootroot00000000000000cmake_minimum_required(VERSION 2.8) project(NANOPB_CMAKE_SIMPLE C) set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../extra) find_package(Nanopb REQUIRED) include_directories(${NANOPB_INCLUDE_DIRS}) nanopb_generate_cpp(PROTO_SRCS PROTO_HDRS simple.proto) include_directories(${CMAKE_CURRENT_BINARY_DIR}) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror -g -O0") add_executable(simple simple.c ${PROTO_SRCS} ${PROTO_HDRS}) nanopb-0.4.9.1/build-tests/legacy_cmake_simple/simple.c000066400000000000000000000042451472303430400230160ustar00rootroot00000000000000#include #include #include #include "simple.pb.h" int main() { /* This is the buffer where we will store our message. */ uint8_t buffer[128]; size_t message_length; bool status; /* Encode our message */ { /* Allocate space on the stack to store the message data. * * Nanopb generates simple struct definitions for all the messages. * - check out the contents of simple.pb.h! * It is a good idea to always initialize your structures * so that you do not have garbage data from RAM in there. */ SimpleMessage message = SimpleMessage_init_zero; /* Create a stream that will write to our buffer. */ pb_ostream_t stream = pb_ostream_from_buffer(buffer, sizeof(buffer)); /* Fill in the lucky number */ message.lucky_number = 13; /* Now we are ready to encode the message! */ status = pb_encode(&stream, SimpleMessage_fields, &message); message_length = stream.bytes_written; /* Then just check for any errors.. */ if (!status) { printf("Encoding failed: %s\n", PB_GET_ERROR(&stream)); return 1; } } /* Now we could transmit the message over network, store it in a file or * wrap it to a pigeon's leg. */ /* But because we are lazy, we will just decode it immediately. */ { /* Allocate space for the decoded message. */ SimpleMessage message = SimpleMessage_init_zero; /* Create a stream that reads from the buffer. */ pb_istream_t stream = pb_istream_from_buffer(buffer, message_length); /* Now we are ready to decode the message. */ status = pb_decode(&stream, SimpleMessage_fields, &message); /* Check for errors... */ if (!status) { printf("Decoding failed: %s\n", PB_GET_ERROR(&stream)); return 1; } /* Print the data contained in the message. */ printf("Your lucky number was %d!\n", message.lucky_number); } return 0; } nanopb-0.4.9.1/build-tests/legacy_cmake_simple/simple.proto000066400000000000000000000002361472303430400237330ustar00rootroot00000000000000// A very simple protocol definition, consisting of only // one message. syntax = "proto2"; message SimpleMessage { required int32 lucky_number = 1; } nanopb-0.4.9.1/build.py000066400000000000000000000003151472303430400146100ustar00rootroot00000000000000from conan.packager import ConanMultiPackager if __name__ == "__main__": builder = ConanMultiPackager(build_policy="outdated") builder.add_common_builds(shared_option_name=None) builder.run() nanopb-0.4.9.1/conan-wrapper/000077500000000000000000000000001472303430400157145ustar00rootroot00000000000000nanopb-0.4.9.1/conan-wrapper/CMakeLists.txt000066400000000000000000000002561472303430400204570ustar00rootroot00000000000000cmake_minimum_required(VERSION 2.8.12) project(cmake_wrapper) include(${CMAKE_CURRENT_BINARY_DIR}/conanbuildinfo.cmake) conan_basic_setup() add_subdirectory(".." "nanopb") nanopb-0.4.9.1/conanfile.py000066400000000000000000000017101472303430400154470ustar00rootroot00000000000000from conans import ConanFile, CMake, tools from os import path class NanoPbConan(ConanFile): name = "nanopb" version = "0.4.9.1" license = "zlib" url = "https://jpa.kapsi.fi/nanopb/" description = "Protocol Buffers with small code size" settings = "os_build", "compiler", "build_type", "arch" generators = "cmake" exports = '*' options = { "fPIC": [True, False], } default_options = { "fPIC": True, } def configure(self): if self.settings.os_build == "Windows" and self.settings.compiler == "Visual Studio": del self.options.fPIC def build(self): cmake = CMake(self) cmake.configure(source_folder=path.join(self.source_folder, "conan-wrapper")) cmake.build() cmake.install() def package_info(self): self.cpp_info.includedirs = ["include"] self.cpp_info.libdirs = ["lib"] self.cpp_info.libs = ["protobuf-nanopb"] nanopb-0.4.9.1/docs/000077500000000000000000000000001472303430400140705ustar00rootroot00000000000000nanopb-0.4.9.1/docs/Makefile000066400000000000000000000014711472303430400155330ustar00rootroot00000000000000INPUTS = index.md concepts.md reference.md security.md migration.md whats_new.md all: $(INPUTS:.md=.html) tmp_menu.html: $(INPUTS) echo '
' > $@ (echo '

Documentation index

'; \ for file in $^; do echo -n '1. ['; sed -n '1 s!^# Nanopb: !! p' $$file; \ echo -n "]("; echo $$file | sed 's/.md/.html)/' ; done;) | \ pandoc -f markdown -t html5 >> $@ echo '
' >> $@ %.html: %.md tmp_menu.html sed '1 s!#!%!' $< | \ pandoc -s -f markdown -t html5 -c lsr.css --toc --toc-depth=4 \ --variable 'header-includes=' \ --indented-code-classes=c \ -o $@ sed -i '/