summaryrefslogtreecommitdiffstats
path: root/plugins/ompgsql
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/ompgsql')
-rw-r--r--plugins/ompgsql/Makefile.am4
-rw-r--r--plugins/ompgsql/ompgsql.c47
-rw-r--r--plugins/ompgsql/ompgsql.h15
3 files changed, 29 insertions, 37 deletions
diff --git a/plugins/ompgsql/Makefile.am b/plugins/ompgsql/Makefile.am
index 5206b36d..b2e3effa 100644
--- a/plugins/ompgsql/Makefile.am
+++ b/plugins/ompgsql/Makefile.am
@@ -1,7 +1,7 @@
pkglib_LTLIBRARIES = ompgsql.la
-ompgsql_la_SOURCES = ompgsql.c ompgsql.h ../../module-template.h
-ompgsql_la_CPPFLAGS = $(pgsql_cflags) -I$(srcdir)/../..
+ompgsql_la_SOURCES = ompgsql.c ompgsql.h
+ompgsql_la_CPPFLAGS = -I$(top_srcdir) $(pgsql_cflags)
ompgsql_la_LDFLAGS = -module -avoid-version
ompgsql_la_LIBADD = $(pgsql_libs)
diff --git a/plugins/ompgsql/ompgsql.c b/plugins/ompgsql/ompgsql.c
index 937539b9..8aaca53e 100644
--- a/plugins/ompgsql/ompgsql.c
+++ b/plugins/ompgsql/ompgsql.c
@@ -12,19 +12,20 @@
* when setting up a test environment (on Fedora):
* http://www.jboss.org/community/wiki/InstallPostgreSQLonFedora
*
- * This program 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 2
- * of the License, or (at your option) any later version.
+ * This file is part of rsyslog.
*
- * This program is distributed in the hope that it will be useful,
+ * 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 this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * 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.
*/
@@ -45,10 +46,14 @@
#include "template.h"
#include "ompgsql.h"
#include "module-template.h"
+#include "errmsg.h"
+
+MODULE_TYPE_OUTPUT
/* internal structures
*/
DEF_OMOD_STATIC_DATA
+DEFobjCurrIf(errmsg)
typedef struct _instanceData {
PGconn *f_hpgsql; /* handle to PgSQL */
@@ -91,27 +96,12 @@ CODESTARTfreeInstance
ENDfreeInstance
-BEGINneedUDPSocket
-CODESTARTneedUDPSocket
-ENDneedUDPSocket
-
-
BEGINdbgPrintInstInfo
CODESTARTdbgPrintInstInfo
/* nothing special here */
ENDdbgPrintInstInfo
-BEGINonSelectReadyWrite
-CODESTARTonSelectReadyWrite
-ENDonSelectReadyWrite
-
-
-BEGINgetWriteFDForSelect
-CODESTARTgetWriteFDForSelect
-ENDgetWriteFDForSelect
-
-
/* log a database error with descriptive message.
* We check if we have a valid handle. If not, we simply
* report an error, but can not be specific. RGerhards, 2007-01-30
@@ -127,7 +117,7 @@ static void reportDBError(instanceData *pData, int bSilent)
/* output log message */
errno = 0;
if(pData->f_hpgsql == NULL) {
- logerror("unknown DB error occured - could not obtain PgSQL handle");
+ errmsg.LogError(NO_ERRCODE, "unknown DB error occured - could not obtain PgSQL handle");
} else { /* we can ask pgsql for the error description... */
ePgSQLStatus = PQstatus(pData->f_hpgsql);
snprintf(errMsg, sizeof(errMsg)/sizeof(char), "db error (%d): %s\n", ePgSQLStatus,
@@ -136,7 +126,7 @@ static void reportDBError(instanceData *pData, int bSilent)
dbgprintf("pgsql, DBError(silent): %s\n", errMsg);
else {
pData->eLastPgSQLStatus = ePgSQLStatus;
- logerror(errMsg);
+ errmsg.LogError(NO_ERRCODE, "%s", errMsg);
}
}
@@ -164,7 +154,7 @@ static rsRetVal initPgSQL(instanceData *pData, int bSilent)
iRet = RS_RET_SUSPENDED;
}
- return iRet;
+ RETiRet;
}
@@ -229,7 +219,7 @@ finalize_it:
pData->eLastPgSQLStatus = CONNECTION_OK; /* reset error for error supression */
}
- return iRet;
+ RETiRet;
}
@@ -307,7 +297,7 @@ CODE_STD_STRING_REQUESTparseSelectorAct(1)
* Retries make no sense.
*/
if (iPgSQLPropErr) {
- logerror("Trouble with PgSQL connection properties. -PgSQL logging disabled");
+ errmsg.LogError(NO_ERRCODE, "Trouble with PgSQL connection properties. -PgSQL logging disabled");
ABORT_FINALIZE(RS_RET_INVALID_PARAMS);
} else {
CHKiRet(initPgSQL(pData, 0));
@@ -329,8 +319,9 @@ ENDqueryEtryPt
BEGINmodInit()
CODESTARTmodInit
- *ipIFVersProvided = 1; /* so far, we only support the initial definition */
+ *ipIFVersProvided = CURR_MOD_IF_VERSION; /* we only support the current interface specification */
CODEmodInit_QueryRegCFSLineHdlr
+ CHKiRet(objUse(errmsg, CORE_COMPONENT));
ENDmodInit
/* vi:set ai:
*/
diff --git a/plugins/ompgsql/ompgsql.h b/plugins/ompgsql/ompgsql.h
index 8285ac33..495291f4 100644
--- a/plugins/ompgsql/ompgsql.h
+++ b/plugins/ompgsql/ompgsql.h
@@ -5,19 +5,20 @@
*
* Copyright 2007 Rainer Gerhards and Adiscon GmbH.
*
- * This program 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 2
- * of the License, or (at your option) any later version.
+ * This file is part of rsyslog.
*
- * This program is distributed in the hope that it will be useful,
+ * 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 this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * 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.
*/