summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cfsysline.c62
-rw-r--r--cfsysline.h2
-rw-r--r--syslogd.c24
3 files changed, 39 insertions, 49 deletions
diff --git a/cfsysline.c b/cfsysline.c
index aa0866b7..8d063b66 100644
--- a/cfsysline.c
+++ b/cfsysline.c
@@ -43,6 +43,43 @@ cslCmd_t *pCmdListLast = NULL;
/* --------------- START functions for handling canned syntaxes --------------- */
+
+/* parse a character from the config line
+ * added 2007-07-17 by rgerhards
+ * TODO: enhance this function to handle different classes of characters
+ * HINT: check if char is ' and, if so, use 'c' where c may also be things
+ * like \t etc.
+ */
+//static void doControlCharEscPrefix(uchar **pp)
+rsRetVal doGetChar(uchar **pp, rsRetVal (*pSetHdlr)(void*, uid_t), void *pVal)
+{
+ rsRetVal iRet = RS_RET_OK;
+
+ assert(pp != NULL);
+ assert(*pp != NULL);
+
+ skipWhiteSpace(pp); /* skip over any whitespace */
+
+ /* if we are not at a '\0', we have our new char - no validity checks here... */
+ if(**pp == '\0') {
+ logerror("No character available");
+ iRet = RS_RET_NOT_FOUND;
+ } else {
+ if(pSetHdlr == NULL) {
+ /* we should set value directly to var */
+ *((uchar*)pVal) = **pp;
+ } else {
+ /* we set value via a set function */
+ CHKiRet(pSetHdlr(pVal, **pp));
+ }
+ ++(*pp); /* eat processed char */
+ }
+
+finalize_it:
+ return iRet;
+}
+
+
/* Parse and interpet a $FileCreateMode and $umask line. This function
* pulls the creation mode and, if successful, stores it
* into the global variable so that the rest of rsyslogd
@@ -97,31 +134,6 @@ rsRetVal doFileCreateMode(uchar **pp, rsRetVal (*pSetHdlr)(void*, uid_t), void *
CHKiRet(pSetHdlr(pVal, iVal));
}
-#if 0
- switch(eDir) {
- case DIR_DIRCREATEMODE:
- fDirCreateMode = iMode;
- dprintf("DirCreateMode set to 0%o.\n", iMode);
- break;
- case DIR_FILECREATEMODE:
- fCreateMode = iMode;
- dprintf("FileCreateMode set to 0%o.\n", iMode);
- break;
- case DIR_UMASK:
- umask(iMode);
- dprintf("umask set to 0%3.3o.\n", iMode);
- break;
- default:/* we do this to avoid compiler warning - not all
- * enum values call this function, so an incomplete list
- * is quite ok (but then we should not run into this code,
- * so at least we log a debug warning).
- */
- dprintf("INTERNAL ERROR: doFileCreateModeUmaskLine() called with invalid eDir %d.\n",
- eDir);
- break;
- }
-#endif
-
p += 4; /* eat the octal number */
*pp = p;
diff --git a/cfsysline.h b/cfsysline.h
index bc1fd71f..f03419db 100644
--- a/cfsysline.h
+++ b/cfsysline.h
@@ -69,7 +69,7 @@ rsRetVal cslchCallHdlr(cslCmdHdlr_t *pThis, uchar **ppConfLine);
rsRetVal doBinaryOptionLine(uchar **pp, rsRetVal (*pSetHdlr)(void*, int), void *pVal);
rsRetVal doGetUID(uchar **pp, rsRetVal (*pSetHdlr)(void*, uid_t), void *pVal);
rsRetVal doGetGID(uchar **pp, rsRetVal (*pSetHdlr)(void*, uid_t), void *pVal);
-//void doFileCreateModeUmaskLine(uchar **pp, enum eDirective eDir);
rsRetVal doFileCreateMode(uchar **pp, rsRetVal (*pSetHdlr)(void*, uid_t), void *pVal);
+rsRetVal doGetChar(uchar **pp, rsRetVal (*pSetHdlr)(void*, uid_t), void *pVal);
#endif /* #ifndef CFSYSLINE_H_INCLUDED */
diff --git a/syslogd.c b/syslogd.c
index 65528ea6..6865a026 100644
--- a/syslogd.c
+++ b/syslogd.c
@@ -3511,28 +3511,6 @@ static void doModLoad(uchar **pp)
skipWhiteSpace(pp); /* skip over any whitespace */
}
-
-/* parse the control character escape prefix and store it.
- * added 2007-07-17 by rgerhards
- */
-static void doControlCharEscPrefix(uchar **pp)
-{
- assert(pp != NULL);
- assert(*pp != NULL);
-
- skipWhiteSpace(pp); /* skip over any whitespace */
-
- /* if we are not at a '\0', we have our new char - no validity checks here... */
- if(**pp == '\0') {
- logerror("No Control Character Prefix Character given - ignoring directive");
- } else {
- cCCEscapeChar = **pp;
- ++(*pp); /* eat processed char */
- }
-
- skipWhiteSpace(pp); /* skip over any whitespace */
-}
-
/* parse and interpret a $-config line that starts with
* a name (this is common code). It is parsed to the name
* and then the proper sub-function is called to handle
@@ -3647,7 +3625,7 @@ void cfsysline(uchar *p)
} else if(!strcasecmp((char*) szCmd, "repeatedmsgreduction")) {
doBinaryOptionLine(&p, NULL, &bReduceRepeatMsgs);
} else if(!strcasecmp((char*) szCmd, "controlcharacterescapeprefix")) {
- doControlCharEscPrefix(&p);
+ doGetChar(&p, NULL, &cCCEscapeChar);
} else if(!strcasecmp((char*) szCmd, "escapecontrolcharactersonreceive")) {
doBinaryOptionLine(&p, NULL, &bEscapeCCOnRcv);
} else if(!strcasecmp((char*) szCmd, "dropmsgswithmaliciousdnsptrrecords")) {