Skip to content

Commit

Permalink
Fixed tests on Android and Raspbian.
Browse files Browse the repository at this point in the history
  • Loading branch information
silvioprog committed May 1, 2020
1 parent c67acfa commit 01e4585
Show file tree
Hide file tree
Showing 10 changed files with 276 additions and 160 deletions.
7 changes: 1 addition & 6 deletions .markdownlint.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
{
"default": true,
"MD013": false,
"MD025": false,
"MD026": false,
"MD040": false,
"MD041": false
"default": true
}
106 changes: 71 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,34 @@
# `libsagui`

[![License: LGPL v2.1](https://img.shields.io/badge/License-LGPL%20v2.1-lemmon.svg)](https://github.com/risoflora/libsagui/blob/master/LICENSE)
[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/2140/badge)](https://bestpractices.coreinfrastructure.org/projects/2140)
[![Language grade: C/C++](https://img.shields.io/lgtm/grade/cpp/g/risoflora/libsagui.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/risoflora/libsagui/context:cpp)
[![GitHub releases](https://img.shields.io/github/v/release/risoflora/libsagui?color=lemmon)](https://github.com/risoflora/libsagui/releases)
[![Build status](https://travis-ci.org/risoflora/libsagui.svg?branch=master)](https://travis-ci.org/risoflora/libsagui)

# Overview
## Overview

Sagui is a cross-platform C library which helps to develop web servers or frameworks. Its core has been developed using the [GNU libmicrohttpd](https://www.gnu.org/software/libmicrohttpd), [uthash](https://troydhanson.github.io/uthash), [PCRE2](https://www.pcre.org), [ZLib](https://www.zlib.net) and [GnuTLS](https://www.gnutls.org), that's why it is so fast, compact and useful to run on embedded systems.
Sagui is a cross-platform C library which helps to develop web servers or
frameworks. Its core has been developed using the [GNU libmicrohttpd](https://www.gnu.org/software/libmicrohttpd),
[uthash](https://troydhanson.github.io/uthash), [PCRE2](https://www.pcre.org),
[ZLib](https://www.zlib.net) and [GnuTLS](https://www.gnutls.org), that's why it
is so fast, compact and useful to run on embedded systems.

# Features
## Features

- **Requests processing through:**
- Event-driven - single-thread + polling.
- Threaded - one thread per request.
- Polling - pre-allocated threads.
- Isolated request - request processed outside main thread.
- **High-performance path routing that supports:**
- Regular expressions using [PCRE2](https://www.pcre.org/current/doc/html/pcre2pattern.html) [syntax](https://www.pcre.org/current/doc/html/pcre2syntax.html).
- Regular expressions using [PCRE2](https://www.pcre.org/current/doc/html/pcre2pattern.html)
[syntax](https://www.pcre.org/current/doc/html/pcre2syntax.html).
- Just-in-time optimization ([JIT](https://www.pcre.org/current/doc/html/pcre2jit.html)).
- Binary search in path entry-points.
- **HTTP compression:**
- [Deflate](https://en.wikipedia.org/wiki/DEFLATE) for static contents and streams compression.
- [Deflate](https://en.wikipedia.org/wiki/DEFLATE) for static contents and
streams compression.
- [Gzip](https://en.wikipedia.org/wiki/Gzip) for files compression.
- **HTTPS support:**
- TLS 1.3 through [GnuTLS](https://www.gnutls.org) library.
Expand All @@ -39,16 +47,16 @@ Sagui is a cross-platform C library which helps to develop web servers or framew
- Fields, parameters, cookies, headers under hash table structure.
- Several callbacks for total library customization.

# Examples
## Examples

A minimal `hello worl` HTTP server:
A minimal `hello world` HTTP server:

```c
void req_cb(void *cls, struct sg_httpreq *req, struct sg_httpres *res) {
sg_httpres_send(res, "Hello world", "text/plain", 200);
}

int main() {
int main(void) {
struct sg_httpsrv *srv = sg_httpsrv_new(req_cb, NULL);
sg_httpsrv_listen(srv, 8080, false);
printf("Server running at http:https://localhost:%d\n", sg_httpsrv_port(srv));
Expand All @@ -58,7 +66,8 @@ int main() {
}
```
The router support is isolated from the HTTP feature, so it can be used to route any path structure, for example:
The router support is isolated from the HTTP feature, so it can be used to route
any path structure, for example:
```c
void home_cb(void *cls, struct sg_route *route) {
Expand All @@ -69,7 +78,7 @@ void download_cb(void *cls, struct sg_route *route) {
printf("Download\n");
}
int main() {
int main(void) {
struct sg_router *router;
struct sg_route *routes = NULL;
sg_routes_add(&routes, "/home", home_cb, NULL);
Expand All @@ -92,22 +101,22 @@ struct Holder {

void route_home_cb(void *cls, struct sg_route *route) {
struct Holder *holder = sg_route_user_data(route);
sg_httpres_send(holder->res, "<html><body>Home</body></html>", "text/html", 200);
sg_httpres_send(holder->res, "Home", "text/plain", 200);
}

void route_download_cb(void *cls, struct sg_route *route) {
struct Holder *holder = sg_route_user_data(route);
sg_httpres_send(holder->res, "<html><body>Download</body></html>", "text/html", 200);
sg_httpres_send(holder->res, "Download", "text/plain", 200);
}

void req_cb(void *cls, struct sg_httpreq *req, struct sg_httpres *res) {
struct sg_router *router = cls;
struct Holder holder = {req, res};
if (sg_router_dispatch(router, sg_httpreq_path(req), &holder) != 0)
sg_httpres_send(res, "<html><body>404</body></html>", "text/html", 404);
sg_httpres_send(res, "404", "text/plain", 404);
}

int main() {
int main(void) {
struct sg_route *routes = NULL;
struct sg_router *router;
struct sg_httpsrv *srv;
Expand All @@ -125,48 +134,75 @@ int main() {
}
```
There are other examples available in the [`examples/`](https://github.com/risoflora/libsagui/tree/master/examples) directory.
There are other examples available in the
[`examples/`](https://github.com/risoflora/libsagui/tree/master/examples)
directory.
# Versioning
## Versioning
Starting from the version 1.0.0, Sagui follows the [SemVer](https://semver.org) rules regarding API changes with backwards compatibility and stable ABI across major releases.
Starting from the version 1.0.0, Sagui follows the [SemVer](https://semver.org)
rules regarding API changes with backwards compatibility and stable ABI across
major releases.
# Licensing
## Licensing
Sagui is released under GNU Lesser General Public License v2.1. Check the [LICENSE file](https://github.com/risoflora/libsagui/blob/master/LICENSE) for more details.
Sagui is released under GNU Lesser General Public License v2.1. Check the
[LICENSE file](https://github.com/risoflora/libsagui/blob/master/LICENSE) for
more details.
# Documentation
## Documentation
The documentation has been written in [Doxygen](https://www.stack.nl/~dimitri/doxygen) and is available in HTML format at [libsagui-docs/index.html](https://risoflora.github.io/libsagui-docs/index.html).
The documentation has been written in [Doxygen](https://www.stack.nl/~dimitri/doxygen)
and is available in HTML format at [libsagui-docs/index.html](https://risoflora.github.io/libsagui-docs/index.html).
# Downloading
## Downloading
All stable binaries are available for download at the [releases page](https://github.com/risoflora/libsagui/releases) with their respective checksums. For other systems, the packages `Source code (tar.gz|zip)` contains the library source.
All stable binaries are available for download at the
[releases page](https://github.com/risoflora/libsagui/releases) with their
respective checksums. For other systems, the packages `Source code (tar.gz|zip)`
contains the library source.
# Building/installing
## Building/installing
The easiest way to build the library is using a Docker container as builder. Follow the instructions at [libsagui-docker/README.md](https://github.com/risoflora/libsagui-docker/blob/master/README.md) for more details.
The easiest way to build the library is using a Docker container as builder.
Follow the instructions at [libsagui-docker/README.md](https://github.com/risoflora/libsagui-docker/blob/master/README.md)
for more details.
Check the [docs/BUILD.md](https://github.com/risoflora/libsagui/blob/master/docs/BUILD.md) for more instructions for how to build the examples, tests, documentation and the library. Also, take a look at [docs/INSTALL.md](https://github.com/risoflora/libsagui/blob/master/docs/INSTALL.md) for how to install the library from sources on your system.
Check the [docs/BUILD.md](https://github.com/risoflora/libsagui/blob/master/docs/BUILD.md)
for more instructions for how to build the examples, tests, documentation and
the library. Also, take a look at [docs/INSTALL.md](https://github.com/risoflora/libsagui/blob/master/docs/INSTALL.md)
for how to install the library from sources on your system.
# Compatibility
## Compatibility
A typical upgrade of the Sagui library does not break the ABI at all. Take a look at the [API/ABI compatibility report](https://abi-laboratory.pro/?view=timeline&l=libsagui) to compare most recent library versions.
A typical upgrade of the Sagui library does not break the ABI at all. Take a
look at the [API/ABI compatibility report](https://abi-laboratory.pro/?view=timeline&l=libsagui)
to compare most recent library versions.
See also [Checking backward API/ABI compatibility of Sagui library versions](https://github.com/risoflora/libsagui/blob/master/docs/ABIComplianceChecker.md).
# Projects using Sagui
## Projects using Sagui
- [Brook framework](https://github.com/risoflora/brookframework) - Pascal framework which helps to develop web applications. [[LGPL v2.1](https://github.com/risoflora/brookframework/blob/master/LICENSE)]
- [Brook framework](https://github.com/risoflora/brookframework) - Pascal
framework which helps to develop web applications.
[[LGPL v2.1](https://github.com/risoflora/brookframework/blob/master/LICENSE)]
Would you like to add your project to that list above? Feel free to open a [new issue](https://github.com/risoflora/libsagui/issues/new?labels=documentation&template=project_using_sagui.md) requesting it! :-)
Would you like to add your project to that list above? Feel free to open a
[new issue](https://github.com/risoflora/libsagui/issues/new?labels=documentation&template=project_using_sagui.md)
requesting it! :-)
# Contributing
## Contributing
Sagui is totally open source and would not be possible without our [contributors](https://github.com/risoflora/libsagui/blob/master/THANKS). If you want to submit contributions, please fork the project on GitHub and send a pull request. You retain the copyright on your contributions. If you have questions, open a new issue at the [issues page](https://github.com/risoflora/libsagui/issues). For donations to support this project, please click the button below.
Sagui is totally open source and would not be possible without our
[contributors](https://github.com/risoflora/libsagui/blob/master/THANKS). If you
want to submit contributions, please fork the project on GitHub and send a pull
request. You retain the copyright on your contributions. If you have questions,
open a new issue at the [issues page](https://github.com/risoflora/libsagui/issues).
For donations to support this project, please click the button below.
[![Support this project](https://www.paypalobjects.com/en_US/GB/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=silvioprog%40gmail%2ecom&lc=US&item_name=libsagui&item_number=libsagui&currency_code=USD&bn=PP%2dDonationsBF%3aproject%2dsupport%2ejpg%3aNonHosted)
# Support
## Support
This project is completely self-explanatory, but, if you need a consulting service to integrate it on your project, [contact us](mailto:[email protected]).
This project is completely self-explanatory, but, if you need a consulting
service to integrate it on your project, [contact us](mailto:[email protected]).
6 changes: 3 additions & 3 deletions cmake/SgDoxygen.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
#
# ::
#
# SG_BUILD_HTML - Enable/disable the API reference generation as HTML.
# SG_GENERATE_HTML - True when enabled the API reference generation as HTML.
# SG_BUILD_HTML - Enable/disable the API reference generation.
# SG_GENERATE_HTML - True when enabled the API reference generation.
#
# DOXYGEN_FOUND - True when Doxygen executable is found.
# DOXYGEN_INPUT_FILE - Template file used to generate the DOXYGEN_OUTPUT_FILE.
# DOXYGEN_OUTPUT_FILE - Production file to be used as Doxygen input file. It is
# generated from the template DOXYGEN_INPUT_FILE.
# DOXYGEN_DOCS_DIR - Directory containing the documentation in HTML and PDF.
# DOXYGEN_DOCS_DIR - Directory containing the documentation.

# _
# ___ __ _ __ _ _ _(_)
Expand Down
19 changes: 13 additions & 6 deletions docs/ABIComplianceChecker.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,17 @@
**Configure the build:**

```bash
export SG_OLD_VER="2.5.2" # Change to old release
export SG_NEW_VER="2.5.4" # Change to new release
export SG_OLD_VER="3.0.0" # Change to old release
export SG_NEW_VER="3.1.0" # Change to new release

curl -SL https://github.com/risoflora/libsagui/archive/v${SG_OLD_VER}.tar.gz | tar -zx
cmake -DCMAKE_BUILD_TYPE=Debug -DSG_HTTPS_SUPPORT=ON -DSG_ABI_COMPLIANCE_CHECKER=ON -DSG_OLD_LIB_DIR=$(pwd)/libsagui-${SG_OLD_VER} -DSG_OLD_LIB_VERSION=${SG_OLD_VER} ..
curl -SL https://github.com/risoflora/libsagui/archive/v${SG_OLD_VER}.tar.gz | \
tar -zx
cmake \
-DCMAKE_BUILD_TYPE=Debug \
-DSG_HTTPS_SUPPORT=ON \
-DSG_ABI_COMPLIANCE_CHECKER=ON \
-DSG_OLD_LIB_DIR=$(pwd)/libsagui-${SG_OLD_VER} \
-DSG_OLD_LIB_VERSION=${SG_OLD_VER} ..
make abi_compliance_checker
```

Expand All @@ -16,7 +22,8 @@ make abi_compliance_checker
```bash
xdg-open compat_reports/sagui/${SG_OLD_VER}_to_${SG_NEW_VER}/compat_report.html

# or just open compat_report.html on your browser
# or just open the "compat_report.html" on your browser
```

**NOTE:** the `Binary Compatibility` and `Source Compatibility` tabs should show `Compatibility: 100%` in their `Test Results` table.
**NOTE:** the `Binary Compatibility` and `Source Compatibility` tabs should
show `Compatibility: 100%` in their `Test Results` table.
Loading

0 comments on commit 01e4585

Please sign in to comment.