|
|
Choosing A Webhost: |
CVS update of libmysequoia/src (CarobMySQL.cpp): msg#00158db.carob.cvs
Date: Wednesday, January 25, 2006 @ 11:58:42 Author: csaba Path: /cvsroot/carob/libmysequoia/src Modified: CarobMySQL.cpp (1.34 -> 1.35) read_ini_file() implementation. ----------------+ CarobMySQL.cpp | 39 ++++++++++++++++++++++++++++++++++++++- 1 files changed, 38 insertions(+), 1 deletion(-) Index: libmysequoia/src/CarobMySQL.cpp diff -u libmysequoia/src/CarobMySQL.cpp:1.34 libmysequoia/src/CarobMySQL.cpp:1.35 --- libmysequoia/src/CarobMySQL.cpp:1.34 Wed Jan 25 09:46:23 2006 +++ libmysequoia/src/CarobMySQL.cpp Wed Jan 25 11:58:42 2006 @@ -21,13 +21,18 @@ #include <CarobMySQL.hpp> #include <ResultSetMetaData.hpp> +#include <IniParser.hpp> #include <Utils.hpp> /* MySQL include */ #include <errmsg.h> +#include <cstdlib> +#include <string> + using namespace CarobNS; +using namespace std; CarobMYSQL::CarobMYSQL (MYSQL *mysql, my_bool free_me) : connectionPtr(0), stmtPtr(0), drsPtr(0), liveResultPtr(0) @@ -820,8 +825,40 @@ LOG4CXX_DEBUG(logger, "Leaving delete_row_data."); } + void CarobMYSQL::read_ini_file() { - // TODO implementation + char *group; + string def_home_env = string(getenv("DEFAULT_HOME_ENV")) + "/my.cnf"; + string home_dir = string(getenv("HOME")) + "/.my.cnf"; + IniParser ini; + +/* + * The order of reading the config files: + * 1. /etc/ + * 2. getenv(DEFAULT_HOME_ENV) + * 3. "" + * 4. "~/" + * 5. user supplied options.my_cnf_file + */ + + ini.parseFile("/etc/my.cnf"); + ini.parseFile(def_home_env.c_str()); + ini.parseFile("my.cnf"); + ini.parseFile(home_dir.c_str()); + ini.parseFile(mysqlPtr->options.my_cnf_file); + + if (mysqlPtr->options.my_cnf_group && *mysqlPtr->options.my_cnf_group) + group = mysqlPtr->options.my_cnf_group; + else + group = "client"; + + mysqlPtr->options.host = cstrdup(ini.get(group, "host").c_str()); + mysqlPtr->options.user = cstrdup(ini.get(group, "user").c_str()); + mysqlPtr->options.password = cstrdup(ini.get(group, "password").c_str()); + mysqlPtr->options.db = cstrdup(ini.get(group, "db").c_str()); + mysqlPtr->options.port = atoi(ini.get(group, "port").c_str()); + + push_init_command(ini.get(group, "init_command").c_str()); }
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | CVS update of libmysequoia (4 files), zsolt-Tt5JLJuBijYiZlD9aYmxOGD2FQJk+8+b |
|---|---|
| Next by Date: | CVS update of carob/include (Connection.hpp), gilles-Tt5JLJuBijYiZlD9aYmxOGD2FQJk+8+b |
| Previous by Thread: | CVS update of carob/src (Common.cpp StringCodecs.cpp), gilles-Tt5JLJuBijYiZlD9aYmxOGD2FQJk+8+b |
| Next by Thread: | CVS update of libmysequoia/src (CarobMySQL.cpp), zsolt-Tt5JLJuBijYiZlD9aYmxOGD2FQJk+8+b |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
Free MagazinesCisco NewsReceive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business. subscribe Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field. subscribe The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business. subscribe Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company. subscribe Total Telecom Total Telecom is "The Economist of the communications industry". subscribe |
Home
| advertise | OSDir is
an inevitable website.
|