summaryrefslogtreecommitdiffstats
path: root/msg.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2008-02-25 13:27:10 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2008-02-25 13:27:10 +0000
commit5ebc0db1a6d4c75ce9c26449ef2a2e3d7b340e10 (patch)
treed9f34f80e487d70da9c764f7c050086eceaff5bf /msg.c
parenta24cee11b718603fbc681e4a7a23f50c8d785ad7 (diff)
downloadrsyslog-5ebc0db1a6d4c75ce9c26449ef2a2e3d7b340e10.tar.gz
rsyslog-5ebc0db1a6d4c75ce9c26449ef2a2e3d7b340e10.tar.xz
rsyslog-5ebc0db1a6d4c75ce9c26449ef2a2e3d7b340e10.zip
- added PUSHMSGVAR operation
- included expression support in filter module (and it works ;))
Diffstat (limited to 'msg.c')
-rw-r--r--msg.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/msg.c b/msg.c
index 5a271580..b2ea1870 100644
--- a/msg.c
+++ b/msg.c
@@ -41,8 +41,11 @@
#include "stringbuf.h"
#include "template.h"
#include "msg.h"
+#include "var.h"
+/* static data */
DEFobjStaticHelpers
+DEFobjCurrIf(var)
static syslogCODE rs_prioritynames[] =
{
@@ -2074,6 +2077,46 @@ char *MsgGetProp(msg_t *pMsg, struct templateEntry *pTpe,
}
+/* The returns a message variable suitable for use with RainerScript. Most importantly, this means
+ * that the value is returned in a var_t object. The var_t is constructed inside this function and
+ * MUST be freed by the caller.
+ * rgerhards, 2008-02-25
+ */
+rsRetVal
+msgGetMsgVar(msg_t *pThis, cstr_t *pstrPropName, var_t **ppVar)
+{
+ DEFiRet;
+ var_t *pVar;
+ uchar *pszProp = NULL;
+ cstr_t *pstrProp;
+ unsigned short bMustBeFreed = 0;
+
+ ISOBJ_TYPE_assert(pThis, msg);
+ ASSERT(pstrPropName != NULL);
+ ASSERT(ppVar != NULL);
+
+ /* make sure we have a var_t instance */
+ CHKiRet(var.Construct(&pVar));
+ CHKiRet(var.ConstructFinalize(pVar));
+
+ /* always call MsgGetProp() without a template specifier */
+ pszProp = (uchar*) MsgGetProp(pThis, NULL, pstrPropName, &bMustBeFreed);
+
+ /* now create a string object out of it and hand that over to the var */
+ CHKiRet(rsCStrConstructFromszStr(&pstrProp, pszProp));
+ CHKiRet(var.SetString(pVar, pstrProp));
+
+ /* finally store var */
+ *ppVar = pVar;
+
+finalize_it:
+ if(bMustBeFreed)
+ free(pszProp);
+
+ RETiRet;
+}
+
+
/* This function can be used as a generic way to set properties.
* We have to handle a lot of legacy, so our return value is not always
* 100% correct (called functions do not always provide one, should
@@ -2158,6 +2201,10 @@ MsgGetSeverity(obj_t *pThis, int *piSeverity)
* rgerhards, 2008-01-04
*/
BEGINObjClassInit(msg, 1)
+ /* request objects we use */
+ CHKiRet(objUse(var));
+
+ /* set our own handlers */
OBJSetMethodHandler(objMethod_SERIALIZE, MsgSerialize);
OBJSetMethodHandler(objMethod_SETPROPERTY, MsgSetProperty);
OBJSetMethodHandler(objMethod_CONSTRUCTION_FINALIZER, msgConstructFinalizer);