Skip to Content.
Sympa Menu

freetds - Re: [freetds] Unicode: Need for a DSN parameter to define the charset

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Sebastien FLAESCH <sf AT 4js.com>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] Unicode: Need for a DSN parameter to define the charset
  • Date: Tue, 15 Jan 2008 13:07:05 +0100

Attached a first diff from the HEAD branch to support new ODBC DSN parameters:

Instance
ClientCharset
DumpFile
DumpFileAppend
DebugFlags
Encryption

So far I have only tested "DumpFile" and "ClientCharset"...

Did not ran ODBC regression tests either (I guess I first need to setup and
enviroment for that).

Sorry if it's not perfect work, but I spent 5 minutes here and there to make
this patch.

Please adapt/review/fix as needed...

Thanks a lot for taking my request into consideration.
Seb

James K. Lowden wrote:
Sebastien FLAESCH wrote:
I was wondering why the "client charset" configuration parameter was not
supported in the ODBC DSN options.

Lack of manpower. It's a small task, not too difficult, and when someone
wants it badly enough, we'll surely see a patch.
I agree it would be well to support all features in an ODBC-only
configuration.
--jkl
_______________________________________________
FreeTDS mailing list
FreeTDS AT lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds


Index: include/tds.h
===================================================================
RCS file: /cvsroot/freetds/freetds/include/tds.h,v
retrieving revision 1.284
diff -c -r1.284 tds.h
*** include/tds.h	27 Dec 2007 13:45:22 -0000	1.284
--- include/tds.h	15 Jan 2008 12:02:35 -0000
***************
*** 1387,1392 ****
--- 1387,1393 ----
  typedef void (*TDSCONFPARSE) (const char *option, const char *value, void *param);
  int tds_read_conf_section(FILE * in, const char *section, TDSCONFPARSE tds_conf_parse, void *parse_param);
  int tds_read_conf_file(TDSCONNECTION * connection, const char *server);
+ void tds_parse_conf_section(const char *option, const char *value, void *param);
  TDSCONNECTION *tds_read_config_info(TDSSOCKET * tds, TDSLOGIN * login, TDSLOCALE * locale);
  void tds_fix_connection(TDSCONNECTION * connection);
  void tds_config_verstr(const char *tdsver, TDSCONNECTION * connection);
Index: src/odbc/connectparams.c
===================================================================
RCS file: /cvsroot/freetds/freetds/src/odbc/connectparams.c,v
retrieving revision 1.72
diff -c -r1.72 connectparams.c
*** src/odbc/connectparams.c	1 Jul 2007 10:10:52 -0000	1.72
--- src/odbc/connectparams.c	15 Jan 2008 12:02:36 -0000
***************
*** 39,44 ****
--- 39,60 ----
  
  TDS_RCSID(var, "$Id: connectparams.c,v 1.72 2007/07/01 10:10:52 freddy77 Exp $");
  
+ static const char *odbc_param_Servername = "Servername";
+ static const char *odbc_param_Address = "Address";
+ static const char *odbc_param_Server = "Server";
+ static const char *odbc_param_Port = "Port";
+ static const char *odbc_param_Instance = "Instance";
+ static const char *odbc_param_TDS_Version = "TDS_Version";
+ static const char *odbc_param_Language = "Language";
+ static const char *odbc_param_Database = "Database";
+ static const char *odbc_param_TextSize = "TextSize";
+ static const char *odbc_param_PacketSize = "PacketSize";
+ static const char *odbc_param_ClientCharset = "ClientCharset";
+ static const char *odbc_param_DumpFile = "DumpFile";
+ static const char *odbc_param_DumpFileAppend = "DumpFileAppend";
+ static const char *odbc_param_DebugFlags = "DebugFlags";
+ static const char *odbc_param_Encryption = "Encryption";
+ 
  #if !HAVE_SQLGETPRIVATEPROFILESTRING
  
  /*
***************
*** 114,119 ****
--- 130,142 ----
  	return 1;
  }
  
+ static int
+ myGetPrivateProfileString(const char *DSN, const char *key, const char *def, char *buf)
+ {
+ 	buf[0] = '\0';
+ 	return SQLGetPrivateProfileString(DSN, key, def, buf, FILENAME_MAX, "odbc.ini");
+ }
+ 
  /** 
   * Read connection information from given DSN
   * @param DSN           DSN name
***************
*** 128,135 ****
  	int address_specified = 0;
  
  	/* use old servername */
