1 |
/* This file is part of GNU RADIUS. |
/* This file is part of GNU Radius. |
2 |
Copyright (C) 2000, Sergey Poznyakoff |
Copyright (C) 2000,2001,2002,2003 Sergey Poznyakoff |
3 |
|
|
4 |
This program is free software; you can redistribute it and/or modify |
GNU Radius is free software; you can redistribute it and/or modify |
5 |
it under the terms of the GNU General Public License as published by |
it under the terms of the GNU General Public License as published by |
6 |
the Free Software Foundation; either version 2 of the License, or |
the Free Software Foundation; either version 2 of the License, or |
7 |
(at your option) any later version. |
(at your option) any later version. |
8 |
|
|
9 |
This program is distributed in the hope that it will be useful, |
GNU Radius is distributed in the hope that it will be useful, |
10 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 |
GNU General Public License for more details. |
GNU General Public License for more details. |
13 |
|
|
14 |
You should have received a copy of the GNU General Public License |
You should have received a copy of the GNU General Public License |
15 |
along with this program; if not, write to the Free Software Foundation, |
along with GNU Radius; if not, write to the Free Software Foundation, |
16 |
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
17 |
|
|
18 |
#define RADIUS_MODULE_MYSQL_C |
#define RADIUS_MODULE_MYSQL_C |
45 |
#define MYSQL_AUTH SQL_AUTH |
#define MYSQL_AUTH SQL_AUTH |
46 |
#define MYSQL_ACCT SQL_ACCT |
#define MYSQL_ACCT SQL_ACCT |
47 |
|
|
|
static int do_mysql_query(struct sql_connection *conn, char *query); |
|
48 |
static int rad_mysql_reconnect(int type, struct sql_connection *conn); |
static int rad_mysql_reconnect(int type, struct sql_connection *conn); |
49 |
static void rad_mysql_disconnect(struct sql_connection *conn, int drop); |
static void rad_mysql_disconnect(struct sql_connection *conn, int drop); |
50 |
static int rad_mysql_query(struct sql_connection *conn, char *query, int *return_count); |
static int rad_mysql_query(struct sql_connection *conn, char *query, int *return_count); |
61 |
*************************************************************************/ |
*************************************************************************/ |
62 |
|
|
63 |
static int |
static int |
64 |
do_mysql_query(conn, query) |
do_mysql_query(struct sql_connection *conn, char *query) |
|
struct sql_connection *conn; |
|
|
char *query; |
|
65 |
{ |
{ |
66 |
int ret; |
int ret; |
67 |
int i; |
int i; |
93 |
|
|
94 |
/* ************************************************************************* */ |
/* ************************************************************************* */ |
95 |
/* Interface routines */ |
/* Interface routines */ |
96 |
int |
static int |
97 |
rad_mysql_reconnect(type, conn) |
rad_mysql_reconnect(int type, struct sql_connection *conn) |
|
int type; |
|
|
struct sql_connection *conn; |
|
98 |
{ |
{ |
99 |
MYSQL *mysql = NULL; |
MYSQL *mysql = NULL; |
100 |
char *dbname; |
char *dbname; |
130 |
return 0; |
return 0; |
131 |
} |
} |
132 |
|
|
133 |
void |
static void |
134 |
rad_mysql_disconnect(conn, drop) |
rad_mysql_disconnect(struct sql_connection *conn, |
135 |
struct sql_connection *conn; |
int drop /* currently unused */) |
|
int drop; /* currently unused */ |
|
136 |
{ |
{ |
137 |
mysql_close(conn->data); |
mysql_close(conn->data); |
138 |
mem_free(conn->data); |
mem_free(conn->data); |
140 |
conn->connected = 0; |
conn->connected = 0; |
141 |
} |
} |
142 |
|
|
143 |
int |
static int |
144 |
rad_mysql_query(conn, query, return_count) |
rad_mysql_query(struct sql_connection *conn, char *query, int *return_count) |
|
struct sql_connection *conn; |
|
|
char *query; |
|
|
int *return_count; |
|
145 |
{ |
{ |
146 |
if (!conn) |
if (!conn) |
147 |
return -1; |
return -1; |
155 |
return 0; |
return 0; |
156 |
} |
} |
157 |
|
|
158 |
char * |
static char * |
159 |
rad_mysql_getpwd(conn, query) |
rad_mysql_getpwd(struct sql_connection *conn, char *query) |
|
struct sql_connection *conn; |
|
|
char *query; |
|
160 |
{ |
{ |
161 |
MYSQL_RES *result; |
MYSQL_RES *result; |
162 |
MYSQL_ROW row; |
MYSQL_ROW row; |
192 |
MYSQL_ROW row; |
MYSQL_ROW row; |
193 |
} RADMYSQL_DATA; |
} RADMYSQL_DATA; |
194 |
|
|
195 |
void * |
static void * |
196 |
rad_mysql_exec(conn, query) |
rad_mysql_exec(struct sql_connection *conn, char *query) |
|
struct sql_connection *conn; |
|
|
char *query; |
|
197 |
{ |
{ |
198 |
MYSQL_RES *result; |
MYSQL_RES *result; |
199 |
RADMYSQL_DATA *data; |
RADMYSQL_DATA *data; |
223 |
return (void*)data; |
return (void*)data; |
224 |
} |
} |
225 |
|
|
226 |
char * |
static char * |
227 |
rad_mysql_column(data, ncol) |
rad_mysql_column(void *data, int ncol) |
|
void *data; |
|
|
int ncol; |
|
228 |
{ |
{ |
229 |
RADMYSQL_DATA *dp = (RADMYSQL_DATA *) data; |
RADMYSQL_DATA *dp = (RADMYSQL_DATA *) data; |
230 |
|
|
239 |
} |
} |
240 |
|
|
241 |
/*ARGSUSED*/ |
/*ARGSUSED*/ |
242 |
int |
static int |
243 |
rad_mysql_next_tuple(conn, data) |
rad_mysql_next_tuple(struct sql_connection *conn, void *data) |
|
struct sql_connection *conn; |
|
|
void *data; |
|
244 |
{ |
{ |
245 |
RADMYSQL_DATA *dp = (RADMYSQL_DATA *) data; |
RADMYSQL_DATA *dp = (RADMYSQL_DATA *) data; |
246 |
|
|
250 |
} |
} |
251 |
|
|
252 |
/*ARGSUSED*/ |
/*ARGSUSED*/ |
253 |
void |
static void |
254 |
rad_mysql_free(conn, data) |
rad_mysql_free(struct sql_connection *conn, void *data) |
|
struct sql_connection *conn; |
|
|
void *data; |
|
255 |
{ |
{ |
256 |
RADMYSQL_DATA *dp = (RADMYSQL_DATA *) data; |
RADMYSQL_DATA *dp = (RADMYSQL_DATA *) data; |
257 |
|
|