Asterisk - The Open Source Telephony Project  GIT-master-a24979a
Macros | Enumerations | Functions | Variables
cdr_odbc.c File Reference

ODBC CDR Backend. More...

#include "asterisk.h"
#include "asterisk/config.h"
#include "asterisk/channel.h"
#include "asterisk/cdr.h"
#include "asterisk/module.h"
#include "asterisk/res_odbc.h"
Include dependency graph for cdr_odbc.c:

Go to the source code of this file.

Macros

#define DATE_FORMAT   "%Y-%m-%d %T"
 

Enumerations

enum  {
  CONFIG_LOGUNIQUEID = 1 << 0 , CONFIG_USEGMTIME = 1 << 1 , CONFIG_DISPOSITIONSTRING = 1 << 2 , CONFIG_HRTIME = 1 << 3 ,
  CONFIG_REGISTERED = 1 << 4 , CONFIG_NEWCDRCOLUMNS = 1 << 5
}
 

Functions

static void __reg_module (void)
 
static void __unreg_module (void)
 
struct ast_moduleAST_MODULE_SELF_SYM (void)
 
static SQLHSTMT execute_cb (struct odbc_obj *obj, void *data)
 
static int load_module (void)
 
static int odbc_load_module (int reload)
 
static int odbc_log (struct ast_cdr *cdr)
 
static int reload (void)
 
static int unload_module (void)
 

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "ODBC CDR Backend" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_EXTENDED, .load = load_module, .unload = unload_module, .reload = reload, .load_pri = AST_MODPRI_CDR_DRIVER, .requires = "cdr,res_odbc", }
 
static const struct ast_module_infoast_module_info = &__mod_info
 
static struct ast_flags config = { 0 }
 
static const char config_file [] = "cdr_odbc.conf"
 
static char * dsn = NULL
 
static const char name [] = "ODBC"
 
static char * table = NULL
 

Detailed Description

ODBC CDR Backend.

Author
Brian K. West brian.nosp@m.@bkw.nosp@m..org http://www.unixodbc.org

Definition in file cdr_odbc.c.

Macro Definition Documentation

◆ DATE_FORMAT

#define DATE_FORMAT   "%Y-%m-%d %T"

Definition at line 51 of file cdr_odbc.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
CONFIG_LOGUNIQUEID 
CONFIG_USEGMTIME 
CONFIG_DISPOSITIONSTRING 
CONFIG_HRTIME 
CONFIG_REGISTERED 
CONFIG_NEWCDRCOLUMNS 

Definition at line 57 of file cdr_odbc.c.

57  {
58  CONFIG_LOGUNIQUEID = 1 << 0,
59  CONFIG_USEGMTIME = 1 << 1,
60  CONFIG_DISPOSITIONSTRING = 1 << 2,
61  CONFIG_HRTIME = 1 << 3,
62  CONFIG_REGISTERED = 1 << 4,
63  CONFIG_NEWCDRCOLUMNS = 1 << 5,
64 };
@ CONFIG_NEWCDRCOLUMNS
Definition: cdr_odbc.c:63
@ CONFIG_HRTIME
Definition: cdr_odbc.c:61
@ CONFIG_REGISTERED
Definition: cdr_odbc.c:62
@ CONFIG_USEGMTIME
Definition: cdr_odbc.c:59
@ CONFIG_DISPOSITIONSTRING
Definition: cdr_odbc.c:60
@ CONFIG_LOGUNIQUEID
Definition: cdr_odbc.c:58

Function Documentation

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 329 of file cdr_odbc.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 329 of file cdr_odbc.c.

◆ AST_MODULE_SELF_SYM()

struct ast_module* AST_MODULE_SELF_SYM ( void  )

Definition at line 329 of file cdr_odbc.c.

◆ execute_cb()

static SQLHSTMT execute_cb ( struct odbc_obj obj,
void *  data 
)
static

Definition at line 68 of file cdr_odbc.c.

