From alteholz at moszumanska.debian.org Mon Mar 19 21:42:06 2018 From: alteholz at moszumanska.debian.org (Thorsten Alteholz) Date: Mon, 19 Mar 2018 21:42:06 +0000 Subject: [Debian-iot-packaging] [glewlwyd] branch master updated (ac14617 -> 77cb271) Message-ID: <20180319214206.5704.36591@moszumanska.debian.org> This is an automated email from the git hooks/post-receive script. alteholz pushed a change to branch master in repository glewlwyd. from ac14617 Import Debian changes 1.2.4-1 new 9944f88 Import Upstream version 1.3.1 new 77cb271 Import Debian changes 1.3.1-1 The 2 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Summary of changes: .gitignore | 1 + INSTALL.md | 21 +- README.md | 14 ++ database/glewlwyd.init-db-only.mariadb.sql | 2 +- database/init-sqlite3-md5.sql | 2 - database/init-sqlite3-sha.sql | 2 - database/init-sqlite3-sha256.sql | 2 - database/init-sqlite3-sha512.sql | 2 - debian/changelog | 8 + debian/compat | 2 +- debian/control | 4 +- glewlwyd.conf.sample | 7 +- resources/ulfius/glewlwyd_resource.c | 89 ++++--- resources/ulfius/glewlwyd_resource.h | 4 +- src/admin.c | 4 +- src/client.c | 39 +-- src/glewlwyd.c | 47 +++- src/glewlwyd.h | 18 +- src/oauth.c | 6 +- src/resource.c | 10 +- src/scope.c | 4 +- src/token.c | 75 +++--- src/user.c | 179 ++++++++++++-- src/webservice.c | 115 +++------ test/Makefile | 23 +- test/glewlwyd_crud_user.c | 56 +++++ test/glewlwyd_http_auth.c | 371 +++++++++++++++++++++++++++++ webapp/app/glewlwyd.react.js | 7 +- 28 files changed, 879 insertions(+), 235 deletions(-) create mode 100644 test/glewlwyd_http_auth.c -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-iot/glewlwyd.git From alteholz at moszumanska.debian.org Mon Mar 19 21:42:07 2018 From: alteholz at moszumanska.debian.org (Thorsten Alteholz) Date: Mon, 19 Mar 2018 21:42:07 +0000 Subject: [Debian-iot-packaging] [glewlwyd] 02/02: Import Debian changes 1.3.1-1 In-Reply-To: <20180319214206.5704.36591@moszumanska.debian.org> References: <20180319214206.5704.36591@moszumanska.debian.org> Message-ID: This is an automated email from the git hooks/post-receive script. alteholz pushed a commit to branch master in repository glewlwyd. commit 77cb2712fa4c03e017195c24f86d4e442ea862ce Merge: ac14617 9944f88 Author: Thorsten Alteholz Date: Tue Jan 30 19:05:19 2018 +0100 Import Debian changes 1.3.1-1 glewlwyd (1.3.1-1) unstable; urgency=medium * New upstream release * debian/control: bump standard to 4.1.3 (no changes) * debian/control: use dh11 .gitignore | 1 + INSTALL.md | 21 +- README.md | 14 ++ database/glewlwyd.init-db-only.mariadb.sql | 2 +- database/init-sqlite3-md5.sql | 2 - database/init-sqlite3-sha.sql | 2 - database/init-sqlite3-sha256.sql | 2 - database/init-sqlite3-sha512.sql | 2 - debian/changelog | 8 + debian/compat | 2 +- debian/control | 4 +- glewlwyd.conf.sample | 7 +- resources/ulfius/glewlwyd_resource.c | 89 ++++--- resources/ulfius/glewlwyd_resource.h | 4 +- src/admin.c | 4 +- src/client.c | 39 +-- src/glewlwyd.c | 47 +++- src/glewlwyd.h | 18 +- src/oauth.c | 6 +- src/resource.c | 10 +- src/scope.c | 4 +- src/token.c | 75 +++--- src/user.c | 179 ++++++++++++-- src/webservice.c | 115 +++------ test/Makefile | 23 +- test/glewlwyd_crud_user.c | 56 +++++ test/glewlwyd_http_auth.c | 371 +++++++++++++++++++++++++++++ webapp/app/glewlwyd.react.js | 7 +- 28 files changed, 879 insertions(+), 235 deletions(-) diff --cc debian/changelog index 0c576f1,0000000..79a63d1 mode 100644,000000..100644 --- a/debian/changelog +++ b/debian/changelog @@@ -1,43 -1,0 +1,51 @@@ ++glewlwyd (1.3.1-1) unstable; urgency=medium ++ ++ * New upstream release ++ * debian/control: bump standard to 4.1.3 (no changes) ++ * debian/control: use dh11 ++ ++ -- Thorsten Alteholz Tue, 30 Jan 2018 19:05:19 +0100 ++ +glewlwyd (1.2.4-1) unstable; urgency=medium + + * New upstream release + + -- Thorsten Alteholz Tue, 21 Nov 2017 18:52:20 +0100 + +glewlwyd (1.2.2-1) unstable; urgency=medium + + * New upstream release + * debian/control: bump standard to 4.1.1 (no changes) + * debian/control: remove dependency on default-libmysqlclient-dev and + let libhoel-dev do the sql magic (Closes: #876714) + + -- Thorsten Alteholz Sat, 07 Oct 2017 16:33:07 +0200 + +glewlwyd (1.2-1) unstable; urgency=medium + + * New upstream release + * move config file to /etc/glewlwyd + + -- Thorsten Alteholz Fri, 15 Sep 2017 18:39:08 +0200 + +glewlwyd (1.1.2-1) unstable; urgency=medium + + * New upstream release + * debian/control: bump standard to 4.1.0 (no changes) + * debian/control: add VCS URLs + * debian/control: set maintainer to team + + -- Thorsten Alteholz Tue, 05 Sep 2017 21:57:32 +0200 + +glewlwyd (1.1-2) unstable; urgency=medium + + * create fonts stuff within dh_install-indep (Closes: #871623) + * put font package into fonts section (Closes: #871589) + + -- Thorsten Alteholz Wed, 16 Aug 2017 20:39:01 +0200 + +glewlwyd (1.1-1) unstable; urgency=medium + + * Initial release + + -- Thorsten Alteholz Mon, 07 Aug 2017 19:39:01 +0200 diff --cc debian/compat index f599e28,0000000..b4de394 mode 100644,000000..100644 --- a/debian/compat +++ b/debian/compat @@@ -1,1 -1,0 +1,1 @@@ - 10 ++11 diff --cc debian/control index eadd3a3,0000000..7d8cd10 mode 100644,000000..100644 --- a/debian/control +++ b/debian/control @@@ -1,68 -1,0 +1,68 @@@ +Source: glewlwyd +Section: web +Priority: optional +Maintainer: Debian IoT Maintainers +Uploaders: Thorsten Alteholz - Build-Depends: debhelper (>= 10) ++Build-Depends: debhelper (>= 11) + , libmicrohttpd-dev + , libjansson-dev + , libcurl4-gnutls-dev + , uuid-dev + , libldap2-dev + , libsqlite3-dev + , libconfig-dev + , libgnutls28-dev + , libssl-dev + , libjwt-dev + , liborcania-dev + , libyder-dev + , libulfius-dev + , libhoel-dev - Standards-Version: 4.1.1 ++Standards-Version: 4.1.3 +Homepage: https://github.com/babelouest/glewlwyd +Vcs-Browser: https://anonscm.debian.org/cgit/debian-iot/glewlwyd.git +Vcs-Git: https://anonscm.debian.org/git/debian-iot/glewlwyd.git + +Package: glewlwyd +Architecture: any +Depends: ${shlibs:Depends}, + , ${misc:Depends} + , lsb-base (>=3.0-6) + , glewlwyd-common +Description: OAuth2 authentication server providing Json Web Tokens + Lightweight, fast and easy to install on small systems. Requires a + MySql or SQLite3 database. Handles LDAP or database for users backend. + . + The API backend is fully written in language C, it's based on Ulfius + HTTP framework, Hoel database framework and Libjwt JSON Web Tokens + library. + +Package: glewlwyd-common +Depends: ${misc:Depends} + , fonts-glewlwyd +Architecture: all +Description: OAuth2 authentication server providing Json Web Tokens - common files + Lightweight, fast and easy to install on small systems. Requires a + MySql or SQLite3 database. Handles LDAP or database for users backend. + . + The API backend is fully written in language C, it's based on Ulfius + HTTP framework, Hoel database framework and Libjwt JSON Web Tokens + library. + . + This package contains the architecture independent files. + +Package: fonts-glewlwyd +Depends: ${misc:Depends} + , fonts-font-awesome +Architecture: all +Section: fonts +Multi-Arch: foreign +Description: OAuth2 authentication server providing Json Web Tokens - font files + Lightweight, fast and easy to install on small systems. Requires a + MySql or SQLite3 database. Handles LDAP or database for users backend. + . + The API backend is fully written in language C, it's based on Ulfius + HTTP framework, Hoel database framework and Libjwt JSON Web Tokens + library. + . + This package contains the needed fonts. -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-iot/glewlwyd.git From alteholz at moszumanska.debian.org Mon Mar 19 21:42:07 2018 From: alteholz at moszumanska.debian.org (Thorsten Alteholz) Date: Mon, 19 Mar 2018 21:42:07 +0000 Subject: [Debian-iot-packaging] [glewlwyd] branch pristine-tar updated (edcda43 -> 6ecb6f2) Message-ID: <20180319214206.5704.21949@moszumanska.debian.org> This is an automated email from the git hooks/post-receive script. alteholz pushed a change to branch pristine-tar in repository glewlwyd. from edcda43 pristine-tar data for glewlwyd_1.2.4.orig.tar.gz new 6ecb6f2 pristine-tar data for glewlwyd_1.3.1.orig.tar.gz The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Summary of changes: glewlwyd_1.3.1.orig.tar.gz.delta | Bin 0 -> 4229 bytes glewlwyd_1.3.1.orig.tar.gz.id | 1 + 2 files changed, 1 insertion(+) create mode 100644 glewlwyd_1.3.1.orig.tar.gz.delta create mode 100644 glewlwyd_1.3.1.orig.tar.gz.id -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-iot/glewlwyd.git From alteholz at moszumanska.debian.org Mon Mar 19 21:42:07 2018 From: alteholz at moszumanska.debian.org (Thorsten Alteholz) Date: Mon, 19 Mar 2018 21:42:07 +0000 Subject: [Debian-iot-packaging] [glewlwyd] 01/01: pristine-tar data for glewlwyd_1.3.1.orig.tar.gz In-Reply-To: <20180319214206.5704.21949@moszumanska.debian.org> References: <20180319214206.5704.21949@moszumanska.debian.org> Message-ID: This is an automated email from the git hooks/post-receive script. alteholz pushed a commit to branch pristine-tar in repository glewlwyd. commit 6ecb6f2d9f0f73d9dd6a67cd182ee29ebfb02f8e Author: Thorsten Alteholz Date: Mon Mar 19 22:41:48 2018 +0100 pristine-tar data for glewlwyd_1.3.1.orig.tar.gz --- glewlwyd_1.3.1.orig.tar.gz.delta | Bin 0 -> 4229 bytes glewlwyd_1.3.1.orig.tar.gz.id | 1 + 2 files changed, 1 insertion(+) diff --git a/glewlwyd_1.3.1.orig.tar.gz.delta b/glewlwyd_1.3.1.orig.tar.gz.delta new file mode 100644 index 0000000..be1b578 Binary files /dev/null and b/glewlwyd_1.3.1.orig.tar.gz.delta differ diff --git a/glewlwyd_1.3.1.orig.tar.gz.id b/glewlwyd_1.3.1.orig.tar.gz.id new file mode 100644 index 0000000..88e9a9a --- /dev/null +++ b/glewlwyd_1.3.1.orig.tar.gz.id @@ -0,0 +1 @@ +ef0df783417313ae8baebc65702c8a778282de72 -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-iot/glewlwyd.git From alteholz at moszumanska.debian.org Mon Mar 19 21:42:07 2018 From: alteholz at moszumanska.debian.org (Thorsten Alteholz) Date: Mon, 19 Mar 2018 21:42:07 +0000 Subject: [Debian-iot-packaging] [glewlwyd] branch upstream updated (c31a53a -> 9944f88) Message-ID: <20180319214206.5704.96972@moszumanska.debian.org> This is an automated email from the git hooks/post-receive script. alteholz pushed a change to branch upstream in repository glewlwyd. from c31a53a Import Upstream version 1.2.4 new 9944f88 Import Upstream version 1.3.1 The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Summary of changes: .gitignore | 1 + INSTALL.md | 21 +- README.md | 14 ++ database/glewlwyd.init-db-only.mariadb.sql | 2 +- database/init-sqlite3-md5.sql | 2 - database/init-sqlite3-sha.sql | 2 - database/init-sqlite3-sha256.sql | 2 - database/init-sqlite3-sha512.sql | 2 - glewlwyd.conf.sample | 7 +- resources/ulfius/glewlwyd_resource.c | 89 ++++--- resources/ulfius/glewlwyd_resource.h | 4 +- src/admin.c | 4 +- src/client.c | 39 +-- src/glewlwyd.c | 47 +++- src/glewlwyd.h | 18 +- src/oauth.c | 6 +- src/resource.c | 10 +- src/scope.c | 4 +- src/token.c | 75 +++--- src/user.c | 179 ++++++++++++-- src/webservice.c | 115 +++------ test/Makefile | 23 +- test/glewlwyd_crud_user.c | 56 +++++ test/glewlwyd_http_auth.c | 371 +++++++++++++++++++++++++++++ webapp/app/glewlwyd.react.js | 7 +- 25 files changed, 868 insertions(+), 232 deletions(-) create mode 100644 test/glewlwyd_http_auth.c -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-iot/glewlwyd.git From alteholz at moszumanska.debian.org Mon Mar 19 21:42:08 2018 From: alteholz at moszumanska.debian.org (Thorsten Alteholz) Date: Mon, 19 Mar 2018 21:42:08 +0000 Subject: [Debian-iot-packaging] [glewlwyd] annotated tag debian/1.3.1-1 created (now 5cbce72) Message-ID: <20180319214208.6685.19860@moszumanska.debian.org> This is an automated email from the git hooks/post-receive script. alteholz pushed a change to annotated tag debian/1.3.1-1 in repository glewlwyd. at 5cbce72 (tag) tagging 77cb2712fa4c03e017195c24f86d4e442ea862ce (commit) replaces debian/1.2.4-1 tagged by Thorsten Alteholz on Mon Mar 19 22:41:37 2018 +0100 - Log ----------------------------------------------------------------- Debian release 1.3.1-1 Thorsten Alteholz (2): Import Upstream version 1.3.1 Import Debian changes 1.3.1-1 ----------------------------------------------------------------------- No new revisions were added by this update. -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-iot/glewlwyd.git From alteholz at moszumanska.debian.org Mon Mar 19 21:42:08 2018 From: alteholz at moszumanska.debian.org (Thorsten Alteholz) Date: Mon, 19 Mar 2018 21:42:08 +0000 Subject: [Debian-iot-packaging] [glewlwyd] annotated tag upstream/1.3.1 created (now 24487ab) Message-ID: <20180319214208.6685.60232@moszumanska.debian.org> This is an automated email from the git hooks/post-receive script. alteholz pushed a change to annotated tag upstream/1.3.1 in repository glewlwyd. at 24487ab (tag) tagging 9944f886507f9ef0c0c449a7368f8d8873008c33 (commit) replaces upstream/1.2.4 tagged by Thorsten Alteholz on Mon Mar 19 22:41:36 2018 +0100 - Log ----------------------------------------------------------------- Upstream version 1.3.1 Thorsten Alteholz (1): Import Upstream version 1.3.1 ----------------------------------------------------------------------- No new revisions were added by this update. -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-iot/glewlwyd.git From alteholz at moszumanska.debian.org Mon Mar 19 21:43:27 2018 From: alteholz at moszumanska.debian.org (Thorsten Alteholz) Date: Mon, 19 Mar 2018 21:43:27 +0000 Subject: [Debian-iot-packaging] [hoel] branch master updated (3e82e6c -> 53b307a) Message-ID: <20180319214326.23982.62624@moszumanska.debian.org> This is an automated email from the git hooks/post-receive script. alteholz pushed a change to branch master in repository hoel. from 3e82e6c Import Debian changes 1.2.1-1 new 67cbba3 Import Upstream version 1.3.1 new 53b307a Import Debian changes 1.3.1-1 The 2 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Summary of changes: Makefile | 2 +- README.md | 87 +++++++++++++++-------- _config.yml | 1 + debian/changelog | 8 +++ debian/compat | 2 +- debian/control | 17 ++--- debian/{libhoel1.2.install => libhoel1.3.install} | 0 debian/libhoel1.3.symbols | 50 +++++++++++++ debian/patches/hardening.patch | 19 +++-- src/Makefile | 11 +-- src/h-private.h | 2 +- src/hoel-mariadb.c | 22 ++++-- src/hoel-pgsql.c | 17 ++++- src/hoel-simple-json.c | 63 ++++++++++++++-- src/hoel-sqlite.c | 18 ++++- src/hoel.c | 12 ++-- src/hoel.h | 22 +++--- test/core.c | 19 +++++ 18 files changed, 287 insertions(+), 85 deletions(-) create mode 100644 _config.yml rename debian/{libhoel1.2.install => libhoel1.3.install} (100%) create mode 100644 debian/libhoel1.3.symbols -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-iot/hoel.git From alteholz at moszumanska.debian.org Mon Mar 19 21:43:27 2018 From: alteholz at moszumanska.debian.org (Thorsten Alteholz) Date: Mon, 19 Mar 2018 21:43:27 +0000 Subject: [Debian-iot-packaging] [hoel] 01/02: Import Upstream version 1.3.1 In-Reply-To: <20180319214326.23982.62624@moszumanska.debian.org> References: <20180319214326.23982.62624@moszumanska.debian.org> Message-ID: This is an automated email from the git hooks/post-receive script. alteholz pushed a commit to branch master in repository hoel. commit 67cbba3eac854d18b0e6d1b4006e41d99fa78fcb Author: Thorsten Alteholz Date: Mon Mar 19 22:43:18 2018 +0100 Import Upstream version 1.3.1 --- Makefile | 2 +- README.md | 87 ++++++++++++++++++++++++++++++++------------------ _config.yml | 1 + src/Makefile | 11 ++++--- src/h-private.h | 2 +- src/hoel-mariadb.c | 22 ++++++++++--- src/hoel-pgsql.c | 17 ++++++++-- src/hoel-simple-json.c | 63 ++++++++++++++++++++++++++++++++---- src/hoel-sqlite.c | 18 +++++++++-- src/hoel.c | 12 +++---- src/hoel.h | 22 ++++++------- test/core.c | 19 +++++++++++ 12 files changed, 207 insertions(+), 69 deletions(-) diff --git a/Makefile b/Makefile index 173dab4..9f3954c 100644 --- a/Makefile +++ b/Makefile @@ -32,7 +32,7 @@ clean: cd $(TEST_LOCATION) && $(MAKE) clean libhoel.so: - cd $(LIBHOEL_LOCATION) && $(MAKE) + cd $(LIBHOEL_LOCATION) && $(MAKE) $(*) simple_example: cd $(EXAMPLE_LOCATION) && $(MAKE) diff --git a/README.md b/README.md index 91b5ffd..0c36a24 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,11 @@ Simple and easy to use database access library. Works with SQLite 3, MariaDB/Mys # Installation -## Linux distribution package +## Debian-ish distribution package -Hoel is now available in Debian Buster (testing), Debian Sid, and soon in Ubuntu. To install the development package on your system, run the command as root: +[![Packaging status](https://repology.org/badge/vertical-allrepos/hoel.svg)](https://repology.org/metapackage/hoel) + +Hoel is now available in Debian Buster (testing) and some Debian based distributions. To install the development package on your system, run the command as root: ```shell # apt install libhoel-dev @@ -16,13 +18,13 @@ Hoel is now available in Debian Buster (testing), Debian Sid, and soon in Ubuntu ## Install from the source -Clone, compile and install [Orcania](https://github.com/babelouest/orcania) and [Yder](https://github.com/babelouest/yder) librares. +Clone, compile and install [Orcania](https://github.com/babelouest/orcania) and [Yder](https://github.com/babelouest/yder) libraries. ### Orcania (Miscellaneous functions) ```shell $ git clone https://github.com/babelouest/orcania.git -$ cd orcania +$ cd orcania/src $ make && sudo make install ``` @@ -30,64 +32,79 @@ $ make && sudo make install ```shell $ git clone https://github.com/babelouest/yder.git -$ cd yder +$ cd yder/src $ make $ sudo make install ``` +### Jansson + Install [Jansson](http://www.digip.org/jansson/) library for JSON manipulation. On a debian-based platform, run the following command: ```shell $ sudo apt-get install libjansson-dev ``` +### Hoel + +Install Hoel dependencies: +- SQLite3: Install the package `libsqlite3-dev` +- MariaDB/Mysql: Install the package `libmysqlclient-dev` or `libmariadbclient-dev` +- PostgreSQL: Install the package `libpq-dev` + Download hoel from github repository. ```shell $ git clone https://github.com/babelouest/hoel.git +$ cd hoel/src +$ make +$ sudo make install ``` -Compile hoel for the backend you need, go to hoel source folder, depending on your database backend needs, follow these instructions. +By default, Hoel is compiled with the 3 databases support. If you don't need one or more database, follow these instructions -## SQLite 3 +#### SQLite 3 -Install `libsqlite3-dev` and uncomment the following lines in the `src/Makefile` +Add DISABLE_SQLITE=1 to the `make` command: -```Makefile -# HAS_SQLITE=-D_HOEL_SQLITE -# LIBS_SQLITE=-lsqlite3 +```shell +$ cd hoel/src +$ make DISABLE_SQLITE=1 +$ sudo make install ``` -## MariaDB/Mysql +#### MariaDB/Mysql -Install `libmysqlclient-dev` and uncomment the following lines in the `src/Makefile` +Add DISABLE_MARIADB=1 to the `make` command: -```Makefile -# FLAGS_MARIADB=-D_HOEL_MARIADB -I/usr/include/mysql/ -# LIBS_MYSQL=-lmysqlclient +```shell +$ cd hoel/src +$ make DISABLE_MARIADB=1 +$ sudo make install ``` -## Postgre SQL +#### Postgre SQL -Install `libpq-dev` and uncomment the following lines in the `src/Makefile` +Add DISABLE_POSTGRESQL=1 to the `make` command: -```Makefile -# HAS_PGSQL=-D_HOEL_PGSQL -I/usr/include/postgresql/ -# LIBS_PGSQL=-lpq +```shell +$ cd hoel/src +$ make DISABLE_POSTGRESQL=1 +$ sudo make install ``` -### Use different backends +### Disable 2 backends -You can use different backends at the same time, simply install the required libraries and uncomment all the required backend requirements in the `src/Makefile`. +You can disable 2 databases backends to keep just one, simply add both parameters to the `make` command: -## Compile and install - -``` -$ cd src -$ make +```shell +$ cd hoel/src +$ make DISABLE_MARIADB=1 DISABLE_POSTGRESQL=1 $ sudo make install ``` +### Installation folder + By default, the shared library and the header file will be installed in the `/usr/local` location. To change this setting, you can modify the `PREFIX` value in the `src/Makefile`. # API Documentation @@ -393,16 +410,24 @@ A `j_query` has the following form: "col1": "value1", // Generates col1='value1' "col2": value_integer, // Generates col2=value_integer "col3": null, // Generates col3=NULL - "col4", { // Generates col4<12 + "col4": { // Generates col4<12 "operator": "<", "value": 12 }, - "col5", { // Generates col5 IS NOT NULL + "col5": { // Generates col5 IS NOT NULL "operator": "NOT NULL" }, - "col6", { // Generates col6 LIKE '%value6%' + "col6": { // Generates col6 LIKE '%value6%' "operator": "raw", "value": "LIKE '%value6%'" + }, + "col7": { + "operator": "IN", // Generates col7 IN ('value1',42,4.2) + "value": [ // Values can be string, real or integer + "value1", + 42, + 4.2 + ] } } } diff --git a/_config.yml b/_config.yml new file mode 100644 index 0000000..2f7efbe --- /dev/null +++ b/_config.yml @@ -0,0 +1 @@ +theme: jekyll-theme-minimal \ No newline at end of file diff --git a/src/Makefile b/src/Makefile index 2ec14b2..b3e5d83 100644 --- a/src/Makefile +++ b/src/Makefile @@ -20,23 +20,26 @@ # CC=gcc -# comment/uncomment these lines to disable/enable sqlite3 support +ifndef DISABLE_SQLITE FLAGS_SQLITE=-D_HOEL_SQLITE LIBS_SQLITE=-lsqlite3 +endif -# comment/uncomment these lines to disable/enable mysql/mariadb support +ifndef DISABLE_MARIADB FLAGS_MARIADB=-D_HOEL_MARIADB $(shell mysql_config --cflags) LIBS_MARIADB=$(shell mysql_config --libs_r) +endif -# comment/uncomment these lines to disable/enable postgresql support +ifndef DISABLE_POSTGRESQL FLAGS_PGSQL=-D_HOEL_PGSQL -I/usr/include/postgresql/ LIBS_PGSQL=-lpq +endif PREFIX=/usr/local CFLAGS=-c -fPIC -Wall -I$(PREFIX)/include $(FLAGS_SQLITE) $(FLAGS_MARIADB) $(FLAGS_PGSQL) -D_REENTRANT $(ADDITIONALFLAGS) LIBS=-L$(PREFIX)/lib -lc -ljansson -lyder -lorcania $(LIBS_SQLITE) $(LIBS_PGSQL) $(LIBS_MARIADB) OUTPUT=libhoel.so -VERSION=1.2 +VERSION=1.3.1 all: release diff --git a/src/h-private.h b/src/h-private.h index cad1fd8..20b19b7 100644 --- a/src/h-private.h +++ b/src/h-private.h @@ -56,4 +56,4 @@ struct _h_data * h_new_data_datetime(const struct tm * datetime); */ struct _h_data * h_new_data_null(); -#endif // __H_PRIVATE_H_ +#endif /* __H_PRIVATE_H_ */ diff --git a/src/hoel-mariadb.c b/src/hoel-mariadb.c index 86f2a1a..95175fb 100644 --- a/src/hoel-mariadb.c +++ b/src/hoel-mariadb.c @@ -24,7 +24,7 @@ #include "h-private.h" #ifdef _HOEL_MARIADB -// MariaDB library Includes +/* MariaDB library Includes */ #include #include #include @@ -84,11 +84,11 @@ struct _h_connection * h_connect_mariadb(const char * host, const char * user, c mysql_close(((struct _h_mariadb *)conn->connection)->db_handle); return NULL; } else { - // Set MYSQL_OPT_RECONNECT to true to reconnect automatically when connection is closed by the server (to avoid CR_SERVER_GONE_ERROR) + /* Set MYSQL_OPT_RECONNECT to true to reconnect automatically when connection is closed by the server (to avoid CR_SERVER_GONE_ERROR) */ mysql_options(((struct _h_mariadb *)conn->connection)->db_handle, MYSQL_OPT_RECONNECT, &reconnect); - // Initialize MUTEX for connection + /* Initialize MUTEX for connection */ pthread_mutexattr_init ( &mutexattr ); - pthread_mutexattr_settype( &mutexattr, PTHREAD_MUTEX_RECURSIVE_NP ); + pthread_mutexattr_settype( &mutexattr, PTHREAD_MUTEX_RECURSIVE ); if (pthread_mutex_init(&(((struct _h_mariadb *)conn->connection)->lock), &mutexattr) != 0) { y_log_message(Y_LOG_LEVEL_ERROR, "Impossible to initialize Mutex Lock for MariaDB connection"); } @@ -397,4 +397,18 @@ struct _h_data * h_get_mariadb_value(const char * value, const unsigned long len } return data; } +#else + +/** + * Dummy functions when Hoel is not built with MariaDB + */ +struct _h_connection * h_connect_mariadb(const char * host, const char * user, const char * passwd, const char * db, const unsigned int port, const char * unix_socket) { + y_log_message(Y_LOG_LEVEL_ERROR, "Hoel was not compiled with MariaDB backend"); + return NULL; +} + +void h_close_mariadb(struct _h_connection * conn) { + y_log_message(Y_LOG_LEVEL_ERROR, "Hoel was not compiled with MariaDB backend"); +} + #endif diff --git a/src/hoel-pgsql.c b/src/hoel-pgsql.c index e28e7c6..abefca5 100644 --- a/src/hoel-pgsql.c +++ b/src/hoel-pgsql.c @@ -24,7 +24,7 @@ #include "h-private.h" #ifdef _HOEL_PGSQL -// PostgreSQL library includes +/* PostgreSQL library includes */ #include #include @@ -49,7 +49,6 @@ struct _h_pgsql { * return pointer to a struct _h_connection * on sucess, NULL on error */ struct _h_connection * h_connect_pgsql(char * conninfo) { - // TODO get oids and types struct _h_connection * conn = NULL; struct _h_result result_types; int res_types, row; @@ -354,4 +353,18 @@ int h_last_insert_id_pgsql(const struct _h_connection * conn) { PQclear(res); return int_res; } +#else + +/** + * Dummy functions when Hoel is not built with PostgreSQL + */ +struct _h_connection * h_connect_pgsql(char * conninfo) { + y_log_message(Y_LOG_LEVEL_ERROR, "Hoel was not compiled with PostgreSQL backend"); + return NULL; +} + +void h_close_pgsql(struct _h_connection * conn) { + y_log_message(Y_LOG_LEVEL_ERROR, "Hoel was not compiled with PostgreSQL backend"); +} + #endif diff --git a/src/hoel-simple-json.c b/src/hoel-simple-json.c index cbc3820..1c52886 100644 --- a/src/hoel-simple-json.c +++ b/src/hoel-simple-json.c @@ -137,9 +137,10 @@ static char * h_get_insert_query_from_json_object(const struct _h_connection * c */ static char * h_get_where_clause_from_json_object(const struct _h_connection * conn, const json_t * where) { const char * key; - json_t * value, * ope, * val; - char * where_clause = NULL, * dump = NULL, * escape = NULL, * tmp, * clause, * dump2 = NULL; + json_t * value, * ope, * val, * j_element; + char * where_clause = NULL, * dump = NULL, * escape = NULL, * tmp, * clause = NULL, * dump2 = NULL; int i = 0; + size_t index; if (conn == NULL) { y_log_message(Y_LOG_LEVEL_DEBUG, "Hoel/h_get_where_clause_from_json_object - Error conn is NULL"); @@ -160,7 +161,7 @@ static char * h_get_where_clause_from_json_object(const struct _h_connection * c if (ope == NULL || !json_is_string(ope) || (val == NULL && 0 != o_strcasecmp("NOT NULL", json_string_value(ope))) || - (!json_is_string(val) && !json_is_real(val) && !json_is_integer(val) && 0 != o_strcasecmp("NOT NULL", json_string_value(ope)))) { + (!json_is_string(val) && !json_is_real(val) && !json_is_integer(val) && 0 != o_strcasecmp("NOT NULL", json_string_value(ope)) && 0 != o_strcasecmp("IN", json_string_value(ope)))) { dump = json_dumps(val, JSON_ENCODE_ANY); dump2 = json_dumps(ope, JSON_ENCODE_ANY); y_log_message(Y_LOG_LEVEL_DEBUG, "Hoel/h_get_where_clause_from_json_object - Error where object value is invalid: %s %s", dump, dump2); @@ -173,6 +174,49 @@ static char * h_get_where_clause_from_json_object(const struct _h_connection * c clause = msprintf("%s IS NOT NULL", key); } else if (0 == o_strcasecmp("raw", json_string_value(ope)) && json_is_string(val)) { clause = msprintf("%s %s", key, json_string_value(val)); + } else if (0 == o_strcasecmp("IN", json_string_value(ope))) { + if (json_is_array(val) && json_array_size(val) > 0) { + clause = NULL, tmp = NULL; + json_array_foreach(val, index, j_element) { + if (!json_is_string(j_element) && !json_is_real(j_element) && !json_is_integer(j_element)) { + o_free(clause); + o_free(where_clause); + y_log_message(Y_LOG_LEVEL_ERROR, "Hoel - Error element value in IN statement array must be real, integer or string"); + return NULL; + } else { + if (json_is_string(j_element)) { + escape = h_escape_string(conn, json_string_value(j_element)); + if (escape == NULL) { + y_log_message(Y_LOG_LEVEL_ERROR, "Hoel - Error escape"); + o_free(clause); + o_free(where_clause); + return NULL; + } + dump = msprintf("'%s'", escape); + o_free(escape); + } else if (json_is_real(j_element)) { + dump = msprintf("%f", json_real_value(j_element)); + } else { + dump = msprintf("%" JSON_INTEGER_FORMAT, json_integer_value(j_element)); + } + if (clause == NULL) { + clause = msprintf("%s IN (%s", key, dump); + } else { + tmp = msprintf("%s,%s", clause, dump); + o_free(clause); + clause = tmp; + } + o_free(dump); + } + } + tmp = msprintf("%s)", clause); + o_free(clause); + clause = tmp; + } else { + o_free(where_clause); + y_log_message(Y_LOG_LEVEL_ERROR, "Hoel - Error value in IN statement must be a non empty JSON array"); + return NULL; + } } else { if (json_is_real(val)) { clause = msprintf("%s %s %f", key, json_string_value(ope), json_real_value(val)); @@ -182,6 +226,7 @@ static char * h_get_where_clause_from_json_object(const struct _h_connection * c escape = h_escape_string(conn, json_string_value(val)); if (escape == NULL) { y_log_message(Y_LOG_LEVEL_ERROR, "Hoel - Error escape"); + o_free(where_clause); return NULL; } clause = msprintf("%s %s '%s'", key, json_string_value(ope), escape); @@ -190,6 +235,7 @@ static char * h_get_where_clause_from_json_object(const struct _h_connection * c } if (clause == NULL) { y_log_message(Y_LOG_LEVEL_ERROR, "Hoel - Error allocating memory for clause"); + o_free(where_clause); return NULL; } } @@ -200,6 +246,7 @@ static char * h_get_where_clause_from_json_object(const struct _h_connection * c escape = h_escape_string(conn, json_string_value(value)); if (escape == NULL) { y_log_message(Y_LOG_LEVEL_ERROR, "Hoel - Error escape"); + o_free(where_clause); return NULL; } clause = msprintf("%s='%s'", key, escape); @@ -215,6 +262,7 @@ static char * h_get_where_clause_from_json_object(const struct _h_connection * c } if (clause == NULL) { y_log_message(Y_LOG_LEVEL_ERROR, "Hoel - Error allocating memory for clause"); + o_free(where_clause); return NULL; } } @@ -223,6 +271,7 @@ static char * h_get_where_clause_from_json_object(const struct _h_connection * c if (where_clause == NULL) { y_log_message(Y_LOG_LEVEL_DEBUG, "Hoel/h_get_where_clause_from_json_object - Error where_clause"); o_free(clause); + o_free(where_clause); return NULL; } o_free(clause); @@ -233,6 +282,7 @@ static char * h_get_where_clause_from_json_object(const struct _h_connection * c if (tmp == NULL) { y_log_message(Y_LOG_LEVEL_DEBUG, "Hoel/h_get_where_clause_from_json_object - Error tmp where_clause"); o_free(clause); + o_free(where_clause); return NULL; } o_free(clause); @@ -426,7 +476,6 @@ int h_select(const struct _h_connection * conn, const json_t * j_query, json_t * } else { str_where_limit = o_strdup(""); } - if (order_by != NULL && json_is_string(order_by)) { str_order_by = msprintf("ORDER BY %s", json_string_value(order_by)); } else { @@ -486,7 +535,7 @@ int h_insert(const struct _h_connection * conn, const json_t * j_query, char ** int res; if (conn != NULL && j_query != NULL && json_is_object(j_query) && json_is_string(json_object_get(j_query, "table")) && (json_is_object(json_object_get(j_query, "values")) || json_is_array(json_object_get(j_query, "values")))) { - // Construct query + /* Construct query */ table = json_string_value((const json_t *)json_object_get(j_query, "table")); values = json_object_get(j_query, "values"); switch json_typeof(values) { @@ -509,7 +558,7 @@ int h_insert(const struct _h_connection * conn, const json_t * j_query, char ** query = h_get_insert_query_from_json_object(conn, j_row, table); if (query != NULL) { if (generated_query != NULL && index == 0) { - // Export just the first query + /* Export just the first query */ *generated_query = o_strdup(query); } res = h_query_insert(conn, query); @@ -546,7 +595,7 @@ json_t * h_last_insert_id(const struct _h_connection * conn) { json_t * j_data = NULL; if (conn != NULL && conn->connection != NULL) { if (0) { - // Not happening + /* Not happening */ #ifdef _HOEL_SQLITE } else if (conn->type == HOEL_DB_TYPE_SQLITE) { int last_id = h_last_insert_id_sqlite(conn); diff --git a/src/hoel-sqlite.c b/src/hoel-sqlite.c index fc6756f..c0c2ae2 100644 --- a/src/hoel-sqlite.c +++ b/src/hoel-sqlite.c @@ -126,7 +126,7 @@ int h_select_query_sqlite(const struct _h_connection * conn, const char * query, row = 0; if (result != NULL) { row_result = sqlite3_step(stmt); - // Filling result object with results in array format + /* Filling result object with results in array format */ result->nb_rows = 0; result->nb_columns = nb_columns; result->data = NULL; @@ -218,7 +218,7 @@ int h_execute_query_json_sqlite(const struct _h_connection * conn, const char * if (sql_result == SQLITE_OK) { nb_columns = sqlite3_column_count(stmt); - // Filling j_result with results in json format + /* Filling j_result with results in json format */ *j_result = json_array(); if (*j_result == NULL) { y_log_message(Y_LOG_LEVEL_ERROR, "Hoel - Error allocating memory for *j_result"); @@ -269,4 +269,18 @@ int h_execute_query_json_sqlite(const struct _h_connection * conn, const char * return H_ERROR_QUERY; } } +#else + +/** + * Dummy functions when Hoel is not built with SQLite + */ +struct _h_connection * h_connect_sqlite(const char * db_path) { + y_log_message(Y_LOG_LEVEL_ERROR, "Hoel was not compiled with SQLite backend"); + return NULL; +} + +void h_close_sqlite(struct _h_connection * conn) { + y_log_message(Y_LOG_LEVEL_ERROR, "Hoel was not compiled with SQLite backend"); +} + #endif diff --git a/src/hoel.c b/src/hoel.c index 52376a4..9c01676 100644 --- a/src/hoel.c +++ b/src/hoel.c @@ -40,7 +40,7 @@ void h_free(void * data) { int h_close_db(struct _h_connection * conn) { if (conn != NULL && conn->connection != NULL) { if (0) { - // Not happening + /* Not happening */ #ifdef _HOEL_SQLITE } else if (conn->type == HOEL_DB_TYPE_SQLITE) { h_close_sqlite(conn); @@ -72,7 +72,7 @@ int h_close_db(struct _h_connection * conn) { char * h_escape_string(const struct _h_connection * conn, const char * unsafe) { if (conn != NULL && conn->connection != NULL && unsafe != NULL) { if (0) { - // Not happening + /* Not happening */ #ifdef _HOEL_SQLITE } else if (conn->type == HOEL_DB_TYPE_SQLITE) { return h_escape_string_sqlite(conn, unsafe); @@ -106,7 +106,7 @@ char * h_escape_string(const struct _h_connection * conn, const char * unsafe) { int h_execute_query(const struct _h_connection * conn, const char * query, struct _h_result * result, int options) { if (conn != NULL && conn->connection != NULL && query != NULL) { if (0) { - // Not happening + /* Not happening */ #ifdef _HOEL_SQLITE } else if (conn->type == HOEL_DB_TYPE_SQLITE) { if (options & H_OPTION_EXEC) { @@ -137,9 +137,9 @@ int h_execute_query(const struct _h_connection * conn, const char * query, struc * return H_OK on success */ int h_execute_query_json(const struct _h_connection * conn, const char * query, json_t ** j_result) { - if (conn != NULL && conn->connection != NULL && query != NULL) { + if (conn != NULL && conn->connection != NULL && query != NULL && j_result != NULL) { if (0) { - // Not happening + /* Not happening */ #ifdef _HOEL_SQLITE } else if (conn->type == HOEL_DB_TYPE_SQLITE) { return h_execute_query_json_sqlite(conn, query, j_result); @@ -290,7 +290,7 @@ struct _h_data * h_query_last_insert_id(const struct _h_connection * conn) { struct _h_data * data = NULL; if (conn != NULL && conn->connection != NULL) { if (0) { - // Not happening + /* Not happening */ #ifdef _HOEL_SQLITE } else if (conn->type == HOEL_DB_TYPE_SQLITE) { int last_id = h_last_insert_id_sqlite(conn); diff --git a/src/hoel.h b/src/hoel.h index 5f181c0..c863d5a 100644 --- a/src/hoel.h +++ b/src/hoel.h @@ -24,7 +24,7 @@ #ifndef __HOEL_H__ #define __HOEL_H__ -#define HOEL_VERSION 1.2 +#define HOEL_VERSION 1.3.1 #include @@ -56,16 +56,16 @@ #define HOEL_COL_TYPE_BOOL 5 #define HOEL_COL_TYPE_NULL 5 -#define H_OK 0 // No error -#define H_ERROR 1 // Generic error -#define H_ERROR_PARAMS 2 // Error in input parameters -#define H_ERROR_CONNECTION 3 // Error in database connection -#define H_ERROR_QUERY 4 // Error executing query -#define H_ERROR_MEMORY 99 // Error allocating memory +#define H_OK 0 /* No error */ +#define H_ERROR 1 /* Generic error */ +#define H_ERROR_PARAMS 2 /* Error in input parameters */ +#define H_ERROR_CONNECTION 3 /* Error in database connection */ +#define H_ERROR_QUERY 4 /* Error executing query */ +#define H_ERROR_MEMORY 99 /* Error allocating memory */ -#define H_OPTION_NONE 0x0000 // Nothing whatsoever -#define H_OPTION_SELECT 0x0001 // Execute a SELECT statement -#define H_OPTION_EXEC 0x0010 // Execute an INSERT, UPDATE or DELETE statement +#define H_OPTION_NONE 0x0000 /* Nothing whatsoever */ +#define H_OPTION_SELECT 0x0001 /* Execute a SELECT statement */ +#define H_OPTION_EXEC 0x0010 /* Execute an INSERT, UPDATE or DELETE statement */ /** * handle container @@ -469,4 +469,4 @@ char * h_escape_string_pgsql(const struct _h_connection * conn, const char * uns int h_last_insert_id_pgsql(const struct _h_connection * conn); #endif -#endif // __HOEL_H__ +#endif /* __HOEL_H__ */ diff --git a/test/core.c b/test/core.c index d0336ca..2fa19b0 100644 --- a/test/core.c +++ b/test/core.c @@ -547,6 +547,25 @@ START_TEST(test_hoel_json_select) json_decref(j_result); h_free(str_query); + str_query = NULL; + j_result = NULL; + j_query = json_pack("{sss{s{sss[ii]}}}", + "table", + "test_table", + "where", + "integer_col", + "operator", + "IN", + "value", + 42, + 66); + ck_assert_int_eq(h_select(conn, j_query, &j_result, &str_query), H_OK); + ck_assert_int_eq(strlen(str_query), strlen("SELECT * FROM `test_table` WHERE integer_col IN (42,66) ")); + ck_assert_int_eq(json_array_size(j_result), 0); + json_decref(j_query); + json_decref(j_result); + h_free(str_query); + j_query = json_pack("{ss}", "table", "test_table"); -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-iot/hoel.git From alteholz at moszumanska.debian.org Mon Mar 19 21:43:27 2018 From: alteholz at moszumanska.debian.org (Thorsten Alteholz) Date: Mon, 19 Mar 2018 21:43:27 +0000 Subject: [Debian-iot-packaging] [hoel] 02/02: Import Debian changes 1.3.1-1 In-Reply-To: <20180319214326.23982.62624@moszumanska.debian.org> References: <20180319214326.23982.62624@moszumanska.debian.org> Message-ID: This is an automated email from the git hooks/post-receive script. alteholz pushed a commit to branch master in repository hoel. commit 53b307ad0c6beb2fcf60011fa0f66569cf7bb5b7 Merge: 3e82e6c 67cbba3 Author: Thorsten Alteholz Date: Sun Jan 21 18:31:49 2018 +0100 Import Debian changes 1.3.1-1 hoel (1.3.1-1) unstable; urgency=medium * New upstream release * debian/control: bump standard to 4.1.3 (no changes) * debian/control: use dh11 Makefile | 2 +- README.md | 87 +++++++++++++++-------- _config.yml | 1 + debian/changelog | 8 +++ debian/compat | 2 +- debian/control | 17 ++--- debian/{libhoel1.2.install => libhoel1.3.install} | 0 debian/libhoel1.3.symbols | 50 +++++++++++++ debian/patches/hardening.patch | 19 +++-- src/Makefile | 11 +-- src/h-private.h | 2 +- src/hoel-mariadb.c | 22 ++++-- src/hoel-pgsql.c | 17 ++++- src/hoel-simple-json.c | 63 ++++++++++++++-- src/hoel-sqlite.c | 18 ++++- src/hoel.c | 12 ++-- src/hoel.h | 22 +++--- test/core.c | 19 +++++ 18 files changed, 287 insertions(+), 85 deletions(-) diff --cc debian/changelog index e8c4d6f,0000000..4ebb3ec mode 100644,000000..100644 --- a/debian/changelog +++ b/debian/changelog @@@ -1,23 -1,0 +1,31 @@@ ++hoel (1.3.1-1) unstable; urgency=medium ++ ++ * New upstream release ++ * debian/control: bump standard to 4.1.3 (no changes) ++ * debian/control: use dh11 ++ ++ -- Thorsten Alteholz Sun, 21 Jan 2018 18:31:49 +0100 ++ +hoel (1.2.1-1) unstable; urgency=medium + + * New upstream release + * debian/control: move to debian-iot group + * debian/control: bump soname of libhoel to 1.2 + + -- Thorsten Alteholz Thu, 05 Oct 2017 19:25:48 +0200 + +hoel (1.1.2-1) unstable; urgency=medium + + * new upstream version + * change homepage URL (Closes: #869933) + * debian/control: bump standard to 4.1.0 (no changes) + * debian/control: add VCS URLs + * refresh patches + + -- Thorsten Alteholz Sat, 02 Sep 2017 17:17:33 +0200 + +hoel (1.1-1) unstable; urgency=medium + + * Initial release + + -- Thorsten Alteholz Tue, 18 Jul 2017 14:32:33 +0200 diff --cc debian/compat index f599e28,0000000..b4de394 mode 100644,000000..100644 --- a/debian/compat +++ b/debian/compat @@@ -1,1 -1,0 +1,1 @@@ - 10 ++11 diff --cc debian/control index 1b78a4e,0000000..06ce28b mode 100644,000000..100644 --- a/debian/control +++ b/debian/control @@@ -1,43 -1,0 +1,44 @@@ +Source: hoel +Section: devel +Priority: optional +Maintainer: Debian IoT Maintainers +Uploaders: Thorsten Alteholz - Build-Depends: debhelper (>= 10) ++Build-Depends: debhelper (>= 11) + , liborcania-dev + , libyder-dev + , libjansson-dev + , libsqlite3-dev + , libpq-dev + , libmariadbclient-dev - Standards-Version: 4.1.0 ++Standards-Version: 4.1.3 +Homepage: https://github.com/babelouest/hoel +Vcs-Browser: https://anonscm.debian.org/cgit/debian-iot/hoel.git +Vcs-Git: https://anonscm.debian.org/git/debian-iot/hoel.git + - Package: libhoel1.2 ++Package: libhoel1.3 +Architecture: any ++Section: libs +Pre-Depends: ${misc:Pre-Depends} +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: database abstraction library written in C - Simple and easy to use database access library. Works with SQLite 3, - MariaDB/Mysql and (barely) PostgreSQL databases. Uses a json-based ++ Simple and easy to use database access library. Works with SQLite 3, ++ MariaDB/Mysql and (barely) PostgreSQL databases. Uses a json-based + language with jansson to execute simples queries based on one table. + +Package: libhoel-dev +Architecture: any +Section: libdevel - Depends: libhoel1.2 (= ${binary:Version}) ++Depends: libhoel1.3 (= ${binary:Version}) + , ${misc:Depends} + , libjansson-dev + , liborcania-dev + , libyder-dev + , libsqlite3-dev + , libpq-dev + , libmariadbclient-dev +Description: database abstraction library written in C - development - Simple and easy to use database access library. Works with SQLite 3, - MariaDB/Mysql and (barely) PostgreSQL databases. Uses a json-based ++ Simple and easy to use database access library. Works with SQLite 3, ++ MariaDB/Mysql and (barely) PostgreSQL databases. Uses a json-based + language with jansson to execute simples queries based on one table. + . + This package contains the development files. diff --cc debian/libhoel1.3.install index 6ac0115,0000000..6ac0115 mode 100644,000000..100644 --- a/debian/libhoel1.3.install +++ b/debian/libhoel1.3.install diff --cc debian/libhoel1.3.symbols index 0000000,0000000..c1123f6 new file mode 100644 --- /dev/null +++ b/debian/libhoel1.3.symbols @@@ -1,0 -1,0 +1,50 @@@ ++# SymbolsHelper-Confirmed: 1.3.1 amd64 ++libhoel.so.1.3 libhoel1.3 #MINVER# ++ h_clean_connection at Base 1.3.1 ++ h_clean_data at Base 1.3.1 ++ h_clean_data_full at Base 1.3.1 ++ h_clean_result at Base 1.3.1 ++ h_close_db at Base 1.3.1 ++ h_close_mariadb at Base 1.3.1 ++ h_close_pgsql at Base 1.3.1 ++ h_close_sqlite at Base 1.3.1 ++ h_connect_mariadb at Base 1.3.1 ++ h_connect_pgsql at Base 1.3.1 ++ h_connect_sqlite at Base 1.3.1 ++ h_delete at Base 1.3.1 ++ h_escape_string at Base 1.3.1 ++ h_escape_string_mariadb at Base 1.3.1 ++ h_escape_string_pgsql at Base 1.3.1 ++ h_escape_string_sqlite at Base 1.3.1 ++ h_exec_query_sqlite at Base 1.3.1 ++ h_execute_query at Base 1.3.1 ++ h_execute_query_json at Base 1.3.1 ++ h_execute_query_json_mariadb at Base 1.3.1 ++ h_execute_query_json_pgsql at Base 1.3.1 ++ h_execute_query_json_sqlite at Base 1.3.1 ++ h_execute_query_mariadb at Base 1.3.1 ++ h_execute_query_pgsql at Base 1.3.1 ++ h_free at Base 1.3.1 ++ h_get_mariadb_value at Base 1.3.1 ++ h_insert at Base 1.3.1 ++ h_last_insert_id at Base 1.3.1 ++ h_last_insert_id_mariadb at Base 1.3.1 ++ h_last_insert_id_pgsql at Base 1.3.1 ++ h_last_insert_id_sqlite at Base 1.3.1 ++ h_new_data_blob at Base 1.3.1 ++ h_new_data_datetime at Base 1.3.1 ++ h_new_data_double at Base 1.3.1 ++ h_new_data_int at Base 1.3.1 ++ h_new_data_null at Base 1.3.1 ++ h_new_data_text at Base 1.3.1 ++ h_query_delete at Base 1.3.1 ++ h_query_insert at Base 1.3.1 ++ h_query_last_insert_id at Base 1.3.1 ++ h_query_select at Base 1.3.1 ++ h_query_select_json at Base 1.3.1 ++ h_query_update at Base 1.3.1 ++ h_result_add_row at Base 1.3.1 ++ h_row_add_data at Base 1.3.1 ++ h_select at Base 1.3.1 ++ h_select_query_sqlite at Base 1.3.1 ++ h_update at Base 1.3.1 diff --cc debian/patches/hardening.patch index e8b5706,0000000..fd299d3 mode 100644,000000..100644 --- a/debian/patches/hardening.patch +++ b/debian/patches/hardening.patch @@@ -1,24 -1,0 +1,29 @@@ +Description: add hardening flags +Author: Thorsten Alteholz - Index: hoel-1.2.1/src/Makefile ++Index: hoel-1.3.1/src/Makefile +=================================================================== - --- hoel-1.2.1.orig/src/Makefile 2017-10-05 19:32:26.552561322 +0200 - +++ hoel-1.2.1/src/Makefile 2017-10-05 19:32:26.548561181 +0200 - @@ -33,7 +33,7 @@ - LIBS_PGSQL=-lpq ++--- hoel-1.3.1.orig/src/Makefile 2018-01-22 11:32:35.639338970 +0100 +++++ hoel-1.3.1/src/Makefile 2018-01-28 19:21:07.580147310 +0100 ++@@ -36,10 +36,11 @@ ++ endif + + PREFIX=/usr/local +-CFLAGS=-c -fPIC -Wall -I$(PREFIX)/include $(FLAGS_SQLITE) $(FLAGS_MARIADB) $(FLAGS_PGSQL) -D_REENTRANT $(ADDITIONALFLAGS) ++CFLAGS+=-c -fPIC -Wall -I$(PREFIX)/include $(FLAGS_SQLITE) $(FLAGS_MARIADB) $(FLAGS_PGSQL) -D_REENTRANT $(ADDITIONALFLAGS) $(CPPFLAGS) + LIBS=-L$(PREFIX)/lib -lc -ljansson -lyder -lorcania $(LIBS_SQLITE) $(LIBS_PGSQL) $(LIBS_MARIADB) + OUTPUT=libhoel.so - VERSION=1.2 - @@ -56,7 +56,7 @@ ++-VERSION=1.3.1 +++#VERSION=1.3.1 +++VERSION=1.3 ++ ++ all: release ++ ++@@ -59,7 +60,7 @@ + $(CC) $(CFLAGS) hoel-simple-json.c + + libhoel.so: hoel-sqlite.o hoel-mariadb.o hoel-pgsql.o hoel-simple-json.o hoel.o +- $(CC) -shared -Wl,-soname,$(OUTPUT) -o $(OUTPUT).$(VERSION) hoel-sqlite.o hoel-mariadb.o hoel-pgsql.o hoel-simple-json.o hoel.o $(LIBS) ++ $(CC) -shared -Wl,-soname,$(OUTPUT).$(VERSION) -o $(OUTPUT).$(VERSION) hoel-sqlite.o hoel-mariadb.o hoel-pgsql.o hoel-simple-json.o hoel.o $(LIBS) $(LDFLAGS) + ln -sf $(OUTPUT).$(VERSION) $(OUTPUT) + + libhoel.a: hoel-sqlite.o hoel-mariadb.o hoel-pgsql.o hoel-simple-json.o hoel.o -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-iot/hoel.git From alteholz at moszumanska.debian.org Mon Mar 19 21:43:27 2018 From: alteholz at moszumanska.debian.org (Thorsten Alteholz) Date: Mon, 19 Mar 2018 21:43:27 +0000 Subject: [Debian-iot-packaging] [hoel] branch pristine-tar updated (e507ac8 -> 0178ce3) Message-ID: <20180319214326.23982.68096@moszumanska.debian.org> This is an automated email from the git hooks/post-receive script. alteholz pushed a change to branch pristine-tar in repository hoel. from e507ac8 pristine-tar data for hoel_1.2.1.orig.tar.gz new 0178ce3 pristine-tar data for hoel_1.3.1.orig.tar.gz The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Summary of changes: hoel_1.3.1.orig.tar.gz.delta | Bin 0 -> 1665 bytes hoel_1.3.1.orig.tar.gz.id | 1 + 2 files changed, 1 insertion(+) create mode 100644 hoel_1.3.1.orig.tar.gz.delta create mode 100644 hoel_1.3.1.orig.tar.gz.id -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-iot/hoel.git From alteholz at moszumanska.debian.org Mon Mar 19 21:43:27 2018 From: alteholz at moszumanska.debian.org (Thorsten Alteholz) Date: Mon, 19 Mar 2018 21:43:27 +0000 Subject: [Debian-iot-packaging] [hoel] 01/01: pristine-tar data for hoel_1.3.1.orig.tar.gz In-Reply-To: <20180319214326.23982.68096@moszumanska.debian.org> References: <20180319214326.23982.68096@moszumanska.debian.org> Message-ID: This is an automated email from the git hooks/post-receive script. alteholz pushed a commit to branch pristine-tar in repository hoel. commit 0178ce331400250830f6618410532c3c1aa96be6 Author: Thorsten Alteholz Date: Mon Mar 19 22:43:19 2018 +0100 pristine-tar data for hoel_1.3.1.orig.tar.gz --- hoel_1.3.1.orig.tar.gz.delta | Bin 0 -> 1665 bytes hoel_1.3.1.orig.tar.gz.id | 1 + 2 files changed, 1 insertion(+) diff --git a/hoel_1.3.1.orig.tar.gz.delta b/hoel_1.3.1.orig.tar.gz.delta new file mode 100644 index 0000000..31523d4 Binary files /dev/null and b/hoel_1.3.1.orig.tar.gz.delta differ diff --git a/hoel_1.3.1.orig.tar.gz.id b/hoel_1.3.1.orig.tar.gz.id new file mode 100644 index 0000000..d42da17 --- /dev/null +++ b/hoel_1.3.1.orig.tar.gz.id @@ -0,0 +1 @@ +f76bdffc6486e9952a015524e0b3af226905c136 -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-iot/hoel.git From alteholz at moszumanska.debian.org Mon Mar 19 21:43:27 2018 From: alteholz at moszumanska.debian.org (Thorsten Alteholz) Date: Mon, 19 Mar 2018 21:43:27 +0000 Subject: [Debian-iot-packaging] [hoel] branch upstream updated (1940cc8 -> 67cbba3) Message-ID: <20180319214326.23982.57563@moszumanska.debian.org> This is an automated email from the git hooks/post-receive script. alteholz pushed a change to branch upstream in repository hoel. from 1940cc8 Import Upstream version 1.2.1 new 67cbba3 Import Upstream version 1.3.1 The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Summary of changes: Makefile | 2 +- README.md | 87 ++++++++++++++++++++++++++++++++------------------ _config.yml | 1 + src/Makefile | 11 ++++--- src/h-private.h | 2 +- src/hoel-mariadb.c | 22 ++++++++++--- src/hoel-pgsql.c | 17 ++++++++-- src/hoel-simple-json.c | 63 ++++++++++++++++++++++++++++++++---- src/hoel-sqlite.c | 18 +++++++++-- src/hoel.c | 12 +++---- src/hoel.h | 22 ++++++------- test/core.c | 19 +++++++++++ 12 files changed, 207 insertions(+), 69 deletions(-) create mode 100644 _config.yml -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-iot/hoel.git From alteholz at moszumanska.debian.org Mon Mar 19 21:43:29 2018 From: alteholz at moszumanska.debian.org (Thorsten Alteholz) Date: Mon, 19 Mar 2018 21:43:29 +0000 Subject: [Debian-iot-packaging] [hoel] annotated tag debian/1.3.1-1 created (now 3ef2161) Message-ID: <20180319214328.25241.65766@moszumanska.debian.org> This is an automated email from the git hooks/post-receive script. alteholz pushed a change to annotated tag debian/1.3.1-1 in repository hoel. at 3ef2161 (tag) tagging 53b307ad0c6beb2fcf60011fa0f66569cf7bb5b7 (commit) replaces debian/1.2.1-1 tagged by Thorsten Alteholz on Mon Mar 19 22:43:19 2018 +0100 - Log ----------------------------------------------------------------- Debian release 1.3.1-1 Thorsten Alteholz (2): Import Upstream version 1.3.1 Import Debian changes 1.3.1-1 ----------------------------------------------------------------------- No new revisions were added by this update. -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-iot/hoel.git From alteholz at moszumanska.debian.org Mon Mar 19 21:43:29 2018 From: alteholz at moszumanska.debian.org (Thorsten Alteholz) Date: Mon, 19 Mar 2018 21:43:29 +0000 Subject: [Debian-iot-packaging] [hoel] annotated tag upstream/1.3.1 created (now 0d993c3) Message-ID: <20180319214328.25241.11081@moszumanska.debian.org> This is an automated email from the git hooks/post-receive script. alteholz pushed a change to annotated tag upstream/1.3.1 in repository hoel. at 0d993c3 (tag) tagging 67cbba3eac854d18b0e6d1b4006e41d99fa78fcb (commit) replaces upstream/1.2.1 tagged by Thorsten Alteholz on Mon Mar 19 22:43:18 2018 +0100 - Log ----------------------------------------------------------------- Upstream version 1.3.1 Thorsten Alteholz (1): Import Upstream version 1.3.1 ----------------------------------------------------------------------- No new revisions were added by this update. -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-iot/hoel.git From alteholz at moszumanska.debian.org Mon Mar 19 21:44:55 2018 From: alteholz at moszumanska.debian.org (Thorsten Alteholz) Date: Mon, 19 Mar 2018 21:44:55 +0000 Subject: [Debian-iot-packaging] [yder] branch master updated (4785c39 -> c9d86e7) Message-ID: <20180319214454.19422.5344@moszumanska.debian.org> This is an automated email from the git hooks/post-receive script. alteholz pushed a change to branch master in repository yder. from 4785c39 Import Debian changes 1.1-3 new 352bb7a Import Upstream version 1.1.1 new c9d86e7 Import Debian changes 1.1.1-1 The 2 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Summary of changes: .gitignore | 1 + README.md | 45 +++++++++ debian/changelog | 8 ++ debian/compat | 2 +- debian/control | 13 +-- debian/patches/hardening.patch | 19 ++-- src/Makefile | 24 ++++- src/yder.c | 214 ++++++++++++++++++++--------------------- src/yder.h | 2 +- 9 files changed, 198 insertions(+), 130 deletions(-) -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-iot/yder.git From alteholz at moszumanska.debian.org Mon Mar 19 21:44:55 2018 From: alteholz at moszumanska.debian.org (Thorsten Alteholz) Date: Mon, 19 Mar 2018 21:44:55 +0000 Subject: [Debian-iot-packaging] [yder] 01/02: Import Upstream version 1.1.1 In-Reply-To: <20180319214454.19422.5344@moszumanska.debian.org> References: <20180319214454.19422.5344@moszumanska.debian.org> Message-ID: This is an automated email from the git hooks/post-receive script. alteholz pushed a commit to branch master in repository yder. commit 352bb7ae667c5a222cedc89c3904aca877af79db Author: Thorsten Alteholz Date: Mon Mar 19 22:44:46 2018 +0100 Import Upstream version 1.1.1 --- .gitignore | 1 + README.md | 45 +++++++++++++ src/Makefile | 24 +++++-- src/yder.c | 214 ++++++++++++++++++++++++++++------------------------------- src/yder.h | 2 +- 5 files changed, 170 insertions(+), 116 deletions(-) diff --git a/.gitignore b/.gitignore index 06235e7..ce69b2d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ *.o *.so *.so.*.* +*.a log_combined log_console log_file diff --git a/README.md b/README.md index 0cb5d5b..9cfe97a 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,31 @@ Yder is mono-thread, which mean that you can use only one instance of yder log a # Installation +## Debian-ish packages + +[![Packaging status](https://repology.org/badge/vertical-allrepos/yder.svg)](https://repology.org/metapackage/yder) + +Yder is now available in Debian Buster (testing) and some Debian based distributions. To install it on your device, use the following command as root: + +```shell +# apt install libyder-dev # Or apt install libyder.1 if you don't need the development files +``` + +## Manual install + +### Prerequisites + +You must install `liborcania` first before building libyder + +```shell +$ git clone https://github.com/babelouest/orcania.git +$ cd orcania/src +$ make +$ sudo make install +``` + +### Install libyder + Download yder from github repository, compile and install. ```shell @@ -19,6 +44,26 @@ $ sudo make install By default, the shared library and the header file will be installed in the `/usr/local` location. To change this setting, you can modify the `PREFIX` value in the `src/Makefile`. +Example: install yder in /tmp/lib directory + +```shell +$ cd src +$ make && make PREFIX=/tmp install +``` + +You can install Yder without root permission if your user has write access to `$(PREFIX)`. +A `ldconfig` command is executed at the end of the install, it will probably fail if you don't have root permission, but this is harmless. +If you choose to install Yder in another directory, you must set your environment variable `LD_LIBRARY_PATH` properly. + +### Install libyder as a static archive + +Install byderlibrary as a static archive, `libyder.a`, use the make commands `make static*`: + +```shell +$ cd src +$ make static && sudo make static-install # or make PREFIX=/tmp static-install if you want to install in `/tmp/lib` +``` + # API Documentation ## Header files and compilation diff --git a/src/Makefile b/src/Makefile index b21ec7f..2305084 100644 --- a/src/Makefile +++ b/src/Makefile @@ -23,7 +23,7 @@ CC=gcc CFLAGS=-c -fPIC -Wall -D_REENTRANT $(ADDITIONALFLAGS) LIBS=-lc -lorcania OUTPUT=libyder.so -VERSION=2.0 +VERSION=1.1.1 all: release @@ -31,19 +31,26 @@ libyder.so: yder.o $(CC) -shared -Wl,-soname,$(OUTPUT) -o $(OUTPUT).$(VERSION) yder.o $(LIBS) ln -sf $(OUTPUT).$(VERSION) $(OUTPUT) +libyder.a: yder.o + ar rcs libyder.a yder.o + yder.o: yder.h yder.c $(CC) $(CFLAGS) yder.c clean: - rm -f *.o *.so $(OUTPUT) $(OUTPUT).* + rm -f *.o *.so *.a $(OUTPUT) $(OUTPUT).* install: all cp $(OUTPUT).$(VERSION) $(PREFIX)/lib cp yder.h $(PREFIX)/include - /sbin/ldconfig -r $(PREFIX) + -ldconfig + +static-install: static + cp libyder.a $(PREFIX)/lib + cp yder.h $(PREFIX)/include uninstall: - rm -f $(PREFIX)/lib/$(OUTPUT) + rm -f $(PREFIX)/lib/$(OUTPUT) $(PREFIX)/lib/libyder.a rm -f $(PREFIX)/lib/$(OUTPUT).* rm -f $(PREFIX)/include/yder.h @@ -54,3 +61,12 @@ debug: libyder.so release: ADDITIONALFLAGS=-O3 release: libyder.so + +static-debug: ADDITIONALFLAGS=-DDEBUG -g -O0 + +static-debug: libyder.a + +static: ADDITIONALFLAGS=-O3 + +static: libyder.a + diff --git a/src/yder.c b/src/yder.c index 61515b8..114dee6 100644 --- a/src/yder.c +++ b/src/yder.c @@ -34,53 +34,103 @@ #include "yder.h" /** - * Private functions declarations - */ -int y_write_log(const char * app_name, const unsigned long init_mode, const unsigned long init_level, const char * init_log_file, const unsigned long level, const char * message); -void y_write_log_console(const char * app_name, const time_t date, const unsigned long level, const char * message); -void y_write_log_syslog(const char * app_name, const unsigned long level, const char * message); -void y_write_log_file(const char * app_name, const time_t date, FILE * log_file, const unsigned long level, const char * message); - -/** - * Initialize logs + * Write log message to console output (stdout or stderr) */ -int y_init_logs(const char * app, const unsigned long init_mode, const unsigned long init_level, const char * init_log_file, const char * message) { - return y_write_log(app, init_mode, init_level, init_log_file, Y_LOG_LEVEL_INFO, message); +static void y_write_log_console(const char * app_name, const time_t date, const unsigned long level, const char * message) { + char * level_name = NULL, date_stamp[20]; + FILE * output = NULL; + struct tm * tm_stamp; + + tm_stamp = localtime (&date); + + strftime (date_stamp, sizeof(date_stamp), "%FT%TZ", tm_stamp); + switch (level) { + case Y_LOG_LEVEL_ERROR: + level_name = "ERROR"; + break; + case Y_LOG_LEVEL_WARNING: + level_name = "WARNING"; + break; + case Y_LOG_LEVEL_INFO: + level_name = "INFO"; + break; + case Y_LOG_LEVEL_DEBUG: + level_name = "DEBUG"; + break; + default: + level_name = "NONE"; + break; + } + if (level & Y_LOG_LEVEL_WARNING || level & Y_LOG_LEVEL_ERROR) { + // Write to stderr + output = stderr; + } else { + // Write to stdout + output = stdout; + } + fprintf(output, "%s - %s %s: %s\n", date_stamp, app_name, level_name, message); + fflush(output); } /** - * Close logs + * Write log message to syslog */ -int y_close_logs() { - return y_write_log(NULL, 0, 0, NULL, 0, NULL); +static void y_write_log_syslog(const char * app_name, const unsigned long level, const char * message) { + openlog(app_name, LOG_PID|LOG_CONS, LOG_USER); + switch (level) { + case Y_LOG_LEVEL_ERROR: + syslog( LOG_ERR, "%s", message ); + break; + case Y_LOG_LEVEL_WARNING: + syslog( LOG_WARNING, "%s", message ); + break; + case Y_LOG_LEVEL_INFO: + syslog( LOG_INFO, "%s", message ); + break; + case Y_LOG_LEVEL_DEBUG: + syslog( LOG_DEBUG, "%s", message ); + break; + } + closelog(); } /** - * Write the message given in parameters to the current outputs if the current level matches + * Append log message to the log file */ -void y_log_message(const unsigned long level, const char * message, ...) { - va_list args, args_cpy; - size_t out_len = 0; - char * out = NULL; - va_start(args, message); - // Use va_copy to make a new args pointer to avoid problems with vsnprintf which can change args parameter on some architectures - va_copy(args_cpy, args); - out_len = vsnprintf(NULL, 0, message, args); - out = o_malloc((out_len + 1)*sizeof(char)); - if (out != NULL) { - vsnprintf(out, (out_len + 1), message, args_cpy); - y_write_log(NULL, Y_LOG_MODE_CURRENT, Y_LOG_LEVEL_CURRENT, NULL, level, out); - o_free(out); +static void y_write_log_file(const char * app_name, const time_t date, FILE * log_file, const unsigned long level, const char * message) { + char * level_name = NULL, date_stamp[20]; + struct tm * tm_stamp; + + if (log_file != NULL) { + tm_stamp = localtime (&date); + strftime (date_stamp, sizeof(date_stamp), "%Y-%m-%d %H:%M:%S", tm_stamp); + switch (level) { + case Y_LOG_LEVEL_ERROR: + level_name = "ERROR"; + break; + case Y_LOG_LEVEL_WARNING: + level_name = "WARNING"; + break; + case Y_LOG_LEVEL_INFO: + level_name = "INFO"; + break; + case Y_LOG_LEVEL_DEBUG: + level_name = "DEBUG"; + break; + default: + level_name = "NONE"; + break; + } + fprintf(log_file, "%s - %s %s: %s\n", date_stamp, app_name, level_name, message); + fflush(log_file); } - va_end(args); - va_end(args_cpy); } /** * Main function for logging messages * Warning ! Contains static variables used for not having to pass general configuration values every time you call log_message */ -int y_write_log(const char * app_name, const unsigned long init_mode, const unsigned long init_level, const char * init_log_file, const unsigned long level, const char * message) { +static int y_write_log(const char * app_name, const unsigned long init_mode, const unsigned long init_level, const char * init_log_file, const unsigned long level, const char * message) { static unsigned long cur_mode = Y_LOG_MODE_NONE, cur_level = Y_LOG_LEVEL_NONE; FILE * cur_log_file = NULL; static char * cur_app_name = NULL; @@ -155,94 +205,36 @@ int y_write_log(const char * app_name, const unsigned long init_mode, const unsi } /** - * Write log message to console output (stdout or stderr) + * Initialize logs */ -void y_write_log_console(const char * app_name, const time_t date, const unsigned long level, const char * message) { - char * level_name = NULL, date_stamp[20]; - FILE * output = NULL; - struct tm * tm_stamp; - - tm_stamp = localtime (&date); - - strftime (date_stamp, sizeof(date_stamp), "%FT%TZ", tm_stamp); - switch (level) { - case Y_LOG_LEVEL_ERROR: - level_name = "ERROR"; - break; - case Y_LOG_LEVEL_WARNING: - level_name = "WARNING"; - break; - case Y_LOG_LEVEL_INFO: - level_name = "INFO"; - break; - case Y_LOG_LEVEL_DEBUG: - level_name = "DEBUG"; - break; - default: - level_name = "NONE"; - break; - } - if (level & Y_LOG_LEVEL_WARNING || level & Y_LOG_LEVEL_ERROR) { - // Write to stderr - output = stderr; - } else { - // Write to stdout - output = stdout; - } - fprintf(output, "%s - %s %s: %s\n", date_stamp, app_name, level_name, message); - fflush(output); +int y_init_logs(const char * app, const unsigned long init_mode, const unsigned long init_level, const char * init_log_file, const char * message) { + return y_write_log(app, init_mode, init_level, init_log_file, Y_LOG_LEVEL_INFO, message); } /** - * Write log message to syslog + * Close logs */ -void y_write_log_syslog(const char * app_name, const unsigned long level, const char * message) { - openlog(app_name, LOG_PID|LOG_CONS, LOG_USER); - switch (level) { - case Y_LOG_LEVEL_ERROR: - syslog( LOG_ERR, "%s", message ); - break; - case Y_LOG_LEVEL_WARNING: - syslog( LOG_WARNING, "%s", message ); - break; - case Y_LOG_LEVEL_INFO: - syslog( LOG_INFO, "%s", message ); - break; - case Y_LOG_LEVEL_DEBUG: - syslog( LOG_DEBUG, "%s", message ); - break; - } - closelog(); +int y_close_logs() { + return y_write_log(NULL, 0, 0, NULL, 0, NULL); } /** - * Append log message to the log file + * Write the message given in parameters to the current outputs if the current level matches */ -void y_write_log_file(const char * app_name, const time_t date, FILE * log_file, const unsigned long level, const char * message) { - char * level_name = NULL, date_stamp[20]; - struct tm * tm_stamp; - - if (log_file != NULL) { - tm_stamp = localtime (&date); - strftime (date_stamp, sizeof(date_stamp), "%Y-%m-%d %H:%M:%S", tm_stamp); - switch (level) { - case Y_LOG_LEVEL_ERROR: - level_name = "ERROR"; - break; - case Y_LOG_LEVEL_WARNING: - level_name = "WARNING"; - break; - case Y_LOG_LEVEL_INFO: - level_name = "INFO"; - break; - case Y_LOG_LEVEL_DEBUG: - level_name = "DEBUG"; - break; - default: - level_name = "NONE"; - break; - } - fprintf(log_file, "%s - %s %s: %s\n", date_stamp, app_name, level_name, message); - fflush(log_file); +void y_log_message(const unsigned long level, const char * message, ...) { + va_list args, args_cpy; + size_t out_len = 0; + char * out = NULL; + va_start(args, message); + // Use va_copy to make a new args pointer to avoid problems with vsnprintf which can change args parameter on some architectures + va_copy(args_cpy, args); + out_len = vsnprintf(NULL, 0, message, args); + out = o_malloc((out_len + 1)*sizeof(char)); + if (out != NULL) { + vsnprintf(out, (out_len + 1), message, args_cpy); + y_write_log(NULL, Y_LOG_MODE_CURRENT, Y_LOG_LEVEL_CURRENT, NULL, level, out); + o_free(out); } + va_end(args); + va_end(args_cpy); } diff --git a/src/yder.h b/src/yder.h index a2defa4..d5c451a 100644 --- a/src/yder.h +++ b/src/yder.h @@ -26,7 +26,7 @@ #ifndef __YDER_H__ #define __YDER_H__ -#define YDER_VERSION 2.0 +#define YDER_VERSION 1.1.1 #define Y_LOG_MODE_NONE 0x0000 #define Y_LOG_MODE_CONSOLE 0x00F0 -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-iot/yder.git From alteholz at moszumanska.debian.org Mon Mar 19 21:44:55 2018 From: alteholz at moszumanska.debian.org (Thorsten Alteholz) Date: Mon, 19 Mar 2018 21:44:55 +0000 Subject: [Debian-iot-packaging] [yder] 02/02: Import Debian changes 1.1.1-1 In-Reply-To: <20180319214454.19422.5344@moszumanska.debian.org> References: <20180319214454.19422.5344@moszumanska.debian.org> Message-ID: This is an automated email from the git hooks/post-receive script. alteholz pushed a commit to branch master in repository yder. commit c9d86e792e20d27c3d6b9d9ac3f7775ce31f810c Merge: 4785c39 352bb7a Author: Thorsten Alteholz Date: Sun Jan 21 18:01:00 2018 +0100 Import Debian changes 1.1.1-1 yder (1.1.1-1) unstable; urgency=medium * New upstream release * debian/control: bump standard to 4.1.3 (no changes) * debian/control: use dh11 .gitignore | 1 + README.md | 45 +++++++++ debian/changelog | 8 ++ debian/compat | 2 +- debian/control | 13 +-- debian/patches/hardening.patch | 19 ++-- src/Makefile | 24 ++++- src/yder.c | 214 ++++++++++++++++++++--------------------- src/yder.h | 2 +- 9 files changed, 198 insertions(+), 130 deletions(-) diff --cc debian/changelog index fe6d756,0000000..fc3164c mode 100644,000000..100644 --- a/debian/changelog +++ b/debian/changelog @@@ -1,18 -1,0 +1,26 @@@ ++yder (1.1.1-1) unstable; urgency=medium ++ ++ * New upstream release ++ * debian/control: bump standard to 4.1.3 (no changes) ++ * debian/control: use dh11 ++ ++ -- Thorsten Alteholz Sun, 21 Jan 2018 18:01:00 +0100 ++ +yder (1.1-3) unstable; urgency=medium + + * debian/control: bump standard to 4.1.0 (no changes) + * debian/control: add VCS URLs + + -- Thorsten Alteholz Sat, 02 Sep 2017 19:28:42 +0200 + +yder (1.1-2) unstable; urgency=medium + + * update dependencies + + -- Thorsten Alteholz Mon, 24 Jul 2017 20:18:42 +0200 + +yder (1.1-1) unstable; urgency=medium + + * Initial release + + -- Thorsten Alteholz Sun, 23 Jul 2017 19:32:33 +0200 diff --cc debian/compat index f599e28,0000000..b4de394 mode 100644,000000..100644 --- a/debian/compat +++ b/debian/compat @@@ -1,1 -1,0 +1,1 @@@ - 10 ++11 diff --cc debian/control index 005a3ba,0000000..399508c mode 100644,000000..100644 --- a/debian/control +++ b/debian/control @@@ -1,37 -1,0 +1,38 @@@ +Source: yder +Section: devel +Priority: optional +Maintainer: Thorsten Alteholz - Build-Depends: debhelper (>= 10) ++Build-Depends: debhelper (>= 11) + , liborcania-dev + , libjansson-dev - Standards-Version: 4.1.0 ++Standards-Version: 4.1.3 +Homepage: https://github.com/babelouest/yder +Vcs-Browser: https://anonscm.debian.org/cgit/debian-iot/yder.git +Vcs-Git: https://anonscm.debian.org/git/debian-iot/yder.git + +Package: libyder2.0 +Architecture: any ++Section: libs +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: logging library written in C - Simple and easy to use logging library. You can log messages to the ++ Simple and easy to use logging library. You can log messages to the + console, a file or syslog. + . - Yder is mono-thread, which mean that you can use only one instance ++ Yder is mono-thread, which mean that you can use only one instance + of yder log at the same time in your program. + +Package: libyder-dev +Architecture: any +Section: libdevel +Depends: libyder2.0 (= ${binary:Version}) + , ${misc:Depends} + , liborcania-dev + , libjansson-dev +Description: logging library written in C - development - Simple and easy to use logging library. You can log messages to the ++ Simple and easy to use logging library. You can log messages to the + console, a file or syslog. + . - Yder is mono-thread, which mean that you can use only one instance ++ Yder is mono-thread, which mean that you can use only one instance + of yder log at the same time in your program. + . + This package contains the development files. diff --cc debian/patches/hardening.patch index 12c8ed3,0000000..2647442 mode 100644,000000..100644 --- a/debian/patches/hardening.patch +++ b/debian/patches/hardening.patch @@@ -1,29 -1,0 +1,34 @@@ +Description: add hardening flags +Author: Thorsten Alteholz - Index: yder-1.1/src/Makefile ++Index: yder-1.1.1/src/Makefile +=================================================================== - --- yder-1.1.orig/src/Makefile 2017-05-25 14:44:28.000000000 +0200 - +++ yder-1.1/src/Makefile 2017-07-18 15:51:53.404125171 +0200 - @@ -20,7 +20,7 @@ ++--- yder-1.1.1.orig/src/Makefile 2018-01-22 12:31:56.623344237 +0100 +++++ yder-1.1.1/src/Makefile 2018-01-22 12:34:13.535344439 +0100 ++@@ -20,22 +20,23 @@ + # + PREFIX=/usr/local + CC=gcc +-CFLAGS=-c -fPIC -Wall -D_REENTRANT $(ADDITIONALFLAGS) ++CFLAGS+=-c -fPIC -Wall -D_REENTRANT $(ADDITIONALFLAGS) + LIBS=-lc -lorcania + OUTPUT=libyder.so - VERSION=2.0 - @@ -28,11 +28,11 @@ ++-VERSION=1.1.1 +++#we still have soname 2.0: VERSION=1.1.1 +++VERSION=2.0 ++ + all: release + + libyder.so: yder.o +- $(CC) -shared -Wl,-soname,$(OUTPUT) -o $(OUTPUT).$(VERSION) yder.o $(LIBS) ++ $(CC) -shared -Wl,-soname,$(OUTPUT).$(VERSION) -o $(OUTPUT).$(VERSION) yder.o $(LIBS) $(LDFLAGS) + ln -sf $(OUTPUT).$(VERSION) $(OUTPUT) + ++ libyder.a: yder.o ++ ar rcs libyder.a yder.o ++ + yder.o: yder.h yder.c +- $(CC) $(CFLAGS) yder.c ++ $(CC) $(CFLAGS) $(CPPFLAGS) yder.c + + clean: - rm -f *.o *.so $(OUTPUT) $(OUTPUT).* ++ rm -f *.o *.so *.a $(OUTPUT) $(OUTPUT).* -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-iot/yder.git From alteholz at moszumanska.debian.org Mon Mar 19 21:44:55 2018 From: alteholz at moszumanska.debian.org (Thorsten Alteholz) Date: Mon, 19 Mar 2018 21:44:55 +0000 Subject: [Debian-iot-packaging] [yder] branch pristine-tar updated (2eb530a -> aedd931) Message-ID: <20180319214455.19422.28577@moszumanska.debian.org> This is an automated email from the git hooks/post-receive script. alteholz pushed a change to branch pristine-tar in repository yder. from 2eb530a pristine-tar data for yder_1.1.orig.tar.gz new aedd931 pristine-tar data for yder_1.1.1.orig.tar.gz The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Summary of changes: yder_1.1.1.orig.tar.gz.delta | Bin 0 -> 1548 bytes yder_1.1.1.orig.tar.gz.id | 1 + 2 files changed, 1 insertion(+) create mode 100644 yder_1.1.1.orig.tar.gz.delta create mode 100644 yder_1.1.1.orig.tar.gz.id -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-iot/yder.git From alteholz at moszumanska.debian.org Mon Mar 19 21:44:55 2018 From: alteholz at moszumanska.debian.org (Thorsten Alteholz) Date: Mon, 19 Mar 2018 21:44:55 +0000 Subject: [Debian-iot-packaging] [yder] 01/01: pristine-tar data for yder_1.1.1.orig.tar.gz In-Reply-To: <20180319214455.19422.28577@moszumanska.debian.org> References: <20180319214455.19422.28577@moszumanska.debian.org> Message-ID: This is an automated email from the git hooks/post-receive script. alteholz pushed a commit to branch pristine-tar in repository yder. commit aedd931d7ee88259517fdc3d80a00533b53a0898 Author: Thorsten Alteholz Date: Mon Mar 19 22:44:47 2018 +0100 pristine-tar data for yder_1.1.1.orig.tar.gz --- yder_1.1.1.orig.tar.gz.delta | Bin 0 -> 1548 bytes yder_1.1.1.orig.tar.gz.id | 1 + 2 files changed, 1 insertion(+) diff --git a/yder_1.1.1.orig.tar.gz.delta b/yder_1.1.1.orig.tar.gz.delta new file mode 100644 index 0000000..4d40771 Binary files /dev/null and b/yder_1.1.1.orig.tar.gz.delta differ diff --git a/yder_1.1.1.orig.tar.gz.id b/yder_1.1.1.orig.tar.gz.id new file mode 100644 index 0000000..4c3eb8c --- /dev/null +++ b/yder_1.1.1.orig.tar.gz.id @@ -0,0 +1 @@ +55bcd17036cad3ba1b79a0304301824c5ec634f8 -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-iot/yder.git From alteholz at moszumanska.debian.org Mon Mar 19 21:44:55 2018 From: alteholz at moszumanska.debian.org (Thorsten Alteholz) Date: Mon, 19 Mar 2018 21:44:55 +0000 Subject: [Debian-iot-packaging] [yder] branch upstream updated (66a6ee2 -> 352bb7a) Message-ID: <20180319214455.19422.88671@moszumanska.debian.org> This is an automated email from the git hooks/post-receive script. alteholz pushed a change to branch upstream in repository yder. from 66a6ee2 Import Upstream version 1.1 new 352bb7a Import Upstream version 1.1.1 The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Summary of changes: .gitignore | 1 + README.md | 45 +++++++++++++ src/Makefile | 24 +++++-- src/yder.c | 214 ++++++++++++++++++++++++++++------------------------------- src/yder.h | 2 +- 5 files changed, 170 insertions(+), 116 deletions(-) -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-iot/yder.git From alteholz at moszumanska.debian.org Mon Mar 19 21:44:56 2018 From: alteholz at moszumanska.debian.org (Thorsten Alteholz) Date: Mon, 19 Mar 2018 21:44:56 +0000 Subject: [Debian-iot-packaging] [yder] annotated tag debian/1.1.1-1 created (now b3db995) Message-ID: <20180319214456.20061.43146@moszumanska.debian.org> This is an automated email from the git hooks/post-receive script. alteholz pushed a change to annotated tag debian/1.1.1-1 in repository yder. at b3db995 (tag) tagging c9d86e792e20d27c3d6b9d9ac3f7775ce31f810c (commit) replaces debian/1.1-3 tagged by Thorsten Alteholz on Mon Mar 19 22:44:46 2018 +0100 - Log ----------------------------------------------------------------- Debian release 1.1.1-1 Thorsten Alteholz (2): Import Upstream version 1.1.1 Import Debian changes 1.1.1-1 ----------------------------------------------------------------------- No new revisions were added by this update. -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-iot/yder.git From alteholz at moszumanska.debian.org Mon Mar 19 21:44:57 2018 From: alteholz at moszumanska.debian.org (Thorsten Alteholz) Date: Mon, 19 Mar 2018 21:44:57 +0000 Subject: [Debian-iot-packaging] [yder] annotated tag upstream/1.1.1 created (now 626e915) Message-ID: <20180319214456.20061.21917@moszumanska.debian.org> This is an automated email from the git hooks/post-receive script. alteholz pushed a change to annotated tag upstream/1.1.1 in repository yder. at 626e915 (tag) tagging 352bb7ae667c5a222cedc89c3904aca877af79db (commit) replaces upstream/1.1 tagged by Thorsten Alteholz on Mon Mar 19 22:44:46 2018 +0100 - Log ----------------------------------------------------------------- Upstream version 1.1.1 Thorsten Alteholz (1): Import Upstream version 1.1.1 ----------------------------------------------------------------------- No new revisions were added by this update. -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-iot/yder.git