summaryrefslogtreecommitdiffstats
path: root/runtime/msg.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2013-03-29 16:04:21 +0100
committerRainer Gerhards <rgerhards@adiscon.com>2013-03-29 16:04:21 +0100
commit474877b9d7912a3d2abc2a350dbc41e4c3b050e4 (patch)
treed2e04c9bb8a4542cf8757194b25441e3cb4d96ac /runtime/msg.c
parentd1caf0e291f0fb587781436f3f634749f761ea03 (diff)
downloadrsyslog-474877b9d7912a3d2abc2a350dbc41e4c3b050e4.tar.gz
rsyslog-474877b9d7912a3d2abc2a350dbc41e4c3b050e4.tar.bz2
rsyslog-474877b9d7912a3d2abc2a350dbc41e4c3b050e4.zip
permit substring extraction relative to end-of-string in templates
Diffstat (limited to 'runtime/msg.c')
-rw-r--r--runtime/msg.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/runtime/msg.c b/runtime/msg.c
index 32a02424..9afd46cf 100644
--- a/runtime/msg.c
+++ b/runtime/msg.c
@@ -3017,13 +3017,20 @@ uchar *MsgGetProp(msg_t *pMsg, struct templateEntry *pTpe,
uchar *pSb;
iFrom = pTpe->data.field.iFromPos;
iTo = pTpe->data.field.iToPos;
- /* need to zero-base to and from (they are 1-based!) */
- if(iFrom > 0)
- --iFrom;
- if(iTo > 0)
- --iTo;
if(bufLen == -1)
bufLen = ustrlen(pRes);
+dbgprintf("DDDD: orginal iFrom %u, iTo %u, len %u\n", iFrom, iTo, bufLen);
+ if(pTpe->data.field.options.bFromPosEndRelative) {
+ iFrom = (bufLen < iFrom) ? 0 : bufLen - iFrom;
+ iTo = (bufLen < iTo)? 0 : bufLen - iTo;
+dbgprintf("DDDD: now iFrom %u, iTo %u\n", iFrom, iTo);
+ } else {
+ /* need to zero-base to and from (they are 1-based!) */
+ if(iFrom > 0)
+ --iFrom;
+ if(iTo > 0)
+ --iTo;
+ }
if(iFrom == 0 && iTo >= bufLen) {
/* in this case, the requested string is a superset of what we already have,
* so there is no need to do any processing. This is a frequent case for size-limited