Commit 755a8733 authored by Bruce Momjian's avatar Bruce Momjian

Run pgindent over ODBC source. We couldn't do this years ago because we

weren't the master source.  We are now, and it really needs it.
parent 505a828a
This diff is collapsed.
......@@ -15,18 +15,24 @@
/*
* 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;
......@@ -36,12 +42,13 @@ 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;
};
BindInfoClass *create_empty_bindings(int num_columns);
void extend_bindings(StatementClass *stmt, int num_columns);
void extend_bindings(StatementClass * stmt, int num_columns);
#endif
......@@ -20,11 +20,12 @@
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;
......@@ -37,7 +38,7 @@ ColumnInfoClass *rv;
}
void
CI_Destructor(ColumnInfoClass *self)
CI_Destructor(ColumnInfoClass * self)
{
CI_free_memory(self);
......@@ -49,16 +50,16 @@ CI_Destructor(ColumnInfoClass *self)
If self is null, then just read, don't store.
*/
char
CI_read_fields(ColumnInfoClass *self, ConnectionClass *conn)
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;
......@@ -68,19 +69,22 @@ ConnInfo *ci;
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);
......@@ -104,14 +108,15 @@ ConnInfo *ci;
void
CI_free_memory(ColumnInfoClass *self)
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 */
......@@ -124,28 +129,27 @@ int num_fields = self->num_fields;
}
void
CI_set_num_fields(ColumnInfoClass *self, int new_num_fields)
CI_set_num_fields(ColumnInfoClass * self, int new_num_fields)
{
CI_free_memory(self); /* always safe to call */
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);
}
void
CI_set_field_info(ColumnInfoClass *self, int field_num, char *new_name,
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,4 +159,3 @@ CI_set_field_info(ColumnInfoClass *self, int field_num, char *new_name,
self->display_size[field_num] = 0;
}
......@@ -12,7 +12,8 @@
#include "psqlodbc.h"
struct ColumnInfoClass_ {
struct ColumnInfoClass_
{
Int2 num_fields;
char **name; /* list of type names */
Oid *adtid; /* list of type ids */
......@@ -29,14 +30,14 @@ struct ColumnInfoClass_ {
#define CI_get_atttypmod(self, col) (self->atttypmod[col])
ColumnInfoClass *CI_Constructor(void);
void CI_Destructor(ColumnInfoClass *self);
void CI_free_memory(ColumnInfoClass *self);
char CI_read_fields(ColumnInfoClass *self, ConnectionClass *conn);
void CI_Destructor(ColumnInfoClass * self);
void CI_free_memory(ColumnInfoClass * self);
char CI_read_fields(ColumnInfoClass * self, ConnectionClass * conn);
/* functions for setting up the fields from within the program, */
/* without reading from a socket */
void CI_set_num_fields(ColumnInfoClass *self, int new_num_fields);
void CI_set_field_info(ColumnInfoClass *self, int field_num, char *new_name,
void CI_set_num_fields(ColumnInfoClass * self, int new_num_fields);
void CI_set_field_info(ColumnInfoClass * self, int field_num, char *new_name,
Oid new_adtid, Int2 new_adtsize, Int4 atttypmod);
......
This diff is collapsed.
......@@ -27,11 +27,14 @@
#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 */
......@@ -122,7 +125,8 @@ typedef struct _StartupPacket
/* 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];
......@@ -180,9 +184,10 @@ 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 */
......@@ -194,7 +199,7 @@ struct col_info {
#define HINSTANCE void *
#endif
typedef BOOL (FAR WINAPI *DataSourceToDriverProc) (UDWORD,
typedef BOOL(FAR WINAPI * DataSourceToDriverProc) (UDWORD,
SWORD,
PTR,
SDWORD,
......@@ -205,7 +210,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,
......@@ -217,8 +222,10 @@ 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;
......@@ -234,9 +241,13 @@ 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;
......@@ -259,24 +270,24 @@ struct ConnectionClass_ {
/* prototypes */
ConnectionClass *CC_Constructor(void);
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);
char CC_connect(ConnectionClass *self, char do_password);
char CC_add_statement(ConnectionClass *self, StatementClass *stmt);
char CC_remove_statement(ConnectionClass *self, StatementClass *stmt);
char CC_get_error(ConnectionClass *self, int *number, char **message);
QResultClass *CC_send_query(ConnectionClass *self, char *query, QueryInfo *qi);
void CC_clear_error(ConnectionClass *self);
char *CC_create_errormsg(ConnectionClass *self);
int CC_send_function(ConnectionClass *conn, int fnid, void *result_buf, int *actual_result_len, int result_is_int, LO_ARG *argv, int nargs);
char CC_send_settings(ConnectionClass *self);
void CC_lookup_lo(ConnectionClass *conn);
void CC_lookup_pg_version(ConnectionClass *conn);
void CC_initialize_pg_version(ConnectionClass *conn);
void CC_log_error(char *func, char *desc, ConnectionClass *self);
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);
char CC_connect(ConnectionClass * self, char do_password);
char CC_add_statement(ConnectionClass * self, StatementClass * stmt);
char CC_remove_statement(ConnectionClass * self, StatementClass * stmt);
char CC_get_error(ConnectionClass * self, int *number, char **message);
QResultClass *CC_send_query(ConnectionClass * self, char *query, QueryInfo * qi);
void CC_clear_error(ConnectionClass * self);
char *CC_create_errormsg(ConnectionClass * self);
int CC_send_function(ConnectionClass * conn, int fnid, void *result_buf, int *actual_result_len, int result_is_int, LO_ARG * argv, int nargs);
char CC_send_settings(ConnectionClass * self);
void CC_lookup_lo(ConnectionClass * conn);
void CC_lookup_pg_version(ConnectionClass * conn);
void CC_initialize_pg_version(ConnectionClass * conn);
void CC_log_error(char *func, char *desc, ConnectionClass * self);
#endif
This diff is collapsed.
......@@ -20,7 +20,8 @@
#define COPY_GENERAL_ERROR 4
#define COPY_NO_DATA_FOUND 5
typedef struct {
typedef struct
{
int m;
int d;
int y;
......@@ -29,14 +30,14 @@ typedef struct {
int ss;
} SIMPLE_TIME;
int copy_and_convert_field_bindinfo(StatementClass *stmt, Int4 field_type, void *value, int col);
int copy_and_convert_field(StatementClass *stmt, Int4 field_type, void *value, Int2 fCType,
PTR rgbValue, SDWORD cbValueMax, SDWORD *pcbValue);
int copy_and_convert_field_bindinfo(StatementClass * stmt, Int4 field_type, void *value, int col);
int copy_and_convert_field(StatementClass * stmt, Int4 field_type, void *value, Int2 fCType,
PTR rgbValue, SDWORD cbValueMax, SDWORD * pcbValue);
int copy_statement_with_parameters(StatementClass *stmt);
int copy_statement_with_parameters(StatementClass * stmt);
char *convert_escape(char *value);
char *convert_money(char *s);
char parse_datetime(char *buf, SIMPLE_TIME *st);
char parse_datetime(char *buf, SIMPLE_TIME * st);
int convert_linefeeds(char *s, char *dst, size_t max);
char *convert_special_chars(char *si, char *dst, int used);
......@@ -45,7 +46,7 @@ int convert_from_pgbinary(unsigned char *value, unsigned char *rgbValue, int cbV
int convert_to_pgbinary(unsigned char *in, char *out, int len);
void encode(char *in, char *out);
void decode(char *in, char *out);
int convert_lo(StatementClass *stmt, void *value, Int2 fCType, PTR rgbValue,
SDWORD cbValueMax, SDWORD *pcbValue);
int convert_lo(StatementClass * stmt, void *value, Int2 fCType, PTR rgbValue,
SDWORD cbValueMax, SDWORD * pcbValue);
#endif
This diff is collapsed.
......@@ -31,23 +31,26 @@
/* 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 */
......@@ -55,17 +58,22 @@
#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_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_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"
......@@ -90,7 +98,8 @@
/* 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
......@@ -118,8 +127,8 @@
void getGlobalDefaults(char *section, char *filename, char override);
#ifdef WIN32
void SetDlgStuff(HWND hdlg, ConnInfo *ci);
void GetDlgStuff(HWND hdlg, ConnInfo *ci);
void SetDlgStuff(HWND hdlg, ConnInfo * ci);
void GetDlgStuff(HWND hdlg, ConnInfo * ci);
int CALLBACK driver_optionsProc(HWND hdlg,
WORD wMsg,
......@@ -129,14 +138,15 @@ int CALLBACK ds_optionsProc(HWND hdlg,
WORD wMsg,
WPARAM wParam,
LPARAM lParam);
#endif /* WIN32 */
void updateGlobals(void);
void writeDSNinfo(ConnInfo *ci);
void getDSNdefaults(ConnInfo *ci);
void getDSNinfo(ConnInfo *ci, char overwrite);
void makeConnectString(char *connect_string, ConnInfo *ci);
void copyAttributes(ConnInfo *ci, char *attribute, char *value);
void writeDSNinfo(ConnInfo * ci);
void getDSNdefaults(ConnInfo * ci);
void getDSNinfo(ConnInfo * ci, char overwrite);
void makeConnectString(char *connect_string, ConnInfo * ci);
void copyAttributes(ConnInfo * ci, char *attribute, char *value);
#endif
......@@ -52,45 +52,50 @@
#include "dlg_specific.h"
/* prototypes */
void dconn_get_connect_attributes(UCHAR FAR *connect_string, ConnInfo *ci);
void dconn_get_connect_attributes(UCHAR FAR * connect_string, ConnInfo * ci);
#ifdef WIN32
BOOL FAR PASCAL dconn_FDriverConnectProc(HWND hdlg, UINT wMsg, WPARAM wParam, LPARAM lParam);
RETCODE dconn_DoDialog(HWND hwnd, ConnInfo *ci);
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,
UCHAR FAR * szConnStrIn,
SWORD cbConnStrIn,
UCHAR FAR *szConnStrOut,
UCHAR FAR * szConnStrOut,
SWORD cbConnStrOutMax,
SWORD FAR *pcbConnStrOut,
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;
}
......@@ -120,13 +125,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:
......@@ -136,17 +141,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:
......@@ -157,14 +162,17 @@ 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;
......@@ -173,12 +181,16 @@ 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;
......@@ -187,7 +199,8 @@ 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;
......@@ -201,25 +214,29 @@ 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);
......@@ -231,35 +248,38 @@ 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;
......@@ -274,7 +294,8 @@ ConnInfo *ci;
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);
......@@ -293,7 +314,8 @@ ConnInfo *ci;
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);
......@@ -328,11 +350,15 @@ ConnInfo *ci;
#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));
......@@ -341,17 +367,16 @@ char *strtok_arg;
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';
......@@ -360,7 +385,7 @@ char *strtok_arg;
mylog("attribute = '%s', value = '%s'\n", attribute, value);
if( !attribute || !value)
if (!attribute || !value)
continue;
/* Copy the appropriate value to the conninfo */
......@@ -371,4 +396,3 @@ char *strtok_arg;
free(our_connect_string);
}
This diff is collapsed.
......@@ -29,17 +29,18 @@
#define ENV_ALLOC_ERROR 1
/********** Environment Handle *************/
struct EnvironmentClass_ {
struct EnvironmentClass_
{
char *errormsg;
int errornumber;
};
/* Environment prototypes */
EnvironmentClass *EN_Constructor(void);
char EN_Destructor(EnvironmentClass *self);
char EN_get_error(EnvironmentClass *self, int *number, char **message);
char EN_add_connection(EnvironmentClass *self, ConnectionClass *conn);
char EN_remove_connection(EnvironmentClass *self, ConnectionClass *conn);
void EN_log_error(char *func, char *desc, EnvironmentClass *self);
char EN_Destructor(EnvironmentClass * self);
char EN_get_error(EnvironmentClass * self, int *number, char **message);
char EN_add_connection(EnvironmentClass * self, ConnectionClass * conn);
char EN_remove_connection(EnvironmentClass * self, ConnectionClass * conn);
void EN_log_error(char *func, char *desc, EnvironmentClass * self);
#endif
This diff is collapsed.
This diff is collapsed.
......@@ -13,25 +13,32 @@
#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,7 +13,8 @@
#include "psqlodbc.h"
struct lo_arg {
struct lo_arg
{
int isint;
int len;
union
......@@ -35,14 +36,13 @@ struct lo_arg {
#define INV_WRITE 0x00020000
#define INV_READ 0x00040000
Oid lo_creat(ConnectionClass *conn, int mode);
int lo_open(ConnectionClass *conn, int lobjId, int mode);
int lo_close(ConnectionClass *conn, int fd);
int lo_read(ConnectionClass *conn, int fd, char *buf, int len);
int lo_write(ConnectionClass *conn, int fd, char *buf, int len);
int lo_lseek(ConnectionClass *conn, int fd, int offset, int len);
int lo_tell(ConnectionClass *conn, int fd);
int lo_unlink(ConnectionClass *conn, Oid lobjId);
Oid lo_creat(ConnectionClass * conn, int mode);
int lo_open(ConnectionClass * conn, int lobjId, int mode);
int lo_close(ConnectionClass * conn, int fd);
int lo_read(ConnectionClass * conn, int fd, char *buf, int len);
int lo_write(ConnectionClass * conn, int fd, char *buf, int len);
int lo_lseek(ConnectionClass * conn, int fd, int offset, int len);
int lo_tell(ConnectionClass * conn, int fd);
int lo_unlink(ConnectionClass * conn, Oid lobjId);
#endif
This diff is collapsed.
......@@ -39,35 +39,37 @@
#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.
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