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