! 	tmp[0] = '\0';
! 	if (SQLGetPrivateProfileString(DSN, "Servername", "", tmp, FILENAME_MAX, "odbc.ini") > 0) {
  		freetds_conf_less = 0;
  		tds_dstr_copy(&connection->server_name, tmp);
  		tds_read_conf_file(connection, tmp);
--- 151,157 ----
  	int address_specified = 0;
  
  	/* use old servername */
! 	if (myGetPrivateProfileString(DSN, odbc_param_Servername, "", tmp) > 0) {
  		freetds_conf_less = 0;
  		tds_dstr_copy(&connection->server_name, tmp);
  		tds_read_conf_file(connection, tmp);
***************
*** 137,152 ****
  
  	/* search for server (compatible with ms one) */
  	if (freetds_conf_less) {
! 		tmp[0] = '\0';
! 		if (SQLGetPrivateProfileString(DSN, "Address", "", tmp, FILENAME_MAX, "odbc.ini") > 0) {
  			address_specified = 1;
  			/* TODO parse like MS */
  			tds_lookup_host(tmp, tmp);
  			tds_dstr_copy(&connection->ip_addr, tmp);
  		}
! 
! 		tmp[0] = '\0';
! 		if (SQLGetPrivateProfileString(DSN, "Server", "", tmp, FILENAME_MAX, "odbc.ini") > 0) {
  			tds_dstr_copy(&connection->server_name, tmp);
  			if (!address_specified) {
  				if (!parse_server(tmp, connection))
--- 159,171 ----
  
  	/* search for server (compatible with ms one) */
  	if (freetds_conf_less) {
! 		if (myGetPrivateProfileString(DSN, odbc_param_Address, "", tmp) > 0) {
  			address_specified = 1;
  			/* TODO parse like MS */
  			tds_lookup_host(tmp, tmp);
  			tds_dstr_copy(&connection->ip_addr, tmp);
  		}
! 		if (myGetPrivateProfileString(DSN, odbc_param_Server, "", tmp) > 0) {
  			tds_dstr_copy(&connection->server_name, tmp);
  			if (!address_specified) {
  				if (!parse_server(tmp, connection))
***************
*** 155,189 ****
  		}
  	}
  
! 	tmp[0] = '\0';
! 	if (SQLGetPrivateProfileString(DSN, "Port", "", tmp, FILENAME_MAX, "odbc.ini") > 0) {
  		connection->port = atoi(tmp);
- 	}
  
! 	tmp[0] = '\0';
! 	if (SQLGetPrivateProfileString(DSN, "TDS_Version", "", tmp, FILENAME_MAX, "odbc.ini") > 0) {
  		tds_config_verstr(tmp, connection);
- 	}
  
! 	tmp[0] = '\0';
! 	if (SQLGetPrivateProfileString(DSN, "Language", "", tmp, FILENAME_MAX, "odbc.ini") > 0) {
  		tds_dstr_copy(&connection->language, tmp);
- 	}
  
- 	tmp[0] = '\0';
  	if (tds_dstr_isempty(&connection->database)
! 	    && SQLGetPrivateProfileString(DSN, "Database", "", tmp, FILENAME_MAX, "odbc.ini") > 0)
  		tds_dstr_copy(&connection->database, tmp);
  
! 	tmp[0] = '\0';
! 	if (SQLGetPrivateProfileString(DSN, "TextSize", "", tmp, FILENAME_MAX, "odbc.ini") > 0) {
! 		connection->text_size = atoi(tmp);
! 	}
  
! 	tmp[0] = '\0';
! 	if (SQLGetPrivateProfileString(DSN, "PacketSize", "", tmp, FILENAME_MAX, "odbc.ini") > 0) {
! 		connection->block_size = atoi(tmp);
! 	}
  
  	return 1;
  }
--- 174,215 ----
  		}
  	}
  
! 	if (myGetPrivateProfileString(DSN, odbc_param_Port, "", tmp) > 0)
  		connection->port = atoi(tmp);
  
! 	if (myGetPrivateProfileString(DSN, odbc_param_Instance, "", tmp) > 0)
! 		tds_dstr_copy(&connection->instance_name, tmp);
! 
! 	if (myGetPrivateProfileString(DSN, odbc_param_TDS_Version, "", tmp) > 0)
  		tds_config_verstr(tmp, connection);
  
! 	if (myGetPrivateProfileString(DSN, odbc_param_Language, "", tmp) > 0)
  		tds_dstr_copy(&connection->language, tmp);
  
  	if (tds_dstr_isempty(&connection->database)
! 	    && myGetPrivateProfileString(DSN, odbc_param_Database, "", tmp) > 0)
  		tds_dstr_copy(&connection->database, tmp);
  
! 	if (myGetPrivateProfileString(DSN, odbc_param_TextSize, "", tmp) > 0)
! 		tds_parse_conf_section(TDS_STR_TEXTSZ, tmp, connection);
  
! 	if (myGetPrivateProfileString(DSN, odbc_param_PacketSize, "", tmp) > 0)
! 		tds_parse_conf_section(TDS_STR_BLKSZ, tmp, connection);
! 
! 	if (myGetPrivateProfileString(DSN, odbc_param_ClientCharset, "", tmp) > 0)
! 		tds_parse_conf_section(TDS_STR_CLCHARSET, tmp, connection);
! 
! 	if (myGetPrivateProfileString(DSN, odbc_param_DumpFile, "", tmp) > 0)
! 		tds_parse_conf_section(TDS_STR_DUMPFILE, tmp, connection);
! 
! 	if (myGetPrivateProfileString(DSN, odbc_param_DumpFileAppend, "", tmp) > 0)
! 		tds_parse_conf_section(TDS_STR_APPENDMODE, tmp, connection);
! 
! 	if (myGetPrivateProfileString(DSN, odbc_param_DebugFlags, "", tmp) > 0)
! 		tds_parse_conf_section(TDS_STR_DEBUGFLAGS, tmp, connection);
! 
! 	if (myGetPrivateProfileString(DSN, odbc_param_Encryption, "", tmp) > 0)
! 		tds_parse_conf_section(TDS_STR_ENCRYPTION, tmp, connection);
  
  	return 1;
  }
***************
*** 279,294 ****
  		} else if (strcasecmp(option, "WSID") == 0) {
  			dest_s = &connection->client_host_name;
  		} else if (strcasecmp(option, "LANGUAGE") == 0) {
! 			dest_s = &connection->language;
! 		} else if (strcasecmp(option, "Port") == 0) {
! 			connection->port = atoi(tds_dstr_cstr(&value));
! 		} else if (strcasecmp(option, "TDS_Version") == 0) {
  			tds_config_verstr(tds_dstr_cstr(&value), connection);
! 		} else if (strcasecmp(option, "TextSize") == 0) {
! 			connection->text_size = atoi(tds_dstr_cstr(&value));
! 		} else if (strcasecmp(option, "PacketSize") == 0) {
! 			connection->block_size = atoi(tds_dstr_cstr(&value));
! 			/* TODO "Address" field */
  		}
  
  		/* copy to destination */
--- 305,333 ----
  		} else if (strcasecmp(option, "WSID") == 0) {
  			dest_s = &connection->client_host_name;
  		} else if (strcasecmp(option, "LANGUAGE") == 0) {
! 			tds_parse_conf_section(TDS_STR_LANGUAGE, tds_dstr_cstr(&value), connection);
! 		} else if (strcasecmp(option, odbc_param_Port) == 0) {
! 			tds_parse_conf_section(TDS_STR_PORT, tds_dstr_cstr(&value), connection);
! 		} else if (strcasecmp(option, odbc_param_Instance) == 0) {
! 			tds_parse_conf_section(TDS_STR_INSTANCE, tds_dstr_cstr(&value), connection);
! 		} else if (strcasecmp(option, odbc_param_TDS_Version) == 0) {
! 			tds_parse_conf_section(TDS_STR_VERSION, tds_dstr_cstr(&value), connection);
  			tds_config_verstr(tds_dstr_cstr(&value), connection);
! 		} else if (strcasecmp(option, odbc_param_TextSize) == 0) {
! 			tds_parse_conf_section(TDS_STR_TEXTSZ, tds_dstr_cstr(&value), connection);
! 		} else if (strcasecmp(option, odbc_param_PacketSize) == 0) {
! 			tds_parse_conf_section(TDS_STR_BLKSZ, tds_dstr_cstr(&value), connection);
! 		} else if (strcasecmp(option, odbc_param_ClientCharset) == 0) {
! 			tds_parse_conf_section(TDS_STR_CLCHARSET, tds_dstr_cstr(&value), connection);
! 		} else if (strcasecmp(option, odbc_param_DumpFile) == 0) {
! 			tds_parse_conf_section(TDS_STR_DUMPFILE, tds_dstr_cstr(&value), connection);
! 		} else if (strcasecmp(option, odbc_param_DumpFileAppend) == 0) {
! 			tds_parse_conf_section(TDS_STR_APPENDMODE, tds_dstr_cstr(&value), connection);
! 		} else if (strcasecmp(option, odbc_param_DebugFlags) == 0) {
! 			tds_parse_conf_section(TDS_STR_DEBUGFLAGS, tds_dstr_cstr(&value), connection);
! 		} else if (strcasecmp(option, odbc_param_Encryption) == 0) {
! 			tds_parse_conf_section(TDS_STR_ENCRYPTION, tds_dstr_cstr(&value), connection);
! 			/* TODO odbc_param_Address field */
  		}
  
  		/* copy to destination */
