{"id":15639751,"url":"https://github.com/squidfunk/protobluff","last_synced_at":"2025-04-15T22:51:29.649Z","repository":{"id":35148180,"uuid":"39373954","full_name":"squidfunk/protobluff","owner":"squidfunk","description":"A modular Protocol Buffers implementation for C","archived":false,"fork":false,"pushed_at":"2023-09-21T06:23:51.000Z","size":1275,"stargazers_count":93,"open_issues_count":1,"forks_count":18,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-03-29T02:12:17.327Z","etag":null,"topics":["lightweight","protocol-buffers"],"latest_commit_sha":null,"homepage":"https://squidfunk.github.io/protobluff/","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"lazada/goprof","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/squidfunk.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-07-20T09:07:34.000Z","updated_at":"2025-03-19T13:36:29.000Z","dependencies_parsed_at":"2024-10-22T21:37:25.834Z","dependency_job_id":null,"html_url":"https://github.com/squidfunk/protobluff","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/squidfunk%2Fprotobluff","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/squidfunk%2Fprotobluff/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/squidfunk%2Fprotobluff/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/squidfunk%2Fprotobluff/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/squidfunk","download_url":"https://codeload.github.com/squidfunk/protobluff/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249167434,"owners_count":21223505,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["lightweight","protocol-buffers"],"created_at":"2024-10-03T11:27:11.236Z","updated_at":"2025-04-15T22:51:29.629Z","avatar_url":"https://github.com/squidfunk.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Codecov][codecov-image]][codecov-link]\n[![Release][release-image]][release-link]\n\n  [codecov-image]: https://img.shields.io/codecov/c/github/squidfunk/protobluff/master.svg\n  [codecov-link]: https://codecov.io/gh/squidfunk/protobluff\n  [release-image]: https://img.shields.io/github/release/squidfunk/protobluff.svg\n  [release-link]: https://github.com/squidfunk/protobluff/releases/latest\n\n# protobluff\n\nprotobluff is a modular Protocol Buffers implementation for C.\n\n## Theory of Operation\n\n[Protocol Buffers][] is a language-neutral, platform-neutral and extensible\nmessage format developed by Google for serializing structured data. It uses\nschema files to describe the structure of messages, which are in turn used to\ngenerate language-specific bindings to automatically handle the decoding and\nencoding for the developer. However, as messages can have a variable amount\nof repeated submessages and fields, decoding and encoding may involve a large\nnumber of scattered allocations which in turn is not very cache-friendly.\n\nprotobluff follows a different approach. It entirely skips the necessary\ndecoding and encoding steps when reading or writing values from messages,\nas it directly operates on the encoded data. New values can be incrementally\nread or written, memory management is centralized and handled by the underlying\njournal. If no alterations that change the size of the underlying journal are\nexpected, the journal can be used in *zero-copy mode*, omitting all dynamic\nallocations.\n\n## Installation\n\n### Building from source\n\nprotobluff is built using [Autotools][] and can be linked as a static or shared\nlibrary. It has no runtime dependencies and is fully self-contained, except for\nthe code generator which depends on the original Protocol Buffers library and\nis necessary to generate bindings from `.proto` schema files. If the original\nlibrary is not available, the generator is not built. The following commands\nbuild and install the protobluff library and code generator:\n\n``` sh\n./autogen.sh \u0026\u0026\n./configure \u0026\u0026\nmake \u0026\u0026\nmake test \u0026\u0026\nmake install\n```\n\nprotobluff should compile and run on all UNIX systems (including Linux and Mac\nOS) as it adheres to the C99 and C++98 standards and does not make use of any\nsystem-specific functionality.\n\nAfter installing protobluff, the code generator can be used to generate\nbindings from `.proto` schema files to get started. See\n[this section](#using-the-code-generator) for more information.\n\n### Additional options\n\nBy default, protobluff is compiled aggressively optimized with `-O3` and some\nfurther optimizations which make it nearly impossible to debug. If debugging\nis necessary, one should disable optimizations. Stripped compilation will\nremove all symbols that are not defined in the public header files, allowing\nfurther optimizations. Enabling the coverage report is only necessary to\ndetermine unit test coverage, and thus only needed during development.\n\n``` sh\n./configure\n  --disable-optimized # No optimizations (default: enabled)\n  --enable-stripped   # Strip internal symbols (default: disabled)\n  --enable-coverage   # Coverage report (default: disabled)\n```\n\nThe tests can only be built if stripped compilation is not enabled, as no\ninternal symbols would be visible to the unit tests.\n\n## Using the code generator\n\nThe code generator is tightly integrated with the protoc compiler toolchain\nincluded in the default Protocol Buffers distribution. Use the `protoc` command\nto invoke the protobluff code generator through the `--protobluff_out` flag,\nto generate and write the respective `.pb.c` and `.pb.h` files to a specific\nlocation:\n\n``` sh\nprotoc --protobluff_out=. *.proto\n```\n\nThe `.pb.h` header files will contain the bindings, the `.pb.c` source files\ncontain the descriptor definitions which are referenced by the bindings.\nTherefore, the source files must be compiled together with your project.\n\n## Using the generated bindings\n\nHere's a usage example taken from the original description of the Google\nProtocol Buffers library and adapted to protobluff:\n\n``` c\n/* Create an empty journal to assemble a new person message */\npb_journal_t journal = pb_journal_create_empty();\n\n/* Create a person message */\npb_message_t person = person_create(\u0026journal);\n\n/* Define the values we want to set */\npb_string_t name   = pb_string_init_from_chars(\"John Doe\"),\n            email  = pb_string_init_from_chars(\"jdoe@example.com\"),\n            home   = pb_string_init_from_chars(\"+1-541-754-3010\"),\n            mobile = pb_string_init_from_chars(\"+1-541-293-8228\");\nint32_t     id     = 1234;\n\n/* Set values on person message and check return codes */\npb_error_t error = PB_ERROR_NONE;\ndo {\n  if ((error = person_put_name(\u0026person, \u0026name)) ||\n      (error = person_put_id(\u0026person, \u0026id)) ||\n      (error = person_put_email(\u0026person, \u0026email)))\n    break;\n\n  /* Set home number */\n  pb_message_t phone1 = person_create_phone(\u0026person);\n  if (!(error = person_phonenumber_put_number(\u0026phone1, \u0026home)) \u0026\u0026\n      !(error = person_phonenumber_put_type_home(\u0026phone1))) {\n\n    /* Set mobile number */\n    pb_message_t phone2 = person_create_phone(\u0026person);\n    if (!(error = person_phonenumber_put_number(\u0026phone2, \u0026mobile)) \u0026\u0026\n        !(error = person_phonenumber_put_type_mobile(\u0026phone2))) {\n\n      /* Dump the journal */\n      pb_journal_dump(\u0026journal);\n\n      /* The encoded message can be accessed as follows */\n      // const uint8_t *data = pb_journal_data(\u0026journal);\n      // const size_t   size = pb_journal_size(\u0026journal);\n    }\n    person_phonenumber_destroy(\u0026phone2);\n  }\n  person_phonenumber_destroy(\u0026phone1);\n} while (0);\n\n/* Print error, if any */\nif (error)\n  fprintf(stderr, \"ERROR: %s\\n\", pb_error_string(error));\n\n/* Cleanup and invalidate */\nperson_destroy(\u0026person);\n\n/* Free all allocated memory and return */\npb_journal_destroy(\u0026journal);\nreturn error\n  ? EXIT_FAILURE\n  : EXIT_SUCCESS;\n```\n\nSee the examples directory for more information.\n\n## Linking\n\n### Manually\n\nFor the generated bindings to function, your project must be linked against the\nprotobluff runtime. The recommended way is to dynamically link the shared\nlibrary. Therefore, the following compiler and linker flags must be obtained\nand added to your build toolchain:\n\n``` sh\npkg-config --cflags protobluff # Add output to compiler flags\npkg-config --libs   protobluff # Add output to linker flags\n```\n\n### Autotools\n\nIf you're using Autotools, the `PKG_CHECK_MODULES` macro will take care of the\nheavy lifting. Adding the following line to your `configure.ac` file will place\nthe compiler flags into the variable `protobluff_CFLAGS` and the linker flags\ninto the variable `protobluff_LDFLAGS`:\n\n``` makefile\nPKG_CHECK_MODULES([protobluff], [protobluff])\n```\n\n## Features\n\n### Already supported\n\n1. Message definitions\n2. Nested submessage definitions\n3. All scalar types\n4. Enumerations\n5. Strings and binaries\n6. Optional, required and repeated fields\n7. Imports\n8. Packages\n9. Extensions and nested extensions\n10. Deprecations for messages, fields, enums and enum values\n11. Packed fields\n12. Oneofs\n\n### Not (yet) supported\n\n1. proto3 support\n2. Services (using gRPC and/or ZMQ)\n3. Groups (unsure)\n\nprotobluff is basically compatible with proto3, as proto2 is binary compatible,\nbut some special types like maps and the `Any` type need to be implemented.\n\n## License\n\nCopyright (c) 2013-2020 Martin Donath\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to\ndeal in the Software without restriction, including without limitation the\nrights to use, copy, modify, merge, publish, distribute, sublicense, and/or\nsell copies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\nFROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\nIN THE SOFTWARE.\n\n[Protocol Buffers]: https://developers.google.com/protocol-buffers/docs/overview\n[Protocol Buffers Encoding Guide]: https://developers.google.com/protocol-buffers/docs/encoding\n[Autotools]: http://www.gnu.org/software/automake/manual/html_node/Autotools-Introduction.html\n[Valgrind]: http://valgrind.org/\n[LCOV]: http://ltp.sourceforge.net/coverage/lcov.php\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsquidfunk%2Fprotobluff","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsquidfunk%2Fprotobluff","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsquidfunk%2Fprotobluff/lists"}