summaryrefslogtreecommitdiffstats
path: root/ommysql.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2007-07-25 10:25:38 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2007-07-25 10:25:38 +0000
commit4c69b80ca0366db28bbbb46ddd03dfbc9d85b09c (patch)
tree09bdad5c352f1635ddeaa9d550d6330a0435f321 /ommysql.c
parentc8eca687f4f0ee08d927e72da1289ffc9d8ff01c (diff)
downloadrsyslog-4c69b80ca0366db28bbbb46ddd03dfbc9d85b09c.tar.gz
rsyslog-4c69b80ca0366db28bbbb46ddd03dfbc9d85b09c.tar.xz
rsyslog-4c69b80ca0366db28bbbb46ddd03dfbc9d85b09c.zip
changed output modules to use a template-based code generation system for
standard entry points (implemented via preprocessor)
Diffstat (limited to 'ommysql.c')
-rw-r--r--ommysql.c132
1 files changed, 51 insertions, 81 deletions
diff --git a/ommysql.c b/ommysql.c
index 509d5b39..dfa1a283 100644
--- a/ommysql.c
+++ b/ommysql.c
@@ -43,18 +43,37 @@
#include "ommysql.h"
#include "mysql/mysql.h"
#include "mysql/errmsg.h"
+#include "module-template.h"
-
-static rsRetVal reInitMySQL(register selector_t *f);
-/* query feature compatibility
+/* internal structures
*/
-static rsRetVal isCompatibleWithFeature(syslogFeature eFeat)
-{
+typedef struct _instanceData {
+} instanceData;
+
+
+BEGINcreateInstance
+CODESTARTcreateInstance
+ENDcreateInstance
+
+
+BEGINisCompatibleWithFeature
+CODESTARTisCompatibleWithFeature
if(eFeat == sFEATURERepeatedMsgReduction)
- return RS_RET_OK;
+ iRet = RS_RET_OK;
+ENDisCompatibleWithFeature
- return RS_RET_INCOMPATIBLE;
-}
+
+BEGINfreeInstance
+CODESTARTfreeInstance
+ switch (f->f_type) {
+# ifdef WITH_DB
+ closeMySQL(f);
+# endif
+ }
+ENDfreeInstance
+
+
+static rsRetVal reInitMySQL(register selector_t *f);
/**
@@ -270,33 +289,29 @@ rsRetVal writeMySQL(register selector_t *f)
return iRet;
}
-/* call the shell action
- */
-static rsRetVal doActionMySQL(selector_t *f)
-{
- assert(f != NULL);
+BEGINdoAction
+CODESTARTdoAction
dprintf("\n");
- return writeMySQL(f);
-}
+ iRet = writeMySQL(f);
+ENDdoAction
-/* try to process a selector action line. Checks if the action
- * applies to this module and, if so, processed it. If not, it
- * is left untouched. The driver will then call another module
- */
-static rsRetVal parseSelectorAct(uchar **pp, selector_t *f)
-{
+BEGINparseSelectorAct
uchar *p;
- rsRetVal iRet = RS_RET_CONFLINE_PROCESSED;
int iMySQLPropErr = 0;
char szTemplateName[128];
-
- assert(pp != NULL);
- assert(f != NULL);
-
+CODESTARTparseSelectorAct
p = *pp;
+ /* yes, the if below is redundant, but I need it now. Will go away as
+ * the code further changes. -- rgerhards, 2007-07-25
+ */
+ if(*p == '>') {
+ if((iRet = createInstance(&pModData)) != RS_RET_OK)
+ return iRet;
+ }
+
switch (*p)
{
case '>':
@@ -381,68 +396,23 @@ static rsRetVal parseSelectorAct(uchar **pp, selector_t *f)
break;
}
- if(iRet == RS_RET_OK)
- iRet = RS_RET_CONFLINE_PROCESSED;
-
- if(iRet == RS_RET_CONFLINE_PROCESSED)
+ if(iRet == RS_RET_OK) {
+ *ppModData = pModData;
*pp = p;
- return iRet;
-}
-
-
-/* free an instance
- */
-static rsRetVal freeInstance(selector_t *f)
-{
- assert(f != NULL);
- switch (f->f_type) {
-# ifdef WITH_DB
- closeMySQL(f);
-# endif
}
- return RS_RET_OK;
-}
+ENDparseSelectorAct
-/* query an entry point
- */
-static rsRetVal queryEtryPt(uchar *name, rsRetVal (**pEtryPoint)())
-{
- if((name == NULL) || (pEtryPoint == NULL))
- return RS_RET_PARAM_ERROR;
-
- *pEtryPoint = NULL;
- if(!strcmp((char*) name, "doAction")) {
- *pEtryPoint = doActionMySQL;
- } else if(!strcmp((char*) name, "parseSelectorAct")) {
- *pEtryPoint = parseSelectorAct;
- } else if(!strcmp((char*) name, "isCompatibleWithFeature")) {
- *pEtryPoint = isCompatibleWithFeature;
- } else if(!strcmp((char*) name, "freeInstance")) {
- *pEtryPoint = freeInstance;
- }
- return(*pEtryPoint == NULL) ? RS_RET_NOT_FOUND : RS_RET_OK;
-}
+BEGINqueryEtryPt
+CODESTARTqueryEtryPt
+CODEqueryEtryPt_STD_OMOD_QUERIES
+ENDqueryEtryPt
-/* initialize the module
- *
- * Later, much more must be done. So far, we only return a pointer
- * to the queryEtryPt() function
- * TODO: do interface version checking & handshaking
- * iIfVersRequeted is the version of the interface specification that the
- * caller would like to see being used. ipIFVersProvided is what we
- * decide to provide.
- */
-rsRetVal modInitMySQL(int iIFVersRequested __attribute__((unused)), int *ipIFVersProvided, rsRetVal (**pQueryEtryPt)())
-{
- if((pQueryEtryPt == NULL) || (ipIFVersProvided == NULL))
- return RS_RET_PARAM_ERROR;
+BEGINmodInit(MySQL)
+CODESTARTmodInit
*ipIFVersProvided = 1; /* so far, we only support the initial definition */
-
- *pQueryEtryPt = queryEtryPt;
- return RS_RET_OK;
-}
+ENDmodInit
#endif /* #ifdef WITH_DB */
/*