***************
*** 487,492 ****
--- 526,544 ----
  	NULL
  };
  
+ static const char *const aEncryption[] = {
+ 	TDS_STR_ENCRYPTION_OFF,
+ 	TDS_STR_ENCRYPTION_REQUEST,
+ 	TDS_STR_ENCRYPTION_REQUIRE,
+ 	NULL
+ };
+ 
+ static const char *const aBoolean[] = {
+ 	"Yes",
+ 	"No",
+ 	NULL
+ };
+ 
  /*
  static const char *aAuth[] = {
  	"Server",
***************
*** 496,624 ****
  };
  */
  
! int
! ODBCINSTGetProperties(HODBCINSTPROPERTY hLastProperty)
  {
  	hLastProperty->pNext = (HODBCINSTPROPERTY) malloc(sizeof(ODBCINSTPROPERTY));
  	hLastProperty = hLastProperty->pNext;
  	memset(hLastProperty, 0, sizeof(ODBCINSTPROPERTY));
! 	hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_TEXTEDIT;
! 	tds_strlcpy(hLastProperty->szName, "Servername", INI_MAX_PROPERTY_NAME);
! 	tds_strlcpy(hLastProperty->szValue, "", INI_MAX_PROPERTY_VALUE);
! 	hLastProperty->pszHelp = (char *) strdup("Name of FreeTDS connection to connect to.\n"
! 						 "This server name refer to entry in freetds.conf file, not real server name.\n"
! 						 "This property cannot be used with Server property.");
! 
! 	hLastProperty->pNext = (HODBCINSTPROPERTY) malloc(sizeof(ODBCINSTPROPERTY));
! 	hLastProperty = hLastProperty->pNext;
! 	memset(hLastProperty, 0, sizeof(ODBCINSTPROPERTY));
! 	hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_TEXTEDIT;
! 	tds_strlcpy(hLastProperty->szName, "Server", INI_MAX_PROPERTY_NAME);
! 	tds_strlcpy(hLastProperty->szValue, "", INI_MAX_PROPERTY_VALUE);
! 	hLastProperty->pszHelp = (char *) strdup("Name of server to connect to.\n"
! 						 "This should be the name of real server.\n"
! 						 "This property cannot be used with Servername property.");
  
! 	hLastProperty->pNext = (HODBCINSTPROPERTY) malloc(sizeof(ODBCINSTPROPERTY));
! 	hLastProperty = hLastProperty->pNext;
! 	memset(hLastProperty, 0, sizeof(ODBCINSTPROPERTY));
  	hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_TEXTEDIT;
! 	tds_strlcpy(hLastProperty->szName, "Address", INI_MAX_PROPERTY_NAME);
! 	tds_strlcpy(hLastProperty->szValue, "", INI_MAX_PROPERTY_VALUE);
! 	hLastProperty->pszHelp = (char *) strdup("The hostname or ip address of the server.");
  
! 	hLastProperty->pNext = (HODBCINSTPROPERTY) malloc(sizeof(ODBCINSTPROPERTY));
! 	hLastProperty = hLastProperty->pNext;
! 	memset(hLastProperty, 0, sizeof(ODBCINSTPROPERTY));
! 	hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_TEXTEDIT;
! 	tds_strlcpy(hLastProperty->szName, "Port", INI_MAX_PROPERTY_NAME);
! 	tds_strlcpy(hLastProperty->szValue, "1433", INI_MAX_PROPERTY_VALUE);
! 	hLastProperty->pszHelp = (char *) strdup("TCP/IP Port to connect to.");
  
! 	hLastProperty->pNext = (HODBCINSTPROPERTY) malloc(sizeof(ODBCINSTPROPERTY));
! 	hLastProperty = hLastProperty->pNext;
! 	memset(hLastProperty, 0, sizeof(ODBCINSTPROPERTY));
! 	hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_TEXTEDIT;
! 	tds_strlcpy(hLastProperty->szName, "Database", INI_MAX_PROPERTY_NAME);
! 	tds_strlcpy(hLastProperty->szValue, "", INI_MAX_PROPERTY_VALUE);
! 	hLastProperty->pszHelp = (char *) strdup("Default database.");
  
! 	hLastProperty->pNext = (HODBCINSTPROPERTY) malloc(sizeof(ODBCINSTPROPERTY));
! 	hLastProperty = hLastProperty->pNext;
! 	memset(hLastProperty, 0, sizeof(ODBCINSTPROPERTY));
  	hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_LISTBOX;
! 	hLastProperty->aPromptData = malloc(sizeof(aTDSver));
! 	memcpy(hLastProperty->aPromptData, aTDSver, sizeof(aTDSver));
! 	tds_strlcpy(hLastProperty->szName, "TDS_Version", INI_MAX_PROPERTY_NAME);
! 	tds_strlcpy(hLastProperty->szValue, "4.2", INI_MAX_PROPERTY_VALUE);
! 	hLastProperty->pszHelp = (char *) strdup("The TDS protocol version.\n"
! 						 " 4.2 MSSQL 6.5 or Sybase < 10.x\n"
! 						 " 5.0 Sybase >= 10.x\n" " 7.0 MSSQL 7 or MSSQL 2000\n" " 8.0 MSSQL 2000");
  
! 	hLastProperty->pNext = (HODBCINSTPROPERTY) malloc(sizeof(ODBCINSTPROPERTY));
! 	hLastProperty = hLastProperty->pNext;
! 	memset(hLastProperty, 0, sizeof(ODBCINSTPROPERTY));
! 	hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_COMBOBOX;
! 	hLastProperty->aPromptData = malloc(sizeof(aLanguage));
! 	memcpy(hLastProperty->aPromptData, aLanguage, sizeof(aLanguage));
! 	tds_strlcpy(hLastProperty->szName, "Language", INI_MAX_PROPERTY_NAME);
! 	tds_strlcpy(hLastProperty->szValue, "us_english", INI_MAX_PROPERTY_VALUE);
! 	hLastProperty->pszHelp = (char *) strdup("The default language setting.");
  
! 	hLastProperty->pNext = (HODBCINSTPROPERTY) malloc(sizeof(ODBCINSTPROPERTY));
! 	hLastProperty = hLastProperty->pNext;
! 	memset(hLastProperty, 0, sizeof(ODBCINSTPROPERTY));
! 	hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_HIDDEN;
! 	tds_strlcpy(hLastProperty->szName, "TextSize", INI_MAX_PROPERTY_NAME);
! 	tds_strlcpy(hLastProperty->szValue, "", INI_MAX_PROPERTY_VALUE);
! 	hLastProperty->pszHelp = (char *) strdup("Text datatype limit.");
  
  	/* ??? in odbc.ini ??? */
  /*
! 	hLastProperty->pNext = (HODBCINSTPROPERTY) malloc(sizeof(ODBCINSTPROPERTY));
! 	hLastProperty = hLastProperty->pNext;
! 	memset(hLastProperty, 0, sizeof(ODBCINSTPROPERTY));
! 	hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_TEXTEDIT;
! 	tds_strlcpy(hLastProperty->szName, "UID", INI_MAX_PROPERTY_NAME);
! 	tds_strlcpy(hLastProperty->szValue, "", INI_MAX_PROPERTY_VALUE);
! 	hLastProperty->pszHelp = (char *) strdup("User ID (Beware of security issues).");
  
! 	hLastProperty->pNext = (HODBCINSTPROPERTY) malloc(sizeof(ODBCINSTPROPERTY));
! 	hLastProperty = hLastProperty->pNext;
! 	memset(hLastProperty, 0, sizeof(ODBCINSTPROPERTY));
! 	hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_TEXTEDIT;
! 	tds_strlcpy(hLastProperty->szName, "PWD", INI_MAX_PROPERTY_NAME);
! 	tds_strlcpy(hLastProperty->szValue, "", INI_MAX_PROPERTY_VALUE);
! 	hLastProperty->pszHelp = (char *) strdup("Password (Beware of security issues).");
  */
  
  /*
! 	hLastProperty->pNext = (HODBCINSTPROPERTY) malloc(sizeof(ODBCINSTPROPERTY));
! 	hLastProperty = hLastProperty->pNext;
! 	memset(hLastProperty, 0, sizeof(ODBCINSTPROPERTY));
! 	hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_LISTBOX;
! 	hLastProperty->aPromptData = malloc(sizeof(aAuth));
! 	memcpy(hLastProperty->aPromptData, aAuth, sizeof(aAuth));
! 	tds_strlcpy(hLastProperty->szName, "Authentication", INI_MAX_PROPERTY_NAME);
! 	tds_strlcpy(hLastProperty->szValue, "Server", INI_MAX_PROPERTY_VALUE);
! 	hLastProperty->pszHelp = (char *) strdup("The server authentication mechanism.");
  */
  
! 	hLastProperty->pNext = (HODBCINSTPROPERTY) malloc(sizeof(ODBCINSTPROPERTY));
! 	hLastProperty = hLastProperty->pNext;
! 	memset(hLastProperty, 0, sizeof(ODBCINSTPROPERTY));
! 	hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_TEXTEDIT;
! 	tds_strlcpy(hLastProperty->szName, "Domain", INI_MAX_PROPERTY_NAME);
! 	tds_strlcpy(hLastProperty->szValue, "", INI_MAX_PROPERTY_VALUE);
! 	hLastProperty->pszHelp = (char *) strdup("The default domain to use when using Domain Authentication.");
  
! 	hLastProperty->pNext = (HODBCINSTPROPERTY) malloc(sizeof(ODBCINSTPROPERTY));
! 	hLastProperty = hLastProperty->pNext;
! 	memset(hLastProperty, 0, sizeof(ODBCINSTPROPERTY));
! 	hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_TEXTEDIT;
! 	tds_strlcpy(hLastProperty->szName, "PacketSize", INI_MAX_PROPERTY_NAME);
! 	tds_strlcpy(hLastProperty->szValue, "", INI_MAX_PROPERTY_VALUE);
! 	hLastProperty->pszHelp = (char *) strdup("Size of network packets.");
  
  	return 1;
  }
