From 9e75c1a30a81d60950227c78a636079d4bc8923a Mon Sep 17 00:00:00 2001 From: "Eric J. Korpela" Date: Mon, 22 Sep 2003 16:08:32 +0000 Subject: [PATCH] *** empty log message *** svn path=/trunk/boinc/; revision=2345 --- checkin_notes | 8 ++++++++ db/db_base.C | 16 +++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/checkin_notes b/checkin_notes index fce6021a8b..cba468cbbe 100755 --- a/checkin_notes +++ b/checkin_notes @@ -6333,3 +6333,11 @@ David Sept 21 2003 feeder.C handle_request.C show_shmem.C + +Eric K 9/22/03 + + Modified DB_CONN::open() to support "db_name@host" syntax for remote + database connections. + + db/db_base.C + diff --git a/db/db_base.C b/db/db_base.C index bdb03eee89..463090d064 100644 --- a/db/db_base.C +++ b/db/db_base.C @@ -11,9 +11,23 @@ DB_CONN::DB_CONN() { } int DB_CONN::open(char* dbname, char* dbpassword) { + char buf[256],*db_name,*db_host,*p; + if (dbname) { + strncpy(buf,dbname,254); + buf[255]=0; + db_name=buf; + } else { + db_name=0; + } + if ((p=strchr(buf,'@'))) { + db_host=p+1; + *p=0; + } else { + db_host=0; + } mysql = mysql_init(0); if (!mysql) return 0; - mysql = mysql_real_connect(mysql, 0, 0, dbpassword, dbname, 0, 0, 0); + mysql = mysql_real_connect(mysql, db_host, 0, dbpassword, db_name, 0, 0, 0); return (mysql == 0); }