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
@@ -123,8 +123,8 @@ mysql_db_open (void **dp, ANUBIS_URL * url, enum anubis_db_mode mode,
123 const char *passwd = anubis_url_get_arg (url, "passwd"); 123 const char *passwd = anubis_url_get_arg (url, "passwd");
124 const char *user = anubis_url_get_arg (url, "account"); 124 const char *user = anubis_url_get_arg (url, "account");
125 const char *rcfile = anubis_url_get_arg (url, "rcfile"); 125 const char *rcfile = anubis_url_get_arg (url, "rcfile");
126 const char *portstr = anubis_url_get_arg (url, "port"); 126 const char *s;
127 const char *s = anubis_url_get_arg (url, "bufsize"); 127 char *optfile;
128 int port = 0; 128 int port = 0;
129 size_t bufsize = 1024; 129 size_t bufsize = 1024;
130 struct mysql_db_data *mdata; 130 struct mysql_db_data *mdata;
@@ -141,6 +141,7 @@ mysql_db_open (void **dp, ANUBIS_URL * url, enum anubis_db_mode mode,
141 if (!rcfile) 141 if (!rcfile)
142 rcfile = "rcfile"; 142 rcfile = "rcfile";
143 143
144 s = anubis_url_get_arg (url, "bufsize");
144 if (s) 145 if (s)
145 { 146 {
146 char *p; 147 char *p;
@@ -152,10 +153,11 @@ mysql_db_open (void **dp, ANUBIS_URL * url, enum anubis_db_mode mode,
152 } 153 }
153 } 154 }
154 155
155 if (portstr) 156 s = anubis_url_get_arg (url, "port");
157 if (s)
156 { 158 {
157 char *p; 159 char *p;
158 port = strtoul (portstr, &p, 10); 160 port = strtoul (s, &p, 10);
159 if (*p) 161 if (*p)
160 { 162 {
161 *errp = sql_open_error_text (ERR_BADPORT); 163 *errp = sql_open_error_text (ERR_BADPORT);
@@ -169,6 +171,19 @@ mysql_db_open (void **dp, ANUBIS_URL * url, enum anubis_db_mode mode,
169 mdata = xmalloc (sizeof (*mdata)); 171 mdata = xmalloc (sizeof (*mdata));
170 amp->data = mdata; 172 amp->data = mdata;
171 mysql_init (&mdata->mysql); 173 mysql_init (&mdata->mysql);
174
175 s = anubis_url_get_arg (url, "options-file");
176 if (!s) {
177 if (access ("/etc/my.cnf", F_OK) == 0)
178 s = "/etc/my.cnf";
179 }
180
181 if (s && *s) {
182 mysql_options (&mdata->mysql, MYSQL_READ_DEFAULT_FILE, s);
183 mysql_options(&mdata->mysql, MYSQL_READ_DEFAULT_GROUP,
184 s ? s : "anubis");
185 }
186
172 if (!mysql_real_connect (&mdata->mysql, 187 if (!mysql_real_connect (&mdata->mysql,
173 url->host, url->user, url->passwd, 188 url->host, url->user, url->passwd,
174 url->path, port, 189 url->path, port,

Return to:

Send suggestions and report system problems to the System administrator.