--- 548,679 ----
  };
  */
  
! static HODBCINSTPROPERTY
! addProperty(HODBCINSTPROPERTY hLastProperty)
  {
  	hLastProperty->pNext = (HODBCINSTPROPERTY) malloc(sizeof(ODBCINSTPROPERTY));
  	hLastProperty = hLastProperty->pNext;
  	memset(hLastProperty, 0, sizeof(ODBCINSTPROPERTY));
! 	return hLastProperty;
! }
  
! static HODBCINSTPROPERTY
! definePropertyString(HODBCINSTPROPERTY hLastProperty, const char *name, const char *value, const char *comment)
! {
! 	hLastProperty = addProperty(hLastProperty);
  	hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_TEXTEDIT;
! 	tds_strlcpy(hLastProperty->szName, name, INI_MAX_PROPERTY_NAME);
! 	tds_strlcpy(hLastProperty->szValue, value, INI_MAX_PROPERTY_VALUE);
! 	hLastProperty->pszHelp = (char *) strdup(comment);
! 	return hLastProperty;
! }
  
! static HODBCINSTPROPERTY
! definePropertyBoolean(HODBCINSTPROPERTY hLastProperty, const char *name, const char *value, const char *comment)
! {
! 	hLastProperty = addProperty(hLastProperty);
! 	hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_LISTBOX;
! 	hLastProperty->aPromptData = malloc(sizeof(aBoolean));
! 	memcpy(hLastProperty->aPromptData, aBoolean, sizeof(aBoolean));
! 	tds_strlcpy(hLastProperty->szName, name, INI_MAX_PROPERTY_NAME);
! 	tds_strlcpy(hLastProperty->szValue, value, INI_MAX_PROPERTY_VALUE);
! 	hLastProperty->pszHelp = (char *) strdup(comment);
! 	return hLastProperty;
! }
  