69 {
70  struct ast_cdr *cdr = data;
71  SQLRETURN ODBC_res;
72  char sqlcmd[2048] = "", timestr[128], new_columns[120] = "", new_values[7] = "";
73  struct ast_tm tm;
74  SQLHSTMT stmt;
75  int i = 0;
76 
77  ast_localtime(&cdr->start, &tm, ast_test_flag(&config, CONFIG_USEGMTIME) ? "GMT" : NULL);
78  ast_strftime(timestr, sizeof(timestr), DATE_FORMAT, &tm);
79 
81  snprintf(new_columns, sizeof(new_columns), "%s", ",peeraccount,linkedid,sequence");
82  snprintf(new_values, sizeof(new_values), "%s", ",?,?,?");
83  }
84 
86  snprintf(sqlcmd,sizeof(sqlcmd),"INSERT INTO %s "
87  "(calldate,clid,src,dst,dcontext,channel,dstchannel,lastapp,"
88  "lastdata,duration,billsec,disposition,amaflags,accountcode,uniqueid,userfield%s) "
89  "VALUES ({ts '%s'},?,?,?,?,?,?,?,?,?,?,?,?,?,?,?%s)", table, new_columns, timestr, new_values);
90  } else {
91  snprintf(sqlcmd,sizeof(sqlcmd),"INSERT INTO %s "
92  "(calldate,clid,src,dst,dcontext,channel,dstchannel,lastapp,lastdata,"
93  "duration,billsec,disposition,amaflags,accountcode%s) "
94  "VALUES ({ts '%s'},?,?,?,?,?,?,?,?,?,?,?,?,?%s)", table, new_columns, timestr, new_values);
95  }
96 
97  ODBC_res = SQLAllocHandle(SQL_HANDLE_STMT, obj->con, &stmt);
98 
99  if ((ODBC_res != SQL_SUCCESS) && (ODBC_res != SQL_SUCCESS_WITH_INFO)) {
100  ast_log(LOG_WARNING, "cdr_odbc: Failure in AllocStatement %d\n", ODBC_res);
101  SQLFreeHandle(SQL_HANDLE_STMT, stmt);
102  return NULL;
103  }
104 
105  SQLBindParameter(stmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cdr->clid), 0, cdr->clid, 0, NULL);
106  SQLBindParameter(stmt, 2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cdr->src), 0, cdr->src, 0, NULL);
107  SQLBindParameter(stmt, 3, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cdr->dst), 0, cdr->dst, 0, NULL);
108  SQLBindParameter(stmt, 4, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cdr->dcontext), 0, cdr->dcontext, 0, NULL);
109  SQLBindParameter(stmt, 5, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cdr->channel), 0, cdr->channel, 0, NULL);
110  SQLBindParameter(stmt, 6, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cdr->dstchannel), 0, cdr->dstchannel, 0, NULL);
111  SQLBindParameter(stmt, 7, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cdr->lastapp), 0, cdr->lastapp, 0, NULL);
112  SQLBindParameter(stmt, 8, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cdr->lastdata), 0, cdr->lastdata, 0, NULL);
113 
115  double hrbillsec = 0.0;
116  double hrduration;
117 
118  if (!ast_tvzero(cdr->answer)) {
119  hrbillsec = (double) ast_tvdiff_us(cdr->end, cdr->answer) / 1000000.0;
120  }
121  hrduration = (double) ast_tvdiff_us(cdr->end, cdr->start) / 1000000.0;
122 
123  SQLBindParameter(stmt, 9, SQL_PARAM_INPUT, SQL_C_DOUBLE, SQL_FLOAT, 0, 0, &hrduration, 0, NULL);
124  SQLBindParameter(stmt, 10, SQL_PARAM_INPUT, SQL_C_DOUBLE, SQL_FLOAT, 0, 0, &hrbillsec, 0, NULL);
125  } else {
126  SQLBindParameter(stmt, 9, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &cdr->duration, 0, NULL);
127  SQLBindParameter(stmt, 10, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &cdr->billsec, 0, NULL);
128  }
129 
131  char *disposition;
132  disposition = ast_strdupa(ast_cdr_disp2str(cdr->disposition));
133  SQLBindParameter(stmt, 11, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(disposition) + 1, 0, disposition, 0, NULL);
134  } else {
135  SQLBindParameter(stmt, 11, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &cdr->disposition, 0, NULL);
136  }
137  SQLBindParameter(stmt, 12, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &cdr->amaflags, 0, NULL);
138  SQLBindParameter(stmt, 13, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cdr->accountcode), 0, cdr->accountcode, 0, NULL);
139 
140  i = 14;
142  SQLBindParameter(stmt, 14, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cdr->uniqueid), 0, cdr->uniqueid, 0, NULL);
143  SQLBindParameter(stmt, 15, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cdr->userfield), 0, cdr->userfield, 0, NULL);
144  i = 16;
145  }
146 
148  SQLBindParameter(stmt, i, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cdr->peeraccount), 0, cdr->peeraccount, 0, NULL);
149  SQLBindParameter(stmt, i + 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cdr->linkedid), 0, cdr->linkedid, 0, NULL);
150  SQLBindParameter(stmt, i + 2, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &cdr->sequence, 0, NULL);
151  }
152 
153  ODBC_res = ast_odbc_execute_sql(obj, stmt, sqlcmd);
154 
155  if ((ODBC_res != SQL_SUCCESS) && (ODBC_res != SQL_SUCCESS_WITH_INFO)) {
156  ast_log(LOG_WARNING, "cdr_odbc: Error in ExecDirect: %d, query is: %s\n", ODBC_res, sqlcmd);
157  SQLFreeHandle(SQL_HANDLE_STMT, stmt);
158  return NULL;
159  }
160 
161  return stmt;
162 }
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:298
#define ast_log
Definition: astobj2.c:42
const char * ast_cdr_disp2str(int disposition)
Disposition to a string.
Definition: cdr.c:3452
static char * table
Definition: cdr_odbc.c:55
static struct ast_flags config
Definition: cdr_odbc.c:66
#define DATE_FORMAT
Definition: cdr_odbc.c:51
#define LOG_WARNING
int ast_strftime(char *buf, size_t len, const char *format, const struct ast_tm *tm)
Special version of strftime(3) that handles fractions of a second. Takes the same arguments as strfti...
Definition: localtime.c:2524
struct ast_tm * ast_localtime(const struct timeval *timep, struct ast_tm *p_tm, const char *zone)
Timezone-independent version of localtime_r(3).
Definition: localtime.c:1739
SQLRETURN ast_odbc_execute_sql(struct odbc_obj *obj, SQLHSTMT *stmt, const char *sql)
Execute a unprepared SQL query.
Definition: res_odbc.c:469
#define NULL
Definition: resample.c:96
Responsible for call detail data.
Definition: cdr.h:277
char dstchannel[AST_MAX_EXTENSION]
Definition: cdr.h:289
long int disposition
Definition: cdr.h:305
char lastdata[AST_MAX_EXTENSION]
Definition: cdr.h:293
char linkedid[AST_MAX_UNIQUEID]
Definition: cdr.h:317
char userfield[AST_MAX_USER_FIELD]
Definition: cdr.h:319
long int billsec
Definition: cdr.h:303
struct timeval answer
Definition: cdr.h:297
char channel[AST_MAX_EXTENSION]
Definition: cdr.h:287
char peeraccount[AST_MAX_ACCOUNT_CODE]
Definition: cdr.h:311
long int duration
Definition: cdr.h:301
long int amaflags
Definition: cdr.h:307
char src[AST_MAX_EXTENSION]
Definition: cdr.h:281
char dst[AST_MAX_EXTENSION]
Definition: cdr.h:283
char clid[AST_MAX_EXTENSION]
Definition: cdr.h:279
char uniqueid[AST_MAX_UNIQUEID]
Definition: cdr.h:315
int sequence
Definition: cdr.h:321
struct timeval start
Definition: cdr.h:295
char accountcode[AST_MAX_ACCOUNT_CODE]
Definition: cdr.h:309
char lastapp[AST_MAX_EXTENSION]
Definition: cdr.h:291
char dcontext[AST_MAX_EXTENSION]
Definition: cdr.h:285
struct timeval end
Definition: cdr.h:299
SQLHDBC con
Definition: res_odbc.h:47
int64_t ast_tvdiff_us(struct timeval end, struct timeval start)
Computes the difference (in microseconds) between two struct timeval instances.
Definition: time.h:85
int ast_tvzero(const struct timeval t)
Returns true if the argument is 0,0.
Definition: time.h:115
#define ast_test_flag(p, flag)
Definition: utils.h:63

References ast_cdr::accountcode, ast_cdr::amaflags, ast_cdr::answer, ast_cdr_disp2str(), ast_localtime(), ast_log, ast_odbc_execute_sql(), ast_strdupa, ast_strftime(), ast_test_flag, ast_tvdiff_us(), ast_tvzero(), ast_cdr::billsec, ast_cdr::channel, ast_cdr::clid, odbc_obj::con, config, CONFIG_DISPOSITIONSTRING, CONFIG_HRTIME, CONFIG_LOGUNIQUEID, CONFIG_NEWCDRCOLUMNS, CONFIG_USEGMTIME, DATE_FORMAT, ast_cdr::dcontext, ast_cdr::disposition, ast_cdr::dst, ast_cdr::dstchannel, ast_cdr::duration, ast_cdr::end, ast_cdr::lastapp, ast_cdr::lastdata, ast_cdr::linkedid, LOG_WARNING, NULL, ast_cdr::peeraccount, ast_cdr::sequence, ast_cdr::src, ast_cdr::start, table, ast_cdr::uniqueid, and ast_cdr::userfield.

Referenced by odbc_log().

◆ load_module()

static int load_module ( void  )
static

Definition at line 296 of file cdr_odbc.c.

297 {
298  return odbc_load_module(0);
299 }
static int odbc_load_module(int reload)
Definition: cdr_odbc.c:190

References odbc_load_module().

◆ odbc_load_module()

static int odbc_load_module ( int  reload)
static

Definition at line 190 of file cdr_odbc.c.

191 {
192  int res = 0;
193  struct ast_config *cfg;
194  struct ast_variable *var;
195  const char *tmp;
196  struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
197 
198  do {
199  cfg = ast_config_load(config_file, config_flags);
200  if (!cfg || cfg == CONFIG_STATUS_FILEINVALID) {
201  ast_log(LOG_WARNING, "cdr_odbc: Unable to load config for ODBC CDR's: %s\n", config_file);
203  break;
204  } else if (cfg == CONFIG_STATUS_FILEUNCHANGED)
205  break;
206 
207  var = ast_variable_browse(cfg, "global");
208  if (!var) {
209  /* nothing configured */
210  break;
211  }
212 
213  if ((tmp = ast_variable_retrieve(cfg, "global", "dsn")) == NULL) {
214  ast_log(LOG_WARNING, "cdr_odbc: dsn not specified. Assuming asteriskdb\n");
215  tmp = "asteriskdb";
216  }
217  if (dsn)
218  ast_free(dsn);
219  dsn = ast_strdup(tmp);
220  if (dsn == NULL) {
221  res = -1;
222  break;
223  }
224 
225  if (((tmp = ast_variable_retrieve(cfg, "global", "dispositionstring"))) && ast_true(tmp))
227  else
229 
230  if (((tmp = ast_variable_retrieve(cfg, "global", "loguniqueid"))) && ast_true(tmp)) {
232  ast_debug(1, "cdr_odbc: Logging uniqueid\n");
233  } else {
235  ast_debug(1, "cdr_odbc: Not logging uniqueid\n");
236  }
237 
238  if (((tmp = ast_variable_retrieve(cfg, "global", "usegmtime"))) && ast_true(tmp)) {
240  ast_debug(1, "cdr_odbc: Logging in GMT\n");
241  } else {
243  ast_debug(1, "cdr_odbc: Logging in local time\n");
244  }
245 
246  if (((tmp = ast_variable_retrieve(cfg, "global", "hrtime"))) && ast_true(tmp)) {
248  ast_debug(1, "cdr_odbc: Logging billsec and duration fields as floats\n");
249  } else {
251  ast_debug(1, "cdr_odbc: Logging billsec and duration fields as integers\n");
252  }
253 
254  if ((tmp = ast_variable_retrieve(cfg, "global", "table")) == NULL) {
255  ast_log(LOG_WARNING, "cdr_odbc: table not specified. Assuming cdr\n");
256  tmp = "cdr";
257  }
258  if (table)
259  ast_free(table);
260  table = ast_strdup(tmp);
261  if (table == NULL) {
262  res = -1;
263  break;
264  }
265 
268  if (res) {
269  ast_log(LOG_ERROR, "cdr_odbc: Unable to register ODBC CDR handling\n");
270  } else {
272  }
273  }
274  if (((tmp = ast_variable_retrieve(cfg, "global", "newcdrcolumns"))) && ast_true(tmp)) {
276  ast_debug(1, "cdr_odbc: Add new cdr columns\n");
277  } else {
279  ast_debug(1, "cdr_odbc: Not add new cdr columns\n");
280  }
281  } while (0);
282 
283  if (ast_test_flag(&config, CONFIG_REGISTERED) && (!cfg || dsn == NULL || table == NULL)) {
286  } else {
288  }
289 
290  if (cfg && cfg != CONFIG_STATUS_FILEUNCHANGED && cfg != CONFIG_STATUS_FILEINVALID) {
291  ast_config_destroy(cfg);
292  }
293  return res;
294 }
#define var
Definition: ast_expr2f.c:614
#define ast_free(a)
Definition: astmm.h:180
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:241
static int tmp()
Definition: bt_open.c:389
int ast_cdr_backend_unsuspend(const char *name)
Unsuspend a CDR backend.
Definition: cdr.c:2906
int ast_cdr_register(const char *name, const char *desc, ast_cdrbe be)
Register a CDR handling engine.
Definition: cdr.c:2965
int ast_cdr_backend_suspend(const char *name)
Suspend a CDR backend temporarily.
Definition: cdr.c:2888
static const char name[]
Definition: cdr_odbc.c:53
static int odbc_log(struct ast_cdr *cdr)
Definition: cdr_odbc.c:165
static const char config_file[]
Definition: cdr_odbc.c:54
static int reload(void)
Definition: cdr_odbc.c:317
#define ast_config_load(filename, flags)
Load a config file.
@ CONFIG_FLAG_FILEUNCHANGED
#define CONFIG_STATUS_FILEUNCHANGED
#define CONFIG_STATUS_FILEINVALID
void ast_config_destroy(struct ast_config *cfg)
Destroys a config.
Definition: extconf.c:1289
const char * ast_variable_retrieve(struct ast_config *config, const char *category, const char *variable)
Definition: main/config.c:768
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category_name)
Definition: extconf.c:1215
#define ast_debug(level,...)
Log a DEBUG message.
#define LOG_ERROR
@ AST_MODULE_LOAD_DECLINE
Module has failed to load, may be in an inconsistent state.
Definition: module.h:78
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true"....
Definition: main/utils.c:2097
Structure used to handle boolean flags.
Definition: utils.h:199
const char * description
Definition: module.h:352
Structure for variables, used for configurations and for channel variables.
Data source name.
Definition: func_odbc.c:163
#define ast_clear_flag(p, flag)
Definition: utils.h:77
#define ast_set_flag(p, flag)
Definition: utils.h:70

References ast_cdr_backend_suspend(), ast_cdr_backend_unsuspend(), ast_cdr_register(), ast_clear_flag, ast_config_destroy(), ast_config_load, ast_debug, ast_free, ast_log, AST_MODULE_LOAD_DECLINE, ast_set_flag, ast_strdup, ast_test_flag, ast_true(), ast_variable_browse(), ast_variable_retrieve(), config, CONFIG_DISPOSITIONSTRING, config_file, CONFIG_FLAG_FILEUNCHANGED, CONFIG_HRTIME, CONFIG_LOGUNIQUEID, CONFIG_NEWCDRCOLUMNS, CONFIG_REGISTERED, CONFIG_STATUS_FILEINVALID, CONFIG_STATUS_FILEUNCHANGED, CONFIG_USEGMTIME, ast_module_info::description, LOG_ERROR, LOG_WARNING, name, NULL, odbc_log(), reload(), table, tmp(), and var.

Referenced by load_module().

◆ odbc_log()

static int odbc_log ( struct ast_cdr cdr)
static

Definition at line 165 of file cdr_odbc.c.

166 {
167  struct odbc_obj *obj = ast_odbc_request_obj(dsn, 0);
168  SQLHSTMT stmt;
169 
170  if (!obj) {
171  ast_log(LOG_ERROR, "Unable to retrieve database handle. CDR failed.\n");
172  return -1;
173  }
174 
175  stmt = ast_odbc_direct_execute(obj, execute_cb, cdr);
176  if (stmt) {
177  SQLLEN rows = 0;
178 
179  SQLRowCount(stmt, &rows);
180  SQLFreeHandle(SQL_HANDLE_STMT, stmt);
181 
182  if (rows == 0)
183  ast_log(LOG_WARNING, "CDR successfully ran, but inserted 0 rows?\n");
184  } else
185  ast_log(LOG_ERROR, "CDR direct execute failed\n");
187  return 0;
188 }
static SQLHSTMT execute_cb(struct odbc_obj *obj, void *data)
Definition: cdr_odbc.c:68
void ast_odbc_release_obj(struct odbc_obj *obj)
Releases an ODBC object previously allocated by ast_odbc_request_obj()
Definition: res_odbc.c:804
SQLHSTMT ast_odbc_direct_execute(struct odbc_obj *obj, SQLHSTMT(*exec_cb)(struct odbc_obj *obj, void *data), void *data)
Executes an non prepared statement and returns the resulting statement handle.
Definition: res_odbc.c:360
#define ast_odbc_request_obj(name, check)
Get a ODBC connection object.
Definition: res_odbc.h:120
ODBC container.
Definition: res_odbc.h:46

References ast_log, ast_odbc_direct_execute(), ast_odbc_release_obj(), ast_odbc_request_obj, execute_cb(), LOG_ERROR, and LOG_WARNING.

Referenced by odbc_load_module().

◆ reload()

static int reload ( void  )
static

Definition at line 317 of file cdr_odbc.c.

318 {
319  return odbc_load_module(1);
320 }

Referenced by odbc_load_module().

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 301 of file cdr_odbc.c.

302 {
303  if (ast_cdr_unregister(name)) {
304  return -1;
305  }
306 
307  if (dsn) {
308  ast_free(dsn);
309  }
310  if (table) {
311  ast_free(table);
312  }
313 
314  return 0;
315 }
int ast_cdr_unregister(const char *name)
Unregister a CDR handling engine.
Definition: cdr.c:3010

References ast_cdr_unregister(), ast_free, name, and table.

Variable Documentation

◆ __mod_info

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "ODBC CDR Backend" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_EXTENDED, .load = load_module, .unload = unload_module, .reload = reload, .load_pri = AST_MODPRI_CDR_DRIVER, .requires = "cdr,res_odbc", }
static

Definition at line 317 of file cdr_odbc.c.

◆ ast_module_info

const struct ast_module_info* ast_module_info = &__mod_info
static

Definition at line 329 of file cdr_odbc.c.

◆ config

struct ast_flags config = { 0 }
static

Definition at line 55 of file cdr_odbc.c.

Referenced by execute_cb(), and odbc_load_module().

◆ config_file

const char config_file[] = "cdr_odbc.conf"
static

◆ dsn

char* dsn = NULL
static

Definition at line 55 of file cdr_odbc.c.

Referenced by create_dsn(), get_dsn(), and load_odbc_config().

◆ name

const char name[] = "ODBC"
static

Definition at line 53 of file cdr_odbc.c.

Referenced by odbc_load_module(), and unload_module().

◆ table

char * table = NULL
static

Definition at line 55 of file cdr_odbc.c.

Referenced by __ast_vm_greeter_register(), __ast_vm_register(), alloc_and_initialize_sorcery(), ast_config_internal_load(), ast_destroy_realtime_fields(), ast_load_realtime_all_fields(), ast_load_realtime_multientry_fields(), ast_odbc_find_column(), ast_parking_blind_transfer_park(), ast_parking_is_exten_park(), ast_parking_park_bridge_channel(), ast_parking_park_call(), ast_parking_provider_registered(), ast_realtime_append_mapping(), ast_realtime_require_field(), ast_store_realtime_fields(), ast_unload_realtime(), ast_update2_realtime_fields(), ast_update_realtime_fields(), ast_vm_greeter_is_registered(), ast_vm_greeter_unregister(), ast_vm_is_registered(), ast_vm_unregister(), config_mysql(), config_odbc(), config_pgsql(), destroy_mysql(), destroy_odbc(), destroy_pgsql(), destroy_table(), destroy_table_cache(), execute_cb(), find_column(), find_engine(), find_table(), free_config(), handle_missing_column(), handle_missing_table(), load_config(), map_s_x(), map_x_s(), odbc_load_module(), quan(), quantize(), realtime_common(), realtime_multi_mysql(), realtime_multi_odbc(), realtime_multi_pgsql(), realtime_mysql(), realtime_odbc(), realtime_sqlite3(), realtime_sqlite3_destroy(), realtime_sqlite3_helper(), realtime_sqlite3_load(), realtime_sqlite3_multi(), realtime_sqlite3_require(), realtime_sqlite3_store(), realtime_sqlite3_update(), realtime_sqlite3_update2(), realtime_switch_common(), release_table(), reload(), reload_module(), require_odbc(), require_pgsql(), route_table_add(), route_table_dtor(), route_table_find(), route_table_remove(), store_mysql(), store_odbc(), store_pgsql(), tds_load_module(), unload_module(), update2_mysql(), update2_odbc(), update2_pgsql(), update_mysql(), update_odbc(), and update_pgsql().