summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2009-06-04 12:15:59 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2009-06-04 12:15:59 +0200
commit9e434f19a9baa4a6f411808b5cb6bc22d6a32781 (patch)
tree36b6ee12c665a9eb781e1984d479002bf4680ef1 /plugins
parent768836ab79268e1091fc3af8bb920c03287db91a (diff)
downloadrsyslog-9e434f19a9baa4a6f411808b5cb6bc22d6a32781.tar.gz
rsyslog-9e434f19a9baa4a6f411808b5cb6bc22d6a32781.tar.xz
rsyslog-9e434f19a9baa4a6f411808b5cb6bc22d6a32781.zip
cleaned up stream class ...
... and also made it callable via an rsyslog interface rather then relying on the OS loader (important if we go for using it inside loadbale modules, which we soon possible will)
Diffstat (limited to 'plugins')
-rw-r--r--plugins/imfile/imfile.c51
1 files changed, 27 insertions, 24 deletions
diff --git a/plugins/imfile/imfile.c b/plugins/imfile/imfile.c
index 92fd30c3..ff32c857 100644
--- a/plugins/imfile/imfile.c
+++ b/plugins/imfile/imfile.c
@@ -56,6 +56,7 @@ DEF_IMOD_STATIC_DATA /* must be present, starts static data */
DEFobjCurrIf(errmsg)
DEFobjCurrIf(glbl)
DEFobjCurrIf(datetime)
+DEFobjCurrIf(strm)
typedef struct fileInfo_s {
uchar *pszFileName;
@@ -139,16 +140,16 @@ openFile(fileInfo_t *pThis)
/* If we reach this point, we have a .si file */
- CHKiRet(strmConstruct(&psSF));
- CHKiRet(strmSettOperationsMode(psSF, STREAMMODE_READ));
- CHKiRet(strmSetsType(psSF, STREAMTYPE_FILE_SINGLE));
- CHKiRet(strmSetFName(psSF, pszSFNam, lenSFNam));
- CHKiRet(strmConstructFinalize(psSF));
+ CHKiRet(strm.Construct(&psSF));
+ CHKiRet(strm.SettOperationsMode(psSF, STREAMMODE_READ));
+ CHKiRet(strm.SetsType(psSF, STREAMTYPE_FILE_SINGLE));
+ CHKiRet(strm.SetFName(psSF, pszSFNam, lenSFNam));
+ CHKiRet(strm.ConstructFinalize(psSF));
/* read back in the object */
CHKiRet(obj.Deserialize(&pThis->pStrm, (uchar*) "strm", psSF, NULL, pThis));
- CHKiRet(strmSeekCurrOffs(pThis->pStrm));
+ CHKiRet(strm.SeekCurrOffs(pThis->pStrm));
/* OK, we could successfully read the file, so we now can request that it be deleted.
* If we need it again, it will be written on the next shutdown.
@@ -157,14 +158,14 @@ openFile(fileInfo_t *pThis)
finalize_it:
if(psSF != NULL)
- strmDestruct(&psSF);
+ strm.Destruct(&psSF);
if(iRet != RS_RET_OK) {
- CHKiRet(strmConstruct(&pThis->pStrm));
- CHKiRet(strmSettOperationsMode(pThis->pStrm, STREAMMODE_READ));
- CHKiRet(strmSetsType(pThis->pStrm, STREAMTYPE_FILE_MONITOR));
- CHKiRet(strmSetFName(pThis->pStrm, pThis->pszFileName, strlen((char*) pThis->pszFileName)));
- CHKiRet(strmConstructFinalize(pThis->pStrm));
+ CHKiRet(strm.Construct(&pThis->pStrm));
+ CHKiRet(strm.SettOperationsMode(pThis->pStrm, STREAMMODE_READ));
+ CHKiRet(strm.SetsType(pThis->pStrm, STREAMTYPE_FILE_MONITOR));
+ CHKiRet(strm.SetFName(pThis->pStrm, pThis->pszFileName, strlen((char*) pThis->pszFileName)));
+ CHKiRet(strm.ConstructFinalize(pThis->pStrm));
}
RETiRet;
@@ -203,7 +204,7 @@ static rsRetVal pollFile(fileInfo_t *pThis, int *pbHadFileData)
/* loop below will be exited when strmReadLine() returns EOF */
while(1) {
- CHKiRet(strmReadLine(pThis->pStrm, &pCStr));
+ CHKiRet(strm.ReadLine(pThis->pStrm, &pCStr));
*pbHadFileData = 1; /* this is just a flag, so set it and forget it */
CHKiRet(enqLine(pThis, pCStr)); /* process line */
rsCStrDestruct(&pCStr); /* discard string (must be done by us!) */
@@ -354,21 +355,21 @@ persistStrmState(fileInfo_t *pInfo)
ASSERT(pInfo != NULL);
/* TODO: create a function persistObj in obj.c? */
- CHKiRet(strmConstruct(&psSF));
- CHKiRet(strmSetDir(psSF, glbl.GetWorkDir(), strlen((char*)glbl.GetWorkDir())));
- CHKiRet(strmSettOperationsMode(psSF, STREAMMODE_WRITE));
- CHKiRet(strmSetiAddtlOpenFlags(psSF, O_TRUNC));
- CHKiRet(strmSetsType(psSF, STREAMTYPE_FILE_SINGLE));
- CHKiRet(strmSetFName(psSF, pInfo->pszStateFile, strlen((char*) pInfo->pszStateFile)));
- CHKiRet(strmConstructFinalize(psSF));
+ CHKiRet(strm.Construct(&psSF));
+ CHKiRet(strm.SetDir(psSF, glbl.GetWorkDir(), strlen((char*)glbl.GetWorkDir())));
+ CHKiRet(strm.SettOperationsMode(psSF, STREAMMODE_WRITE));
+ CHKiRet(strm.SetiAddtlOpenFlags(psSF, O_TRUNC));
+ CHKiRet(strm.SetsType(psSF, STREAMTYPE_FILE_SINGLE));
+ CHKiRet(strm.SetFName(psSF, pInfo->pszStateFile, strlen((char*) pInfo->pszStateFile)));
+ CHKiRet(strm.ConstructFinalize(psSF));
- CHKiRet(strmSerialize(pInfo->pStrm, psSF));
+ CHKiRet(strm.Serialize(pInfo->pStrm, psSF));
- CHKiRet(strmDestruct(&psSF));
+ CHKiRet(strm.Destruct(&psSF));
finalize_it:
if(psSF != NULL)
- strmDestruct(&psSF);
+ strm.Destruct(&psSF);
RETiRet;
}
@@ -388,7 +389,7 @@ CODESTARTafterRun
for(i = 0 ; i < iFilPtr ; ++i) {
if(files[i].pStrm != NULL) { /* stream open? */
persistStrmState(&files[i]);
- strmDestruct(&(files[i].pStrm));
+ strm.Destruct(&(files[i].pStrm));
}
}
ENDafterRun
@@ -401,6 +402,7 @@ ENDafterRun
BEGINmodExit
CODESTARTmodExit
/* release objects we used */
+ objRelease(strm, CORE_COMPONENT);
objRelease(datetime, CORE_COMPONENT);
objRelease(glbl, CORE_COMPONENT);
objRelease(errmsg, CORE_COMPONENT);
@@ -512,6 +514,7 @@ CODEmodInit_QueryRegCFSLineHdlr
CHKiRet(objUse(errmsg, CORE_COMPONENT));
CHKiRet(objUse(glbl, CORE_COMPONENT));
CHKiRet(objUse(datetime, CORE_COMPONENT));
+ CHKiRet(objUse(strm, CORE_COMPONENT));
CHKiRet(omsdRegCFSLineHdlr((uchar *)"inputfilename", 0, eCmdHdlrGetWord,
NULL, &pszFileName, STD_LOADABLE_MODULE_ID));