! static HODBCINSTPROPERTY
! definePropertyHidden(HODBCINSTPROPERTY hLastProperty, const char *name, const char *value, const char *comment)
! {
! 	hLastProperty = addProperty(hLastProperty);
! 	hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_HIDDEN;
! 	tds_strlcpy(hLastProperty->szName, name, INI_MAX_PROPERTY_NAME);
! 	tds_strlcpy(hLastProperty->szValue, value, INI_MAX_PROPERTY_VALUE);
! 	hLastProperty->pszHelp = (char *) strdup(comment);
! 	return hLastProperty;
! }
  
! static HODBCINSTPROPERTY
! definePropertyList(HODBCINSTPROPERTY hLastProperty, const char *name, const char *value, void *list, int size, const char *comment)
! {
! 	hLastProperty = addProperty(hLastProperty);
  	hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_LISTBOX;
! 	hLastProperty->aPromptData = malloc(size);
! 	memcpy(hLastProperty->aPromptData, list, size);
! 	tds_strlcpy(hLastProperty->szName, name, INI_MAX_PROPERTY_NAME);
! 	tds_strlcpy(hLastProperty->szValue, value, INI_MAX_PROPERTY_VALUE);
! 	hLastProperty->pszHelp = (char *) strdup(comment);
! 	return hLastProperty;
! }
  
