Hello community,
here is the log from the commit of package liblognorm for openSUSE:Factory checked in at 2017-11-16 13:58:46
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/liblognorm (Old)
and /work/SRC/openSUSE:Factory/.liblognorm.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "liblognorm"
Thu Nov 16 13:58:46 2017 rev:22 rq:541825 version:2.0.4
Changes:
--------
--- /work/SRC/openSUSE:Factory/liblognorm/liblognorm.changes 2017-05-16 14:29:22.636133662 +0200
+++ /work/SRC/openSUSE:Factory/.liblognorm.new/liblognorm.changes 2017-11-16 13:58:48.678415266 +0100
@@ -1,0 +2,10 @@
+Tue Nov 14 13:59:35 UTC 2017 - astieger@suse.com
+
+- liblognorm 2.0.4:
+ * added support for native JSON number formats
+ supported by parsers: number, float, hex
+ * added support for creating unix timestamps
+ supported by parsers: date-rfc3164, date-rfc5424
+- add liblognorm-2.0.4-no-return-in-nonvoid-function.patch
+
+-------------------------------------------------------------------
Old:
----
liblognorm-2.0.3.tar.gz
New:
----
liblognorm-2.0.4-no-return-in-nonvoid-function.patch
liblognorm-2.0.4.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ liblognorm.spec ++++++
--- /var/tmp/diff_new_pack.SLQvUr/_old 2017-11-16 13:58:50.574346569 +0100
+++ /var/tmp/diff_new_pack.SLQvUr/_new 2017-11-16 13:58:50.574346569 +0100
@@ -18,13 +18,14 @@
%define sover 5
Name: liblognorm
-Version: 2.0.3
+Version: 2.0.4
Release: 0
Summary: Library and tool to normalize log data
License: LGPL-2.1+ and Apache-2.0
Group: Development/Libraries/C and C++
Url: http://www.liblognorm.com/
Source0: http://www.liblognorm.com/download/files/download/%{name}-%{version}.tar.gz
+Patch0: liblognorm-2.0.4-no-return-in-nonvoid-function.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildRequires: pkgconfig >= 0.9.0
BuildRequires: pkgconfig(libestr)
@@ -107,6 +108,7 @@
%prep
%setup -q
+%patch0 -p1
%build
%configure \
++++++ liblognorm-2.0.4-no-return-in-nonvoid-function.patch ++++++
From: Andreas Stieger
Date: Tue, 14 Nov 2017 13:58:09 +0000
Subject: fix no-return-in-nonvoid-function
Upstream: no
References: https://github.com/rsyslog/liblognorm/pull/265
I: Program returns random data in a function
E: liblognorm no-return-in-nonvoid-function strndup.c:42
Index: liblognorm-2.0.4/compat/strndup.c
===================================================================
--- liblognorm-2.0.4.orig/compat/strndup.c 2017-10-02 13:14:45.000000000 +0200
+++ liblognorm-2.0.4/compat/strndup.c 2017-11-14 14:57:40.910552382 +0100
@@ -36,8 +36,4 @@ strndup(const char *s, size_t n)
new_s[len] = '\0';
return new_s;
}
-#else /* #ifndef HAVE_STRNDUP */
-int dummy_dummy_required_for_solaris_do_not_use(void)
-{
-}
#endif /* #ifndef HAVE_STRNDUP */
++++++ liblognorm-2.0.3.tar.gz -> liblognorm-2.0.4.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/liblognorm-2.0.3/ChangeLog new/liblognorm-2.0.4/ChangeLog
--- old/liblognorm-2.0.3/ChangeLog 2017-03-22 08:36:19.000000000 +0100
+++ new/liblognorm-2.0.4/ChangeLog 2017-10-04 12:15:08.000000000 +0200
@@ -1,4 +1,13 @@
----------------------------------------------------------------------
+Version 2.0.4, 2017-10-04
+- added support for native JSON number formats
+ supported by parsers: number, float, hex
+- added support for creating unix timestamps
+ supported by parsers: date-rfc3164, date-rfc5424
+- fixed build problems on Solaris
+ ... but there still seem to be some code issues, manifested in
+ testbench failures. So use with care!
+----------------------------------------------------------------------
Version 2.0.3, 2017-03-22
- add ability to load rulebase from a string
introduces new API:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/liblognorm-2.0.3/compat/strndup.c new/liblognorm-2.0.4/compat/strndup.c
--- old/liblognorm-2.0.3/compat/strndup.c 2017-01-23 15:32:52.000000000 +0100
+++ new/liblognorm-2.0.4/compat/strndup.c 2017-10-02 13:14:45.000000000 +0200
@@ -36,5 +36,8 @@
new_s[len] = '\0';
return new_s;
}
-
+#else /* #ifndef HAVE_STRNDUP */
+int dummy_dummy_required_for_solaris_do_not_use(void)
+{
+}
#endif /* #ifndef HAVE_STRNDUP */
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/liblognorm-2.0.3/configure new/liblognorm-2.0.4/configure
--- old/liblognorm-2.0.3/configure 2017-03-22 10:44:35.000000000 +0100
+++ new/liblognorm-2.0.4/configure 2017-10-04 12:15:56.000000000 +0200
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for liblognorm 2.0.3.
+# Generated by GNU Autoconf 2.69 for liblognorm 2.0.4.
#
# Report bugs to .
#
@@ -590,8 +590,8 @@
# Identity of this package.
PACKAGE_NAME='liblognorm'
PACKAGE_TARNAME='liblognorm'
-PACKAGE_VERSION='2.0.3'
-PACKAGE_STRING='liblognorm 2.0.3'
+PACKAGE_VERSION='2.0.4'
+PACKAGE_STRING='liblognorm 2.0.4'
PACKAGE_BUGREPORT='rgerhards@adiscon.com'
PACKAGE_URL=''
@@ -1370,7 +1370,7 @@
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures liblognorm 2.0.3 to adapt to many kinds of systems.
+\`configure' configures liblognorm 2.0.4 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1441,7 +1441,7 @@
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of liblognorm 2.0.3:";;
+ short | recursive ) echo "Configuration of liblognorm 2.0.4:";;
esac
cat <<\_ACEOF
@@ -1576,7 +1576,7 @@
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-liblognorm configure 2.0.3
+liblognorm configure 2.0.4
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2045,7 +2045,7 @@
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by liblognorm $as_me 2.0.3, which was
+It was created by liblognorm $as_me 2.0.4, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
@@ -2908,7 +2908,7 @@
# Define the identity of the package.
PACKAGE='liblognorm'
- VERSION='2.0.3'
+ VERSION='2.0.4'
cat >>confdefs.h <<_ACEOF
@@ -15720,7 +15720,7 @@
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by liblognorm $as_me 2.0.3, which was
+This file was extended by liblognorm $as_me 2.0.4, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -15786,7 +15786,7 @@
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
-liblognorm config.status 2.0.3
+liblognorm config.status 2.0.4
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/liblognorm-2.0.3/configure.ac new/liblognorm-2.0.4/configure.ac
--- old/liblognorm-2.0.3/configure.ac 2017-03-22 10:44:02.000000000 +0100
+++ new/liblognorm-2.0.4/configure.ac 2017-10-04 12:15:35.000000000 +0200
@@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.61)
-AC_INIT([liblognorm], [2.0.3], [rgerhards@adiscon.com])
+AC_INIT([liblognorm], [2.0.4], [rgerhards@adiscon.com])
AM_INIT_AUTOMAKE
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
AC_CONFIG_SRCDIR([src/lognorm.c])
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/liblognorm-2.0.3/doc/configuration.rst new/liblognorm-2.0.4/doc/configuration.rst
--- old/liblognorm-2.0.3/doc/configuration.rst 2016-07-11 17:12:58.000000000 +0200
+++ new/liblognorm-2.0.4/doc/configuration.rst 2017-10-04 12:09:40.000000000 +0200
@@ -69,7 +69,8 @@
* named_suffixed
The recursive and descent parsers should be replaced by user-defined types
-in. The tokenized parsers should be replaced by repeat. For the others,
+in. The tokenized parsers should be replaced by repeat. The interpret functionality
+is provided via the parser's "format" parameters. For the others,
currently there exists no replacement, but will the exception of regex,
will be added based on demand. If you think regex support is urgently
needed, please read our
@@ -431,12 +432,42 @@
One or more decimal digits.
+Parameters
+..........
+
+format
+~~~~~~
+
+Specifies the format of the json object. Possible values are "string" and
+"number", with string being the default. If "number" is used, the json
+object will be a native json integer.
+
+maxval
+~~~~~~
+
+Maximum value permitted for this number. If the value is higher than this,
+it will not be detected by this parser definition and an alternate detection
+path will be pursued.
float
#####
A floating-pt number represented in non-scientific form.
+Parameters
+..........
+
+format
+~~~~~~
+
+Specifies the format of the json object. Possible values are "string" and
+"number", with string being the default. If "number" is used, the json
+object will be a native json floating point number. Note that we try to
+preserve the original string serialization format, but keep on your mind
+that floating point numbers are inherently imprecise, so slight variance
+may occur depending on processing them.
+
+
hexnumber
#########
@@ -445,6 +476,28 @@
space. Any interleaving non-hex digits will cause non-detection. The
rules are strict to avoid false positives.
+Parameters
+..........
+
+format
+~~~~~~
+
+Specifies the format of the json object. Possible values are "string" and
+"number", with string being the default. If "number" is used, the json
+object will be a native json integer. Note that json numbers are always
+decimal, so if "number" is selected, the hex number will be converted
+to decimal. The original hex string is no longer available in this case.
+
+maxval
+~~~~~~
+
+Maximum value permitted for this number. If the value is higher than this,
+it will not be detected by this parser definition and an alternate detection
+path will be pursued. This is most useful if fixed-size hex numbers need to
+be processed. For example, for byte values the "maxval" could be set to 255,
+which ensures that invalid values are not misdetected.
+
+
kernel-timestamp
################
@@ -498,9 +551,6 @@
* **required** - quotes must be present
* **auto** - quotes are permitted, but not required
-Not!>!/
-parameters.
-
Default is ``auto``.
quoting.escape.mode
@@ -698,6 +748,23 @@
This parser implements several quirks to match malformed
timestamps from some devices.
+Parameters
+..........
+
+format
+~~~~~~
+
+Specifies the format of the json object. Possible values are
+
+- **string** - string representation as given in input data
+- **timestamp-unix** - string converted to an unix timestamp (seconds since epoch)
+- **timestamp-unix-ms** - a kind of unix-timestamp, but with millisecond resolution.
+ This format is understood for example by ElasticSearch. Note that RFC3164 does **not**
+ contain subsecond resolution, so this option makes no sense for RFC3164-data only.
+ It is usefull, howerver, if processing mixed sources, some of which contain higher
+ precision.
+
+
date-rfc5424
############
@@ -705,6 +772,23 @@
'1985-04-12T19:20:50.52-04:00'.
Slightly different formats are allowed.
+Parameters
+..........
+
+format
+~~~~~~
+
+Specifies the format of the json object. Possible values are
+
+- **string** - string representation as given in input data
+- **timestamp-unix** - string converted to an unix timestamp (seconds since epoch).
+ If subsecond resolution is given in the original timestamp, it is lost.
+- **timestamp-unix-ms** - a kind of unix-timestamp, but with millisecond resolution.
+ This format is understood for example by ElasticSearch. Note that a RFC5424
+ timestamp can contain higher than ms resolution. If so, the timestamp is
+ truncated to millisecond resolution.
+
+
ipv4
####
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/liblognorm-2.0.3/src/parser.c new/liblognorm-2.0.4/src/parser.c
--- old/liblognorm-2.0.3/src/parser.c 2017-03-22 08:34:25.000000000 +0100
+++ new/liblognorm-2.0.4/src/parser.c 2017-10-04 12:09:40.000000000 +0200
@@ -1,6 +1,6 @@
/*
* liblognorm - a fast samples-based log normalization library
- * Copyright 2010-2015 by Rainer Gerhards and Adiscon GmbH.
+ * Copyright 2010-2017 by Rainer Gerhards and Adiscon GmbH.
*
* Modified by Pavel Levshin (pavel@levshin.spb.ru) in 2013
*
@@ -33,6 +33,7 @@
#include
#include
#include
+#include
#include "liblognorm.h"
#include "lognorm.h"
@@ -47,6 +48,14 @@
#endif
+/* how should output values be formatted? */
+enum FMT_MODE {
+ FMT_AS_STRING = 0,
+ FMT_AS_NUMBER = 1,
+ FMT_AS_TIMESTAMP_UX = 2,
+ FMT_AS_TIMESTAMP_UX_MS = 3
+ };
+
/* some helpers */
static inline int
hParseInt(const unsigned char **buf, size_t *lenBuf)
@@ -146,23 +155,175 @@
void ln_destruct##ParserName(__attribute__((unused)) ln_ctx ctx, void *const pdata)
+/* the following table saves us from computing an additional date to get
+ * the ordinal day of the year - at least from 1967-2099
+ * Note: non-2038+ compliant systems (Solaris) will generate compiler
+ * warnings on the post 2038-rollover years.
+ */
+static const int yearInSec_startYear = 1967;
+/* for x in $(seq 1967 2099) ; do
+ * printf %s', ' $(date --date="Dec 31 ${x} UTC 23:59:59" +%s)
+ * done |fold -w 70 -s */
+static const time_t yearInSecs[] = {
+ -63158401, -31536001, -1, 31535999, 63071999, 94694399, 126230399,
+ 157766399, 189302399, 220924799, 252460799, 283996799, 315532799,
+ 347155199, 378691199, 410227199, 441763199, 473385599, 504921599,
+ 536457599, 567993599, 599615999, 631151999, 662687999, 694223999,
+ 725846399, 757382399, 788918399, 820454399, 852076799, 883612799,
+ 915148799, 946684799, 978307199, 1009843199, 1041379199, 1072915199,
+ 1104537599, 1136073599, 1167609599, 1199145599, 1230767999,
+ 1262303999, 1293839999, 1325375999, 1356998399, 1388534399,
+ 1420070399, 1451606399, 1483228799, 1514764799, 1546300799,
+ 1577836799, 1609459199, 1640995199, 1672531199, 1704067199,
+ 1735689599, 1767225599, 1798761599, 1830297599, 1861919999,
+ 1893455999, 1924991999, 1956527999, 1988150399, 2019686399,
+ 2051222399, 2082758399, 2114380799, 2145916799, 2177452799,
+ 2208988799, 2240611199, 2272147199, 2303683199, 2335219199,
+ 2366841599, 2398377599, 2429913599, 2461449599, 2493071999,
+ 2524607999, 2556143999, 2587679999, 2619302399, 2650838399,
+ 2682374399, 2713910399, 2745532799, 2777068799, 2808604799,
+ 2840140799, 2871763199, 2903299199, 2934835199, 2966371199,
+ 2997993599, 3029529599, 3061065599, 3092601599, 3124223999,
+ 3155759999, 3187295999, 3218831999, 3250454399, 3281990399,
+ 3313526399, 3345062399, 3376684799, 3408220799, 3439756799,
+ 3471292799, 3502915199, 3534451199, 3565987199, 3597523199,
+ 3629145599, 3660681599, 3692217599, 3723753599, 3755375999,
+ 3786911999, 3818447999, 3849983999, 3881606399, 3913142399,
+ 3944678399, 3976214399, 4007836799, 4039372799, 4070908799,
+ 4102444799};
+
+/**
+ * convert syslog timestamp to time_t
+ * Note: it would be better to use something similar to mktime() here.
+ * Unfortunately, mktime() semantics are problematic: first of all, it
+ * works on local time, on the machine's time zone. In syslog, we have
+ * to deal with multiple time zones at once, so we cannot plainly rely
+ * on the local zone, and so we cannot rely on mktime(). One solution would
+ * be to refactor all time-related functions so that they are all guarded
+ * by a mutex to ensure TZ consistency (which would also enable us to
+ * change the TZ at will for specific function calls). But that would
+ * potentially mean a lot of overhead.
+ * Also, mktime() has some side effects, at least setting of tzname. With
+ * a refactoring as described above that should probably not be a problem,
+ * but would also need more work. For some more thoughts on this topic,
+ * have a look here:
+ * http://stackoverflow.com/questions/18355101/is-standard-c-mktime-thread-safe...
+ * In conclusion, we keep our own code for generating the unix timestamp.
+ * rgerhards, 2016-03-02 (taken from rsyslog sources)
+ */
+static time_t
+syslogTime2time_t(const int year, const int month, const int day,
+ const int hour, const int minute, const int second,
+ const int OffsetHour, const int OffsetMinute, const char OffsetMode)
+{
+ long MonthInDays, NumberOfYears, NumberOfDays;
+ int utcOffset;
+ time_t TimeInUnixFormat;
+
+ if(year < 1970 || year > 2100) {
+ TimeInUnixFormat = 0;
+ goto done;
+ }
+
+ /* Counting how many Days have passed since the 01.01 of the
+ * selected Year (Month level), according to the selected Month*/
+
+ switch(month)
+ {
+ case 1:
+ MonthInDays = 0; //until 01 of January
+ break;
+ case 2:
+ MonthInDays = 31; //until 01 of February - leap year handling down below!
+ break;
+ case 3:
+ MonthInDays = 59; //until 01 of March
+ break;
+ case 4:
+ MonthInDays = 90; //until 01 of April
+ break;
+ case 5:
+ MonthInDays = 120; //until 01 of Mai
+ break;
+ case 6:
+ MonthInDays = 151; //until 01 of June
+ break;
+ case 7:
+ MonthInDays = 181; //until 01 of July
+ break;
+ case 8:
+ MonthInDays = 212; //until 01 of August
+ break;
+ case 9:
+ MonthInDays = 243; //until 01 of September
+ break;
+ case 10:
+ MonthInDays = 273; //until 01 of Oktober
+ break;
+ case 11:
+ MonthInDays = 304; //until 01 of November
+ break;
+ case 12:
+ MonthInDays = 334; //until 01 of December
+ break;
+ default: /* this cannot happen (and would be a program error)
+ * but we need the code to keep the compiler silent.
+ */
+ MonthInDays = 0; /* any value fits ;) */
+ break;
+ }
+ /* adjust for leap years */
+ if((year % 100 != 0 && year % 4 == 0) || (year == 2000)) {
+ if(month > 2)
+ MonthInDays++;
+ }
+
+
+ /* 1) Counting how many Years have passed since 1970
+ 2) Counting how many Days have passed since the 01.01 of the selected Year
+ (Day level) according to the Selected Month and Day. Last day doesn't count,
+ it should be until last day
+ 3) Calculating this period (NumberOfDays) in seconds*/
+
+ NumberOfYears = year - yearInSec_startYear - 1;
+ NumberOfDays = MonthInDays + day - 1;
+ TimeInUnixFormat = (yearInSecs[NumberOfYears] + 1) + NumberOfDays * 86400;
+
+ /*Add Hours, minutes and seconds */
+ TimeInUnixFormat += hour*60*60;
+ TimeInUnixFormat += minute*60;
+ TimeInUnixFormat += second;
+ /* do UTC offset */
+ utcOffset = OffsetHour*3600 + OffsetMinute*60;
+ if(OffsetMode == '+')
+ utcOffset *= -1; /* if timestamp is ahead, we need to "go back" to UTC */
+ TimeInUnixFormat += utcOffset;
+done:
+ return TimeInUnixFormat;
+}
+
+struct data_RFC5424Date {
+ enum FMT_MODE fmt_mode;
+};
/**
* Parse a TIMESTAMP as specified in RFC5424 (subset of RFC3339).
*/
PARSER_Parse(RFC5424Date)
const unsigned char *pszTS;
+ struct data_RFC5424Date *const data = (struct data_RFC5424Date*) pdata;
/* variables to temporarily hold time information while we parse */
- __attribute__((unused)) int year;
+ int year;
int month;
int day;
int hour; /* 24 hour clock */
int minute;
int second;
- __attribute__((unused)) int secfrac; /* fractional seconds (must be 32 bit!) */
- __attribute__((unused)) int secfracPrecision;
+ int secfrac; /* fractional seconds (must be 32 bit!) */
+ int secfracPrecision;
int OffsetHour; /* UTC offset in hours */
int OffsetMinute; /* UTC offset in minutes */
+ char OffsetMode;
size_t len;
size_t orglen;
/* end variables to temporarily hold time information while we parse */
@@ -217,9 +378,13 @@
if(len == 0) goto done;
if(*pszTS == 'Z') {
+ OffsetHour = 0;
+ OffsetMinute = 0;
+ OffsetMode = '+';
--len;
pszTS++; /* eat Z */
} else if((*pszTS == '+') || (*pszTS == '-')) {
+ OffsetMode = *pszTS;
--len;
pszTS++;
@@ -247,27 +412,90 @@
*parsed = orglen - len;
if(value != NULL) {
- *value = json_object_new_string_len(npb->str+(*offs), *parsed);
+ if(data->fmt_mode == FMT_AS_STRING) {
+ *value = json_object_new_string_len(npb->str+(*offs), *parsed);
+ } else {
+ int64_t timestamp = syslogTime2time_t(year, month, day,
+ hour, minute, second, OffsetHour, OffsetMinute, OffsetMode);
+ if(data->fmt_mode == FMT_AS_TIMESTAMP_UX_MS) {
+ timestamp *= 1000;
+ /* simulate pow(), do not use math lib! */
+ int div = 1;
+ if(secfracPrecision == 1) {
+ secfrac *= 100;
+ } else if(secfracPrecision == 2) {
+ secfrac *= 10;
+ } else if(secfracPrecision > 3) {
+ for(int i = 0 ; i < (secfracPrecision - 3) ; ++i)
+ div *= 10;
+ }
+ timestamp += secfrac / div;
+ }
+ *value = json_object_new_int64(timestamp);
+ }
}
r = 0; /* success */
done:
return r;
}
+PARSER_Construct(RFC5424Date)
+{
+ int r = 0;
+ struct data_RFC5424Date *data =
+ (struct data_RFC5424Date*) calloc(1, sizeof(struct data_RFC5424Date));
+ data->fmt_mode = FMT_AS_STRING;
+
+ if(json == NULL)
+ goto done;
+
+ struct json_object_iterator it = json_object_iter_begin(json);
+ struct json_object_iterator itEnd = json_object_iter_end(json);
+ while (!json_object_iter_equal(&it, &itEnd)) {
+ const char *key = json_object_iter_peek_name(&it);
+ struct json_object *const val = json_object_iter_peek_value(&it);
+ if(!strcmp(key, "format")) {
+ const char *fmtmode = json_object_get_string(val);
+ if(!strcmp(fmtmode, "timestamp-unix")) {
+ data->fmt_mode = FMT_AS_TIMESTAMP_UX;
+ } else if(!strcmp(fmtmode, "timestamp-unix-ms")) {
+ data->fmt_mode = FMT_AS_TIMESTAMP_UX_MS;
+ } else if(!strcmp(fmtmode, "string")) {
+ data->fmt_mode = FMT_AS_STRING;
+ } else {
+ ln_errprintf(ctx, 0, "invalid value for date-rfc5424:format %s",
+ fmtmode);
+ }
+ } else {
+ ln_errprintf(ctx, 0, "invalid param for date-rfc5424 %s", key);
+ }
+ json_object_iter_next(&it);
+ }
+
+done:
+ *pdata = data;
+ return r;
+}
+PARSER_Destruct(RFC5424Date)
+{
+ free(pdata);
+}
+struct data_RFC3164Date {
+ enum FMT_MODE fmt_mode;
+};
/**
* Parse a RFC3164 Date.
*/
PARSER_Parse(RFC3164Date)
const unsigned char *p;
size_t len, orglen;
+ struct data_RFC3164Date *const data = (struct data_RFC3164Date*) pdata;
/* variables to temporarily hold time information while we parse */
- __attribute__((unused)) int month;
+ int year;
+ int month;
int day;
-#if 0 /* TODO: why does this still exist? */
- int year = 0; /* 0 means no year provided */
-#endif
int hour; /* 24 hour clock */
int minute;
int second;
@@ -475,14 +703,75 @@
/* we had success, so update parse pointer */
*parsed = orglen - len;
if(value != NULL) {
- *value = json_object_new_string_len(npb->str+(*offs), *parsed);
+ if(data->fmt_mode == FMT_AS_STRING) {
+ *value = json_object_new_string_len(npb->str+(*offs), *parsed);
+ } else {
+ /* we assume year == current year, so let's obtain current year */
+ struct tm tm;
+ const time_t curr = time(NULL);
+ gmtime_r(&curr, &tm);
+ year = tm.tm_year + 1900;
+ int64_t timestamp = syslogTime2time_t(year, month, day,
+ hour, minute, second, 0, 0, '+');
+ if(data->fmt_mode == FMT_AS_TIMESTAMP_UX_MS) {
+ /* we do not have more precise info, just bring
+ * into common format!
+ */
+ timestamp *= 1000;
+ }
+ *value = json_object_new_int64(timestamp);
+ }
}
r = 0; /* success */
done:
return r;
}
+PARSER_Construct(RFC3164Date)
+{
+ int r = 0;
+ struct data_RFC3164Date *data = (struct data_RFC3164Date*) calloc(1, sizeof(struct data_RFC3164Date));
+ data->fmt_mode = FMT_AS_STRING;
+
+ if(json == NULL)
+ goto done;
+
+ struct json_object_iterator it = json_object_iter_begin(json);
+ struct json_object_iterator itEnd = json_object_iter_end(json);
+ while (!json_object_iter_equal(&it, &itEnd)) {
+ const char *key = json_object_iter_peek_name(&it);
+ struct json_object *const val = json_object_iter_peek_value(&it);
+ if(!strcmp(key, "format")) {
+ const char *fmtmode = json_object_get_string(val);
+ if(!strcmp(fmtmode, "timestamp-unix")) {
+ data->fmt_mode = FMT_AS_TIMESTAMP_UX;
+ } else if(!strcmp(fmtmode, "timestamp-unix-ms")) {
+ data->fmt_mode = FMT_AS_TIMESTAMP_UX_MS;
+ } else if(!strcmp(fmtmode, "string")) {
+ data->fmt_mode = FMT_AS_STRING;
+ } else {
+ ln_errprintf(ctx, 0, "invalid value for date-rfc3164:format %s",
+ fmtmode);
+ }
+ } else {
+ ln_errprintf(ctx, 0, "invalid param for date-rfc3164 %s", key);
+ }
+ json_object_iter_next(&it);
+ }
+
+done:
+ *pdata = data;
+ return r;
+}
+PARSER_Destruct(RFC3164Date)
+{
+ free(pdata);
+}
+struct data_Number {
+ int64_t maxval;
+ enum FMT_MODE fmt_mode;
+};
/**
* Parse a Number.
* Note that a number is an abstracted concept. We always represent it
@@ -491,68 +780,202 @@
PARSER_Parse(Number)
const char *c;
size_t i;
+ int64_t val = 0;
+ struct data_Number *const data = (struct data_Number*) pdata;
+
+ enum FMT_MODE fmt_mode = FMT_AS_STRING;
+ int64_t maxval = 0;
+ if(data != NULL) {
+ fmt_mode = data->fmt_mode;
+ maxval = data->maxval;
+ }
assert(npb->str != NULL);
assert(offs != NULL);
assert(parsed != NULL);
c = npb->str;
- for (i = *offs; i < npb->strLen && myisdigit(c[i]); i++);
+ for (i = *offs; i < npb->strLen && myisdigit(c[i]); i++)
+ val = val * 10 + c[i] - '0';
+
+ if(maxval > 0 && val > maxval) {
+ LN_DBGPRINTF(npb->ctx, "number parser: val too large (max %" PRIu64
+ ", actual %" PRIu64 ")",
+ maxval, val);
+ goto done;
+ }
+
if (i == *offs)
goto done;
/* success, persist */
*parsed = i - *offs;
if(value != NULL) {
- *value = json_object_new_string_len(npb->str+(*offs), *parsed);
+ if(fmt_mode == FMT_AS_STRING) {
+ *value = json_object_new_string_len(npb->str+(*offs), *parsed);
+ } else {
+ *value = json_object_new_int64(val);
+ }
}
r = 0; /* success */
done:
return r;
}
+PARSER_Construct(Number)
+{
+ int r = 0;
+ struct data_Number *data = (struct data_Number*) calloc(1, sizeof(struct data_Number));
+ data->fmt_mode = FMT_AS_STRING;
+
+ if(json == NULL)
+ goto done;
+
+ struct json_object_iterator it = json_object_iter_begin(json);
+ struct json_object_iterator itEnd = json_object_iter_end(json);
+ while (!json_object_iter_equal(&it, &itEnd)) {
+ const char *key = json_object_iter_peek_name(&it);
+ struct json_object *const val = json_object_iter_peek_value(&it);
+ if(!strcmp(key, "maxval")) {
+ errno = 0;
+ data->maxval = json_object_get_int64(val);
+ if(errno != 0) {
+ ln_errprintf(ctx, errno, "param 'maxval' must be integer but is: %s",
+ json_object_to_json_string(val));
+ }
+ } else if(!strcmp(key, "format")) {
+ const char *fmtmode = json_object_get_string(val);
+ if(!strcmp(fmtmode, "number")) {
+ data->fmt_mode = FMT_AS_NUMBER;
+ } else if(!strcmp(fmtmode, "string")) {
+ data->fmt_mode = FMT_AS_STRING;
+ } else {
+ ln_errprintf(ctx, 0, "invalid value for number:format %s",
+ fmtmode);
+ }
+ } else {
+ ln_errprintf(ctx, 0, "invalid param for number: %s", key);
+ }
+ json_object_iter_next(&it);
+ }
+
+done:
+ *pdata = data;
+ return r;
+}
+PARSER_Destruct(Number)
+{
+ free(pdata);
+}
+
+struct data_Float {
+ enum FMT_MODE fmt_mode;
+};
/**
* Parse a Real-number in floating-pt form.
*/
PARSER_Parse(Float)
const char *c;
size_t i;
+ const struct data_Float *const data = (struct data_Float*) pdata;
assert(npb->str != NULL);
assert(offs != NULL);
assert(parsed != NULL);
c = npb->str;
+ int isNeg = 0;
+ double val = 0;
int seen_point = 0;
+ double frac = 10;
i = *offs;
- if (c[i] == '-') i++;
+ if (c[i] == '-') {
+ isNeg = 1;
+ i++;
+ }
for (; i < npb->strLen; i++) {
if (c[i] == '.') {
- if (seen_point != 0) break;
+ if (seen_point != 0)
+ break;
seen_point = 1;
- } else if (! myisdigit(c[i])) {
+ } else if (myisdigit(c[i])) {
+ if(seen_point) {
+ val += (c[i] - '0') / frac;
+ frac *= 10;
+ } else {
+ val = val * 10 + c[i] - '0';
+ }
+ } else {
break;
}
}
if (i == *offs)
goto done;
+ if(isNeg)
+ val *= -1;
+
/* success, persist */
*parsed = i - *offs;
if(value != NULL) {
- *value = json_object_new_string_len(npb->str+(*offs), *parsed);
+ if(data->fmt_mode == FMT_AS_STRING) {
+ *value = json_object_new_string_len(npb->str+(*offs), *parsed);
+ } else {
+ char *serialized = strndup(npb->str+(*offs), *parsed);
+ *value = json_object_new_double_s(val, serialized);
+ free(serialized);
+ }
}
r = 0; /* success */
done:
return r;
}
+PARSER_Construct(Float)
+{
+ int r = 0;
+ struct data_Float *data = (struct data_Float*) calloc(1, sizeof(struct data_Float));
+ data->fmt_mode = FMT_AS_STRING;
+
+ if(json == NULL)
+ goto done;
+
+ struct json_object_iterator it = json_object_iter_begin(json);
+ struct json_object_iterator itEnd = json_object_iter_end(json);
+ while (!json_object_iter_equal(&it, &itEnd)) {
+ const char *key = json_object_iter_peek_name(&it);
+ struct json_object *const val = json_object_iter_peek_value(&it);
+ if(!strcmp(key, "format")) {
+ const char *fmtmode = json_object_get_string(val);
+ if(!strcmp(fmtmode, "number")) {
+ data->fmt_mode = FMT_AS_NUMBER;
+ } else if(!strcmp(fmtmode, "string")) {
+ data->fmt_mode = FMT_AS_STRING;
+ } else {
+ ln_errprintf(ctx, 0, "invalid value for float:format %s",
+ fmtmode);
+ }
+ } else {
+ ln_errprintf(ctx, 0, "invalid param for float: %s", key);
+ }
+ json_object_iter_next(&it);
+ }
+
+done:
+ *pdata = data;
+ return r;
+}
+PARSER_Destruct(Float)
+{
+ free(pdata);
+}
struct data_HexNumber {
uint64_t maxval;
+ enum FMT_MODE fmt_mode;
};
/**
* Parse a hex Number.
@@ -595,7 +1018,11 @@
/* success, persist */
*parsed = i - *offs;
if(value != NULL) {
- *value = json_object_new_string_len(npb->str+(*offs), *parsed);
+ if(data->fmt_mode == FMT_AS_STRING) {
+ *value = json_object_new_string_len(npb->str+(*offs), *parsed);
+ } else {
+ *value = json_object_new_int64((int64_t) val);
+ }
}
r = 0; /* success */
done:
@@ -605,6 +1032,7 @@
{
int r = 0;
struct data_HexNumber *data = (struct data_HexNumber*) calloc(1, sizeof(struct data_HexNumber));
+ data->fmt_mode = FMT_AS_STRING;
if(json == NULL)
goto done;
@@ -621,9 +1049,18 @@
ln_errprintf(ctx, errno, "param 'maxval' must be integer but is: %s",
json_object_to_json_string(val));
}
+ } else if(!strcmp(key, "format")) {
+ const char *fmtmode = json_object_get_string(val);
+ if(!strcmp(fmtmode, "number")) {
+ data->fmt_mode = FMT_AS_NUMBER;
+ } else if(!strcmp(fmtmode, "string")) {
+ data->fmt_mode = FMT_AS_STRING;
+ } else {
+ ln_errprintf(ctx, 0, "invalid value for hexnumber:format %s",
+ fmtmode);
+ }
} else {
- ln_errprintf(ctx, 0, "invalid param for hexnumber: %s",
- json_object_to_json_string(val));
+ ln_errprintf(ctx, 0, "invalid param for hexnumber: %s", key);
}
json_object_iter_next(&it);
}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/liblognorm-2.0.3/src/parser.h new/liblognorm-2.0.4/src/parser.h
--- old/liblognorm-2.0.3/src/parser.h 2016-04-26 16:27:14.000000000 +0200
+++ new/liblognorm-2.0.4/src/parser.h 2017-10-04 12:09:40.000000000 +0200
@@ -39,17 +39,17 @@
// TODO #warning check how to handle "value" - does it need to be set to NULL?
#define PARSERDEF_NO_DATA(parser) \
- int ln_v2_parse##parser(npb_t *npb, size_t *offs, void *const, size_t *parsed, struct json_object **value);
+ int ln_v2_parse##parser(npb_t *npb, size_t *offs, void *const, size_t *parsed, struct json_object **value)
#define PARSERDEF(parser) \
int ln_construct##parser(ln_ctx ctx, json_object *const json, void **pdata); \
int ln_v2_parse##parser(npb_t *npb, size_t *offs, void *const, size_t *parsed, struct json_object **value); \
- void ln_destruct##parser(ln_ctx ctx, void *const pdata);
+ void ln_destruct##parser(ln_ctx ctx, void *const pdata)
-PARSERDEF_NO_DATA(RFC5424Date);
-PARSERDEF_NO_DATA(RFC3164Date);
-PARSERDEF_NO_DATA(Number);
-PARSERDEF_NO_DATA(Float);
+PARSERDEF(RFC5424Date);
+PARSERDEF(RFC3164Date);
+PARSERDEF(Number);
+PARSERDEF(Float);
PARSERDEF(HexNumber);
PARSERDEF_NO_DATA(KernelTimestamp);
PARSERDEF_NO_DATA(Whitespace);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/liblognorm-2.0.3/src/pdag.c new/liblognorm-2.0.4/src/pdag.c
--- old/liblognorm-2.0.3/src/pdag.c 2017-01-23 15:32:52.000000000 +0100
+++ new/liblognorm-2.0.4/src/pdag.c 2017-10-04 12:09:40.000000000 +0200
@@ -70,10 +70,10 @@
static struct ln_parser_info parser_lookup_table[] = {
PARSER_ENTRY("literal", Literal, 4),
PARSER_ENTRY("repeat", Repeat, 4),
- PARSER_ENTRY_NO_DATA("date-rfc3164", RFC3164Date, 8),
- PARSER_ENTRY_NO_DATA("date-rfc5424", RFC5424Date, 8),
- PARSER_ENTRY_NO_DATA("number", Number, 16),
- PARSER_ENTRY_NO_DATA("float", Float, 16),
+ PARSER_ENTRY("date-rfc3164", RFC3164Date, 8),
+ PARSER_ENTRY("date-rfc5424", RFC5424Date, 8),
+ PARSER_ENTRY("number", Number, 16),
+ PARSER_ENTRY("float", Float, 16),
PARSER_ENTRY("hexnumber", HexNumber, 16),
PARSER_ENTRY_NO_DATA("kernel-timestamp", KernelTimestamp, 16),
PARSER_ENTRY_NO_DATA("whitespace", Whitespace, 4),
@@ -415,7 +415,7 @@
static void
-deleteComponentID(struct ln_pdag *const __restrict dag)
+deleteComponentID(struct ln_pdag *const __restrict__ dag)
{
free((void*)dag->rb_id);
dag->rb_id = NULL;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/liblognorm-2.0.3/src/v1_ptree.c new/liblognorm-2.0.4/src/v1_ptree.c
--- old/liblognorm-2.0.3/src/v1_ptree.c 2017-01-23 15:32:52.000000000 +0100
+++ new/liblognorm-2.0.4/src/v1_ptree.c 2017-10-02 13:06:32.000000000 +0200
@@ -145,7 +145,7 @@
* does not contain any subtrees.
* @return 1 if it is a leaf, 0 otherwise
*/
-static inline int
+static int
isLeaf(struct ln_ptree *tree)
{
int r = 0;
@@ -231,7 +231,7 @@
* @param[in] tree tree to split
* @param[in] offs offset into common prefix (must be less than prefix length!)
*/
-static inline struct ln_ptree*
+static struct ln_ptree*
splitTree(struct ln_ptree *tree, unsigned short offs)
{
unsigned char *c;
@@ -529,7 +529,7 @@
/**
* add unparsed string to event.
*/
-static inline int
+static int
addUnparsedField(const char *str, size_t strLen, int offs, struct json_object *json)
{
int r = 1;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/liblognorm-2.0.3/tests/Makefile.am new/liblognorm-2.0.4/tests/Makefile.am
--- old/liblognorm-2.0.3/tests/Makefile.am 2017-03-22 08:34:25.000000000 +0100
+++ new/liblognorm-2.0.4/tests/Makefile.am 2017-10-04 12:09:40.000000000 +0200
@@ -3,7 +3,7 @@
json_eq_self_sources = json_eq.c
json_eq_SOURCES = $(json_eq_self_sources)
json_eq_CPPFLAGS = $(JSON_C_CFLAGS) $(WARN_CFLAGS) -I$(top_srcdir)/src
-json_eq_LDADD = $(JSON_C_LIBS)
+json_eq_LDADD = $(JSON_C_LIBS) -lm -lestr
json_eq_LDFLAGS = -no-install
#user_test_SOURCES = user_test.c
@@ -64,7 +64,11 @@
strict_prefix_matching_2.sh \
field_string.sh \
field_string_perm_chars.sh \
+ field_number.sh \
+ field_number-fmt_number.sh \
+ field_number_maxval.sh \
field_hexnumber.sh \
+ field_hexnumber-fmt_number.sh \
field_hexnumber_jsoncnf.sh \
field_hexnumber_range.sh \
field_hexnumber_range_jsoncnf.sh \
@@ -95,7 +99,10 @@
field_duration.sh \
field_duration_jsoncnf.sh \
field_float.sh \
+ field_float-fmt_number.sh \
field_float_jsoncnf.sh \
+ field_rfc5424timestamp-fmt_timestamp-unix.sh \
+ field_rfc5424timestamp-fmt_timestamp-unix-ms.sh \
very_long_logline_jsoncnf.sh
# now come tests for the legacy (v1) engine
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/liblognorm-2.0.3/tests/Makefile.in new/liblognorm-2.0.4/tests/Makefile.in
--- old/liblognorm-2.0.3/tests/Makefile.in 2017-03-22 10:44:35.000000000 +0100
+++ new/liblognorm-2.0.4/tests/Makefile.in 2017-10-04 12:15:56.000000000 +0200
@@ -519,7 +519,7 @@
json_eq_self_sources = json_eq.c
json_eq_SOURCES = $(json_eq_self_sources)
json_eq_CPPFLAGS = $(JSON_C_CFLAGS) $(WARN_CFLAGS) -I$(top_srcdir)/src
-json_eq_LDADD = $(JSON_C_LIBS)
+json_eq_LDADD = $(JSON_C_LIBS) -lm -lestr
json_eq_LDFLAGS = -no-install
#user_test_SOURCES = user_test.c
@@ -557,7 +557,9 @@
parser_whitespace.sh parser_whitespace_jsoncnf.sh parser_LF.sh \
parser_LF_jsoncnf.sh strict_prefix_actual_sample1.sh \
strict_prefix_matching_1.sh strict_prefix_matching_2.sh \
- field_string.sh field_string_perm_chars.sh field_hexnumber.sh \
+ field_string.sh field_string_perm_chars.sh field_number.sh \
+ field_number-fmt_number.sh field_number_maxval.sh \
+ field_hexnumber.sh field_hexnumber-fmt_number.sh \
field_hexnumber_jsoncnf.sh field_hexnumber_range.sh \
field_hexnumber_range_jsoncnf.sh rule_last_str_short.sh \
field_mac48.sh field_mac48_jsoncnf.sh field_name_value.sh \
@@ -571,10 +573,12 @@
field_v2-iptables_jsoncnf.sh field_cef.sh field_cef_jsoncnf.sh \
field_checkpoint-lea.sh field_checkpoint-lea_jsoncnf.sh \
field_duration.sh field_duration_jsoncnf.sh field_float.sh \
- field_float_jsoncnf.sh very_long_logline_jsoncnf.sh \
- missing_line_ending_v1.sh runaway_rule_v1.sh \
- runaway_rule_comment_v1.sh field_hexnumber_v1.sh \
- field_mac48_v1.sh field_name_value_v1.sh \
+ field_float-fmt_number.sh field_float_jsoncnf.sh \
+ field_rfc5424timestamp-fmt_timestamp-unix.sh \
+ field_rfc5424timestamp-fmt_timestamp-unix-ms.sh \
+ very_long_logline_jsoncnf.sh missing_line_ending_v1.sh \
+ runaway_rule_v1.sh runaway_rule_comment_v1.sh \
+ field_hexnumber_v1.sh field_mac48_v1.sh field_name_value_v1.sh \
field_kernel_timestamp_v1.sh field_whitespace_v1.sh \
field_rest_v1.sh field_json_v1.sh field_cee-syslog_v1.sh \
field_ipv6_v1.sh field_v2-iptables_v1.sh field_cef_v1.sh \
@@ -1169,6 +1173,27 @@
--log-file $$b.log --trs-file $$b.trs \
$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
"$$tst" $(AM_TESTS_FD_REDIRECT)
+field_number.sh.log: field_number.sh
+ @p='field_number.sh'; \
+ b='field_number.sh'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+field_number-fmt_number.sh.log: field_number-fmt_number.sh
+ @p='field_number-fmt_number.sh'; \
+ b='field_number-fmt_number.sh'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+field_number_maxval.sh.log: field_number_maxval.sh
+ @p='field_number_maxval.sh'; \
+ b='field_number_maxval.sh'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
field_hexnumber.sh.log: field_hexnumber.sh
@p='field_hexnumber.sh'; \
b='field_hexnumber.sh'; \
@@ -1176,6 +1201,13 @@
--log-file $$b.log --trs-file $$b.trs \
$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
"$$tst" $(AM_TESTS_FD_REDIRECT)
+field_hexnumber-fmt_number.sh.log: field_hexnumber-fmt_number.sh
+ @p='field_hexnumber-fmt_number.sh'; \
+ b='field_hexnumber-fmt_number.sh'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
field_hexnumber_jsoncnf.sh.log: field_hexnumber_jsoncnf.sh
@p='field_hexnumber_jsoncnf.sh'; \
b='field_hexnumber_jsoncnf.sh'; \
@@ -1386,12 +1418,33 @@
--log-file $$b.log --trs-file $$b.trs \
$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
"$$tst" $(AM_TESTS_FD_REDIRECT)
+field_float-fmt_number.sh.log: field_float-fmt_number.sh
+ @p='field_float-fmt_number.sh'; \
+ b='field_float-fmt_number.sh'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
field_float_jsoncnf.sh.log: field_float_jsoncnf.sh
@p='field_float_jsoncnf.sh'; \
b='field_float_jsoncnf.sh'; \
$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
--log-file $$b.log --trs-file $$b.trs \
$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+field_rfc5424timestamp-fmt_timestamp-unix.sh.log: field_rfc5424timestamp-fmt_timestamp-unix.sh
+ @p='field_rfc5424timestamp-fmt_timestamp-unix.sh'; \
+ b='field_rfc5424timestamp-fmt_timestamp-unix.sh'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+field_rfc5424timestamp-fmt_timestamp-unix-ms.sh.log: field_rfc5424timestamp-fmt_timestamp-unix-ms.sh
+ @p='field_rfc5424timestamp-fmt_timestamp-unix-ms.sh'; \
+ b='field_rfc5424timestamp-fmt_timestamp-unix-ms.sh'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
"$$tst" $(AM_TESTS_FD_REDIRECT)
very_long_logline_jsoncnf.sh.log: very_long_logline_jsoncnf.sh
@p='very_long_logline_jsoncnf.sh'; \
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/liblognorm-2.0.3/tests/field_float-fmt_number.sh new/liblognorm-2.0.4/tests/field_float-fmt_number.sh
--- old/liblognorm-2.0.3/tests/field_float-fmt_number.sh 1970-01-01 01:00:00.000000000 +0100
+++ new/liblognorm-2.0.4/tests/field_float-fmt_number.sh 2017-10-02 14:25:53.000000000 +0200
@@ -0,0 +1,27 @@
+# added 2017-10-02 by singh.janmejay
+# This file is part of the liblognorm project, released under ASL 2.0
+. $srcdir/exec.sh
+
+test_def $0 "float field"
+add_rule 'version=2'
+add_rule 'rule=:here is a number %{ "type":"float", "name":"num", "format":"number"}% in floating pt form'
+execute 'here is a number 15.9 in floating pt form'
+assert_output_json_eq '{"num": 15.9}'
+
+reset_rules
+
+# note: floating point numbers are tricky to get right, even more so if negative.
+add_rule 'version=2'
+add_rule 'rule=:here is a negative number %{ "type":"float", "name":"num", "format":"number"}% for you'
+execute 'here is a negative number -4.2 for you'
+assert_output_json_eq '{"num": -4.2}'
+
+reset_rules
+
+add_rule 'version=2'
+add_rule 'rule=:here is another real number %{ "type":"float", "name":"num", "format":"number"}%.'
+execute 'here is another real number 2.71.'
+assert_output_json_eq '{"num": 2.71}'
+
+
+cleanup_tmp_files
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/liblognorm-2.0.3/tests/field_hexnumber-fmt_number.sh new/liblognorm-2.0.4/tests/field_hexnumber-fmt_number.sh
--- old/liblognorm-2.0.3/tests/field_hexnumber-fmt_number.sh 1970-01-01 01:00:00.000000000 +0100
+++ new/liblognorm-2.0.4/tests/field_hexnumber-fmt_number.sh 2017-10-02 14:25:53.000000000 +0200
@@ -0,0 +1,18 @@
+# added 2017-10-02 by Rainer Gerhards
+# This file is part of the liblognorm project, released under ASL 2.0
+
+. $srcdir/exec.sh
+
+test_def $0 "hexnumber field"
+add_rule 'version=2'
+add_rule 'rule=:here is a number %{ "type":"hexnumber", "name":"num", "format":"number"} % in hex form'
+execute 'here is a number 0x1234 in hex form'
+assert_output_json_eq '{"num": 4660}'
+
+#check cases where parsing failure must occur
+execute 'here is a number 0x1234in hex form'
+assert_output_json_eq '{ "originalmsg": "here is a number 0x1234in hex form", "unparsed-data": "0x1234in hex form" }'
+
+
+cleanup_tmp_files
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/liblognorm-2.0.3/tests/field_number-fmt_number.sh new/liblognorm-2.0.4/tests/field_number-fmt_number.sh
--- old/liblognorm-2.0.3/tests/field_number-fmt_number.sh 1970-01-01 01:00:00.000000000 +0100
+++ new/liblognorm-2.0.4/tests/field_number-fmt_number.sh 2017-10-02 14:25:53.000000000 +0200
@@ -0,0 +1,17 @@
+# added 2017-10-02 by Rainer Gerhards
+# This file is part of the liblognorm project, released under ASL 2.0
+
+. $srcdir/exec.sh
+
+test_def $0 "number field in native format"
+add_rule 'version=2'
+add_rule 'rule=:here is a number %{ "type":"number", "name":"num", "format":"number"}% in dec form'
+execute 'here is a number 1234 in dec form'
+assert_output_json_eq '{"num": 1234}'
+
+#check cases where parsing failure must occur
+execute 'here is a number 1234in dec form'
+assert_output_json_eq '{ "originalmsg": "here is a number 1234in dec form", "unparsed-data": "in dec form" }'
+
+
+cleanup_tmp_files
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/liblognorm-2.0.3/tests/field_number.sh new/liblognorm-2.0.4/tests/field_number.sh
--- old/liblognorm-2.0.3/tests/field_number.sh 1970-01-01 01:00:00.000000000 +0100
+++ new/liblognorm-2.0.4/tests/field_number.sh 2017-10-02 14:25:53.000000000 +0200
@@ -0,0 +1,17 @@
+# added 2017-10-02 by Rainer Gerhards
+# This file is part of the liblognorm project, released under ASL 2.0
+
+. $srcdir/exec.sh
+
+test_def $0 "number field"
+add_rule 'version=2'
+add_rule 'rule=:here is a number %num:number% in dec form'
+execute 'here is a number 1234 in dec form'
+assert_output_json_eq '{"num": "1234"}'
+
+#check cases where parsing failure must occur
+execute 'here is a number 1234in dec form'
+assert_output_json_eq '{ "originalmsg": "here is a number 1234in dec form", "unparsed-data": "in dec form" }'
+
+
+cleanup_tmp_files
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/liblognorm-2.0.3/tests/field_number_maxval.sh new/liblognorm-2.0.4/tests/field_number_maxval.sh
--- old/liblognorm-2.0.3/tests/field_number_maxval.sh 1970-01-01 01:00:00.000000000 +0100
+++ new/liblognorm-2.0.4/tests/field_number_maxval.sh 2017-10-02 14:25:53.000000000 +0200
@@ -0,0 +1,17 @@
+# added 2017-10-02 by Rainer Gerhards
+# This file is part of the liblognorm project, released under ASL 2.0
+
+. $srcdir/exec.sh
+
+test_def $0 "number field with maxval"
+add_rule 'version=2'
+add_rule 'rule=:here is a number %{ "type":"number", "name":"num", "maxval":1000}% in dec form'
+execute 'here is a number 234 in dec form'
+assert_output_json_eq '{"num": "234"}'
+
+#check cases where parsing failure must occur
+execute 'here is a number 1234in dec form'
+assert_output_json_eq '{ "originalmsg": "here is a number 1234in dec form", "unparsed-data": "1234in dec form" }'
+
+
+cleanup_tmp_files
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/liblognorm-2.0.3/tests/field_rfc5424timestamp-fmt_timestamp-unix-ms.sh new/liblognorm-2.0.4/tests/field_rfc5424timestamp-fmt_timestamp-unix-ms.sh
--- old/liblognorm-2.0.3/tests/field_rfc5424timestamp-fmt_timestamp-unix-ms.sh 1970-01-01 01:00:00.000000000 +0100
+++ new/liblognorm-2.0.4/tests/field_rfc5424timestamp-fmt_timestamp-unix-ms.sh 2017-10-04 12:09:40.000000000 +0200
@@ -0,0 +1,33 @@
+# added 2017-10-02 by Rainer Gerhards
+# This file is part of the liblognorm project, released under ASL 2.0
+
+. $srcdir/exec.sh
+
+test_def $0 "RFC5424 timestamp in timestamp-unix format"
+add_rule 'version=2'
+add_rule 'rule=:here is a timestamp %{ "type":"date-rfc5424", "name":"num", "format":"timestamp-unix-ms"}% in RFC5424 format'
+execute 'here is a timestamp 2000-03-11T14:15:16+01:00 in RFC5424 format'
+assert_output_json_eq '{ "num": 952780516000}'
+
+# with milliseconds (too-low precision)
+execute 'here is a timestamp 2000-03-11T14:15:16.1+01:00 in RFC5424 format'
+assert_output_json_eq '{ "num": 952780516100 }'
+execute 'here is a timestamp 2000-03-11T14:15:16.12+01:00 in RFC5424 format'
+assert_output_json_eq '{ "num": 952780516120 }'
+
+# with milliseconds (exactly right precision)
+execute 'here is a timestamp 2000-03-11T14:15:16.123+01:00 in RFC5424 format'
+assert_output_json_eq '{ "num": 952780516123 }'
+
+# with overdone precision
+execute 'here is a timestamp 2000-03-11T14:15:16.1234+01:00 in RFC5424 format'
+assert_output_json_eq '{ "num": 952780516123 }'
+execute 'here is a timestamp 2000-03-11T14:15:16.123456789+01:00 in RFC5424 format'
+assert_output_json_eq '{ "num": 952780516123 }'
+
+#check cases where parsing failure must occur
+execute 'here is a timestamp 2000-03-11T14:15:16+01:00in RFC5424 format'
+assert_output_json_eq '{ "originalmsg": "here is a timestamp 2000-03-11T14:15:16+01:00in RFC5424 format", "unparsed-data": "2000-03-11T14:15:16+01:00in RFC5424 format" }'
+
+
+cleanup_tmp_files
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/liblognorm-2.0.3/tests/field_rfc5424timestamp-fmt_timestamp-unix.sh new/liblognorm-2.0.4/tests/field_rfc5424timestamp-fmt_timestamp-unix.sh
--- old/liblognorm-2.0.3/tests/field_rfc5424timestamp-fmt_timestamp-unix.sh 1970-01-01 01:00:00.000000000 +0100
+++ new/liblognorm-2.0.4/tests/field_rfc5424timestamp-fmt_timestamp-unix.sh 2017-10-04 12:09:40.000000000 +0200
@@ -0,0 +1,21 @@
+# added 2017-10-02 by Rainer Gerhards
+# This file is part of the liblognorm project, released under ASL 2.0
+
+. $srcdir/exec.sh
+
+test_def $0 "RFC5424 timestamp in timestamp-unix format"
+add_rule 'version=2'
+add_rule 'rule=:here is a timestamp %{ "type":"date-rfc5424", "name":"num", "format":"timestamp-unix"}% in RFC5424 format'
+execute 'here is a timestamp 2000-03-11T14:15:16+01:00 in RFC5424 format'
+assert_output_json_eq '{"num": 952780516}'
+
+# with milliseconds (must be ignored with this format!)
+execute 'here is a timestamp 2000-03-11T14:15:16.321+01:00 in RFC5424 format'
+assert_output_json_eq '{"num": 952780516}'
+
+#check cases where parsing failure must occur
+execute 'here is a timestamp 2000-03-11T14:15:16+01:00in RFC5424 format'
+assert_output_json_eq '{ "originalmsg": "here is a timestamp 2000-03-11T14:15:16+01:00in RFC5424 format", "unparsed-data": "2000-03-11T14:15:16+01:00in RFC5424 format" }'
+
+
+cleanup_tmp_files