summaryrefslogtreecommitdiffstats
path: root/outchannel.c
diff options
context:
space:
mode:
Diffstat (limited to 'outchannel.c')
-rw-r--r--outchannel.c78
1 files changed, 50 insertions, 28 deletions
diff --git a/outchannel.c b/outchannel.c
index 0427a4a4..5c348b63 100644
--- a/outchannel.c
+++ b/outchannel.c
@@ -6,13 +6,28 @@
* Please see syslogd.c for license information.
* This code is placed under the GPL.
* begun 2005-06-21 rgerhards
+ *
+ * Copyright (C) 2005 by Rainer Gerhards and Adiscon GmbH
+ *
+ * This file is part of rsyslog.
+ *
+ * Rsyslog is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Rsyslog is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Rsyslog. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * A copy of the GPL can be found in the file "COPYING" in this distribution.
*/
#include "config.h"
-#ifdef __FreeBSD__
-#define BSD
-#endif
-
#include "rsyslog.h"
#include <stdio.h>
#include <unistd.h>
@@ -22,7 +37,7 @@
#include <assert.h>
#include "stringbuf.h"
#include "outchannel.h"
-#include "syslogd.h"
+#include "dirty.h"
static struct outchannel *ochRoot = NULL; /* the root of the outchannel list */
static struct outchannel *ochLast = NULL; /* points to the last element of the outchannel list */
@@ -76,12 +91,12 @@ static void skip_Comma(char **pp)
/* helper to ochAddLine. Parses a comma-delimited field
* The field is delimited by SP or comma. Leading whitespace
* is "eaten" and does not become part of the field content.
- * returns: 0 - ok, 1 - failure
*/
-static int get_Field(uchar **pp, uchar **pField)
+static rsRetVal get_Field(uchar **pp, uchar **pField)
{
+ DEFiRet;
register uchar *p;
- rsCStrObj *pStrB;
+ cstr_t *pStrB = NULL;
assert(pp != NULL);
assert(*pp != NULL);
@@ -90,21 +105,25 @@ static int get_Field(uchar **pp, uchar **pField)
skip_Comma((char**)pp);
p = *pp;
- if((pStrB = rsCStrConstruct()) == NULL)
- return 1;
+ CHKiRet(rsCStrConstruct(&pStrB));
rsCStrSetAllocIncrement(pStrB, 32);
/* copy the field */
while(*p && *p != ' ' && *p != ',') {
- rsCStrAppendChar(pStrB, *p++);
+ CHKiRet(rsCStrAppendChar(pStrB, *p++));
}
*pp = p;
- rsCStrFinish(pStrB);
- if(rsCStrConvSzStrAndDestruct(pStrB, pField, 0) != RS_RET_OK)
- return 1;
+ CHKiRet(rsCStrFinish(pStrB));
+ CHKiRet(rsCStrConvSzStrAndDestruct(pStrB, pField, 0));
- return 0;
+finalize_it:
+ if(iRet != RS_RET_OK) {
+ if(pStrB != NULL)
+ rsCStrDestruct(&pStrB);
+ }
+
+ RETiRet;
}
@@ -141,12 +160,12 @@ static int get_off_t(uchar **pp, off_t *pOff_t)
* current position to the end of line and returns it
* to the caller. Leading white space is removed, but
* not trailing.
- * returns: 0 - ok, 1 - failure
*/
-static inline int get_restOfLine(uchar **pp, uchar **pBuf)
+static inline rsRetVal get_restOfLine(uchar **pp, uchar **pBuf)
{
+ DEFiRet;
register uchar *p;
- rsCStrObj *pStrB;
+ cstr_t *pStrB = NULL;
assert(pp != NULL);
assert(*pp != NULL);
@@ -155,21 +174,25 @@ static inline int get_restOfLine(uchar **pp, uchar **pBuf)
skip_Comma((char**)pp);
p = *pp;
- if((pStrB = rsCStrConstruct()) == NULL)
- return 1;
+ CHKiRet(rsCStrConstruct(&pStrB));
rsCStrSetAllocIncrement(pStrB, 32);
/* copy the field */
while(*p) {
- rsCStrAppendChar(pStrB, *p++);
+ CHKiRet(rsCStrAppendChar(pStrB, *p++));
}
*pp = p;
- rsCStrFinish(pStrB);
- if(rsCStrConvSzStrAndDestruct(pStrB, pBuf, 0) != RS_RET_OK)
- return 1;
+ CHKiRet(rsCStrFinish(pStrB));
+ CHKiRet(rsCStrConvSzStrAndDestruct(pStrB, pBuf, 0));
- return 0;
+finalize_it:
+ if(iRet != RS_RET_OK) {
+ if(pStrB != NULL)
+ rsCStrDestruct(&pStrB);
+ }
+
+ RETiRet;
}
@@ -271,11 +294,10 @@ void ochPrintList(void)
while(pOch != NULL) {
dbgprintf("Outchannel: Name='%s'\n", pOch->pszName == NULL? "NULL" : pOch->pszName);
dbgprintf("\tFile Template: '%s'\n", pOch->pszFileTemplate == NULL ? "NULL" : (char*) pOch->pszFileTemplate);
- dbgprintf("\tMax Size.....: %lu\n", pOch->uSizeLimit);
+ dbgprintf("\tMax Size.....: %lu\n", (long unsigned) pOch->uSizeLimit);
dbgprintf("\tOnSizeLimtCmd: '%s'\n", pOch->cmdOnSizeLimit == NULL ? "NULL" : (char*) pOch->cmdOnSizeLimit);
pOch = pOch->pNext; /* done, go next */
}
}
-/*
- * vi:set ai:
+/* vi:set ai:
*/