6
* Copyright (C) 2005-2006 Marco Lorrai
7
* Copyright (C) 2008 1&1 Internet AG
9
* This file is part of Kamailio, a free SIP server.
11
* Kamailio is free software; you can redistribute it and/or modify
12
* it under the terms of the GNU General Public License as published by
13
* the Free Software Foundation; either version 2 of the License, or
14
* (at your option) any later version
16
* Kamailio is distributed in the hope that it will be useful,
17
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
* GNU General Public License for more details.
21
* You should have received a copy of the GNU General Public License
22
* along with this program; if not, write to the Free Software
23
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28
* 2005-12-01 initial commit (chgen)
35
#include "../../lib/srdb1/db_pool.h"
36
#include "../../lib/srdb1/db_id.h"
56
struct db_id* id; /*!< Connection identifier */
57
unsigned int ref; /*!< Reference count */
58
struct pool_con* next; /*!< Next connection in the pool */
59
SQLHENV env; /*!< Environment handle */
60
SQLHSTMT stmt_handle; /*!< Actual result */
61
SQLHDBC dbc; /*!< Connection representation */
62
char** row; /*!< Actual row in the result */
63
time_t timestamp; /*!< Timestamp of last query */
67
* Some convenience wrappers
69
#define CON_RESULT(db_con) (((struct my_con*)((db_con)->tail))->stmt_handle)
70
#define CON_CONNECTION(db_con) (((struct my_con*)((db_con)->tail))->dbc)
71
#define CON_ROW(db_con) (((struct my_con*)((db_con)->tail))->row)
72
#define CON_TIMESTAMP(db_con) (((struct my_con*)((db_con)->tail))->timestamp)
73
#define CON_ID(db_con) (((struct my_con*)((db_con)->tail))->id)
74
#define CON_ENV(db_con) (((struct my_con*)((db_con)->tail))->env)
76
#define MAX_CONN_STR_LEN 2048
79
* Create a new connection structure,
80
* open the UNIXODBC connection and set reference count to 1
82
struct my_con* db_unixodbc_new_connection(struct db_id* id);
85
* Close the connection and release memory
87
void db_unixodbc_free_connection(struct my_con* con);
89
char *db_unixodbc_build_conn_str(const struct db_id* id, char *buf);
91
void db_unixodbc_extract_error(const char *fn, const SQLHANDLE handle, const SQLSMALLINT type, char* stret);