aboutsummaryrefslogtreecommitdiff
path: root/src/mysql.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mysql.c')
-rw-r--r--src/mysql.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/mysql.c b/src/mysql.c
index 676618a..81ea62c 100644
--- a/src/mysql.c
+++ b/src/mysql.c
@@ -120,14 +120,14 @@ mysql_db_open (void **dp, ANUBIS_URL * url, enum anubis_db_mode mode,
struct anubis_sql_db *amp = NULL;
const char *table = anubis_url_get_arg (url, "table");
const char *authid = anubis_url_get_arg (url, "authid");
const char *passwd = anubis_url_get_arg (url, "passwd");
const char *user = anubis_url_get_arg (url, "account");
const char *rcfile = anubis_url_get_arg (url, "rcfile");
- const char *portstr = anubis_url_get_arg (url, "port");
- const char *s = anubis_url_get_arg (url, "bufsize");
+ const char *s;
+ char *optfile;
int port = 0;
size_t bufsize = 1024;
struct mysql_db_data *mdata;
/* Provide reasonable defaults */
if (!table)
@@ -138,27 +138,29 @@ mysql_db_open (void **dp, ANUBIS_URL * url, enum anubis_db_mode mode,
passwd = "passwd";
if (!user)
user = "account";
if (!rcfile)
rcfile = "rcfile";
+ s = anubis_url_get_arg (url, "bufsize");
if (s)
{
char *p;
bufsize = strtoul (s, &p, 10);
if (*p)
{
*errp = sql_open_error_text (ERR_BADBUFSIZE);
return ANUBIS_DB_FAIL;
}
}
- if (portstr)
+ s = anubis_url_get_arg (url, "port");
+ if (s)
{
char *p;
- port = strtoul (portstr, &p, 10);
+ port = strtoul (s, &p, 10);
if (*p)
{
*errp = sql_open_error_text (ERR_BADPORT);
return ANUBIS_DB_FAIL;
}
}
@@ -166,12 +168,25 @@ mysql_db_open (void **dp, ANUBIS_URL * url, enum anubis_db_mode mode,
amp = xzalloc (sizeof (*amp));
amp->buf = xmalloc (bufsize);
amp->bufsize = bufsize;
mdata = xmalloc (sizeof (*mdata));
amp->data = mdata;
mysql_init (&mdata->mysql);
+
+ s = anubis_url_get_arg (url, "options-file");
+ if (!s) {
+ if (access ("/etc/my.cnf", F_OK) == 0)
+ s = "/etc/my.cnf";
+ }
+
+ if (s && *s) {
+ mysql_options (&mdata->mysql, MYSQL_READ_DEFAULT_FILE, s);
+ mysql_options(&mdata->mysql, MYSQL_READ_DEFAULT_GROUP,
+ s ? s : "anubis");
+ }
+
if (!mysql_real_connect (&mdata->mysql,
url->host, url->user, url->passwd,
url->path, port,
anubis_url_get_arg (url, "socket"), 0))
{
free (amp->data);

Return to:

Send suggestions and report system problems to the System administrator.