summaryrefslogtreecommitdiff
path: root/plugins/imfile
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2008-12-12 17:46:20 +0100
committerMichael Biebl <biebl@debian.org>2008-12-12 17:46:20 +0100
commit84080b58f8c6c5c040723a02503ddd90f02b5898 (patch)
treecf8c63e076f1ebb9cb2bea644a4f45172808a3e5 /plugins/imfile
parent53123ea8a1b9180b9aa0568e847f9245987c1b7c (diff)
downloadrsyslog-84080b58f8c6c5c040723a02503ddd90f02b5898.tar.gz
Imported Upstream version 3.20.2upstream/3.20.2
Diffstat (limited to 'plugins/imfile')
-rw-r--r--plugins/imfile/Makefile.am2
-rw-r--r--plugins/imfile/Makefile.in13
-rw-r--r--plugins/imfile/imfile.c28
3 files changed, 30 insertions, 13 deletions
diff --git a/plugins/imfile/Makefile.am b/plugins/imfile/Makefile.am
index 23b64d1..a4011d1 100644
--- a/plugins/imfile/Makefile.am
+++ b/plugins/imfile/Makefile.am
@@ -1,6 +1,6 @@
pkglib_LTLIBRARIES = imfile.la
imfile_la_SOURCES = imfile.c
-imfile_la_CPPFLAGS = -I$(top_srcdir) $(pthreads_cflags)
+imfile_la_CPPFLAGS = -I$(top_srcdir) $(pthreads_cflags) $(rsrt_cflags)
imfile_la_LDFLAGS = -module -avoid-version
imfile_la_LIBADD =
diff --git a/plugins/imfile/Makefile.in b/plugins/imfile/Makefile.in
index ab7b871..0df3527 100644
--- a/plugins/imfile/Makefile.in
+++ b/plugins/imfile/Makefile.in
@@ -102,6 +102,7 @@ EXEEXT = @EXEEXT@
F77 = @F77@
FFLAGS = @FFLAGS@
GREP = @GREP@
+HAVE_GNUTLS_CONFIG = @HAVE_GNUTLS_CONFIG@
HAVE_MYSQL_CONFIG = @HAVE_MYSQL_CONFIG@
HAVE_PGSQL_CONFIG = @HAVE_PGSQL_CONFIG@
INSTALL = @INSTALL@
@@ -110,6 +111,8 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
+LIBLOGGING_CFLAGS = @LIBLOGGING_CFLAGS@
+LIBLOGGING_LIBS = @LIBLOGGING_LIBS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
@@ -130,6 +133,8 @@ PKG_CONFIG = @PKG_CONFIG@
RANLIB = @RANLIB@
RELP_CFLAGS = @RELP_CFLAGS@
RELP_LIBS = @RELP_LIBS@
+RFC3195_CFLAGS = @RFC3195_CFLAGS@
+RFC3195_LIBS = @RFC3195_LIBS@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
@@ -160,6 +165,8 @@ dl_libs = @dl_libs@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
+gnutls_cflags = @gnutls_cflags@
+gnutls_libs = @gnutls_libs@
gss_libs = @gss_libs@
host = @host@
host_alias = @host_alias@
@@ -189,8 +196,8 @@ program_transform_name = @program_transform_name@
psdir = @psdir@
pthreads_cflags = @pthreads_cflags@
pthreads_libs = @pthreads_libs@
-rfc3195_cflags = @rfc3195_cflags@
-rfc3195_libs = @rfc3195_libs@
+rsrt_cflags = @rsrt_cflags@
+rsrt_libs = @rsrt_libs@
rt_libs = @rt_libs@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
@@ -205,7 +212,7 @@ top_srcdir = @top_srcdir@
zlib_libs = @zlib_libs@
pkglib_LTLIBRARIES = imfile.la
imfile_la_SOURCES = imfile.c
-imfile_la_CPPFLAGS = -I$(top_srcdir) $(pthreads_cflags)
+imfile_la_CPPFLAGS = -I$(top_srcdir) $(pthreads_cflags) $(rsrt_cflags)
imfile_la_LDFLAGS = -module -avoid-version
imfile_la_LIBADD =
all: all-am
diff --git a/plugins/imfile/imfile.c b/plugins/imfile/imfile.c
index 2df1aaf..3bc07b9 100644
--- a/plugins/imfile/imfile.c
+++ b/plugins/imfile/imfile.c
@@ -36,13 +36,14 @@
# include <sys/stat.h>
#endif
#include "rsyslog.h" /* error codes etc... */
-#include "syslogd.h"
+#include "dirty.h"
#include "cfsysline.h" /* access to config file objects */
#include "module-template.h" /* generic module interface code - very important, read it! */
#include "srUtils.h" /* some utility functions */
#include "msg.h"
#include "stream.h"
#include "errmsg.h"
+#include "glbl.h"
#include "datetime.h"
MODULE_TYPE_INPUT /* must be present for input modules, do not remove */
@@ -52,6 +53,7 @@ MODULE_TYPE_INPUT /* must be present for input modules, do not remove */
/* Module static data */
DEF_IMOD_STATIC_DATA /* must be present, starts static data */
DEFobjCurrIf(errmsg)
+DEFobjCurrIf(glbl)
DEFobjCurrIf(datetime)
typedef struct fileInfo_s {
@@ -95,7 +97,7 @@ static rsRetVal enqLine(fileInfo_t *pInfo, cstr_t *cstrLine)
MsgSetUxTradMsg(pMsg, (char*)rsCStrGetSzStr(cstrLine));
MsgSetRawMsg(pMsg, (char*)rsCStrGetSzStr(cstrLine));
MsgSetMSG(pMsg, (char*)rsCStrGetSzStr(cstrLine));
- MsgSetHOSTNAME(pMsg, (char*)LocalHostName);
+ MsgSetHOSTNAME(pMsg, (char*)glbl.GetLocalHostName());
MsgSetTAG(pMsg, (char*)pInfo->pszTag);
pMsg->iFacility = LOG_FAC(pInfo->iFacility);
pMsg->iSeverity = LOG_PRI(pInfo->iSeverity);
@@ -121,7 +123,7 @@ openFile(fileInfo_t *pThis)
/* Construct file name */
lenSFNam = snprintf((char*)pszSFNam, sizeof(pszSFNam) / sizeof(uchar), "%s/%s",
- (char*) glblGetWorkDir(), (char*)pThis->pszStateFile);
+ (char*) glbl.GetWorkDir(), (char*)pThis->pszStateFile);
/* check if the file exists */
if(stat((char*) pszSFNam, &stat_buf) == -1) {
@@ -179,7 +181,10 @@ static void pollFileCancelCleanup(void *pArg)
rsCStrDestruct(ppCStr);
ENDfunc;
}
+
+
/* poll a file, need to check file rollover etc. open file if not open */
+#pragma GCC diagnostic ignored "-Wempty-body"
static rsRetVal pollFile(fileInfo_t *pThis, int *pbHadFileData)
{
cstr_t *pCStr = NULL;
@@ -220,6 +225,7 @@ finalize_it:
RETiRet;
}
+#pragma GCC diagnostic warning "-Wempty-body"
/* This function is the cancel cleanup handler. It is called when rsyslog decides the
@@ -276,6 +282,7 @@ inputModuleCleanup(void __attribute__((unused)) *arg)
* On spamming the main queue: keep in mind that it will automatically rate-limit
* ourselfes if we begin to overrun it. So we really do not need to care here.
*/
+#pragma GCC diagnostic ignored "-Wempty-body"
BEGINrunInput
int i;
int bHadFileData; /* were there at least one file with data during this run? */
@@ -308,6 +315,7 @@ CODESTARTrunInput
pthread_cleanup_pop(0); /* just for completeness, but never called... */
RETiRet; /* use it to make sure the housekeeping is done! */
ENDrunInput
+#pragma GCC diagnostic warning "-Wempty-body"
/* END no-touch zone *
* ------------------------------------------------------------------------------------------ */
@@ -322,7 +330,7 @@ ENDrunInput
BEGINwillRun
CODESTARTwillRun
if(iFilPtr == 0) {
- errmsg.LogError(NO_ERRCODE, "No files configured to be monitored");
+ errmsg.LogError(0, RS_RET_NO_RUN, "No files configured to be monitored");
ABORT_FINALIZE(RS_RET_NO_RUN);
}
@@ -346,7 +354,7 @@ persistStrmState(fileInfo_t *pInfo)
/* TODO: create a function persistObj in obj.c? */
CHKiRet(strmConstruct(&psSF));
- CHKiRet(strmSetDir(psSF, glblGetWorkDir(), strlen((char*)glblGetWorkDir())));
+ 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));
@@ -393,6 +401,7 @@ BEGINmodExit
CODESTARTmodExit
/* release objects we used */
objRelease(datetime, CORE_COMPONENT);
+ objRelease(glbl, CORE_COMPONENT);
objRelease(errmsg, CORE_COMPONENT);
ENDmodExit
@@ -450,21 +459,21 @@ static rsRetVal addMonitor(void __attribute__((unused)) *pVal, uchar *pNewVal)
pThis = &files[iFilPtr];
/* TODO: check for strdup() NULL return */
if(pszFileName == NULL) {
- errmsg.LogError(NO_ERRCODE, "imfile error: no file name given, file monitor can not be created");
+ errmsg.LogError(0, RS_RET_CONFIG_ERROR, "imfile error: no file name given, file monitor can not be created");
ABORT_FINALIZE(RS_RET_CONFIG_ERROR);
} else {
pThis->pszFileName = (uchar*) strdup((char*) pszFileName);
}
if(pszFileTag == NULL) {
- errmsg.LogError(NO_ERRCODE, "imfile error: no tag value given , file monitor can not be created");
+ errmsg.LogError(0, RS_RET_CONFIG_ERROR, "imfile error: no tag value given , file monitor can not be created");
ABORT_FINALIZE(RS_RET_CONFIG_ERROR);
} else {
pThis->pszTag = (uchar*) strdup((char*) pszFileTag);
}
if(pszStateFile == NULL) {
- errmsg.LogError(NO_ERRCODE, "imfile error: not state file name given, file monitor can not be created");
+ errmsg.LogError(0, RS_RET_CONFIG_ERROR, "imfile error: not state file name given, file monitor can not be created");
ABORT_FINALIZE(RS_RET_CONFIG_ERROR);
} else {
pThis->pszStateFile = (uchar*) strdup((char*) pszStateFile);
@@ -473,7 +482,7 @@ static rsRetVal addMonitor(void __attribute__((unused)) *pVal, uchar *pNewVal)
pThis->iSeverity = iSeverity;
pThis->iFacility = iFacility;
} else {
- errmsg.LogError(NO_ERRCODE, "Too many file monitors configured - ignoring this one");
+ errmsg.LogError(0, RS_RET_OUT_OF_DESRIPTORS, "Too many file monitors configured - ignoring this one");
ABORT_FINALIZE(RS_RET_OUT_OF_DESRIPTORS);
}
@@ -500,6 +509,7 @@ CODESTARTmodInit
*ipIFVersProvided = CURR_MOD_IF_VERSION; /* we only support the current interface specification */
CODEmodInit_QueryRegCFSLineHdlr
CHKiRet(objUse(errmsg, CORE_COMPONENT));
+ CHKiRet(objUse(glbl, CORE_COMPONENT));
CHKiRet(objUse(datetime, CORE_COMPONENT));
CHKiRet(omsdRegCFSLineHdlr((uchar *)"inputfilename", 0, eCmdHdlrGetWord,