mirror of
https://github.com/mdbtools/mdbtools.git
synced 2025-04-05 20:31:00 +08:00
Moved ODBC ConnectParams into struct _hdbc
So now struct _hdbc contains the real allocated data. SQLAllocConnect doesn't hack it anymore with its own stucture.
This commit is contained in:
parent
eefddaffcc
commit
aac9c61536
@ -30,6 +30,7 @@
|
|||||||
# include <iodbcinst.h>
|
# include <iodbcinst.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "connectparams.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@ -40,6 +41,7 @@ struct _henv {
|
|||||||
};
|
};
|
||||||
struct _hdbc {
|
struct _hdbc {
|
||||||
struct _henv *henv;
|
struct _henv *henv;
|
||||||
|
ConnectParams* params;
|
||||||
};
|
};
|
||||||
struct _hstmt {
|
struct _hstmt {
|
||||||
struct _hdbc *hdbc;
|
struct _hdbc *hdbc;
|
||||||
|
@ -31,7 +31,6 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "mdbodbc.h"
|
#include "mdbodbc.h"
|
||||||
#include "connectparams.h"
|
|
||||||
|
|
||||||
//#define TRACE(x) fprintf(stderr,"Function %s\n", x);
|
//#define TRACE(x) fprintf(stderr,"Function %s\n", x);
|
||||||
#define TRACE(x)
|
#define TRACE(x)
|
||||||
@ -185,16 +184,6 @@ static void LogError (const char* error)
|
|||||||
lastError[_MAX_ERROR_LEN] = '\0'; /* in case we had a long message */
|
lastError[_MAX_ERROR_LEN] = '\0'; /* in case we had a long message */
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Driver specific connectionn information
|
|
||||||
*/
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
struct _hdbc hdbc;
|
|
||||||
ConnectParams* params;
|
|
||||||
} ODBCConnection;
|
|
||||||
|
|
||||||
static SQLRETURN do_connect (
|
static SQLRETURN do_connect (
|
||||||
SQLHDBC hdbc,
|
SQLHDBC hdbc,
|
||||||
char *database)
|
char *database)
|
||||||
@ -226,7 +215,7 @@ static SQLRETURN SQL_API _SQLDriverConnect(
|
|||||||
TRACE("_SQLDriverConnect");
|
TRACE("_SQLDriverConnect");
|
||||||
strcpy (lastError, "");
|
strcpy (lastError, "");
|
||||||
|
|
||||||
params = ((ODBCConnection*) hdbc)->params;
|
params = ((struct _hdbc*) hdbc)->params;
|
||||||
|
|
||||||
if ((dsn = ExtractDSN (params, (gchar*)szConnStrIn))) {
|
if ((dsn = ExtractDSN (params, (gchar*)szConnStrIn))) {
|
||||||
if (!LookupDSN (params, dsn)){
|
if (!LookupDSN (params, dsn)){
|
||||||
@ -550,12 +539,12 @@ static SQLRETURN SQL_API _SQLAllocConnect(
|
|||||||
SQLHDBC *phdbc)
|
SQLHDBC *phdbc)
|
||||||
{
|
{
|
||||||
struct _henv *env;
|
struct _henv *env;
|
||||||
ODBCConnection* dbc;
|
struct _hdbc* dbc;
|
||||||
|
|
||||||
TRACE("_SQLAllocConnect");
|
TRACE("_SQLAllocConnect");
|
||||||
env = (struct _henv *) henv;
|
env = (struct _henv *) henv;
|
||||||
dbc = (SQLHDBC) g_malloc0(sizeof (ODBCConnection));
|
dbc = (SQLHDBC) g_malloc0(sizeof(struct _hdbc));
|
||||||
dbc->hdbc.henv=env;
|
dbc->henv=env;
|
||||||
|
|
||||||
dbc->params = NewConnectParams ();
|
dbc->params = NewConnectParams ();
|
||||||
*phdbc=dbc;
|
*phdbc=dbc;
|
||||||
@ -683,7 +672,7 @@ static SQLRETURN SQL_API _SQLConnect(
|
|||||||
TRACE("_SQLConnect");
|
TRACE("_SQLConnect");
|
||||||
strcpy (lastError, "");
|
strcpy (lastError, "");
|
||||||
|
|
||||||
params = ((ODBCConnection*) hdbc)->params;
|
params = ((struct _hdbc*) hdbc)->params;
|
||||||
|
|
||||||
params->dsnName = g_string_assign (params->dsnName, (gchar*)szDSN);
|
params->dsnName = g_string_assign (params->dsnName, (gchar*)szDSN);
|
||||||
|
|
||||||
@ -1212,7 +1201,7 @@ SQLRETURN SQL_API SQLFreeHandle(
|
|||||||
static SQLRETURN SQL_API _SQLFreeConnect(
|
static SQLRETURN SQL_API _SQLFreeConnect(
|
||||||
SQLHDBC hdbc)
|
SQLHDBC hdbc)
|
||||||
{
|
{
|
||||||
ODBCConnection* dbc = (ODBCConnection*) hdbc;
|
struct _hdbc* dbc = (struct _hdbc*) hdbc;
|
||||||
|
|
||||||
TRACE("_SQLFreeConnect");
|
TRACE("_SQLFreeConnect");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user