summaryrefslogtreecommitdiff
path: root/src/offlinelogstorage/dlt_offline_logstorage.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/offlinelogstorage/dlt_offline_logstorage.c')
-rw-r--r--src/offlinelogstorage/dlt_offline_logstorage.c63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/offlinelogstorage/dlt_offline_logstorage.c b/src/offlinelogstorage/dlt_offline_logstorage.c
index a03a861..b8793c7 100644
--- a/src/offlinelogstorage/dlt_offline_logstorage.c
+++ b/src/offlinelogstorage/dlt_offline_logstorage.c
@@ -22,6 +22,7 @@
#include <stdlib.h>
#include <limits.h>
#include <ctype.h>
+#include <sys/syslog.h>
#include <syslog.h>
#include <sys/stat.h>
#include <sys/stat.h>
@@ -73,6 +74,11 @@ DLT_STATIC void dlt_logstorage_filter_config_free(DltLogStorageFilterConfig *dat
if (data->log != NULL)
fclose(data->log);
+#ifdef DLT_LOGSTORAGE_USE_GZIP
+ if (data->gzlog != NULL)
+ gzclose(data->gzlog);
+#endif
+
if (data->cache != NULL) {
free(data->cache);
data->cache = NULL;
@@ -421,6 +427,34 @@ DLT_STATIC int dlt_logstorage_read_number(unsigned int *number, char *value)
}
/**
+ * dlt_logstorage_read_bool
+ *
+ * Evaluate a boolean config value. Values such as '1', 'on' or 'true' will be
+ * treated as true otherwise the config value will be interpreted as false.
+ *
+ * @param bool The boolean to populate
+ * @param value The string from the config file
+ * @returns 0 on success, -1 on error
+ */
+DLT_STATIC int dlt_logstorage_read_bool(unsigned int *boolean, char *value)
+{
+ int len = 0;
+ if (value == NULL)
+ return -1;
+
+ len = strnlen(value, 5);
+ *boolean = 0;
+ if (strncmp(value, "on", len) == 0) {
+ *boolean = 1;
+ } else if (strncmp(value, "true", len) == 0) {
+ *boolean = 1;
+ } else if (strncmp(value, "1", len) == 0) {
+ *boolean = 1;
+ }
+ return 0;
+}
+
+/**
* dlt_logstorage_get_keys_list
*
* Obtain key list and number of keys for id list passed
@@ -1052,6 +1086,20 @@ DLT_STATIC int dlt_logstorage_check_nofiles(DltLogStorageFilterConfig *config,
return dlt_logstorage_read_number(&config->num_files, value);
}
+DLT_STATIC int dlt_logstorage_check_gzip_compression(DltLogStorageFilterConfig *config,
+ char *value)
+{
+ if ((config == NULL) || (value == NULL))
+ return -1;
+
+ int result = dlt_logstorage_read_bool(&config->gzip_compression, value);
+#ifndef DLT_LOGSTORAGE_USE_GZIP
+ dlt_log(LOG_WARNING, "dlt-daemon not compiled with logstorage gzip support\n");
+ config->gzip_compression = 0;
+#endif
+ return result;
+}
+
DLT_STATIC int dlt_logstorage_check_specificsize(DltLogStorageFilterConfig *config,
char *value)
{
@@ -1195,6 +1243,11 @@ DLT_STATIC DltLogstorageFilterConf
.key = "SpecificSize",
.func = dlt_logstorage_check_specificsize,
.is_opt = 1
+ },
+ [DLT_LOGSTORAGE_FILTER_CONF_GZIP_COMPRESSION] = {
+ .key = "GzipCompression",
+ .func = dlt_logstorage_check_gzip_compression,
+ .is_opt = 1
}
};
@@ -1250,6 +1303,11 @@ DLT_STATIC DltLogstorageFilterConf
.key = NULL,
.func = dlt_logstorage_check_specificsize,
.is_opt = 1
+ },
+ [DLT_LOGSTORAGE_FILTER_CONF_GZIP_COMPRESSION] = {
+ .key = "GzipCompression",
+ .func = dlt_logstorage_check_gzip_compression,
+ .is_opt = 1
}
};
@@ -1304,6 +1362,11 @@ DLT_STATIC DltLogstorageFilterConf
.key = NULL,
.func = dlt_logstorage_check_specificsize,
.is_opt = 1
+ },
+ [DLT_LOGSTORAGE_FILTER_CONF_GZIP_COMPRESSION] = {
+ .key = "GzipCompression",
+ .func = dlt_logstorage_check_gzip_compression,
+ .is_opt = 1
}
};
/**