{"id":19904580,"url":"https://github.com/risoflora/libsagui","last_synced_at":"2025-04-06T19:10:59.500Z","repository":{"id":139842701,"uuid":"101064628","full_name":"risoflora/libsagui","owner":"risoflora","description":"Cross-platform library which helps to develop web servers or frameworks.","archived":false,"fork":false,"pushed_at":"2025-02-25T01:22:08.000Z","size":1417,"stargazers_count":91,"open_issues_count":4,"forks_count":23,"subscribers_count":15,"default_branch":"main","last_synced_at":"2025-03-30T18:07:59.650Z","etag":null,"topics":["c","cross-platform","embedded","gzip","http","iot","pcre","rest","tls"],"latest_commit_sha":null,"homepage":"https://risoflora.github.io/libsagui","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-2.1","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/risoflora.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"docs/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-08-22T13:14:50.000Z","updated_at":"2025-03-21T01:47:31.000Z","dependencies_parsed_at":null,"dependency_job_id":"4f1d7bfa-f142-461b-b661-e3267403240f","html_url":"https://github.com/risoflora/libsagui","commit_stats":null,"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/risoflora%2Flibsagui","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/risoflora%2Flibsagui/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/risoflora%2Flibsagui/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/risoflora%2Flibsagui/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/risoflora","download_url":"https://codeload.github.com/risoflora/libsagui/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247535516,"owners_count":20954576,"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":["c","cross-platform","embedded","gzip","http","iot","pcre","rest","tls"],"created_at":"2024-11-12T20:28:57.215Z","updated_at":"2025-04-06T19:10:59.474Z","avatar_url":"https://github.com/risoflora.png","language":"C","funding_links":["https://www.paypal.com/cgi-bin/webscr?cmd=_donations\u0026business=silvioprog%40gmail%2ecom\u0026lc=US\u0026item_name=libsagui\u0026item_number=libsagui\u0026currency_code=USD\u0026bn=PP%2dDonationsBF%3aproject%2dsupport%2ejpg%3aNonHosted"],"categories":[],"sub_categories":[],"readme":"# `libsagui`\n\n[![License: LGPL v2.1][license-badge]](LICENSE)\n[![CII Best Practices][bestpractices-badge]][1]\n[![GitHub releases][releases-badge]][2]\n[![Build status][build-status-badge]][3]\n\n## Overview\n\nSagui is a cross-platform C library which helps to develop web servers or\nframeworks. Its core has been developed using the [GNU libmicrohttpd][4],\n[uthash][5], [PCRE2][6], [ZLib][7] and [GnuTLS][8], that's why it is so fast,\ncompact and useful to run on embedded systems.\n\n## Features\n\n- **Requests processing through:**\n  - Event-driven - single-thread + polling.\n  - Threaded - one thread per request.\n  - Polling - pre-allocated threads.\n  - Isolated request - request processed outside main thread.\n- **High-performance path routing that supports:**\n  - Regular expressions using [PCRE2][9] [syntax][10].\n  - Just-in-time optimization ([JIT][11]).\n  - Binary search in path entry-points.\n- **HTTP compression:**\n  - [Deflate][12] for static contents and\n    streams compression.\n  - [Gzip][13] for files compression.\n- **HTTPS support:**\n  - TLS 1.3 through [GnuTLS][8] library.\n- **Dual stack:**\n  - Single socket for IPv4 and IPv6 support.\n- **Basic authentication:**\n  - For standard login using _user name/password_.\n- **Upload/download streaming by:**\n  - Payload - for raw data transferring as JSON, XML and other.\n  - File - for large data transferring as videos, images, binaries and so on.\n- **Mathematical expression evaluator:**\n  - Arithmetic, bitwise and logical operators.\n  - Variables allocation at build and/or run time.\n  - Macro support to define functions at run time.\n  - Extendable with custom functions.\n  - Error handling with error kind and position.\n- **Dynamic strings:**\n  - Makes it easy strings operations in C.\n- **String map:**\n  - Fast key-value mapping.\n- **And more:**\n  - Fields, parameters, cookies, headers under hash table structure.\n  - Several callbacks for total library customization.\n\n## Examples\n\nA minimal `hello world` HTTP server:\n\n```c\nvoid req_cb(void *cls, struct sg_httpreq *req, struct sg_httpres *res) {\n    sg_httpres_send(res, \"Hello world\", \"text/plain\", 200);\n}\n\nint main(void) {\n    struct sg_httpsrv *srv = sg_httpsrv_new(req_cb, NULL);\n    sg_httpsrv_listen(srv, 8080, false);\n    printf(\"Server running at http://localhost:%d\\n\", sg_httpsrv_port(srv));\n    getchar();\n    sg_httpsrv_free(srv);\n    return 0;\n}\n```\n\nThe router support is isolated from the HTTP feature, so it can be used to route\nany path structure, for example:\n\n```c\nvoid home_cb(void *cls, struct sg_route *route) {\n    printf(\"Home\\n\");\n}\n\nvoid download_cb(void *cls, struct sg_route *route) {\n    printf(\"Download\\n\");\n}\n\nint main(void) {\n    struct sg_router *router;\n    struct sg_route *routes = NULL;\n    sg_routes_add(\u0026routes, \"/home\", home_cb, NULL);\n    sg_routes_add(\u0026routes, \"/download\", download_cb, NULL);\n    router = sg_router_new(routes);\n    sg_router_dispatch(router, \"/home\", NULL);\n    sg_routes_cleanup(\u0026routes);\n    sg_router_free(router);\n    return 0;\n}\n```\n\nlastly, putting everything together:\n\n```c\nstruct Holder {\n    struct sg_httpreq *req;\n    struct sg_httpres *res;\n};\n\nvoid route_home_cb(void *cls, struct sg_route *route) {\n    struct Holder *holder = sg_route_user_data(route);\n    sg_httpres_send(holder-\u003eres, \"Home\", \"text/plain\", 200);\n}\n\nvoid route_download_cb(void *cls, struct sg_route *route) {\n    struct Holder *holder = sg_route_user_data(route);\n    sg_httpres_send(holder-\u003eres, \"Download\", \"text/plain\", 200);\n}\n\nvoid req_cb(void *cls, struct sg_httpreq *req, struct sg_httpres *res) {\n    struct sg_router *router = cls;\n    struct Holder holder = {req, res};\n    if (sg_router_dispatch(router, sg_httpreq_path(req), \u0026holder) != 0)\n        sg_httpres_send(res, \"404\", \"text/plain\", 404);\n}\n\nint main(void) {\n    struct sg_route *routes = NULL;\n    struct sg_router *router;\n    struct sg_httpsrv *srv;\n    sg_routes_add(\u0026routes, \"/home\", route_home_cb, NULL);\n    sg_routes_add(\u0026routes, \"/download\", route_download_cb, NULL);\n    router = sg_router_new(routes);\n    srv = sg_httpsrv_new(req_cb, router);\n    sg_httpsrv_listen(srv, 8080, false);\n    printf(\"Server running at http://localhost:%d\\n\", sg_httpsrv_port(srv));\n    getchar();\n    sg_httpsrv_free(srv);\n    sg_routes_cleanup(\u0026routes);\n    sg_router_free(router);\n    return 0;\n}\n```\n\nThere are other examples available in the [`examples`](examples) directory.\n\n## Downloading\n\nAll stable binaries are available for download at the [releases page][2] with\ntheir respective checksums. For other systems, the packages\n`Source code (tar.gz|zip)` contains the library source.\n\n## Building/installing\n\nThe easiest way to build the library is using a Docker container as a builder.\nFollow the instructions at [libsagui-docker/README.md][17] for more details.\n\nCheck the [docs/BUILD.md](docs/BUILD.md) for more instructions for how to build\nthe examples, tests, documentation and the library. Also, take a look at\n[docs/INSTALL.md](docs/INSTALL.md) for how to install the library from sources\non your system.\n\n## Documentation\n\nThe documentation has been written in [Doxygen][15] and is available in HTML\nformat at [libsagui-docs/index.html][16].\n\n## Versioning\n\nStarting from the version 1.0.0, Sagui follows the [SemVer][14] rules regarding\nAPI changes with backwards compatibility and stable ABI across major releases.\n\n## Compatibility\n\nA typical upgrade of the Sagui library does not break the ABI at all. Take a\nlook at the [API/ABI compatibility report][18] to compare most recent library\nversions.\n\nSee also [Checking backward API/ABI compatibility of Sagui library versions](docs/ABIComplianceChecker.md).\n\n## Contributing\n\nSagui is totally open source and would not be possible without our\n[contributors](THANKS). If you want to submit contributions, please fork the\nproject on GitHub and send a pull request. You retain the copyright on your\ncontributions.\n\n## Donations\n\nMany open source projects, large and small, receive donations to encourage their\nauthors, therefore, it would be not different in Sagui.\n\nAll money collected from donations are invested to the purchase of study\nmaterials. This way, directly or indirectly, all knowledge acquired in the\nstudies influence the spread of this project.\n\nIf you want to support this project, please click the button below:\n\n[![Support this project via PayPal][paypal-gif]][19]\n\nCheck the list of [all donors](DONORS) that lovely supported this idea! :heart:\n\n## Support\n\nThis project values being simple, direct and self-explanatory. However, if you\nneed some help to integrate Sagui to your application, we have the option of a\npaid consulting service. [Contact us][20]!\n\n## Projects using Sagui\n\n- [Brook framework][21] - Pascal framework which helps to develop web\n  applications. [LGPL v2.1][22]\n\nWould you like to add your project to that list above? Feel free to open a\n[new issue][23] requesting it! 🙂\n\n## Licensing\n\nSagui is released under GNU Lesser General Public License v2.1. Check the\n[LICENSE file](LICENSE) for more details.\n\n[license-badge]: https://img.shields.io/badge/license-LGPL%20v2.1-lemmon.svg\n[bestpractices-badge]: https://bestpractices.coreinfrastructure.org/projects/2140/badge\n[releases-badge]: https://img.shields.io/github/v/release/risoflora/libsagui?color=lemmon\n[build-status-badge]: https://github.com/risoflora/libsagui/actions/workflows/CI.yml/badge.svg?style=flat-square \"CI/CD\"\n[paypal-gif]: https://www.paypalobjects.com/en_US/GB/i/btn/btn_donateCC_LG.gif\n[1]: https://bestpractices.coreinfrastructure.org/projects/2140 \"Best practices link\"\n[2]: https://github.com/risoflora/libsagui/releases \"Releases page\"\n[3]: https://github.com/risoflora/libsagui/actions/workflows/CI.yml \"GitHub actions\"\n[4]: https://www.gnu.org/software/libmicrohttpd \"libmicrohttpd page\"\n[5]: https://troydhanson.github.io/uthash \"uthash page\"\n[6]: https://www.pcre.org \"PCRE page\"\n[7]: https://www.zlib.net \"ZLib page\"\n[8]: https://www.gnutls.org \"GnuTLS page\"\n[9]: https://www.pcre.org/current/doc/html/pcre2pattern.html\n[10]: https://www.pcre.org/current/doc/html/pcre2syntax.html\n[11]: https://www.pcre.org/current/doc/html/pcre2jit.html\n[12]: https://en.wikipedia.org/wiki/DEFLATE \"DEFLATE wiki\"\n[13]: https://en.wikipedia.org/wiki/Gzip \"Gzip wiki\"\n[14]: https://semver.org \"Semantic Versioning page\"\n[15]: https://www.doxygen.nl/index.html \"Doxygen page\"\n[16]: https://risoflora.github.io/libsagui-docs/index.html \"Sagui documentation\"\n[17]: https://github.com/risoflora/libsagui-docker/blob/master/README.md \"Sagui Docker\"\n[18]: https://abi-laboratory.pro/?view=timeline\u0026l=libsagui \"Sagui ABI status\"\n[19]: https://www.paypal.com/cgi-bin/webscr?cmd=_donations\u0026business=silvioprog%40gmail%2ecom\u0026lc=US\u0026item_name=libsagui\u0026item_number=libsagui\u0026currency_code=USD\u0026bn=PP%2dDonationsBF%3aproject%2dsupport%2ejpg%3aNonHosted \"PayPal link\"\n[20]: mailto:silvioprog@gmail.com\n[21]: https://github.com/risoflora/brookframework\n[22]: https://github.com/risoflora/brookframework/blob/master/LICENSE\n[23]: https://github.com/risoflora/libsagui/issues/new?labels=documentation\u0026template=project_using_sagui.md\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frisoflora%2Flibsagui","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frisoflora%2Flibsagui","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frisoflora%2Flibsagui/lists"}