/[radius]/radius/sql/mysql.c
ViewVC logotype

Diff of /radius/sql/mysql.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.12 by gray, Fri Aug 2 11:18:43 2002 UTC revision 1.13 by gray, Wed Apr 30 08:44:33 2003 UTC
# Line 1  Line 1 
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
# Line 45  static char rcsid[] = Line 45  static char rcsid[] =
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);
# Line 62  static void rad_mysql_free(struct sql_co Line 61  static void rad_mysql_free(struct sql_co
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;
# Line 96  do_mysql_query(conn, query) Line 93  do_mysql_query(conn, query)
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;
# Line 135  rad_mysql_reconnect(type, conn) Line 130  rad_mysql_reconnect(type, conn)
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);
# Line 146  rad_mysql_disconnect(conn, drop) Line 140  rad_mysql_disconnect(conn, drop)
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;
# Line 164  rad_mysql_query(conn, query, return_coun Line 155  rad_mysql_query(conn, query, return_coun
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;
# Line 203  typedef struct { Line 192  typedef struct {
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;
# Line 236  rad_mysql_exec(conn, query) Line 223  rad_mysql_exec(conn, query)
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    
# Line 254  rad_mysql_column(data, ncol) Line 239  rad_mysql_column(data, ncol)
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    
# Line 267  rad_mysql_next_tuple(conn, data) Line 250  rad_mysql_next_tuple(conn, data)
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    

Legend:
Removed from v.1.12  
changed lines
  Added in v.1.13

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26