summaryrefslogtreecommitdiffstats
path: root/runtime/stream.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2012-11-22 11:05:45 +0100
committerRainer Gerhards <rgerhards@adiscon.com>2012-11-22 11:05:45 +0100
commit42cd1fa7d786a020ef934ed71162f18b464d55bf (patch)
tree98ccb728030c6019669577172806ccc452c57af8 /runtime/stream.c
parent014c1818e6d103342199157c341d609741a24f42 (diff)
parent59c7a299e9907f81f0970d3523a47f4361466d08 (diff)
downloadrsyslog-42cd1fa7d786a020ef934ed71162f18b464d55bf.tar.gz
rsyslog-42cd1fa7d786a020ef934ed71162f18b464d55bf.tar.bz2
rsyslog-42cd1fa7d786a020ef934ed71162f18b464d55bf.zip
Merge branch 'v7-stable'
Conflicts: configure.ac doc/manual.html plugins/imfile/imfile.c plugins/imklog/bsd.c plugins/imklog/imklog.c plugins/imklog/imklog.h
Diffstat (limited to 'runtime/stream.c')
-rw-r--r--runtime/stream.c32
1 files changed, 22 insertions, 10 deletions
diff --git a/runtime/stream.c b/runtime/stream.c
index 23e6c943..9f4d3556 100644
--- a/runtime/stream.c
+++ b/runtime/stream.c
@@ -596,25 +596,33 @@ strmReadLine(strm_t *pThis, cstr_t **ppCStr, int mode)
* mode = 2 LF <not whitespace> mode, a log line starts at the beginning of a line, but following lines that are indented are part of the same log entry
* This modal interface is not nearly as flexible as being able to define a regex for when a new record starts, but it's also not nearly as hard (or as slow) to implement
*/
- DEFiRet;
uchar c;
uchar finished;
+ rsRetVal readCharRet;
+ DEFiRet;
ASSERT(pThis != NULL);
ASSERT(ppCStr != NULL);
CHKiRet(cstrConstruct(ppCStr));
-
- /* now read the line */
CHKiRet(strmReadChar(pThis, &c));
- if (mode == 0){
- while(c != '\n') {
+
+ if(mode == 0) {
+ /* append previous message to current message if necessary */
+ if(pThis->prevLineSegment != NULL) {
+ CHKiRet(cstrAppendCStr(*ppCStr, pThis->prevLineSegment));
+ cstrDestruct(&pThis->prevLineSegment);
+ }
+ while(c != '\n') {
CHKiRet(cstrAppendChar(*ppCStr, c));
- CHKiRet(strmReadChar(pThis, &c));
+ readCharRet = strmReadChar(pThis, &c);
+ if(readCharRet == RS_RET_EOF) {/* end of file reached without \n? */
+ CHKiRet(rsCStrConstructFromCStr(&pThis->prevLineSegment, *ppCStr));
+ }
+ CHKiRet(readCharRet);
}
CHKiRet(cstrFinalize(*ppCStr));
- }
- if (mode == 1){
+ } else if(mode == 1) {
finished=0;
while(finished == 0){
if(c != '\n') {
@@ -635,8 +643,7 @@ strmReadLine(strm_t *pThis, cstr_t **ppCStr, int mode)
}
}
CHKiRet(cstrFinalize(*ppCStr));
- }
- if (mode == 2){
+ } else if(mode == 2) {
/* indented follow-up lines */
finished=0;
while(finished == 0){
@@ -690,6 +697,7 @@ BEGINobjConstruct(strm) /* be sure to specify the object type also in END macro!
pThis->sType = STREAMTYPE_FILE_SINGLE;
pThis->sIOBufSize = glblGetIOBufSize();
pThis->tOpenMode = 0600;
+ pThis->prevLineSegment = NULL;
ENDobjConstruct(strm)
@@ -1683,6 +1691,8 @@ static rsRetVal strmSerialize(strm_t *pThis, strm_t *pStrm)
l = pThis->iCurrOffs;
objSerializeSCALAR_VAR(pStrm, iCurrOffs, INT64, l);
+ objSerializePTR(pStrm, prevLineSegment, PSZ);
+
CHKiRet(obj.EndSerialize(pStrm));
finalize_it:
@@ -1788,6 +1798,8 @@ static rsRetVal strmSetProperty(strm_t *pThis, var_t *pProp)
CHKiRet(strmSetiFileNumDigits(pThis, pProp->val.num));
} else if(isProp("bDeleteOnClose")) {
CHKiRet(strmSetbDeleteOnClose(pThis, pProp->val.num));
+ } else if(isProp("prevLineSegment")) {
+ CHKiRet(rsCStrConstructFromCStr(&pThis->prevLineSegment, pProp->val.pStr));
}
finalize_it: