summaryrefslogtreecommitdiffstats
path: root/syslogd.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2005-09-15 10:33:47 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2005-09-15 10:33:47 +0000
commitcaf76db7c08183bc23167687702cb8652c254337 (patch)
tree281794d7358fa1c53ee11a104a67f600fbb00ff9 /syslogd.c
parentf820d0ac236f6953e7bd5d115775a8751837ef4f (diff)
downloadrsyslog-caf76db7c08183bc23167687702cb8652c254337.tar.gz
rsyslog-caf76db7c08183bc23167687702cb8652c254337.tar.xz
rsyslog-caf76db7c08183bc23167687702cb8652c254337.zip
prepared for new parse object; now removed allmost all liblogging borrowed
code
Diffstat (limited to 'syslogd.c')
-rw-r--r--syslogd.c122
1 files changed, 63 insertions, 59 deletions
diff --git a/syslogd.c b/syslogd.c
index 4cdefd03..2118ae15 100644
--- a/syslogd.c
+++ b/syslogd.c
@@ -181,10 +181,7 @@
#include "outchannel.h"
#include "syslogd.h"
-/* from liblogging */
-#include "liblogging-stub.h"
#include "stringbuf.h"
-/* end liblogging */
#ifdef WITH_DB
#define _DB_MAXDBLEN 128 /* maximum number of db */
@@ -2004,20 +2001,23 @@ int MsgSetRawMsg(struct msg *pMsg, char* pszRawMsg)
* rgerhards 2004-11-23
* regular expression support contributed by Andres Riancho merged
* on 2005-09-13
+ * changed so that it now an be called without a template entry (NULL).
+ * In this case, only the (unmodified) property is returned. This will
+ * be used in selector line processing.
+ * rgerhards 2005-09-15
*/
char *MsgGetProp(struct msg *pMsg, struct templateEntry *pTpe, unsigned short *pbMustBeFreed)
{
char *pName;
char *pRes; /* result pointer */
-
-#ifdef FEATURE_REGEXP
- /* Variables necessary for regular expression matching */
- size_t nmatch = 2;
- regmatch_t pmatch[2];
+
+#ifdef FEATURE_REGEXP
+ /* Variables necessary for regular expression matching */
+ size_t nmatch = 2;
+ regmatch_t pmatch[2];
#endif
assert(pMsg != NULL);
- assert(pTpe != NULL);
assert(pbMustBeFreed != NULL);
pName = pTpe->data.field.pPropRepl;
@@ -2054,6 +2054,12 @@ char *MsgGetProp(struct msg *pMsg, struct templateEntry *pTpe, unsigned short *p
} else {
pRes = "**INVALID PROPERTY NAME**";
}
+
+ /* If we did not receive a template pointer, we are already done... */
+ if(pTpe == NULL) {
+ *pbMustBeFreed = 0;
+ return pRes;
+ }
/* Now check if we need to make "temporary" transformations (these
* are transformations that do not go back into the message -
@@ -2103,54 +2109,52 @@ char *MsgGetProp(struct msg *pMsg, struct templateEntry *pTpe, unsigned short *p
free(pRes);
pRes = pBufStart;
*pbMustBeFreed = 1;
- #ifdef FEATURE_REGEXP
- } else {
- /* Check for regular expressions */
- if (pTpe->data.field.has_regex != 0) {
- if (pTpe->data.field.has_regex == 2)
- /* Could not compile regex before! */
- return
- "**NO MATCH** **BAD REGULAR EXPRESSION**";
-
- dprintf
- ("debug: String to match for regex is: %s\n",
- pRes);
-
- if (0 !=
- regexec(&pTpe->data.field.re, pRes, nmatch,
- pmatch, 0)) {
- /* we got no match! */
- return "**NO MATCH**";
- } else {
- /* Match! */
- /* I need to malloc pBuf */
- int iLen;
- char *pBuf;
-
- iLen = pmatch[1].rm_eo - pmatch[1].rm_so;
- pBuf = (char *) malloc((iLen + 1) * sizeof(char));
-
- if (pBuf == NULL) {
- if (*pbMustBeFreed == 1)
- free(pRes);
- *pbMustBeFreed = 0;
- return
- "**OUT OF MEMORY ALLOCATING pBuf**";
- }
- *pBuf = '\0';
-
- /* Lets copy the matched substring to the buffer */
- /* TODO: RGer: I think we can use memcpy() here, too (faster) */
- strncpy(pBuf, pRes + pmatch[1].rm_so,
- iLen);
- pBuf[iLen] = '\0'; /* Null termination of string */
-
- if (*pbMustBeFreed == 1)
- free(pRes);
- pRes = pBuf;
- *pbMustBeFreed = 1;
- }
- }
+#ifdef FEATURE_REGEXP
+ } else {
+ /* Check for regular expressions */
+ if (pTpe->data.field.has_regex != 0) {
+ if (pTpe->data.field.has_regex == 2)
+ /* Could not compile regex before! */
+ return
+ "**NO MATCH** **BAD REGULAR EXPRESSION**";
+
+ dprintf("debug: String to match for regex is: %s\n",
+ pRes);
+
+ if (0 != regexec(&pTpe->data.field.re, pRes, nmatch,
+ pmatch, 0)) {
+ /* we got no match! */
+ return "**NO MATCH**";
+ } else {
+ /* Match! */
+ /* I need to malloc pBuf */
+ int iLen;
+ char *pBuf;
+
+ iLen = pmatch[1].rm_eo - pmatch[1].rm_so;
+ pBuf = (char *) malloc((iLen + 1) * sizeof(char));
+
+ if (pBuf == NULL) {
+ if (*pbMustBeFreed == 1)
+ free(pRes);
+ *pbMustBeFreed = 0;
+ return
+ "**OUT OF MEMORY ALLOCATING pBuf**";
+ }
+ *pBuf = '\0';
+
+ /* Lets copy the matched substring to the buffer */
+ /* TODO: RGer: I think we can use memcpy() here, too (faster) */
+ strncpy(pBuf, pRes + pmatch[1].rm_so,
+ iLen);
+ pBuf[iLen] = '\0'; /* Null termination of string */
+
+ if (*pbMustBeFreed == 1)
+ free(pRes);
+ pRes = pBuf;
+ *pbMustBeFreed = 1;
+ }
+ }
#endif /* #ifdef FEATURE_REGEXP */
}
@@ -3518,7 +3522,7 @@ void doSQLEscape(char **pp, size_t *pLen, unsigned short *pbMustBeFreed)
while(*p) {
if(*p == '\'') {
- if(rsCStrAppendChar(pStrB, '\'') != SR_RET_OK) {
+ if(rsCStrAppendChar(pStrB, '\'') != RS_RET_OK) {
doSQLEmergencyEscape(*pp);
rsCStrFinish(pStrB);
if((pszGenerated = rsCStrConvSzStrAndDestruct(pStrB))
@@ -3528,7 +3532,7 @@ void doSQLEscape(char **pp, size_t *pLen, unsigned short *pbMustBeFreed)
iLen++; /* reflect the extra character */
}
}
- if(rsCStrAppendChar(pStrB, *p) != SR_RET_OK) {
+ if(rsCStrAppendChar(pStrB, *p) != RS_RET_OK) {
doSQLEmergencyEscape(*pp);
rsCStrFinish(pStrB);
if((pszGenerated = rsCStrConvSzStrAndDestruct(pStrB))