! int
! ODBCINSTGetProperties(HODBCINSTPROPERTY hLastProperty)
! {
! 	hLastProperty = definePropertyString(hLastProperty, odbc_param_Servername, "", 
! 		"Name of FreeTDS connection to connect to.\n"
! 		"This server name refer to entry in freetds.conf file, not real server name.\n"
! 		"This property cannot be used with Server property.");
! 
! 	hLastProperty = definePropertyString(hLastProperty, odbc_param_Server, "", 
! 		"Name of server to connect to.\n"
! 		"This should be the name of real server.\n"
! 		"This property cannot be used with Servername property.");
! 
! 	hLastProperty = definePropertyString(hLastProperty, odbc_param_Address, "", 
! 		"The hostname or ip address of the server.");
! 
! 	hLastProperty = definePropertyString(hLastProperty, odbc_param_Port, "1433", 
! 		"TCP/IP Port to connect to.");
! 
! 	hLastProperty = definePropertyString(hLastProperty, odbc_param_Database, "", 
! 		"Default database.");
! 
! 	hLastProperty = definePropertyList(hLastProperty, odbc_param_TDS_Version, "4.2", (void*) aTDSver, sizeof(aTDSver),
! 		"The TDS protocol version.\n"
! 		" 4.2 MSSQL 6.5 or Sybase < 10.x\n"
! 		" 5.0 Sybase >= 10.x\n"
! 		" 7.0 MSSQL 7 or MSSQL 2000\n"
! 		" 8.0 MSSQL 2000");
  
! 	hLastProperty = definePropertyList(hLastProperty, odbc_param_Language, "us_english", (void*) aLanguage, sizeof(aLanguage),
! 		"The default language setting.");
! 
! 	hLastProperty = definePropertyHidden(hLastProperty, odbc_param_TextSize, "", 
! 		"Text datatype limit.");
  
  	/* ??? in odbc.ini ??? */
  /*
! 	hLastProperty = definePropertyString(hLastProperty, odbc_param_UID, "", 
! 		"User ID (Beware of security issues).");
  
! 	hLastProperty = definePropertyString(hLastProperty, odbc_param_PWD, "", 
! 		"Password (Beware of security issues).");
  */
  
  /*
! 	hLastProperty = definePropertyList(hLastProperty, odbc_param_Authentication, "Server", aAuth, sizeof(aAuth),
! 		"The server authentication mechanism.");
! 
! 	hLastProperty = definePropertyString(hLastProperty, odbc_param_Domain, "", 
! 		"The default domain to use when using Domain Authentication.");
  */
  
! 	hLastProperty = definePropertyString(hLastProperty, odbc_param_PacketSize, "", 
! 		"Size of network packets.");
  
! 	hLastProperty = definePropertyString(hLastProperty, odbc_param_ClientCharset, "", 
! 		"The client character set name to convert application characters to UCS-2 in TDS 7.0 and higher.");
! 
! 	hLastProperty = definePropertyString(hLastProperty, odbc_param_DumpFile, "",
! 		"Specifies the location of a tds dump file and turns on logging.");
! 
! 	hLastProperty = definePropertyBoolean(hLastProperty, odbc_param_DumpFileAppend, "",
! 		"Appends dump file instead of overwriting it. Useful for debugging when many processes are active.");
! 
! 	hLastProperty = definePropertyString(hLastProperty, odbc_param_DebugFlags, "", 
! 		"Sets granularity of logging. A set of bit that specify levels and informations. See table below for bit specification.");
! 
! 	hLastProperty = definePropertyList(hLastProperty, odbc_param_Encryption, TDS_STR_ENCRYPTION_OFF, aEncryption, sizeof(aEncryption),
! 		"The encryption method.");
  
  	return 1;
  }
