bk commit - MyODBC 3.51 (1.514)
am 04.10.2005 23:28:16 von pharveyBelow is the list of changes that have just been commited into a local
MyODBC 3.51 repository of 'pharvey'. When 'pharvey' does a push, they will
be propogaged to the main repository and within 2 hours after the push
into the public repository.
For more information on how to access the public repository see:
http://www.mysql.com/products/myodbc/faq_2.html#Development_ source
You can also browse the changes from public repository:
Complete repository: http://mysql.bkbits.net:8080/myodbc3/
This changeset : http://mysql.bkbits.net:8080/myodbc3/cset@1.514
ChangeSet
1.514 05/10/04 14:28:11 pharvey@sun.codebydesign.com +8 -0
- now uses ODBCINI env var again (but just for SQLConnect at the moment)
- cleaned out some old ini i/o code as we cannow rely upon a free SDK on all platforms which provide this - even for driver only solutions
util/util.vpj
1.2 05/10/04 14:27:40 pharvey@sun.codebydesign.com +1 -0
- now uses ODBCINI env var again (but just for SQLConnect at the moment)
- cleaned out some old ini i/o code as we cannow rely upon a free SDK on all platforms which provide this - even for driver only solutions
util/MYODBCUtil.h
1.15 05/10/04 14:27:40 pharvey@sun.codebydesign.com +2 -1
- now uses ODBCINI env var again (but just for SQLConnect at the moment)
- cleaned out some old ini i/o code as we cannow rely upon a free SDK on all platforms which provide this - even for driver only solutions
driver/driver.vpj
1.5 05/10/04 14:27:40 pharvey@sun.codebydesign.com +0 -1
- now uses ODBCINI env var again (but just for SQLConnect at the moment)
- cleaned out some old ini i/o code as we cannow rely upon a free SDK on all platforms which provide this - even for driver only solutions
driver/driver.pro
1.6 05/10/04 14:27:40 pharvey@sun.codebydesign.com +1 -1
- now uses ODBCINI env var again (but just for SQLConnect at the moment)
- cleaned out some old ini i/o code as we cannow rely upon a free SDK on all platforms which provide this - even for driver only solutions
driver/connect.c
1.76 05/10/04 14:27:40 pharvey@sun.codebydesign.com +17 -22
- now uses ODBCINI env var again (but just for SQLConnect at the moment)
- cleaned out some old ini i/o code as we cannow rely upon a free SDK on all platforms which provide this - even for driver only solutions
driver/Makefile.am
1.23 05/10/04 14:27:40 pharvey@sun.codebydesign.com +0 -1
- now uses ODBCINI env var again (but just for SQLConnect at the moment)
- cleaned out some old ini i/o code as we cannow rely upon a free SDK on all platforms which provide this - even for driver only solutions
BitKeeper/deleted/.del-misc.c~ec9496e423e8965e
1.23 05/10/04 13:24:54 pharvey@sun.codebydesign.com +7 -165
Delete: driver/misc.c
util/MYODBCUtilGetIniFileName.c
1.1 05/10/04 13:24:33 pharvey@sun.codebydesign.com +43 -0
util/MYODBCUtilGetIniFileName.c
1.0 05/10/04 13:24:33 pharvey@sun.codebydesign.com +0 -0
BitKeeper file /home/pharvey/SandBox/32/myodbc-3.51/util/MYODBCUtilGetIniFi leName.c
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: pharvey
# Host: sun.codebydesign.com
# Root: /home/pharvey/SandBox/32/myodbc-3.51
--- 1.75/driver/connect.c 2005-08-22 02:27:52 -07:00
+++ 1.76/driver/connect.c 2005-10-04 14:27:40 -07:00
@@ -182,13 +182,13 @@
@purpose : to connect to mysql server
*/
-SQLRETURN SQL_API SQLConnect(SQLHDBC hdbc,
- SQLCHAR FAR *szDSN,
- SQLSMALLINT cbDSN,
- SQLCHAR FAR *szUID,
- SQLSMALLINT cbUID,
- SQLCHAR FAR *szAuthStr,
- SQLSMALLINT cbAuthStr)
+SQLRETURN SQL_API SQLConnect( SQLHDBC hdbc,
+ SQLCHAR FAR * szDSN,
+ SQLSMALLINT cbDSN,
+ SQLCHAR FAR * szUID,
+ SQLSMALLINT cbUID,
+ SQLCHAR FAR * szAuthStr,
+ SQLSMALLINT cbAuthStr )
{
char host[64],user[64],passwd[64],dsn[NAME_LEN+1],database[NAME_L EN+1];
char port[10],flag[10],init_stmt[256],*dsn_ptr;
@@ -210,33 +210,28 @@
DBUG_RETURN(set_conn_error(hdbc, MYERR_S1000,
"Invalid Connection Parameters",0));
- SQLGetPrivateProfileString(dsn_ptr,"user","", user, sizeof(user),"ODBC.INI");
- SQLGetPrivateProfileString(dsn_ptr,"password","", passwd, sizeof(passwd),"ODBC.INI");
- SQLGetPrivateProfileString(dsn_ptr,"server","localhost", host, sizeof(host),"ODBC.INI");
- SQLGetPrivateProfileString(dsn_ptr,"database",dsn_ptr, database, sizeof(database),"ODBC.INI");
- SQLGetPrivateProfileString(dsn_ptr,"port","0", port, sizeof(port),"ODBC.INI");
+ SQLGetPrivateProfileString(dsn_ptr,"user","", user, sizeof(user), MYODBCUtilGetIniFileName( TRUE ) );
+ SQLGetPrivateProfileString(dsn_ptr,"password","", passwd, sizeof(passwd), MYODBCUtilGetIniFileName( TRUE ) );
+ SQLGetPrivateProfileString(dsn_ptr,"server","localhost", host, sizeof(host), MYODBCUtilGetIniFileName( TRUE ) );
+ SQLGetPrivateProfileString(dsn_ptr,"database",dsn_ptr, database, sizeof(database), MYODBCUtilGetIniFileName( TRUE ) );
+ SQLGetPrivateProfileString(dsn_ptr,"port","0", port, sizeof(port), MYODBCUtilGetIniFileName( TRUE ) );
port_nr= (uint) atoi(port);
- SQLGetPrivateProfileString(dsn_ptr,"option","0", flag, sizeof(flag),"ODBC.INI");
+ SQLGetPrivateProfileString(dsn_ptr,"option","0", flag, sizeof(flag), MYODBCUtilGetIniFileName( TRUE ) );
flag_nr= (ulong) atol(flag);
#ifdef _UNIX_
- SQLGetPrivateProfileString(dsn_ptr,"socket",
- "", socket, sizeof(socket),"ODBC.INI");
+ SQLGetPrivateProfileString(dsn_ptr,"socket", "", socket, sizeof(socket), MYODBCUtilGetIniFileName( TRUE ) );
#endif
- SQLGetPrivateProfileString(dsn_ptr,"stmt",
- "", init_stmt, sizeof(init_stmt),"ODBC.INI");
-
- SQLGetPrivateProfileString(dsn_ptr, "TRACE", "", szTRACE, sizeof(szTRACE),
- "ODBC.INI");
+ SQLGetPrivateProfileString(dsn_ptr,"stmt", "", init_stmt, sizeof(init_stmt), MYODBCUtilGetIniFileName( TRUE ) );
+ SQLGetPrivateProfileString(dsn_ptr, "TRACE", "", szTRACE, sizeof(szTRACE), MYODBCUtilGetIniFileName( TRUE ) );
if (szTRACE[0] == '0' || szTRACE[0] == 'N' || szTRACE[0] == 'n' ||
((szTRACE[0] == 'O' || szTRACE[0] == 'o') &&
(szTRACE[1] == 'N' || szTRACE[1] == 'n')))
{
char szTRACEFILE[FILENAME_MAX+1]= "";
char szMYODBC_LOG[FILENAME_MAX+20]= "";
- SQLGetPrivateProfileString(dsn_ptr, "TRACEFILE", "", szTRACEFILE,
- sizeof(szTRACEFILE), "ODBC.INI");
+ SQLGetPrivateProfileString(dsn_ptr, "TRACEFILE", "", szTRACEFILE, sizeof(szTRACEFILE), MYODBCUtilGetIniFileName( TRUE ) );
if (*szTRACEFILE)
{
sprintf(szMYODBC_LOG, "d:t:F:L:S:A,%s", szTRACEFILE);
--- 1.22/driver/Makefile.am 2005-01-28 11:33:49 -08:00
+++ 1.23/driver/Makefile.am 2005-10-04 14:27:40 -07:00
@@ -46,7 +46,6 @@
execute.c \
handle.c\
info.c \
-misc.c \
myodbc3.c \
options.c \
prepare.c \
--- 1.22/driver/misc.c 2005-08-22 02:27:52 -07:00
+++ 1.23/BitKeeper/deleted/.del-misc.c~ec9496e423e8965e 2005-10-04 13:24:54 -07:00
@@ -31,176 +31,18 @@
#include "myodbc3.h"
-#if defined(_UNIX_)
-
#include
-static void open_ini_files(FILE **sys_file, FILE **user_file)
-{
- char *home_dir, *odbcini;
- FILE *system_ini= NULL, *user_ini= NULL;
-
- if ((odbcini= getenv("ODBCINI")))
- user_ini= fopen(odbcini,"r");
-
- /* only look in $HOME/.odbc.ini if $ODBCINI wasn't there */
- if (!user_ini)
- {
- /* find the homedir */
- if (!(home_dir= getenv("HOME")))
- {
- struct passwd *pwd;
- /*
- WARNING:
- The following is clearly not threadsafe in
- most environments
- */
- if ((pwd= getpwuid(getuid())))
- home_dir= pwd->pw_dir;
- }
-
- if (home_dir && home_dir[0])
- {
- char tmp[1024];
- strxmov(tmp, home_dir, "/.odbc.ini", NullS);
- user_ini= fopen(tmp,"r");
- }
- }
-
- system_ini= fopen(SYSTEM_ODBC_INI,"r");
- *sys_file= system_ini;
- *user_file= user_ini;
-}
-
-
-static void close_ini_files(FILE *sys_file, FILE *user_file)
-{
- if (sys_file)
- fclose(sys_file);
- if (user_file)
- fclose(user_file);
-}
-
-/* skip space */
-
-static inline char *skip_space(char *pos)
-{
- while (isspace(*pos))
- pos++;
- return pos;
-}
-
-
-/* skip end space; Terminate string with \0 */
-
-static char *skip_end_space(char *pos, char *end)
-{
- while (end > pos && isspace(end[-1]))
- end--;
- *end= 0;
- return end;
-}
-
-
-/*
- Searches for a section, returns non-zero on success
-
- If successeful, positions on the line after the section
- name.
-*/
-
-static int
-find_section(FILE *ini, const char *section)
-{
- char buf[1024];
-
- while (fgets(buf,sizeof(buf)-1,ini))
- {
- char *pos= skip_space(buf);
- char *end;
-
- if (!*pos || *pos == ';' || *pos =='#')
- continue; /* comment or empty line */
-
- if (*pos == '[') /* Found new section */
- {
- pos= skip_space(pos+1);
- end= strchr(pos+1, ']');
- if (end)
- {
- skip_end_space(pos, end); /* Terminates pos */
- if (!myodbc_strcasecmp(pos, section))
- return 1; /* Found section */
- }
- }
- }
- return 0;
-}
-
-
-/*
- Returns NULL if not found, otherwise result must be freed with my_free()
- Expects ini to be positioned at the beginning of a section
-*/
-
-static char *
-find_key(FILE *ini, const char *key)
-{
- char buf[1024], *value= NullS;
-
- /* if any of those starts a line, the line is ignored */
- static const char *skipchars= ";#=\r\n";
-
- while (fgets(buf,sizeof(buf)-1,ini))
- {
- char *tmp, *pos= buf;
-
- pos= skip_space(pos);
- if (!*pos || strchr(skipchars,*pos))
- continue; /* comment or empty line */
- if (*pos == '[')
- break; /* new section */
-
- if ((tmp= strchr(pos,'=')))
- {
- skip_end_space(pos, tmp); /* Will \0 terminate pos */
- if (!myodbc_strcasecmp(pos, key))
- {
- char *end;
- tmp= skip_space(tmp+1); /* Skip '=' and spaces */
- end= skip_end_space(tmp, strend(tmp));
- value= my_strdup_with_length(tmp, (uint) (end-tmp), MYF(0));
- break;
- }
- }
- }
- return value;
-}
-
-
-/*
- First look for key in the user ini file, then in system.
- Do not mix up values from both.
-
- NOTE: key must be freed with my_free()
-*/
-
-static char *
-find_key_by_dsn(const char *dsn, const char *key)
+char *getIniFileName( my_bool bUseEnvVar )
{
- FILE *sys;
- FILE *user;
- char *ret= NULL;
+ char *pszIniFileName = NULL;
- open_ini_files(&sys,&user);
+ if ( bUseEnvVar )
+ pszIniFileName = getenv( "ODBCINI" );
- if (user && find_section(user,dsn))
- ret= find_key(user,key);
- else if (sys && find_section(sys,dsn))
- ret= find_key(sys,key);
+ if ( !pszIniFileName )
+ pszIniFileName = "odbc.ini";
- close_ini_files(sys,user);
- return ret;
+ return pszIniFileName;
}
-#endif /* defined(_UNIX_) */
--- 1.14/util/MYODBCUtil.h 2005-08-22 02:27:52 -07:00
+++ 1.15/util/MYODBCUtil.h 2005-10-04 14:27:40 -07:00
@@ -46,7 +46,7 @@
Handle case on OSX where we want to use GetPrivateProfileString (because it
actually works properly) instead of SQLGetPrivateProfileString but
GetPrivateProfileString does not exist because we are dealing with 10.4 or
- newer.
+ newer - I admit - this is a bit of a hack.
*/
#ifndef GetPrivateProfileString
#define GetPrivateProfileString SQLGetPrivateProfileString
@@ -194,6 +194,7 @@
BOOL MYODBCUtilGetDriverNames( char *pszBuffer, int nBuffer );
BOOL MYODBCUtilGetDataSourceNames( char *pszBuffer, int nBuffer, UWORD nScope );
+char * MYODBCUtilGetIniFileName( BOOL bUseEnvVar );
/* MYODBCUTIL_DRIVER */
MYODBCUTIL_DRIVER * MYODBCUtilAllocDriver();
--- 1.5/driver/driver.pro 2005-09-20 22:19:19 -07:00
+++ 1.6/driver/driver.pro 2005-10-04 14:27:40 -07:00
@@ -110,7 +110,6 @@
execute.c \
handle.c \
info.c \
- misc.c \
myodbc3.c \
options.c \
prepare.c \
@@ -127,6 +126,7 @@
../util/MYODBCUtilFreeDriver.c \
../util/MYODBCUtilGetDataSourceNames.c \
../util/MYODBCUtilGetDriverNames.c \
+ ../util/MYODBCUtilGetIniFileName.c \
../util/MYODBCUtilInsertStr.c \
../util/MYODBCUtilReadConnectStr.c \
../util/MYODBCUtilReadDataSource.c \
--- 1.4/driver/driver.vpj 2005-09-11 16:46:34 -07:00
+++ 1.5/driver/driver.vpj 2005-10-04 14:27:40 -07:00
@@ -60,7 +60,6 @@
-
--- 1.1/util/util.vpj 2005-08-05 22:57:15 -07:00
+++ 1.2/util/util.vpj 2005-10-04 14:27:40 -07:00
@@ -62,6 +62,7 @@
+
--- New file ---
+++ util/MYODBCUtilGetIniFileName.c 05/10/04 13:24:33
/* Copyright (C) 2000-2005 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
There are special exceptions to the terms and conditions of the GPL as it
is applied to this software. View the full text of the exception in file
EXCEPTIONS in the directory of this software distribution.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include "MYODBCUtil.h"
/*!
\brief Get the file name to use for SQLGetPrivateProfileString().
Not all calls to SQLGetPrivateProfileString will want to use this
but it should be used when getting DSN details for a SQLConnect.
\param bUseEnvVar True if caller wants the ODBCINI env var to be returned (if its set).
*/
char *MYODBCUtilGetIniFileName( BOOL bUseEnvVar )
{
char *pszIniFileName = NULL;
if ( bUseEnvVar )
pszIniFileName = getenv( "ODBCINI" );
if ( !pszIniFileName )
pszIniFileName = "odbc.ini";
return pszIniFileName;
}
--
MySQL ODBC Mailing List
For list archives: http://lists.mysql.com/myodbc
To unsubscribe: http://lists.mysql.com/myodbc?unsub=gcdmo-myodbc@m.gmane.org