summaryrefslogtreecommitdiff
path: root/libodbcpp/error.cpp
diff options
context:
space:
mode:
authorrandomdan <randomdan@localhost>2011-02-09 01:33:33 +0000
committerrandomdan <randomdan@localhost>2011-02-09 01:33:33 +0000
commit6d7c18f1119de8941c7055910e55c13c411eeb92 (patch)
tree9468662e07280c26e29de53f7fdfa228eb62ecde /libodbcpp/error.cpp
parentAdd missing conversion in generic visitor (diff)
downloadlibdbpp-odbc-6d7c18f1119de8941c7055910e55c13c411eeb92.tar.bz2
libdbpp-odbc-6d7c18f1119de8941c7055910e55c13c411eeb92.tar.xz
libdbpp-odbc-6d7c18f1119de8941c7055910e55c13c411eeb92.zip
Fix the build system to do dependencies properly
Break down libodbcpp into a set of base classes; libdbpp Add a native PostgreSQL implementation of libdbpp; libpqpp Extend project2 rdbms stuff to work with generic connectors Update datasources to specify connector type Build libmisc as .so
Diffstat (limited to 'libodbcpp/error.cpp')
-rw-r--r--libodbcpp/error.cpp31
1 files changed, 7 insertions, 24 deletions
diff --git a/libodbcpp/error.cpp b/libodbcpp/error.cpp
index 51b90c6..e971714 100644
--- a/libodbcpp/error.cpp
+++ b/libodbcpp/error.cpp
@@ -3,23 +3,17 @@
#include <syslog.h>
#include <malloc.h>
#include <time.h>
+#include <string.h>
#include "error.h"
static
void
-odbc_verror(RETCODE err, SQLSMALLINT handletype, SQLHANDLE handle, char const * actionfmt, va_list ap, char ** msg)
+odbc_verror(RETCODE err, SQLSMALLINT handletype, SQLHANDLE handle, char const * action, char ** msg)
{
SQLCHAR sqlstatus[6];
SQLINTEGER sqlerr;
SQLCHAR sqlerrmsg[12800];
- char * action;
- if (vasprintf(&action, actionfmt, ap) < 0) {
- syslog(LOG_WARNING, "%s: %d: %ld: %5.5s: \"%s\" : failed to malloc for vasprintf",
- __FUNCTION__, err, sqlerr, sqlstatus, sqlerrmsg);
- return;
- }
-
SQLRETURN rc = SQLGetDiagRec(handletype, handle, 1, sqlstatus, &sqlerr, sqlerrmsg,
sizeof(sqlerrmsg), NULL);
switch (rc) {
@@ -62,28 +56,17 @@ odbc_verror(RETCODE err, SQLSMALLINT handletype, SQLHANDLE handle, char const *
syslog(LOG_ERR, "%s: Unexpected error!!", __FUNCTION__);
break;
}
- free(action);
}
-ODBC::Error::Error(RETCODE err, SQLSMALLINT handletype, SQLHANDLE handle, char const * action, ...)
+ODBC::Error::Error(RETCODE err, SQLSMALLINT handletype, SQLHANDLE handle, char const * action)
{
- va_list ap;
-
- va_start(ap, action);
- odbc_verror(err, handletype, handle, action, ap, &msg);
- va_end(ap);
+ odbc_verror(err, handletype, handle, action, &msg);
}
-ODBC::Error::Error(char const * action, ...)
+ODBC::Error::Error(char const * action)
{
- va_list ap;
-
- va_start(ap, action);
- vsyslog(LOG_ERR, action, ap);
- if (vasprintf(&msg, action, ap) < 1) {
- msg = NULL;
- }
- va_end(ap);
+ syslog(LOG_ERR, "%s", action);
+ msg = strdup(action);
}
ODBC::Error::Error(char * m) : msg(m)