Commit 92c7722f authored by Leigh B. Stoller's avatar Leigh B. Stoller

Add support for contacting remote mysql, with user/password.

   int
   dbinit_withparams(char *host, char *user, char *passwd, char *dbname)

This library could thus be installed on the experimental nodes to
provide easier support for contacting ops mysql.
parent 3d2ad4a4
......@@ -26,12 +26,15 @@
*/
static MYSQL db;
static char *dbname = TBDBNAME;
static char *dbuser = (char *) NULL;
static char *dbpass = (char *) NULL;
static char *dbhost = (char *) NULL;
static int
mydb_connect()
{
mysql_init(&db);
if (mysql_real_connect(&db, 0, 0, 0,
if (mysql_real_connect(&db, dbhost, dbuser, dbpass,
dbname, 0, 0, CLIENT_INTERACTIVE) == 0) {
error("%s: connect failed: %s\n", dbname, mysql_error(&db));
return 0;
......@@ -67,6 +70,16 @@ dbinit(void)
return mydb_connect();
}
int
dbinit_withparams(char *host, char *user, char *passwd, char *name)
{
dbhost = host;
dbuser = user;
dbname = name;
dbpass = passwd;
return mydb_connect();
}
void
dbclose(void)
{
......
/*
* EMULAB-COPYRIGHT
* Copyright (c) 2000-2003 University of Utah and the Flux Group.
* Copyright (c) 2000-2003, 2006 University of Utah and the Flux Group.
* All rights reserved.
*/
......@@ -15,6 +15,8 @@
* Generic interface.
*/
int dbinit(void);
int dbinit_withparams(char *host,
char *user, char *passwd, char *name);
void dbclose(void);
/*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment