283 Commits

Author SHA1 Message Date
Rainer Gerhards
b326c76f45 style: normalize C source formatting via clang-format (PoC)
This commit applies the new canonical formatting style using `clang-format` with custom settings (notably 4-space indentation), as part of our shift toward automated formatting normalization.

⚠️ No functional changes are included — only whitespace and layout modifications as produced by `clang-format`.

This change is part of the formatting modernization strategy discussed in:
https://github.com/rsyslog/rsyslog/issues/5747

Key context:
- Formatting is now treated as a disposable view, normalized via tooling.
- The `.clang-format` file defines the canonical style.
- A fixup script (`devtools/format-code.sh`) handles remaining edge cases.
- Formatting commits are added to `.git-blame-ignore-revs` to reduce noise.
- Developers remain free to format code however they prefer locally.
2025-07-16 13:56:21 +02:00
Rainer Gerhards
e7dfcc9a74
cleanup and doc improvement
among others, remove some warning suppressions by "fixing" the
respective constructs with work-arounds (root cause is compilers
do not handle enums in switch well).
2025-06-14 14:38:51 +02:00
Rainer Gerhards
7245abb709
core/template: implement negative position.to
This will easily permit to drop the last n characters from a property
without the need to know the exact length of the string. This is
especially useful as the exact length is most often not known
beforehand.
2023-01-20 10:47:22 +01:00
Rainer Gerhards
246b8d8553
core bugfix: template system may generate invalid json
When
- a list template
- is created with option.jsonf="on"
- and the last list element is a property with onEmpty="skip"
- and that property is actually empty
invalid JSON is generated.

The JSON string in this case ends with ", " instead of "}\n". This
patch fixes the issue.