Index: src/tds/config.c
===================================================================
RCS file: /cvsroot/freetds/freetds/src/tds/config.c,v
retrieving revision 1.132
diff -c -r1.132 config.c
*** src/tds/config.c	23 Dec 2007 21:12:02 -0000	1.132
--- src/tds/config.c	15 Jan 2008 12:02:36 -0000
***************
*** 84,90 ****
  static void tds_config_env_tdsport(TDSCONNECTION * connection);
  static void tds_config_env_tdshost(TDSCONNECTION * connection);
  static int tds_read_conf_sections(FILE * in, const char *server, TDSCONNECTION * connection);
- static void tds_parse_conf_section(const char *option, const char *value, void *param);
  static void tds_read_interfaces(const char *server, TDSCONNECTION * connection);
  static int tds_config_boolean(const char *value);
  static int parse_server_name_for_port(TDSCONNECTION * connection, TDSLOGIN * login);
--- 84,89 ----
***************
*** 352,360 ****
  static int
  tds_config_boolean(const char *value)
  {
! 	if (!strcmp(value, "yes") || !strcmp(value, "on") || !strcmp(value, "true") || !strcmp(value, "1"))
  		return 1;
! 	if (!strcmp(value, "no") || !strcmp(value, "off") || !strcmp(value, "false") || !strcmp(value, "0"))
  		return 0;
  	tdsdump_log(TDS_DBG_INFO1, "UNRECOGNIZED boolean value: '%s'. Treating as 'no'.\n", value);
  	return 0;
--- 351,361 ----
  static int
  tds_config_boolean(const char *value)
  {
! 	if (!strcmp(value, "Yes") || !strcmp(value, "yes") || !strcmp(value, "on")
! 	        || !strcmp(value, "true") || !strcmp(value, "1"))
  		return 1;
! 	if (!strcmp(value, "No") || !strcmp(value, "no") || !strcmp(value, "off")
! 		|| !strcmp(value, "false") || !strcmp(value, "0"))
  		return 0;
  	tdsdump_log(TDS_DBG_INFO1, "UNRECOGNIZED boolean value: '%s'. Treating as 'no'.\n", value);
  	return 0;
***************
*** 471,477 ****
  #undef option
  }
  
! static void
  tds_parse_conf_section(const char *option, const char *value, void *param)
  {
  	TDSCONNECTION *connection = (TDSCONNECTION *) param;
--- 472,479 ----
  #undef option
  }
  
! /* Also used to scan ODBC.INI entries */
! void
  tds_parse_conf_section(const char *option, const char *value, void *param)
  {
  	TDSCONNECTION *connection = (TDSCONNECTION *) param;



Archive powered by MHonArc 2.6.24.

Top of Page