Commit 594e97b7 authored by Bruce Momjian's avatar Bruce Momjian

Back out all ODBC formatting changes, and back out removal of <6.4

protocol. I have left in Tom's SOCK_get_next_byte() fix, and the new
win32.mak file addition.  I have also left in the 'X' connection close
fix.
parent 18b04ae1
......@@ -2,7 +2,7 @@
#
# GNUMakefile for psqlodbc (Postgres ODBC driver)
#
# $Header: /cvsroot/pgsql/src/interfaces/odbc/Attic/GNUmakefile,v 1.12 2001/02/10 16:51:40 petere Exp $
# $Header: /cvsroot/pgsql/src/interfaces/odbc/Attic/GNUmakefile,v 1.13 2001/02/14 05:45:38 momjian Exp $
#
#-------------------------------------------------------------------------
......@@ -24,6 +24,7 @@ OBJS = info.o bind.o columninfo.o connection.o convert.o drvconn.o \
gpps.o tuple.o tuplelist.o dlg_specific.o $(OBJX)
SHLIB_LINK = $(filter -lm, $(LIBS))
all: all-lib
# Shared library stuff
......@@ -32,7 +33,6 @@ include $(top_srcdir)/src/Makefile.shlib
# Symbols must be resolved to the version in the shared library because
# the driver manager (e.g., iodbc) provides some symbols with the same
# names and we don't want those. (This issue is probably ELF specific.)
LINK.shared += $(shlib_symbolic)
odbc_headers = isql.h isqlext.h iodbc.h
......
This diff is collapsed.
......@@ -15,24 +15,18 @@
/*
* BindInfoClass -- stores information about a bound column
*/
struct BindInfoClass_
{
struct BindInfoClass_ {
Int4 buflen; /* size of buffer */
Int4 data_left; /* amount of data left to read
* (SQLGetData) */
Int4 data_left; /* amount of data left to read (SQLGetData) */
char *buffer; /* pointer to the buffer */
Int4 *used; /* used space in the buffer (for strings
* not counting the '\0') */
Int2 returntype; /* kind of conversion to be applied when
* returning (SQL_C_DEFAULT,
* SQL_C_CHAR...) */
Int4 *used; /* used space in the buffer (for strings not counting the '\0') */
Int2 returntype; /* kind of conversion to be applied when returning (SQL_C_DEFAULT, SQL_C_CHAR...) */
};
/*
* ParameterInfoClass -- stores information about a bound parameter
*/
struct ParameterInfoClass_
{
struct ParameterInfoClass_ {
Int4 buflen;
char *buffer;
Int4 *used;
......@@ -42,8 +36,7 @@ struct ParameterInfoClass_
UInt4 precision;
Int2 scale;
Oid lobj_oid;
Int4 *EXEC_used; /* amount of data OR the oid of the large
* object */
Int4 *EXEC_used; /* amount of data OR the oid of the large object */
char *EXEC_buffer; /* the data or the FD of the large object */
char data_at_exec;
};
......
/* Module: columninfo.c
*
* Description: This module contains routines related to
......@@ -20,12 +21,11 @@
ColumnInfoClass *
CI_Constructor()
{
ColumnInfoClass *rv;
ColumnInfoClass *rv;
rv = (ColumnInfoClass *) malloc(sizeof(ColumnInfoClass));
if (rv)
{
if (rv) {
rv->num_fields = 0;
rv->name = NULL;
rv->adtid = NULL;
......@@ -52,14 +52,14 @@ CI_Destructor(ColumnInfoClass *self)
char
CI_read_fields(ColumnInfoClass *self, ConnectionClass *conn)
{
Int2 lf;
int new_num_fields;
Oid new_adtid;
Int2 new_adtsize;
Int4 new_atttypmod = -1;
char new_field_name[MAX_MESSAGE_LEN + 1];
SocketClass *sock;
ConnInfo *ci;
Int2 lf;
int new_num_fields;
Oid new_adtid;
Int2 new_adtsize;
Int4 new_atttypmod = -1;
char new_field_name[MAX_MESSAGE_LEN+1];
SocketClass *sock;
ConnInfo *ci;
sock = CC_get_socket(conn);
ci = &conn->connInfo;
......@@ -69,21 +69,20 @@ CI_read_fields(ColumnInfoClass *self, ConnectionClass *conn)
mylog("num_fields = %d\n", new_num_fields);
if (self)
{ /* according to that allocate memory */
if (self) { /* according to that allocate memory */
CI_set_num_fields(self, new_num_fields);
}
/* now read in the descriptions */
for (lf = 0; lf < new_num_fields; lf++)
{
for(lf = 0; lf < new_num_fields; lf++) {
SOCK_get_string(sock, new_field_name, MAX_MESSAGE_LEN);
new_adtid = (Oid) SOCK_get_int(sock, 4);
new_adtsize = (Int2) SOCK_get_int(sock, 2);
/* If 6.4 protocol, then read the atttypmod field */
if (PG_VERSION_GE(conn, 6.4))
{
if (PG_VERSION_GE(conn, 6.4)) {
mylog("READING ATTTYPMOD\n");
new_atttypmod = (Int4) SOCK_get_int(sock, 4);
......@@ -91,6 +90,7 @@ CI_read_fields(ColumnInfoClass *self, ConnectionClass *conn)
new_atttypmod -= 4;
if (new_atttypmod < 0)
new_atttypmod = -1;
}
mylog("CI_read_fields: fieldname='%s', adtid=%d, adtsize=%d, atttypmod=%d\n", new_field_name, new_adtid, new_adtsize, new_atttypmod);
......@@ -107,13 +107,12 @@ CI_read_fields(ColumnInfoClass *self, ConnectionClass *conn)
void
CI_free_memory(ColumnInfoClass *self)
{
register Int2 lf;
int num_fields = self->num_fields;
register Int2 lf;
int num_fields = self->num_fields;
for (lf = 0; lf < num_fields; lf++)
{
if (self->name[lf])
free(self->name[lf]);
for (lf = 0; lf < num_fields; lf++) {
if( self->name[lf])
free (self->name[lf]);
}
/* Safe to call even if null */
......@@ -132,9 +131,9 @@ CI_set_num_fields(ColumnInfoClass *self, int new_num_fields)
self->num_fields = new_num_fields;
self->name = (char **) malloc(sizeof(char *) * self->num_fields);
self->adtid = (Oid *) malloc(sizeof(Oid) * self->num_fields);
self->adtsize = (Int2 *) malloc(sizeof(Int2) * self->num_fields);
self->name = (char **) malloc (sizeof(char *) * self->num_fields);
self->adtid = (Oid *) malloc (sizeof(Oid) * self->num_fields);
self->adtsize = (Int2 *) malloc (sizeof(Int2) * self->num_fields);
self->display_size = (Int2 *) malloc(sizeof(Int2) * self->num_fields);
self->atttypmod = (Int4 *) malloc(sizeof(Int4) * self->num_fields);
}
......@@ -143,9 +142,11 @@ void
CI_set_field_info(ColumnInfoClass *self, int field_num, char *new_name,
Oid new_adtid, Int2 new_adtsize, Int4 new_atttypmod)
{
/* check bounds */
if ((field_num < 0) || (field_num >= self->num_fields))
if((field_num < 0) || (field_num >= self->num_fields)) {
return;
}
/* store the info */
self->name[field_num] = strdup(new_name);
......@@ -155,3 +156,4 @@ CI_set_field_info(ColumnInfoClass *self, int field_num, char *new_name,
self->display_size[field_num] = 0;
}
......@@ -12,8 +12,7 @@
#include "psqlodbc.h"
struct ColumnInfoClass_
{
struct ColumnInfoClass_ {
Int2 num_fields;
char **name; /* list of type names */
Oid *adtid; /* list of type ids */
......
This diff is collapsed.
......@@ -27,14 +27,11 @@
#endif
typedef enum
{
typedef enum {
CONN_NOT_CONNECTED, /* Connection has not been established */
CONN_CONNECTED, /* Connection is up and has been
* established */
CONN_CONNECTED, /* Connection is up and has been established */
CONN_DOWN, /* Connection is broken */
CONN_EXECUTING /* the connection is currently executing a
* statement */
CONN_EXECUTING /* the connection is currently executing a statement */
} CONN_Status;
/* These errors have general sql error state */
......@@ -109,8 +106,10 @@ typedef unsigned int ProtocolVersion;
#define PG_PROTOCOL(major, minor) (((major) << 16) | (minor))
#define PG_PROTOCOL_LATEST PG_PROTOCOL(2, 0)
#define PG_PROTOCOL_63 PG_PROTOCOL(1, 0)
#define PG_PROTOCOL_62 PG_PROTOCOL(0, 0)
/* This startup packet is to support latest Postgres protocol */
/* This startup packet is to support latest Postgres protocol (6.4, 6.3) */
typedef struct _StartupPacket
{
ProtocolVersion protoVersion;
......@@ -122,11 +121,22 @@ typedef struct _StartupPacket
} StartupPacket;
/* This startup packet is to support pre-Postgres 6.3 protocol */
typedef struct _StartupPacket6_2
{
unsigned int authtype;
char database[PATH_SIZE];
char user[NAMEDATALEN];
char options[ARGV_SIZE];
char execfile[ARGV_SIZE];
char tty[PATH_SIZE];
} StartupPacket6_2;
/* Structure to hold all the connection attributes for a specific
connection (used for both registry and file, DSN and DRIVER)
*/
typedef struct
{
typedef struct {
char dsn[MEDIUM_REGISTRY_LEN];
char desc[MEDIUM_REGISTRY_LEN];
char driver[MEDIUM_REGISTRY_LEN];
......@@ -147,6 +157,12 @@ typedef struct
char focus_password;
} ConnInfo;
/* Macro to determine is the connection using 6.2 protocol? */
#define PROTOCOL_62(conninfo_) (strncmp((conninfo_)->protocol, PG62, strlen(PG62)) == 0)
/* Macro to determine is the connection using 6.3 protocol? */
#define PROTOCOL_63(conninfo_) (strncmp((conninfo_)->protocol, PG63, strlen(PG63)) == 0)
/*
* Macros to compare the server's version with a specified version
* 1st parameter: pointer to a ConnectionClass object
......@@ -184,10 +200,9 @@ typedef struct
#define PG_VERSION_LT(conn, ver) (! PG_VERSION_GE(conn, ver))
/* This is used to store cached table information in the connection */
struct col_info
{
struct col_info {
QResultClass *result;
char name[MAX_TABLE_LEN + 1];
char name[MAX_TABLE_LEN+1];
};
/* Translation DLL entry points */
......@@ -199,7 +214,7 @@ struct col_info
#define HINSTANCE void *
#endif
typedef BOOL (FAR WINAPI * DataSourceToDriverProc) (UDWORD,
typedef BOOL (FAR WINAPI *DataSourceToDriverProc) (UDWORD,
SWORD,
PTR,
SDWORD,
......@@ -210,7 +225,7 @@ typedef BOOL (FAR WINAPI * DataSourceToDriverProc) (UDWORD,
SWORD,
SWORD FAR *);
typedef BOOL (FAR WINAPI * DriverToDataSourceProc) (UDWORD,
typedef BOOL (FAR WINAPI *DriverToDataSourceProc) (UDWORD,
SWORD,
PTR,
SDWORD,
......@@ -222,10 +237,8 @@ typedef BOOL (FAR WINAPI * DriverToDataSourceProc) (UDWORD,
SWORD FAR *);
/******* The Connection handle ************/
struct ConnectionClass_
{
HENV henv; /* environment this connection was created
* on */
struct ConnectionClass_ {
HENV henv; /* environment this connection was created on */
StatementOptions stmtOptions;
char *errormsg;
int errornumber;
......@@ -241,13 +254,9 @@ struct ConnectionClass_
HINSTANCE translation_handle;
DataSourceToDriverProc DataSourceToDriver;
DriverToDataSourceProc DriverToDataSource;
char transact_status;/* Is a transaction is currently in
* progress */
char errormsg_created; /* has an informative error msg
* been created? */
char pg_version[MAX_INFO_STRING]; /* Version of PostgreSQL
* we're connected to -
* DJP 25-1-2001 */
char transact_status; /* Is a transaction is currently in progress */
char errormsg_created; /* has an informative error msg been created? */
char pg_version[MAX_INFO_STRING]; /* Version of PostgreSQL we're connected to - DJP 25-1-2001 */
float pg_version_number;
Int2 pg_version_major;
Int2 pg_version_minor;
......@@ -274,7 +283,7 @@ char CC_Destructor(ConnectionClass *self);
int CC_cursor_count(ConnectionClass *self);
char CC_cleanup(ConnectionClass *self);
char CC_abort(ConnectionClass *self);
int CC_set_translation(ConnectionClass *self);
int CC_set_translation (ConnectionClass *self);
char CC_connect(ConnectionClass *self, char do_password);
char CC_add_statement(ConnectionClass *self, StatementClass *stmt);
char CC_remove_statement(ConnectionClass *self, StatementClass *stmt);
......
This diff is collapsed.
......@@ -20,8 +20,7 @@
#define COPY_GENERAL_ERROR 4
#define COPY_NO_DATA_FOUND 5
typedef struct
{
typedef struct {
int m;
int d;
int y;
......
This diff is collapsed.
......@@ -31,26 +31,23 @@
/* INI File Stuff */
#ifndef WIN32
#define ODBC_INI ".odbc.ini"
#ifdef ODBCINSTDIR
#define ODBCINST_INI ODBCINSTDIR "/odbcinst.ini"
#else
#define ODBCINST_INI "/etc/odbcinst.ini"
#warning "location of odbcinst.ini file defaulted to /etc"
#endif
# define ODBC_INI ".odbc.ini"
# ifdef ODBCINSTDIR
# define ODBCINST_INI ODBCINSTDIR "/odbcinst.ini"
# else
# define ODBCINST_INI "/etc/odbcinst.ini"
# warning "location of odbcinst.ini file defaulted to /etc"
# endif
#else /* WIN32 */
#define ODBC_INI "ODBC.INI" /* ODBC initialization file */
#define ODBCINST_INI "ODBCINST.INI" /* ODBC Installation file */
# define ODBC_INI "ODBC.INI" /* ODBC initialization file */
# define ODBCINST_INI "ODBCINST.INI" /* ODBC Installation file */
#endif /* WIN32 */
#define INI_DSN DBMS_NAME /* Name of default Datasource in
* ini file (not used?) */
#define INI_DSN DBMS_NAME /* Name of default Datasource in ini file (not used?) */
#define INI_KDESC "Description" /* Data source description */
#define INI_SERVER "Servername" /* Name of Server running
* the Postgres service */
#define INI_PORT "Port" /* Port on which the Postmaster is
* listening */
#define INI_SERVER "Servername" /* Name of Server running the Postgres service */
#define INI_PORT "Port" /* Port on which the Postmaster is listening */
#define INI_DATABASE "Database" /* Database Name */
#define INI_USER "Username" /* Default User Name */
#define INI_PASSWORD "Password" /* Default Password */
......@@ -58,23 +55,17 @@
#define INI_FETCH "Fetch" /* Fetch Max Count */
#define INI_SOCKET "Socket" /* Socket buffer size */
#define INI_READONLY "ReadOnly" /* Database is read only */
#define INI_COMMLOG "CommLog" /* Communication to backend
* logging */
#define INI_COMMLOG "CommLog" /* Communication to backend logging */
#define INI_PROTOCOL "Protocol" /* What protocol (6.2) */
#define INI_OPTIMIZER "Optimizer" /* Use backend genetic optimizer */
#define INI_KSQO "Ksqo" /* Keyset query optimization */
#define INI_CONNSETTINGS "ConnSettings" /* Anything to send to
* backend on successful
* connection */
#define INI_UNIQUEINDEX "UniqueIndex" /* Recognize unique
* indexes */
#define INI_UNKNOWNSIZES "UnknownSizes" /* How to handle unknown
* result set sizes */
#define INI_CONNSETTINGS "ConnSettings" /* Anything to send to backend on successful connection */
#define INI_UNIQUEINDEX "UniqueIndex" /* Recognize unique indexes */
#define INI_UNKNOWNSIZES "UnknownSizes" /* How to handle unknown result set sizes */
#define INI_CANCELASFREESTMT "CancelAsFreeStmt"
#define INI_USEDECLAREFETCH "UseDeclareFetch" /* Use Declare/Fetch
* cursors */
#define INI_USEDECLAREFETCH "UseDeclareFetch" /* Use Declare/Fetch cursors */
/* More ini stuff */
#define INI_TEXTASLONGVARCHAR "TextAsLongVarchar"
......@@ -99,8 +90,7 @@
/* Connection Defaults */
#define DEFAULT_PORT "5432"
#define DEFAULT_READONLY 1
#define DEFAULT_PROTOCOL "6.4" /* the latest protocol is
* the default */
#define DEFAULT_PROTOCOL "6.4" /* the latest protocol is the default */
#define DEFAULT_USEDECLAREFETCH 0
#define DEFAULT_TEXTASLONGVARCHAR 1
#define DEFAULT_UNKNOWNSASLONGVARCHAR 0
......@@ -139,7 +129,6 @@ int CALLBACK ds_optionsProc(HWND hdlg,
WORD wMsg,
WPARAM wParam,
LPARAM lParam);
#endif /* WIN32 */
void updateGlobals(void);
......
/* Module: drvconn.c
*
* Description: This module contains only routines related to
......@@ -58,15 +59,13 @@ void dconn_get_connect_attributes(UCHAR FAR *connect_string, ConnInfo *ci);
BOOL FAR PASCAL dconn_FDriverConnectProc(HWND hdlg, UINT wMsg, WPARAM wParam, LPARAM lParam);
RETCODE dconn_DoDialog(HWND hwnd, ConnInfo *ci);
extern HINSTANCE NEAR s_hModule;/* Saved module handle. */
extern HINSTANCE NEAR s_hModule; /* Saved module handle. */
#endif
extern GLOBAL_VALUES globals;
RETCODE SQL_API
SQLDriverConnect(
RETCODE SQL_API SQLDriverConnect(
HDBC hdbc,
HWND hwnd,
UCHAR FAR *szConnStrIn,
......@@ -76,26 +75,23 @@ SQLDriverConnect(
SWORD FAR *pcbConnStrOut,
UWORD fDriverCompletion)
{
static char *func = "SQLDriverConnect";
ConnectionClass *conn = (ConnectionClass *) hdbc;
ConnInfo *ci;
static char *func = "SQLDriverConnect";
ConnectionClass *conn = (ConnectionClass *) hdbc;
ConnInfo *ci;
#ifdef WIN32
RETCODE dialog_result;
RETCODE dialog_result;
#endif
RETCODE result;
char connStrIn[MAX_CONNECT_STRING];
char connStrOut[MAX_CONNECT_STRING];
int retval;
char password_required = FALSE;
int len = 0;
RETCODE result;
char connStrIn[MAX_CONNECT_STRING];
char connStrOut[MAX_CONNECT_STRING];
int retval;
char password_required = FALSE;
int len = 0;
mylog("%s: entering...\n", func);
if (!conn)
{
if ( ! conn) {
CC_log_error(func, "", NULL);
return SQL_INVALID_HANDLE;
}
......@@ -125,13 +121,13 @@ dialog:
#endif
ci->focus_password = password_required;
switch (fDriverCompletion)
{
switch(fDriverCompletion) {
#ifdef WIN32
case SQL_DRIVER_PROMPT:
dialog_result = dconn_DoDialog(hwnd, ci);
if (dialog_result != SQL_SUCCESS)
if(dialog_result != SQL_SUCCESS) {
return dialog_result;
}
break;
case SQL_DRIVER_COMPLETE_REQUIRED:
......@@ -141,16 +137,17 @@ dialog:
case SQL_DRIVER_COMPLETE:
/* Password is not a required parameter. */
if (ci->username[0] == '\0' ||
if( ci->username[0] == '\0' ||
ci->server[0] == '\0' ||
ci->database[0] == '\0' ||
ci->port[0] == '\0' ||
password_required)
{
password_required) {
dialog_result = dconn_DoDialog(hwnd, ci);
if (dialog_result != SQL_SUCCESS)
if(dialog_result != SQL_SUCCESS) {
return dialog_result;
}
}
break;
#else
case SQL_DRIVER_PROMPT:
......@@ -161,17 +158,14 @@ dialog:
break;
}
/*
* Password is not a required parameter unless authentication asks for
* it. For now, I think it's better to just let the application ask
* over and over until a password is entered (the user can always hit
* Cancel to get out)
/* Password is not a required parameter unless authentication asks for it.
For now, I think it's better to just let the application ask over and over until
a password is entered (the user can always hit Cancel to get out)
*/
if (ci->username[0] == '\0' ||
if( ci->username[0] == '\0' ||
ci->server[0] == '\0' ||
ci->database[0] == '\0' ||
ci->port[0] == '\0')
{
ci->port[0] == '\0') {
/* (password_required && ci->password[0] == '\0')) */
return SQL_NO_DATA_FOUND;
......@@ -180,16 +174,12 @@ dialog:
/* do the actual connect */
retval = CC_connect(conn, password_required);
if (retval < 0)
{ /* need a password */
if (fDriverCompletion == SQL_DRIVER_NOPROMPT)
{
if (retval < 0) { /* need a password */
if (fDriverCompletion == SQL_DRIVER_NOPROMPT) {
CC_log_error(func, "Need password but Driver_NoPrompt", conn);
return SQL_ERROR; /* need a password but not allowed to
* prompt so error */
return SQL_ERROR; /* need a password but not allowed to prompt so error */
}
else
{
else {
#ifdef WIN32
password_required = TRUE;
goto dialog;
......@@ -198,8 +188,7 @@ dialog:
#endif
}
}
else if (retval == 0)
{
else if (retval == 0) {
/* error msg filled in above */
CC_log_error(func, "Error from CC_Connect", conn);
return SQL_ERROR;
......@@ -213,29 +202,25 @@ dialog:
makeConnectString(connStrOut, ci);
len = strlen(connStrOut);
if (szConnStrOut)
{
/*
* Return the completed string to the caller. The correct method
* is to only construct the connect string if a dialog was put up,
* otherwise, it should just copy the connection input string to
* the output. However, it seems ok to just always construct an
* output string. There are possible bad side effects on working
* applications (Access) by implementing the correct behavior,
* anyway.
if(szConnStrOut) {
/* Return the completed string to the caller. The correct method is to
only construct the connect string if a dialog was put up, otherwise,
it should just copy the connection input string to the output.
However, it seems ok to just always construct an output string. There
are possible bad side effects on working applications (Access) by
implementing the correct behavior, anyway.
*/
strncpy_null(szConnStrOut, connStrOut, cbConnStrOutMax);
if (len >= cbConnStrOutMax)
{
if (len >= cbConnStrOutMax) {
result = SQL_SUCCESS_WITH_INFO;
conn->errornumber = CONN_TRUNCATED;
conn->errormsg = "The buffer was too small for the result.";
}
}
if (pcbConnStrOut)
if(pcbConnStrOut)
*pcbConnStrOut = len;
mylog("szConnStrOut = '%s'\n", szConnStrOut);
......@@ -247,38 +232,35 @@ dialog:
}
#ifdef WIN32
RETCODE
dconn_DoDialog(HWND hwnd, ConnInfo *ci)
RETCODE dconn_DoDialog(HWND hwnd, ConnInfo *ci)
{
int dialog_result;
int dialog_result;
mylog("dconn_DoDialog: ci = %u\n", ci);
mylog("dconn_DoDialog: ci = %u\n", ci);
if (hwnd)
{
if(hwnd) {
dialog_result = DialogBoxParam(s_hModule, MAKEINTRESOURCE(DLG_CONFIG),
hwnd, dconn_FDriverConnectProc, (LPARAM) ci);
if (!dialog_result || (dialog_result == -1))
if(!dialog_result || (dialog_result == -1)) {
return SQL_NO_DATA_FOUND;
else
} else {
return SQL_SUCCESS;
}
}
return SQL_ERROR;
}
BOOL FAR PASCAL
dconn_FDriverConnectProc(
BOOL FAR PASCAL dconn_FDriverConnectProc(
HWND hdlg,
UINT wMsg,
WPARAM wParam,
LPARAM lParam)
{
ConnInfo *ci;
ConnInfo *ci;
switch (wMsg)
{
switch (wMsg) {
case WM_INITDIALOG:
ci = (ConnInfo *) lParam;
......@@ -293,8 +275,7 @@ dconn_FDriverConnectProc(
ShowWindow(GetDlgItem(hdlg, IDC_DESCTEXT), SW_HIDE);
ShowWindow(GetDlgItem(hdlg, IDC_DESC), SW_HIDE);
SetWindowLong(hdlg, DWL_USER, lParam); /* Save the ConnInfo for
* the "OK" */
SetWindowLong(hdlg, DWL_USER, lParam);/* Save the ConnInfo for the "OK" */
SetDlgStuff(hdlg, ci);
......@@ -313,8 +294,7 @@ dconn_FDriverConnectProc(
break;
case WM_COMMAND:
switch (GET_WM_COMMAND_ID(wParam, lParam))
{
switch (GET_WM_COMMAND_ID(wParam, lParam)) {
case IDOK:
ci = (ConnInfo *) GetWindowLong(hdlg, DWL_USER);
......@@ -349,15 +329,11 @@ dconn_FDriverConnectProc(
#endif /* WIN32 */
void
dconn_get_connect_attributes(UCHAR FAR *connect_string, ConnInfo *ci)
void dconn_get_connect_attributes(UCHAR FAR *connect_string, ConnInfo *ci)
{
char *our_connect_string;
char *pair,
*attribute,
*value,
*equals;
char *strtok_arg;
char *our_connect_string;
char *pair, *attribute, *value, *equals;
char *strtok_arg;
memset(ci, 0, sizeof(ConnInfo));
......@@ -366,16 +342,17 @@ dconn_get_connect_attributes(UCHAR FAR *connect_string, ConnInfo *ci)
mylog("our_connect_string = '%s'\n", our_connect_string);
while (1)
{
while(1) {
pair = strtok(strtok_arg, ";");
if (strtok_arg)
if(strtok_arg) {
strtok_arg = 0;
if (!pair)
}
if(!pair) {
break;
}
equals = strchr(pair, '=');
if (!equals)
if ( ! equals)
continue;
*equals = '\0';
......@@ -384,13 +361,15 @@ dconn_get_connect_attributes(UCHAR FAR *connect_string, ConnInfo *ci)
mylog("attribute = '%s', value = '%s'\n", attribute, value);
if (!attribute || !value)
if( !attribute || !value)
continue;
/* Copy the appropriate value to the conninfo */
copyAttributes(ci, attribute, value);
}
free(our_connect_string);
}
This diff is collapsed.
......@@ -29,8 +29,7 @@
#define ENV_ALLOC_ERROR 1
/********** Environment Handle *************/
struct EnvironmentClass_
{
struct EnvironmentClass_ {
char *errormsg;
int errornumber;
};
......
This diff is collapsed.
This diff is collapsed.
......@@ -13,30 +13,25 @@
#endif
#ifdef __cplusplus
extern "C"
{
extern "C" {
#endif
DWORD GetPrivateProfileString(char *theSection, /* section name */
DWORD
GetPrivateProfileString(char *theSection, /* section name */
char *theKey, /* search key name */
char *theDefault, /* default value if not
* found */
char *theReturnBuffer, /* return valuse stored
* here */
size_t theBufferLength, /* byte length of return
* buffer */
char *theIniFileName); /* pathname of ini file
* to search */
char *theDefault, /* default value if not found */
char *theReturnBuffer, /* return valuse stored here */
size_t theBufferLength, /* byte length of return buffer */
char *theIniFileName); /* pathname of ini file to search */
DWORD WritePrivateProfileString(char *theSection, /* section name */
DWORD
WritePrivateProfileString(char *theSection, /* section name */
char *theKey, /* write key name */
char *theBuffer, /* input buffer */
char *theIniFileName); /* pathname of ini file
* to write */
char *theIniFileName); /* pathname of ini file to write */
#ifdef __cplusplus
}
#endif
#ifndef WIN32
......
This diff is collapsed.
#ifndef _IODBC_H
#define _IODBC_H
#if !defined(WIN32) && !defined(WIN32_SYSTEM)
#define _UNIX_
#include <stdlib.h>
#include <sys/types.h>
#define MEM_ALLOC(size) (malloc((size_t)(size)))
#define MEM_FREE(ptr) {if(ptr) free(ptr);}
#define STRCPY(t, s) (strcpy((char*)(t), (char*)(s)))
#define STRNCPY(t,s,n) (strncpy((char*)(t), (char*)(s), (size_t)(n)))
#define STRCAT(t, s) (strcat((char*)(t), (char*)(s)))
#define STRNCAT(t,s,n) (strncat((char*)(t), (char*)(s), (size_t)(n)))
#define STREQ(a, b) (strcmp((char*)(a), (char*)(b)) == 0)
#define STRLEN(str) ((str)? strlen((char*)(str)):0)
#define EXPORT
#define CALLBACK
#define FAR
typedef signed short SSHOR;
typedef short WORD;
typedef long DWORD;
typedef WORD WPARAM;
typedef DWORD LPARAM;
typedef void *HWND;
typedef int BOOL;
#endif /* _UNIX_ */
#if defined(WIN32) || defined(WIN32_SYSTEM)
#include <windows.h>
#include <windowsx.h>
#ifdef _MSVC_
#define MEM_ALLOC(size) (fmalloc((size_t)(size)))
#define MEM_FREE(ptr) ((ptr)? ffree((PTR)(ptr)):0))
#define STRCPY(t, s) (fstrcpy((char FAR*)(t), (char FAR*)(s)))
#define STRNCPY(t,s,n) (fstrncpy((char FAR*)(t), (char FAR*)(s), (size_t)(n)))
#define STRLEN(str) ((str)? fstrlen((char FAR*)(str)):0)
#define STREQ(a, b) (fstrcmp((char FAR*)(a), (char FAR*)(b) == 0)
#endif
#ifdef _BORLAND_
#define MEM_ALLOC(size) (farmalloc((unsigned long)(size))
#define MEM_FREE(ptr) ((ptr)? farfree((void far*)(ptr)):0)
#define STRCPY(t, s) (_fstrcpy((char FAR*)(t), (char FAR*)(s)))
#define STRNCPY(t,s,n) (_fstrncpy((char FAR*)(t), (char FAR*)(s), (size_t)(n)))
#define STRLEN(str) ((str)? _fstrlen((char FAR*)(str)):0)
#define STREQ(a, b) (_fstrcmp((char FAR*)(a), (char FAR*)(b) == 0)
#endif
#endif /* WIN32 */
#define SYSERR (-1)
#ifndef NULL
#define NULL ((void FAR*)0UL)
#endif
# if !defined(WIN32) && !defined(WIN32_SYSTEM)
# define _UNIX_
# include <stdlib.h>
# include <sys/types.h>
# define MEM_ALLOC(size) (malloc((size_t)(size)))
# define MEM_FREE(ptr) {if(ptr) free(ptr);}
# define STRCPY(t, s) (strcpy((char*)(t), (char*)(s)))
# define STRNCPY(t,s,n) (strncpy((char*)(t), (char*)(s), (size_t)(n)))
# define STRCAT(t, s) (strcat((char*)(t), (char*)(s)))
# define STRNCAT(t,s,n) (strncat((char*)(t), (char*)(s), (size_t)(n)))
# define STREQ(a, b) (strcmp((char*)(a), (char*)(b)) == 0)
# define STRLEN(str) ((str)? strlen((char*)(str)):0)
# define EXPORT
# define CALLBACK
# define FAR
typedef signed short SSHOR;
typedef short WORD;
typedef long DWORD;
typedef WORD WPARAM;
typedef DWORD LPARAM;
typedef void* HWND;
typedef int BOOL;
# endif /* _UNIX_ */
# if defined(WIN32) || defined(WIN32_SYSTEM)
# include <windows.h>
# include <windowsx.h>
# ifdef _MSVC_
# define MEM_ALLOC(size) (fmalloc((size_t)(size)))
# define MEM_FREE(ptr) ((ptr)? ffree((PTR)(ptr)):0))
# define STRCPY(t, s) (fstrcpy((char FAR*)(t), (char FAR*)(s)))
# define STRNCPY(t,s,n) (fstrncpy((char FAR*)(t), (char FAR*)(s), (size_t)(n)))
# define STRLEN(str) ((str)? fstrlen((char FAR*)(str)):0)
# define STREQ(a, b) (fstrcmp((char FAR*)(a), (char FAR*)(b) == 0)
# endif
# ifdef _BORLAND_
# define MEM_ALLOC(size) (farmalloc((unsigned long)(size))
# define MEM_FREE(ptr) ((ptr)? farfree((void far*)(ptr)):0)
# define STRCPY(t, s) (_fstrcpy((char FAR*)(t), (char FAR*)(s)))
# define STRNCPY(t,s,n) (_fstrncpy((char FAR*)(t), (char FAR*)(s), (size_t)(n)))
# define STRLEN(str) ((str)? _fstrlen((char FAR*)(str)):0)
# define STREQ(a, b) (_fstrcmp((char FAR*)(a), (char FAR*)(b) == 0)
# endif
# endif /* WIN32 */
# define SYSERR (-1)
# ifndef NULL
# define NULL ((void FAR*)0UL)
# endif
#endif
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -13,8 +13,7 @@
#include "psqlodbc.h"
struct lo_arg
{
struct lo_arg {
int isint;
int len;
union
......@@ -46,3 +45,4 @@ int lo_tell(ConnectionClass *conn, int fd);
int lo_unlink(ConnectionClass *conn, Oid lobjId);
#endif
This diff is collapsed.
......@@ -39,37 +39,35 @@
#ifdef MY_LOG
#define MYLOGFILE "mylog_"
#ifndef WIN32
#define MYLOGDIR "/tmp"
#else
#define MYLOGDIR "c:"
#endif
extern void mylog(char *fmt,...);
#define MYLOGFILE "mylog_"
#ifndef WIN32
#define MYLOGDIR "/tmp"
#else
#define MYLOGDIR "c:"
#endif
extern void mylog(char * fmt, ...);
#else
#ifndef WIN32
#define mylog(args...) /* GNU convention for variable arguments */
#else
#define mylog /* mylog */
#endif
#ifndef WIN32
#define mylog(args...) /* GNU convention for variable arguments */
#else
#define mylog /* mylog */
#endif
#endif
#ifdef Q_LOG
#define QLOGFILE "psqlodbc_"
#ifndef WIN32
#define QLOGDIR "/tmp"
#else
#define QLOGDIR "c:"
#endif
extern void qlog(char *fmt,...);
#define QLOGFILE "psqlodbc_"
#ifndef WIN32
#define QLOGDIR "/tmp"
#else
#define QLOGDIR "c:"
#endif
extern void qlog(char * fmt, ...);
#else
#ifndef WIN32
#define qlog(args...) /* GNU convention for variable arguments */
#else
#define qlog /* qlog */
#endif
#ifndef WIN32
#define qlog(args...) /* GNU convention for variable arguments */
#else
#define qlog /* qlog */
#endif
#endif
#ifndef WIN32
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -17,7 +17,7 @@
#if 0
#define PG_TYPE_LO ????/* waiting for permanent type */
#define PG_TYPE_LO ???? /* waiting for permanent type */
#endif
#define PG_TYPE_BOOL 16
......@@ -95,3 +95,4 @@ char *pgtype_create_params(StatementClass *stmt, Int4 type);
Int2 sqltype_to_default_ctype(Int2 sqltype);
#endif
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment