~ubuntu-branches/debian/sid/kamailio/sid

« back to all changes in this revision

Viewing changes to modules/db_unixodbc/con.h

  • Committer: Package Import Robot
  • Author(s): Victor Seva
  • Date: 2014-01-06 11:47:13 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20140106114713-t8xidp4arzrnyeya
Tags: 4.1.1-1
* New upstream release
* debian/patches:
  - add upstream fixes
* Added tls outbound websocket autheph dnssec modules
  - openssl exception added to their license
* removing sparc and ia64 from supported archs
  for mono module (Closes: #728915)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* 
2
 
 * $Id$
3
 
 *
4
 
 * UNIXODBC module
5
 
 *
6
 
 * Copyright (C) 2005-2006 Marco Lorrai
7
 
 * Copyright (C) 2008 1&1 Internet AG
8
 
 *
9
 
 * This file is part of Kamailio, a free SIP server.
10
 
 *
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
15
 
 *
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.
20
 
 *
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
24
 
 *
25
 
 *
26
 
 * History:
27
 
 * --------
28
 
 *  2005-12-01  initial commit (chgen)
29
 
 */
30
 
 
31
 
 
32
 
#ifndef MY_CON_H
33
 
#define MY_CON_H
34
 
 
35
 
#include "../../lib/srdb1/db_pool.h"
36
 
#include "../../lib/srdb1/db_id.h"
37
 
 
38
 
#include <time.h>
39
 
#include <stdio.h>
40
 
#include <string.h>
41
 
#include <sql.h>
42
 
#include <sqlext.h>
43
 
#include <sqlucode.h>
44
 
 
45
 
 
46
 
#define STRN_LEN 1024
47
 
 
48
 
typedef struct strn
49
 
{
50
 
        char s[STRN_LEN];
51
 
} strn;
52
 
 
53
 
 
54
 
struct my_con
55
 
{
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 */
64
 
};
65
 
 
66
 
/*
67
 
 * Some convenience wrappers
68
 
 */
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)
75
 
 
76
 
#define MAX_CONN_STR_LEN 2048
77
 
 
78
 
/*
79
 
 * Create a new connection structure,
80
 
 * open the UNIXODBC connection and set reference count to 1
81
 
 */
82
 
struct my_con* db_unixodbc_new_connection(struct db_id* id);
83
 
 
84
 
/*
85
 
 * Close the connection and release memory
86
 
 */
87
 
void db_unixodbc_free_connection(struct my_con* con);
88
 
 
89
 
char *db_unixodbc_build_conn_str(const struct db_id* id, char *buf);
90
 
 
91
 
void db_unixodbc_extract_error(const char *fn, const SQLHANDLE handle, const SQLSMALLINT type, char* stret);
92
 
 
93
 
#endif  /* MY_CON_H */