summaryrefslogtreecommitdiffstats
path: root/template.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2011-03-31 16:30:13 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2011-03-31 16:30:13 +0200
commit945bc9bd0d9de984ab11b9faf609b809a1f3cb90 (patch)
treef3464946b2eef29b2f8a4e54c32f7bf063a2c27f /template.c
parentf057fb2db388cc16475f9c5a7de64aeb1f3bdb43 (diff)
parenteccfbf71f9dbc235309c2ad40035d41620f5e5df (diff)
downloadrsyslog-945bc9bd0d9de984ab11b9faf609b809a1f3cb90.zip
rsyslog-945bc9bd0d9de984ab11b9faf609b809a1f3cb90.tar.gz
rsyslog-945bc9bd0d9de984ab11b9faf609b809a1f3cb90.tar.xz
Merge branch 'v5-beta' into v5-devel
Conflicts: ChangeLog
Diffstat (limited to 'template.c')
-rw-r--r--template.c41
1 files changed, 32 insertions, 9 deletions
diff --git a/template.c b/template.c
index 5aaf1bc..2038c6c 100644
--- a/template.c
+++ b/template.c
@@ -42,10 +42,13 @@
/* static data */
DEFobjCurrIf(obj)
DEFobjCurrIf(errmsg)
-DEFobjCurrIf(regexp)
DEFobjCurrIf(strgen)
+#ifdef FEATURE_REGEXP
+DEFobjCurrIf(regexp)
static int bFirstRegexpErrmsg = 1; /**< did we already do a "can't load regexp" error message? */
+#endif
+
static struct template *tplRoot = NULL; /* the root of the template list */
static struct template *tplLast = NULL; /* points to the last element of the template list */
static struct template *tplLastStatic = NULL; /* last static element of the template list */
@@ -549,10 +552,9 @@ static int do_Parameter(unsigned char **pp, struct template *pTpl)
cstr_t *pStrB;
struct templateEntry *pTpe;
int iNum; /* to compute numbers */
- rsRetVal iRetLocal;
-
#ifdef FEATURE_REGEXP
/* APR: variables for regex */
+ rsRetVal iRetLocal;
int longitud;
unsigned char *regex_char;
unsigned char *regex_end;
@@ -856,19 +858,37 @@ tplAddTplMod(struct template *pTpl, uchar** ppRestOfConfLine)
{
uchar *pSrc, *pDst;
uchar szMod[2048];
+ unsigned lenMod;
strgen_t *pStrgen;
DEFiRet;
pSrc = *ppRestOfConfLine;
pDst = szMod;
- while(*pSrc && !isspace(*pSrc) && pDst < &(szMod[sizeof(szMod) - 1])) {
- *pDst++ = *pSrc++;
+ lenMod = 0;
+ while(*pSrc && !isspace(*pSrc) && lenMod < sizeof(szMod) - 1) {
+ szMod[lenMod] = *pSrc++;
+ lenMod++;
+
}
- *pDst = '\0';
+ szMod[lenMod] = '\0';
*ppRestOfConfLine = pSrc;
CHKiRet(strgen.FindStrgen(&pStrgen, szMod));
pTpl->pStrgen = pStrgen->pModule->mod.sm.strgen;
- dbgprintf("template bound to strgen '%s'\n", szMod);
+ DBGPRINTF("template bound to strgen '%s'\n", szMod);
+ /* check if the name potentially contains some well-known options
+ * Note: we have opted to let the name contain all options. This sounds
+ * useful, because the strgen MUST actually implement a specific set
+ * of options. Doing this via the name looks to the enduser as if the
+ * regular syntax were used, and it make sure the strgen postively
+ * acknowledged implementing the option. -- rgerhards, 2011-03-21
+ */
+ if(lenMod > 6 && !strcasecmp((char*) szMod + lenMod - 7, ",stdsql")) {
+ pTpl->optFormatForSQL = 2;
+ DBGPRINTF("strgen suports the stdsql option\n");
+ } else if(lenMod > 3 && !strcasecmp((char*) szMod+ lenMod - 4, ",sql")) {
+ pTpl->optFormatForSQL = 1;
+ DBGPRINTF("strgen suports the sql option\n");
+ }
finalize_it:
RETiRet;
@@ -936,8 +956,7 @@ struct template *tplAddLine(char* pName, uchar** ppRestOfConfLine)
/* we simply make the template defunct in this case by setting
* its name to a zero-string. We do not free it, as this would
* require additional code and causes only a very small memory
- * consumption. Memory is freed, however, in normal operation
- * and most importantly by HUPing syslogd.
+ * consumption.
*/
*pTpl->pszName = '\0';
return NULL;
@@ -1067,11 +1086,13 @@ void tplDeleteAll(void)
break;
case FIELD:
/* check if we have a regexp and, if so, delete it */
+#ifdef FEATURE_REGEXP
if(pTpeDel->data.field.has_regex != 0) {
if(objUse(regexp, LM_REGEXP_FILENAME) == RS_RET_OK) {
regexp.regfree(&(pTpeDel->data.field.re));
}
}
+#endif
break;
}
/*dbgprintf("\n");*/
@@ -1120,12 +1141,14 @@ void tplDeleteNew(void)
free(pTpeDel->data.constant.pConstant);
break;
case FIELD:
+#ifdef FEATURE_REGEXP
/* check if we have a regexp and, if so, delete it */
if(pTpeDel->data.field.has_regex != 0) {
if(objUse(regexp, LM_REGEXP_FILENAME) == RS_RET_OK) {
regexp.regfree(&(pTpeDel->data.field.re));
}
}
+#endif
break;
}
/*dbgprintf("\n");*/