Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,8 @@ mac/iODBCtest/build/
mac/iODBCtestw/build/
mac/include/
mac/**/xcuserdata/

#
# IDE configuration files
#
.idea/
86 changes: 50 additions & 36 deletions README_MACOSX.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,28 @@ Packages, which you can download from <http://developer.apple.com/tools>.
Then, execute the following commands in a terminal session, to build all the frameworks and demo applications:

```shell
$ cd mac
$ make
cd mac
make
```

If there are errors, first try to clean up temporary files:

```shell
sudo make clean
```

After building the iODBC libraries and applications, you have to install them on your system with the command:

```shell
$ sudo make install
sudo make install
```

To generate and install a development build with debug symbols, run:

```shell
sudo make realclean
make MODEL=Development
sudo make install MODEL=Development
```

This installs the `iODBCinst` and `iODBC` frameworks into —
Expand Down Expand Up @@ -86,16 +100,16 @@ using the [HomeBrew package manager](http://brew.sh/) to install these tools, ac
To build the libraries, open up a terminal session in **`Terminal.app`** or similar, and execute the following commands:

```shell
$ sh autogen.sh
$ ./configure
$ make
sh autogen.sh
./configure
make
```

To install the header files and libraries in `/usr/local`, execute the following command as an administrator,
and provide that user's password when prompted:

```shell
$ sudo make install
sudo make install
```

Note that, by default, this will build components that only run on the CPU type you are building on, so `ppc`
Expand All @@ -112,18 +126,18 @@ The following commands will build a release of iODBC that supports Mac OS X Leop
Mac OS X Snow Leopard (10.6), on `ppc` (including as emulated by Rosetta), `x86`, and `x86_64`:

```shell
$ CFLAGS="-O -arch ppc -arch i386 -arch x86_64"
$ CFLAGS="$CFLAGS -isysroot /Developer/SDKs/MacOSX10.5.sdk"
$ CFLAGS="$CFLAGS -mmacosx-version-min=10.5"
$ export CFLAGS
CFLAGS="-O -arch ppc -arch i386 -arch x86_64"
CFLAGS="$CFLAGS -isysroot /Developer/SDKs/MacOSX10.5.sdk"
CFLAGS="$CFLAGS -mmacosx-version-min=10.5"
export CFLAGS

$ sh autogen.sh
$ ./configure \
sh autogen.sh
./configure \
--disable-dependency-tracking \
--prefix=/usr/local/iODBC.universal

$ make
$ sudo make install
make
sudo make install
```

### Mac OS X Lion (10.7) and OS X Mountain Lion (10.8)
Expand All @@ -132,17 +146,17 @@ The following commands will build a release of iODBC that works on Mac OS X Lion
and OS X Mountain Lion (10.8):

```shell
$ CFLAGS="-O -arch i386 -arch x86_64"
$ CFLAGS="$CFLAGS -mmacosx-version-min=10.7"
$ export CFLAGS
CFLAGS="-O -arch i386 -arch x86_64"
CFLAGS="$CFLAGS -mmacosx-version-min=10.7"
export CFLAGS

$ sh autogen.sh
$ ./configure \
sh autogen.sh
./configure \
--disable-dependency-tracking \
--prefix=/usr/local/iODBC.universal

$ make
$ sudo make install
make
sudo make install
```

### OS X Mavericks (10.9) through macOS Big Sur (11.x) on `x86` or `x86_64` (including Rosetta2 emulation)
Expand All @@ -152,17 +166,17 @@ supporting other components built for `x86` (through macOS Mojave (10.14), where
components) or `x86_64` (including Rosetta2 emulation):

```shell
$ CFLAGS="-O -arch i386 -arch x86_64"
$ CFLAGS="$CFLAGS -mmacosx-version-min=10.9"
$ export CFLAGS
CFLAGS="-O -arch i386 -arch x86_64"
CFLAGS="$CFLAGS -mmacosx-version-min=10.9"
export CFLAGS

$ sh autogen.sh
$ ./configure \
sh autogen.sh
./configure \
--disable-dependency-tracking \
--prefix=/usr/local/iODBC.universal

$ make
$ sudo make install
$make
sudo make install
```

### macOS Big Sur (11.x) through macOS Ventura (13.x) on `x86_64` (including Rosetta2 emulation) or `arm64` (Apple Silicon a/k/a M1 or M2)
Expand All @@ -171,17 +185,17 @@ The following commands will build a release of iODBC that works on macOS Big Sur
running on Intel (`x86_64`) or Apple Silicon (`arm64` a/k/a `M1` or `M2`):

```shell
$ CFLAGS="-O -arch arm64 -arch x86_64"
$ CFLAGS="$CFLAGS -mmacosx-version-min=10.9"
$ export CFLAGS
CFLAGS="-O -arch arm64 -arch x86_64"
CFLAGS="$CFLAGS -mmacosx-version-min=10.9"
export CFLAGS

$ sh autogen.sh
$ ./configure \
sh autogen.sh
./configure \
--disable-dependency-tracking \
--prefix=/usr/local/iODBC.universal

$ make
$ sudo make install
make
sudo make install
```

### Test DSN connection
Expand Down
5 changes: 4 additions & 1 deletion drvproxy/mac/IODBCProxy_LoginController.m
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,16 @@ BOOL showLogin(const char* title, const char *username, const char *password, TL

NSInteger rc = [app runModalForWindow:dlg.window];
[dlg.window orderOut:dlg.window];

BOOL result = FALSE;
if (log_t && rc == 1){
log_t->user = (char*)conv_NSString_to_char(dlg.d_uid);
log_t->pwd = (char*)conv_NSString_to_char(dlg.d_pwd);
log_t->ok = 1;
result = TRUE;
}
[dlg release];
return rc == 1 ? TRUE : FALSE;
return result;
}

}
Expand Down
58 changes: 55 additions & 3 deletions iodbcadm/drvconn.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,14 +272,15 @@ iodbcdm_drvconn_dialboxw (
TDSNCHOOSER choose_t;
wchar_t *string = NULL, *prov, *prov1, *szDSN = NULL, *szDriver = NULL;
wchar_t *szFILEDSN = NULL, *szSAVEFILE = NULL;
wchar_t tokenstr[4096];
wchar_t tokenstr[4096]= { L'\0' };
wchar_t drvbuf[4096] = { L'\0'};
char *_szdriver_u8 = NULL;
wchar_t *_szdriver_w = NULL;
HDLL handle;
pDriverConnFunc pDrvConn;
pDriverConnWFunc pDrvConnW;
int i, skip;
size_t offset = 0;
#if defined (__APPLE__) && !defined (NO_FRAMEWORKS)
CFBundleRef bundle = NULL;
CFBundleRef bundle_dll = NULL;
Expand Down Expand Up @@ -379,15 +380,66 @@ iodbcdm_drvconn_dialboxw (
{
WCSCPY (string, L"DSN=");
WCSCAT (string, choose_t.dsn);
string[WCSLEN (string) + 1] = L'\0';
szDSN = string + WCSLEN (L"DSN=");
szDSN = choose_t.dsn + L'\0';
retcode = SQL_SUCCESS;
}
else
{
if (sqlStat)
*sqlStat = errSqlStat;
}

/* Try to copy the DSN parameters */
offset = WCSLEN(string);
size_t remaining_space = cbInOutConnStr - offset;
BOOL buffer_error = FALSE;

/* Set configuration mode once before reading parameters */
SQLSetConfigMode(choose_t.type_dsn == SYSTEM_DSN ? ODBC_SYSTEM_DSN : ODBC_USER_DSN);

/* Explicitly read parameters from odbc.ini */
if (SQLGetPrivateProfileStringW(szDSN, NULL, L"",
tokenstr, sizeof(tokenstr)/sizeof(wchar_t), L"odbc.ini"))
{
/* Add each parameter to the connection string with semicolons */
for (wchar_t *paramName = tokenstr; *paramName != L'\0'; paramName += (WCSLEN(paramName) + 1))
{
wchar_t valueBuf[1024] = { L'\0' };

/* Skip "Driver" parameter if present in odbc.ini */
if (WCSCASEEQ(paramName, L"Driver"))
continue;

/* Get the value for this parameter */
SQLGetPrivateProfileStringW(szDSN, paramName, L"",
valueBuf, sizeof(valueBuf)/sizeof(wchar_t),
L"odbc.ini");

size_t param_space = 1 + WCSLEN(paramName) + 1 + WCSLEN(valueBuf);

/* Check if enough space remains */
if (remaining_space > param_space) {
string[offset++] = L';';
WCSCPY(string + offset, paramName);
offset += WCSLEN(paramName);
string[offset++] = L'=';
WCSCPY(string + offset, valueBuf);
offset += WCSLEN(valueBuf);
remaining_space -= param_space;
}
else {
if (sqlStat)
*sqlStat = errSqlStat; /* Use the already defined error state */
retcode = SQL_ERROR;
buffer_error = TRUE;
break;
}
}
if (!buffer_error)
string[offset] = L'\0';

}

}
else if (choose_t.fdsn && choose_t.type_dsn == FILE_DSN)
{
Expand Down
56 changes: 48 additions & 8 deletions iodbcadm/mac/Helpers.m
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ void addDrivers_to_list(NSArrayController* list)
_drv_u8 = (char *) conv_NSString_to_char(a_drv);
if (_drv_u8 == NULL)
goto skip;

if ((handle = DLL_OPEN(_drv_u8)) != NULL)
{
if ((allocHdl = (pSQLAllocHandle)DLL_PROC(handle, "SQLAllocHandle")) != NULL)
Expand Down Expand Up @@ -718,12 +718,56 @@ void test_dsn(BOOL systemDSN, NSString *dsn, NSString *driver)
wchar_t *szDSN = conv_NSString_to_wchar(dsn);
wchar_t *szDriver = conv_NSString_to_wchar(driver);
wchar_t connstr[4096] = { L'\0' }, outconnstr[4096] = { L'\0' };
wchar_t tokenstr[4096] = { L'\0' };
HENV henv;
HDBC hdbc;
SWORD buflen;

size_t offset = 0;

if (szDSN && szDriver){
/* Start with basic DSN */
WCSCPY(connstr, L"DSN=");
WCSCAT(connstr, szDSN);
offset = WCSLEN(connstr);

/* Set configuration mode once before reading parameters */
SQLSetConfigMode(systemDSN ? ODBC_SYSTEM_DSN : ODBC_USER_DSN);

/* Explicitly read parameters from odbc.ini */
if (SQLGetPrivateProfileStringW(szDSN, NULL, L"",
tokenstr, sizeof(tokenstr)/sizeof(wchar_t), L"odbc.ini"))
{
/* Add each parameter to the connection string with semicolons */
for (wchar_t *paramName = tokenstr; *paramName != L'\0'; paramName += (WCSLEN(paramName) + 1)) {
wchar_t valueBuf[1024] = { L'\0' };

/* Skip "Driver" parameter if present in odbc.ini */
if (WCSCASEEQ(paramName, L"Driver"))
continue;

/* Get the value for this parameter */
SQLGetPrivateProfileStringW(szDSN, paramName, L"",
valueBuf, sizeof(valueBuf)/sizeof(wchar_t),
L"odbc.ini");

/* Add semicolon before next parameter */
connstr[offset++] = L';';

/* Copy parameter name */
WCSCPY(connstr + offset, paramName);
offset += WCSLEN(paramName);

connstr[offset++] = L'=';

/* Copy value */
WCSCPY(connstr + offset, valueBuf);
offset += WCSLEN(valueBuf);
}

/* Ensure string is properly terminated */
connstr[offset] = L'\0';
}

/* Make the connection */
#if (ODBCVER < 0x300)
if (SQLAllocEnv (&henv) != SQL_SUCCESS)
Expand Down Expand Up @@ -752,11 +796,7 @@ void test_dsn(BOOL systemDSN, NSString *dsn, NSString *driver)
SQLFreeEnv (henv);
goto done;
}

WCSCPY(connstr, L"DSN=");
WCSCAT(connstr, szDSN);

SQLSetConfigMode (systemDSN?ODBC_SYSTEM_DSN: ODBC_USER_DSN);

if (SQLDriverConnectW (hdbc, (void*)1L, connstr, SQL_NTS,
outconnstr, sizeof (outconnstr) / sizeof(wchar_t), &buflen,
SQL_DRIVER_PROMPT) != SQL_SUCCESS)
Expand Down
Loading