closes https://github.com/rsyslog/rsyslog/issues/5050
2022-12-30 17:13:17 +01:00
Rainer Gerhards
6c16d84237
Merge pull request #4758 from mbarbon/mbarbon/format-iso-week
add property options to support ISO week/year number
2022-04-01 12:57:31 +02:00
Michael Biebl
6569133c75
Typo fixes (#4801)
* typo fix: ambigious -> ambiguous

* typo fix: aquire -> acquire

* typo fix: assgined -> assigned

* typo fix: cancelation -> cancellation

* typo fix: childs -> children

* typo fix: configuraton -> configuration

* typo fix: delemiter -> delimiter

* typo fix: forwardig -> forwarding

* typo fix: initializiation -> initialization

* typo fix: intializing -> initializing

* typo fix: lengh -> length

* typo fix: mesage -> message

* typo fix: occured -> occurred

* typo fix: occurence -> occurrence

* typo fix: paramter -> parameter

* typo fix: remaing -> remaining

* typo fix: resetted -> reset

* typo fix: suppored -> supported

* typo fix: Sytem -> System

* typo fix: uncommited -> uncommitted

* typo fix: depricated -> deprecated

* typo fix: stoping -> stopping

* type fix: allow to -> allow one to
2022-02-17 10:54:12 +01:00
Mattia Barbon
a11ad1a451 add property options to support ISO week/year number 2021-12-28 10:35:59 +01:00
alakatos
66bcd91196 Clarify meaning of loadConf and RunConf 2021-12-15 10:26:52 +01:00
Paul Dee
4c07e5faeb
Update template.c
trim extra "has"
2020-11-05 21:39:06 +01:00
Rainer Gerhards
d247c31888
add 'exists()' script function to check if variable exists
This implements a way to check if rsyslog variables (e.g. '$!path!var') is
currently set of not.

Sample: if exists($!somevar) then ...

closes https://github.com/rsyslog/rsyslog/issues/4385
2020-10-05 12:38:58 +02:00
Rainer Gerhards
5361d994b8
fix misleading/invalid indention
detected by clang 10
2019-12-18 10:14:16 +01:00
Rainer Gerhards
9d2084989a
core/config: "fix" valgrind false positive
While this is a false positiv, we actually restructure the code to
"solve" the issue. As it is only-config related code, the performance
is not affected. As such the "fix" is acceptable.
2019-12-02 18:33:42 +01:00
Rainer Gerhards
602d6b1a9f
template: add datatype template option for JSON generation
The new "datatype" and "onEmpty"  template options permits to
generate non-string data rather easily. It works together with
jsonf formatting, which is what people should use nowadays.

closes https://github.com/rsyslog/rsyslog/issues/2827
2019-05-16 15:49:45 +02:00
Philippe Duveau
c8d8871aea
Merge branch 'AIX_Port_step2' into master 2019-02-21 09:23:40 +01:00
Rainer Gerhards
00f09d8723
cleanup: use less verbose C11 method to use pragmas 2019-02-20 17:13:28 +01:00
Philippe Duveau
9ad7324dfa AIX_port: second phase 2019-02-14 14:36:05 +01:00
Rainer Gerhards
0c74a1902f
cleanup: remove commented-out code
detected by lgtm.com
2019-01-14 13:14:18 +01:00
Rainer Gerhards
ca49b004d0
bugfix debug output: date property options output wrongly
inside debug logging, the date property options were not all
properly converted into strings. Some of the newer ones were
invalidly flagged as "UNKNOWN". This is primarily a cosmetic
problem and has no effect other than puzzling folks looking at
the debug log.
2018-11-27 11:49:25 +01:00
Rainer Gerhards
9bece39dc6
SQUASH
debug cleanup: remove some old, no longer used macros
2018-10-30 12:46:04 +01:00
Rainer Gerhards
531e356a64
cleanup: remove commented-out code, simplify a bit
commented-out code detected by lgtm.com
2018-10-29 09:14:13 +01:00
Rainer Gerhards
26db406974
cleanup: remove no longer needed code
array mode templates are no longer supported

If they are needed again, check v7 for importing code
2018-09-26 18:55:31 +02:00
PascalWithopf
c83e3ed216 correct codestyle in rsyslog part 2 2018-08-01 16:11:33 +02:00
PascalWithopf
19133327cc correct codestyle in rsyslog 2018-07-31 09:44:27 +02:00
Rainer Gerhards
69cc25ddd7
cleanup: another FIXME that wasn't removed in time... 2018-07-02 13:36:07 +02:00
Rainer Gerhards
93bebb1f1f template: add option to generate json "container"
This enables easy JSON generation via template.

This commit also corrects an issue with the constant "jsonf"
format. That was recently added, and the implementation problem
only became visible when used inside a larger json object. No
officially released code is affected, thought - so it rellay
is just a side-note.

closes https://github.com/rsyslog/rsyslog/issues/2347
2018-02-16 08:22:49 +01:00
Rainer Gerhards
87f296fd2e core/template: add format jsonf to constant template entries
closes https://github.com/rsyslog/rsyslog/issues/2348
2018-02-10 19:04:40 +01:00
PascalWithopf
29c9fb1f9a codestyle: reduce line length to 120
lines are still checked for a length of 125 because
these are just some of the lines
2017-12-21 17:09:32 +01:00
PascalWithopf
79de51e4fc codestyle: reduce max line length to 125 2017-12-20 16:16:57 +01:00
Jan Gerhards
ceddd7e75d template: use new errmsg interface 2017-11-15 13:03:57 +01:00
PascalWithopf
e485c5c5bc codestyle: shorten lines to max 130 chars 2017-11-15 09:04:42 +01:00
Rainer Gerhards
741aaf87d3 core/template bugfis: potential NULL pointer access at config load
could happen if the config was loaded and the parameters could not
properly be processed. If so, this occured only during the startup
phase.

Detected by Coverity scan, CID 185318
2017-11-11 15:25:01 +01:00
Rainer Gerhards
ed9b9ba877 simplify code
Detected by Coverity scan, CID 185356
2017-11-09 19:17:55 +01:00
Rainer Gerhards
a83b72e5f6 template: fix potential NULL pointer access
could happen during config processing on invalid config parameters

Detected by Coverity scan, CID 185437
2017-10-31 13:00:33 +01:00
Rainer Gerhards
72496ac8b4 core/template: fix double free due to 9e3efd4960eb6133c99b0842e5a717ba37b5cda1
Fix 9e3efd4960eb6133c99b0842e5a717ba37b5cda1 was incomplete, causing
a double-free.

Detected by Coverity scan, CID 185476
2017-10-30 09:40:16 +01:00
Rainer Gerhards
07609d5794 template object: NULL pointer access on invalid parameters
could happen only during startup

Detected by Coverity scan, CID 185376
2017-10-29 19:13:04 +01:00
Rainer Gerhards
9e3efd4960 core: fix theoritical memory leak in template processing
can occur if the system is totally out of memory

Detected by Coverity scan, CID 185321
2017-10-29 19:13:04 +01:00
Rainer Gerhards
309f2439cc core/template: detect potential internal logic error
problem identified by clang static analyzer. Extremely
unlikely, so currently handled by given an appropriate
error message and return state.
2017-10-24 11:23:33 +02:00
Rainer Gerhards
8ac4776543 template/bugfix: invalid template option conflict detection
closes https://github.com/rsyslog/rsyslog/issues/1811
2017-10-05 14:49:17 +02:00
Jan Gerhards
779fce20b3 multiple modules: add better error messages when regcomp is failing
see also: https://github.com/rsyslog/rsyslog/issues/1102
2017-06-26 11:03:00 +02:00
Rainer Gerhards
8d67c03d45 solaris: fix coding issues 2017-04-11 10:18:42 +02:00
Pascal Withopf
b63a6b9010 codestyle: line length adjusted 2017-01-17 08:54:37 +01:00
purnima
d45daa2af0 Rebase,redefine msgDestruct() as smsg_t is used 2016-11-22 14:24:25 +05:30
Rainer Gerhards
a31015abe2 template emergency json escaping: use slash instead of backslash
This is only triggered if we do not get memory to do proper escaping,
so this code is unlikely to be executed. However, we think that
forwards slash is a better susbstitute for backslash than is the
single quote char.
2016-10-26 11:59:38 +02:00
Rainer Gerhards
b0dc6c16f2 fix json template encoding (correct predicate check)
commit 27af112637b47fd80c9ffb80565e61e049b88774 tried to fix
json encoding, but introduced an invalid predicate check that
lead to no encoding at all.

see also https://github.com/rsyslog/rsyslog/pull/1216
2016-10-26 11:54:29 +02:00
usuario
27af112637 Modified template to add "\\" on doEscape for JSON_ESCAPE fixing #1126 2016-10-24 22:00:14 +02:00
Rainer Gerhards
5e3b075d53 fix compiler warnings 2016-06-02 12:08:55 +02:00
Rainer Gerhards
17553f5195 cleanup: compiler warnings 2016-06-01 09:49:46 +02:00
Rainer Gerhards
5e4671b765 fix potential misadressing (could cause segfault on startup)
Happens when template name shorter than two chars and outname
is not set. Once we are over startup, things work reliably.

This was a bug that's present for quite a while.
2016-05-19 17:34:31 +02:00
Rainer Gerhards
822ef895ff fix mem leak
This was present for quite a while, new clang 3.8 static anaylzer
finally detected it.
2016-05-19 17:33:14 +02:00
Rainer Gerhards
7989397975 fix bugs introduced today (found by clang static analyzer) 2016-05-19 17:19:29 +02:00