summaryrefslogtreecommitdiffstats
path: root/runtime/msg.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2010-12-01 11:35:04 +0100
committerRainer Gerhards <rgerhards@adiscon.com>2010-12-01 11:35:04 +0100
commitb030fe7b1f8fb26dad24ce23243f11603b5c9d4e (patch)
tree9172220b8fa3a44ad5edf17d5bd501061dd7abb4 /runtime/msg.c
parent471f07f45a382c29f74e1c676bd081c3b304d7db (diff)
downloadrsyslog-b030fe7b1f8fb26dad24ce23243f11603b5c9d4e.tar.gz
rsyslog-b030fe7b1f8fb26dad24ce23243f11603b5c9d4e.tar.xz
rsyslog-b030fe7b1f8fb26dad24ce23243f11603b5c9d4e.zip
milestone: ability to use normalized names in templates
Diffstat (limited to 'runtime/msg.c')
-rw-r--r--runtime/msg.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/runtime/msg.c b/runtime/msg.c
index 479b2ba3..7299b5bf 100644
--- a/runtime/msg.c
+++ b/runtime/msg.c
@@ -2227,6 +2227,40 @@ static uchar *getNOW(eNOWType eNow)
#undef tmpBUFSIZE /* clean up */
+/* Get a CEE-Property from libee. This function probably should be
+ * placed somewhere else, but this smells like a big restructuring
+ * useful in any case. So for the time being, I'll simply leave the
+ * function here, as the context seems good enough. -- rgerhards, 2010-12-01
+ */
+static inline void
+getCEEPropVal(msg_t *pMsg, struct templateEntry *pTpe, uchar **pRes, unsigned short *pbMustBeFreed)
+{
+ struct ee_field *field;
+ es_str_t *str;
+
+ if(*pbMustBeFreed)
+ free(*pRes);
+ *pRes = NULL;
+
+ if(pMsg->event == NULL) goto finalize_it;
+ if((field = ee_getEventField(pMsg->event, pTpe->data.field.propName)) == NULL)
+ goto finalize_it;
+ /* right now, we always extract data from the first field value. A reason for this
+ * is that as of now (2010-12-01) liblognorm never populates more than one ;)
+ */
+ if((str = ee_getFieldValueAsStr(field, 0)) == NULL) goto finalize_it;
+ *pRes = (unsigned char*) es_str2cstr(str, "#000");
+ es_deleteStr(str);
+ *pbMustBeFreed = 1;
+
+finalize_it:
+ if(*pRes == NULL) {
+ /* could not find any value, so set it to empty */
+ *pRes = (unsigned char*)"";
+ *pbMustBeFreed = 0;
+ }
+}
+
/* This function returns a string-representation of the
* requested message property. This is a generic function used
* to abstract properties so that these can be easier
@@ -2432,6 +2466,9 @@ uchar *MsgGetProp(msg_t *pMsg, struct templateEntry *pTpe,
es_deleteStr(str);
*pbMustBeFreed = 1; /* all of these functions allocate dyn. memory */
break;
+ case PROP_CEE:
+ getCEEPropVal(pMsg, pTpe, &pRes, pbMustBeFreed);
+ break;
default:
/* there is no point in continuing, we may even otherwise render the
* error message unreadable. rgerhards, 2007-07-10