freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
Coldfusion Professional and freetds/ODBC SQLGetInfo code
- From: "Paul Williamson" <pwillia6 AT csc.com.au>
- To: freetds AT franklin.oit.unc.edu
- Subject: Coldfusion Professional and freetds/ODBC SQLGetInfo code
- Date: Fri, 25 Jan 2002 02:11:55 -0500
After purchasing Coldfusion Professional I found out that the MERANT
Driver was disable so I install freetds. To my horror it still did not
work. It turns out that if the ODBC driver deoes not return
SQL_DRIVER_NAME or SQL_ODBC_DRIVER_VERSION for a call to SQLGetInfo then
CF Professional rejects it.
Anyway here is a contribution to SQLGetInfo that you may like to add.
The code replaces the space SQLGetInfo is in (strncpy_null and some of the
code was adapted from the PostgresSQL OpenODBC driver):
---------------------------------------------------------------------
/*// strncpy copies up to len characters, and doesn't terminate */
/*// the destination string if src has len characters or more. */
/*// instead, I want it to copy up to len-1 characters and always */
/*// terminate the destination string. */
char *strncpy_null(char *dst, const char *src, int len)
{
int i;
if (NULL != dst) {
/* Just in case, check for special lengths */
if (len == SQL_NULL_DATA) {
dst[0] = '\0';
return NULL;
}
else if (len == SQL_NTS)
len = strlen(src) + 1;
for(i = 0; src[i] && i < len - 1; i++) {
dst[i] = src[i];
}
if(len > 0) {
dst[i] = '\0';
}
}
return dst;
}
SQLRETURN SQL_API SQLGetInfo(
SQLHDBC hdbc,
SQLUSMALLINT fInfoType,
SQLPOINTER rgbInfoValue,
SQLSMALLINT cbInfoValueMax,
SQLSMALLINT FAR *pcbInfoValue)
{
char *p = NULL;
int len;
switch (fInfoType) {
case SQL_DRIVER_NAME: /* ODBC 1.0 */
p = "libtdsodbc.so";
break;
case SQL_DRIVER_ODBC_VER:
p = "1.0";
break;
}
if (p) { /* char/binary data */
len = strlen(p);
if (rgbInfoValue) {
strncpy_null((char *)rgbInfoValue, p,
(size_t)cbInfoValueMax);
if (len >= cbInfoValueMax) {
LogError("The buffer was too small for the
result.");
return( SQL_SUCCESS_WITH_INFO);
}
}
}
return SQL_SUCCESS;
}
-
Coldfusion Professional and freetds/ODBC SQLGetInfo code,
Paul Williamson, 01/25/2002
- <Possible follow-up(s)>
- Re: Coldfusion Professional and freetds/ODBC SQLGetInfo code, Brian Bruns, 01/25/2002
Archive powered by MHonArc 2.6.24.