Skip to Content.
Sympa Menu

freetds - An advice to login SQL SERVERs & Sybase Servers

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "York Ye" <york1975 AT 163.net>
  • To: freetds AT franklin.oit.unc.edu
  • Subject: An advice to login SQL SERVERs & Sybase Servers
  • Date: Sat, 17 Aug 2002 00:23:09 -0400


Dear sir,

I have Sybase Server run on server "yry" port 4100, and a SQL Server run on
"stc" port 1433, i wanna connect these two server on one PHP script, i must
modify the env TDSPORT or modify file freetds.conf.

To avoid this trouble, may user use "yry:4100" or "stc:1433" as server_name
to login with that server that port. so i have a advice to append a function
to src/tds/config.c to do, it works fine, code:

/* check the server name to find port info first :-) */
/* return 1 when found, or return 0 */
/* Warnning: config-> & login-> are all modified when needed */
static int check_login_server_name_for_port( TDSCONFIGINFO *config, TDSLOGIN
*login )
{
char *pSep, *pEnd;

if( ! login->server_name )
return 0;/* FALSE */

/* seek the ':' in login server_name */
pEnd = login->server_name + strlen( login->server_name );
for( pSep = login->server_name; pSep < pEnd; pSep ++ )
if( *pSep == ':' ) break;

if(( pSep < pEnd )&&( pSep != login->server_name ))/* yes, i found it! */
{
if( config->server_name ) free( config->server_name );
config->server_name = strdup( login->server_name );

/* modify config-> && login->server_name & ->port */
login->port = config->port = atoi( pSep + 1 );
config->server_name[pSep - login->server_name] = 0;/* end the
server_name before the ':' */
*pSep = 0;

/* config->ip_addr needed */
{
char tmp[256];

lookup_host (config->server_name, NULL, tmp, NULL);
if (config->ip_addr)
free (config->ip_addr);
config->ip_addr = strdup (tmp);
}

return 1;/* TRUE */
}
else
return 0;/* FALSE */
}

And, i add a line into the fucntion tds_get_config( ):

...
check_login_server_name_for_port( config, login );

/* Now check the environment variables */
tds_config_env_tdsver(config);
tds_config_env_tdsdump(config);
.......

This is my advice, thx!

B.Regards,
York
2002-08-17 PM, China



  • An advice to login SQL SERVERs & Sybase Servers, York Ye, 08/17/2002

Archive powered by MHonArc 2.6.24.

Top of Page