diff options
-rw-r--r-- | module-template.h | 18 | ||||
-rw-r--r-- | modules.h | 12 | ||||
-rw-r--r-- | omfile.c | 5 | ||||
-rw-r--r-- | omfwd.c | 17 | ||||
-rw-r--r-- | ommysql.c | 5 | ||||
-rw-r--r-- | omshell.c | 1 | ||||
-rw-r--r-- | omusrmsg.c | 5 | ||||
-rw-r--r-- | syslogd.c | 14 |
8 files changed, 37 insertions, 40 deletions
diff --git a/module-template.h b/module-template.h index 470d81d8..b3c3229c 100644 --- a/module-template.h +++ b/module-template.h @@ -60,13 +60,12 @@ static rsRetVal createInstance(instanceData **ppData)\ /* freeInstance() */ #define BEGINfreeInstance \ -static rsRetVal freeInstance(selector_t *f, void* pModData)\ +static rsRetVal freeInstance(void* pModData)\ {\ rsRetVal iRet = RS_RET_OK;\ instanceData *pData; #define CODESTARTfreeInstance \ - assert(f != NULL);\ pData = (instanceData*) pModData; #define ENDfreeInstance \ @@ -91,12 +90,11 @@ static rsRetVal isCompatibleWithFeature(syslogFeature __attribute__((unused)) eF /* doAction() */ #define BEGINdoAction \ -static rsRetVal doAction(selector_t *f, uchar __attribute__((unused)) **ppString, unsigned __attribute__((unused)) iMsgOpts, instanceData __attribute__((unused)) *pData)\ +static rsRetVal doAction(uchar __attribute__((unused)) **ppString, unsigned __attribute__((unused)) iMsgOpts, instanceData __attribute__((unused)) *pData)\ {\ rsRetVal iRet = RS_RET_OK; #define CODESTARTdoAction \ - assert(f != NULL);\ assert(ppString != NULL); #define ENDdoAction \ @@ -109,13 +107,12 @@ static rsRetVal doAction(selector_t *f, uchar __attribute__((unused)) **ppString * Print debug information about this instance. */ #define BEGINdbgPrintInstInfo \ -static rsRetVal dbgPrintInstInfo(selector_t *f, void *pModData)\ +static rsRetVal dbgPrintInstInfo(void *pModData)\ {\ rsRetVal iRet = RS_RET_OK;\ instanceData *pData = NULL; #define CODESTARTdbgPrintInstInfo \ - assert(f != NULL);\ pData = (instanceData*) pModData; #define ENDdbgPrintInstInfo \ @@ -151,13 +148,12 @@ static rsRetVal needUDPSocket(void *pModData)\ * before. */ #define BEGINonSelectReadyWrite \ -static rsRetVal onSelectReadyWrite(selector_t *f, void *pModData)\ +static rsRetVal onSelectReadyWrite(void *pModData)\ {\ rsRetVal iRet = RS_RET_NONE;\ instanceData *pData = NULL; #define CODESTARTonSelectReadyWrite \ - assert(f != NULL);\ pData = (instanceData*) pModData; #define ENDonSelectReadyWrite \ @@ -174,13 +170,12 @@ static rsRetVal onSelectReadyWrite(selector_t *f, void *pModData)\ * continue modularization. */ #define BEGINgetWriteFDForSelect \ -static rsRetVal getWriteFDForSelect(selector_t *f, void *pModData, short *fd)\ +static rsRetVal getWriteFDForSelect(void *pModData, short *fd)\ {\ rsRetVal iRet = RS_RET_NONE;\ instanceData *pData = NULL; #define CODESTARTgetWriteFDForSelect \ - assert(f != NULL);\ assert(fd != NULL);\ pData = (instanceData*) pModData; @@ -204,7 +199,7 @@ static rsRetVal getWriteFDForSelect(selector_t *f, void *pModData, short *fd)\ * placed right after CODESTARTparseSelectorAct. */ #define BEGINparseSelectorAct \ -static rsRetVal parseSelectorAct(uchar **pp, selector_t *f, void **ppModData, omodStringRequest_t **ppOMSR)\ +static rsRetVal parseSelectorAct(uchar **pp, void **ppModData, omodStringRequest_t **ppOMSR)\ {\ rsRetVal iRet = RS_RET_OK;\ uchar *p;\ @@ -213,7 +208,6 @@ static rsRetVal parseSelectorAct(uchar **pp, selector_t *f, void **ppModData, om #define CODESTARTparseSelectorAct \ assert(pp != NULL);\ assert(ppModData != NULL);\ - assert(f != NULL);\ assert(ppOMSR != NULL);\ p = *pp; @@ -56,11 +56,11 @@ typedef struct moduleInfo { /* be sure to support version handshake! */ rsRetVal (*modQueryEtryPt)(uchar *name, rsRetVal (**EtryPoint)()); /* query entry point addresses */ rsRetVal (*isCompatibleWithFeature)(syslogFeature); - rsRetVal (*freeInstance)(struct filed*, void*);/* called before termination or module unload */ - rsRetVal (*getWriteFDForSelect)(struct filed*, void*,short *);/* called before termination or module unload */ - rsRetVal (*onSelectReadyWrite)(struct filed*, void*);/* called when fd is writeable after select() */ + rsRetVal (*freeInstance)(void*);/* called before termination or module unload */ + rsRetVal (*getWriteFDForSelect)(void*,short *);/* called before termination or module unload */ + rsRetVal (*onSelectReadyWrite)(void*);/* called when fd is writeable after select() */ rsRetVal (*needUDPSocket)(void*);/* called when fd is writeable after select() */ - rsRetVal (*dbgPrintInstInfo)(struct filed*, void*);/* called before termination or module unload */ + rsRetVal (*dbgPrintInstInfo)(void*);/* called before termination or module unload */ rsRetVal (*modExit)(); /* called before termination or module unload */ /* below: parse a configuration line - return if processed * or not. If not, must be parsed to next module. @@ -79,8 +79,8 @@ typedef struct moduleInfo { struct {/* data for output modules */ /* below: perform the configured action */ - rsRetVal (*doAction)(selector_t*, uchar**, unsigned, void*); - rsRetVal (*parseSelectorAct)(uchar**, selector_t*, void**,omodStringRequest_t**); + rsRetVal (*doAction)(uchar**, unsigned, void*); + rsRetVal (*parseSelectorAct)(uchar**, void**,omodStringRequest_t**); } om; } mod; } modInfo_t; @@ -444,12 +444,11 @@ static int prepareDynFile(instanceData *pData, uchar *newFileName, unsigned iMsg * will be called for all outputs using file semantics, * for example also for pipes. */ -static rsRetVal writeFile(selector_t *f, uchar **ppString, unsigned iMsgOpts, instanceData *pData) +static rsRetVal writeFile(uchar **ppString, unsigned iMsgOpts, instanceData *pData) { off_t actualFileSize; rsRetVal iRet = RS_RET_OK; - assert(f != NULL); assert(pData != NULL); /* first check if we have a dynamic file name and, if so, @@ -575,7 +574,7 @@ CODESTARTdoAction * all others are doomed. */ if(pData->bDynamicName || (pData->fd != -1)) - iRet = writeFile(f, ppString, iMsgOpts, pData); + iRet = writeFile(ppString, iMsgOpts, pData); ENDdoAction @@ -279,7 +279,7 @@ static int TCPSendCreateSocket(instanceData *pData, struct addrinfo *addrDest) * octet-counting, only this framing mode is used within the session. * rgerhards, 2006-12-07 */ -static int TCPSend(selector_t *f, instanceData *pData, char *msg, size_t len) +static int TCPSend(instanceData *pData, char *msg, size_t len) { int retry = 0; int done = 0; @@ -290,7 +290,6 @@ static int TCPSend(selector_t *f, instanceData *pData, char *msg, size_t len) TCPFRAMINGMODE framingToUse; assert(pData != NULL); - assert(f != NULL); assert(msg != NULL); assert(len > 0); @@ -598,7 +597,15 @@ CODESTARTdoAction f_forw: dprintf(" %s:%s/%s\n", pData->f_hname, getFwdSyslogPt(pData), pData->protocol == FORW_UDP ? "udp" : "tcp"); - if ( strcmp(getHOSTNAME(f->f_pMsg), LocalHostName) && NoHops ) + if ( 0) // TODO: think about this strcmp(getHOSTNAME(f->f_pMsg), LocalHostName) && NoHops ) + /* what we need to do is get the hostname as an additonal string (during parseSe..). Then, + * we can compare that string to LocalHostName. That way, we do not need to access the + * msgobject, and everything is clean. The question remains, though, if that functionality + * here actually makes sense or not. If we really need it, it might make more sense to compare + * the target IP address to the IP addresses of the local machene - that is a far better way of + * handling things than to relay on the error-prone hostname property. + * rgerhards, 2007-07-27 + */ dprintf("Not sending message to remote.\n"); else { pData->ttSuspend = time(NULL); @@ -681,7 +688,7 @@ CODESTARTdoAction } } else { /* forward via TCP */ - if(TCPSend(f, pData, psz, l) != 0) { + if(TCPSend(pData, psz, l) != 0) { /* error! */ pData->eDestState = eDestFORW_SUSP; errno = 0; @@ -882,7 +889,7 @@ CODESTARTonSelectReadyWrite TCPSendSetStatus(pData, TCP_SEND_READY); /* Send stored message (if any) */ if(pData->savedMsg != NULL) { - if(TCPSend(f, pData, pData->savedMsg, + if(TCPSend(pData, pData->savedMsg, pData->savedMsgLen) != 0) { /* error! */ pData->eDestState = eDestFORW_SUSP; @@ -286,11 +286,10 @@ static rsRetVal reInitMySQL(instanceData *pData) * to an established MySQL session. * Initially added 2004-10-28 mmeckelein */ -rsRetVal writeMySQL(register selector_t *f, uchar *psz, instanceData *pData) +rsRetVal writeMySQL(uchar *psz, instanceData *pData) { int iCounter=0; rsRetVal iRet = RS_RET_OK; - assert(f != NULL); assert(pData != NULL); if((iRet = checkDBErrorState(pData)) != RS_RET_OK) @@ -321,7 +320,7 @@ rsRetVal writeMySQL(register selector_t *f, uchar *psz, instanceData *pData) BEGINdoAction CODESTARTdoAction dprintf("\n"); - iRet = writeMySQL(f, ppString[0], pData); + iRet = writeMySQL(ppString[0], pData); ENDdoAction @@ -64,7 +64,6 @@ ENDisCompatibleWithFeature BEGINfreeInstance CODESTARTfreeInstance - /* TODO: free the instance pointer (currently a leak, will go away) */ ENDfreeInstance @@ -147,7 +147,7 @@ void endutent(void) * Adjust the size of a variable to prevent a buffer overflow * should _PATH_DEV ever contain something different than "/dev/". */ -static void wallmsg(selector_t *f, uchar* pMsg, instanceData *pData) +static void wallmsg(uchar* pMsg, instanceData *pData) { char p[sizeof(_PATH_DEV) + UNAMESZ]; @@ -157,7 +157,6 @@ static void wallmsg(selector_t *f, uchar* pMsg, instanceData *pData) struct utmp ut; struct utmp *uptr; - assert(f != NULL); assert(pMsg != NULL); if (reenter++) @@ -247,7 +246,7 @@ BEGINdoAction CODESTARTdoAction dprintf("\n"); /* TODO: change wallmsg so that it returns iRet */ - wallmsg(f, ppString[0], pData); + wallmsg(ppString[0], pData); ENDdoAction @@ -3112,7 +3112,7 @@ rsRetVal fprintlog(register selector_t *f) goto finalize_it; } } - iRet = f->pMod->mod.om.doAction(f, f->ppMsgs, f->f_pMsg->msgFlags, f->pModData); /* call configured action */ + iRet = f->pMod->mod.om.doAction(f->ppMsgs, f->f_pMsg->msgFlags, f->pModData); /* call configured action */ if(iRet == RS_RET_DISABLE_ACTION) f->bEnabled = 0; /* that's it... */ @@ -3907,7 +3907,7 @@ static void freeSelectors(void) } /* free the action instances */ - f->pMod->freeInstance(f, f->pModData); + f->pMod->freeInstance(f->pModData); if(f->f_pMsg != NULL) MsgDestruct(f->f_pMsg); @@ -4204,7 +4204,7 @@ static void init() printf("\tAction...: "); } printf("%s: ", modGetStateName(f->pMod)); - f->pMod->dbgPrintInstInfo(f, f->pModData); + f->pMod->dbgPrintInstInfo(f->pModData); printf("\tinstance data: 0x%x\n", (unsigned) f->pModData); if(f->f_ReduceRepeated) printf(" [RepeatedMsgReduction]"); @@ -4868,7 +4868,7 @@ static rsRetVal cfline(char *line, register selector_t *f) /* loop through all modules and see if one picks up the line */ pMod = omodGetNxt(NULL); while(pMod != NULL) { - iRet = pMod->mod.om.parseSelectorAct(&p , f, &pModData, &pOMSR); + iRet = pMod->mod.om.parseSelectorAct(&p, &pModData, &pOMSR); dprintf("trying selector action for %s: %d\n", modGetName(pMod), iRet); if(iRet == RS_RET_OK) { addAction(f, pMod, pModData, pOMSR); @@ -5167,7 +5167,7 @@ static void mainloop(void) short fdMod; FD_ZERO(&writefds); for (f = Files; f != NULL ; f = f->f_next) { - if(f->pMod->getWriteFDForSelect(f, f->pModData, &fdMod) == RS_RET_OK) { + if(f->pMod->getWriteFDForSelect(f->pModData, &fdMod) == RS_RET_OK) { FD_SET(fdMod, &writefds); if(fdMod > maxfds) maxfds = fdMod; @@ -5281,9 +5281,9 @@ static void mainloop(void) short fdMod; rsRetVal iRet; for (f = Files; f != NULL ; f = f->f_next) { - if(f->pMod->getWriteFDForSelect(f, f->pModData, &fdMod) == RS_RET_OK) { + if(f->pMod->getWriteFDForSelect(f->pModData, &fdMod) == RS_RET_OK) { if(FD_ISSET(fdMod, &writefds)) { - if((iRet = f->pMod->onSelectReadyWrite(f, f->pModData)) != RS_RET_OK) { + if((iRet = f->pMod->onSelectReadyWrite(f->pModData)) != RS_RET_OK) { dprintf("error %d from onSelectReadyWrite() - continuing\n", iRet); } } |