[Debian-iot-packaging] [yder] 01/02: Import Upstream version 1.1.1
Thorsten Alteholz
alteholz at moszumanska.debian.org
Mon Mar 19 21:44:55 UTC 2018
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 <debian at alteholz.de>
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
More information about the Debian-iot-packaging
mailing list