~ubuntu-branches/ubuntu/natty/freeradius/natty-updates

« back to all changes in this revision

Viewing changes to src/modules/rlm_sql/drivers/rlm_sql_unixodbc/sql_unixodbc.c

  • Committer: Bazaar Package Importer
  • Author(s): Josip Rodin
  • Date: 2009-11-23 03:57:37 UTC
  • mfrom: (1.2.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 28.
  • Revision ID: james.westby@ubuntu.com-20091123035737-zsgtzhfych8hir68
Tags: 2.1.7+dfsg-1
* Adopting the package, closes: #536623.
* New upstream version, closes: #513484.
  + Fixes the blooper in unlang evaluation logic, closes: #526175.
* Used quilt (and added README.source), and moved upstream file patching
  into debian/patches/. The source is no longer in collab-maint git
  (to make it simpler for me to finally get this out the door), but
  kept the .gitignore should we need that again.
* Dropped the dialup_admin/bin/backup_radacct patch (integrated upstream).
* Dropped the raddb/Makefile patch (problem no longer exists upstream).
* Dropped the lib/packet.c lib/radius.c main/listen.c patches (was from
  upstream 2.0.5 anyway).
* Dropped references to otp.conf, it no longer exists upstream.
  Keep removing the conffile statoverride in prerm.
* Dropped references to snmp.conf, it no longer exists upstream.
  Keep removing the conffile statoverride in prerm.
* Ship /etc/freeradius/modules/* in the freeradius package.
* Stop shipping sites-enabled symlinks in the package and instead create
  them only on initial install, thanks to Matej Vela, closes: #533396.
* Add export PATH="${PATH:+$PATH:}/usr/sbin:/sbin" to the init script
  at the request of John Morrissey, closes: #550143.
* Stop installing /var/run/freeradius in the package to silence Lintian.
  The init script already recreates it at will.
* Remove executable bit from example.pl to silence Lintian.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 */
21
21
 
22
22
#include <freeradius-devel/ident.h>
23
 
RCSID("$Id: sql_unixodbc.c,v 1.23 2007/12/17 07:45:46 aland Exp $")
 
23
RCSID("$Id$")
24
24
 
25
25
#include <freeradius-devel/radiusd.h>
26
26
 
122
122
 *      Purpose: Free socket and private connection data
123
123
 *
124
124
 *************************************************************************/
125
 
static int sql_destroy_socket(SQLSOCK *sqlsocket, SQL_CONFIG *config)
 
125
static int sql_destroy_socket(SQLSOCK *sqlsocket, UNUSED SQL_CONFIG *config)
126
126
{
127
127
        free(sqlsocket->conn);
128
128
        sqlsocket->conn = NULL;
166
166
 *************************************************************************/
167
167
static int sql_select_query(SQLSOCK *sqlsocket, SQL_CONFIG *config, char *querystr) {
168
168
    rlm_sql_unixodbc_sock *unixodbc_sock = sqlsocket->conn;
169
 
    SQLINTEGER column, len;
 
169
    SQLINTEGER column;
 
170
    SQLLEN len;
170
171
    int numfields;
171
172
    int state;
172
173
 
184
185
 
185
186
    for(column=1; column<=numfields; column++) {
186
187
        SQLColAttributes(unixodbc_sock->stmt_handle,((SQLUSMALLINT) column),SQL_COLUMN_LENGTH,NULL,0,NULL,&len);
187
 
        unixodbc_sock->row[column-1] = (SQLCHAR*)rad_malloc((int)++len);
 
188
        unixodbc_sock->row[column-1] = (char*)rad_malloc((int)++len);
188
189
        SQLBindCol(unixodbc_sock->stmt_handle, column, SQL_C_CHAR, (SQLCHAR *)unixodbc_sock->row[column-1], len, NULL);
189
190
    }
190
191
        return 0;
199
200
 *               set for the query.
200
201
 *
201
202
 *************************************************************************/
202
 
static int sql_store_result(SQLSOCK *sqlsocket, SQL_CONFIG *config) {
 
203
static int sql_store_result(UNUSED SQLSOCK *sqlsocket, UNUSED SQL_CONFIG *config) {
203
204
  /* Not used */
204
205
    return 0;
205
206
}
290
291
 *      Purpose: End the query, such as freeing memory
291
292
 *
292
293
 *************************************************************************/
293
 
static int sql_finish_query(SQLSOCK *sqlsocket, SQL_CONFIG *config) {
 
294
static int sql_finish_query(SQLSOCK *sqlsocket, UNUSED SQL_CONFIG *config) {
294
295
    rlm_sql_unixodbc_sock *unixodbc_sock = sqlsocket->conn;
295
296
 
296
297
    SQLFreeStmt(unixodbc_sock->stmt_handle, SQL_CLOSE);
331
332
 *               connection and cleans up any open handles.
332
333
 *
333
334
 *************************************************************************/
334
 
static int sql_close(SQLSOCK *sqlsocket, SQL_CONFIG *config) {
 
335
static int sql_close(SQLSOCK *sqlsocket, UNUSED SQL_CONFIG *config) {
335
336
    rlm_sql_unixodbc_sock *unixodbc_sock = sqlsocket->conn;
336
337
 
337
338
    SQLFreeStmt(unixodbc_sock->stmt_handle, SQL_DROP);
350
351
 *               connection
351
352
 *
352
353
 *************************************************************************/
353
 
static const char *sql_error(SQLSOCK *sqlsocket, SQL_CONFIG *config) {
 
354
static const char *sql_error(SQLSOCK *sqlsocket, UNUSED SQL_CONFIG *config) {
354
355
    SQLCHAR state[256];
355
356
    SQLCHAR error[256];
356
357
    SQLINTEGER errornum = 0;
384
385
 *               connection related or -1 for other errors
385
386
 *
386
387
 *************************************************************************/
387
 
static int sql_state(long err_handle, SQLSOCK *sqlsocket, SQL_CONFIG *config) {
 
388
static int sql_state(long err_handle, SQLSOCK *sqlsocket, UNUSED SQL_CONFIG *config) {
388
389
    SQLCHAR state[256];
389
390
    SQLCHAR error[256];
390
391
    SQLINTEGER errornum = 0;
440
441
static int sql_affected_rows(SQLSOCK *sqlsocket, SQL_CONFIG *config) {
441
442
    rlm_sql_unixodbc_sock *unixodbc_sock = sqlsocket->conn;
442
443
    long err_handle;
443
 
    int affected_rows;
 
444
    SQLLEN affected_rows;
444
445
 
445
 
    err_handle = SQLRowCount(unixodbc_sock->stmt_handle, (SQLINTEGER *)&affected_rows);
 
446
    err_handle = SQLRowCount(unixodbc_sock->stmt_handle, &affected_rows);
446
447
    if (sql_state(err_handle, sqlsocket, config))
447
448
        return -1;
448
449