Asterisk - The Open Source Telephony Project  18.5.0
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 = "30ef0c93b36035ec78c9cfd712d36d9b" , .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

See also:

Definition in file cdr_odbc.c.

Macro Definition Documentation

◆ DATE_FORMAT

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

Definition at line 54 of file cdr_odbc.c.

Referenced by execute_cb().

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
CONFIG_LOGUNIQUEID 
CONFIG_USEGMTIME 
CONFIG_DISPOSITIONSTRING 
CONFIG_HRTIME 
CONFIG_REGISTERED 
CONFIG_NEWCDRCOLUMNS 

Definition at line 60 of file cdr_odbc.c.

Function Documentation

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 332 of file cdr_odbc.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 332 of file cdr_odbc.c.

◆ AST_MODULE_SELF_SYM()

struct ast_module* AST_MODULE_SELF_SYM ( void  )

Definition at line 332 of file cdr_odbc.c.

◆ execute_cb()

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

Definition at line 71 of file cdr_odbc.c.

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_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().

72 {
73  struct ast_cdr *cdr = data;
74  SQLRETURN ODBC_res;
75  char sqlcmd[2048] = "", timestr[128], new_columns[120] = "", new_values[7] = "";
76  struct ast_tm tm;
77  SQLHSTMT stmt;
78  int i = 0;
79 
80  ast_localtime(&cdr->start, &tm, ast_test_flag(&config, CONFIG_USEGMTIME) ? "GMT" : NULL);
81  ast_strftime(timestr, sizeof(timestr), DATE_FORMAT, &tm);
82 
84  snprintf(new_columns, sizeof(new_columns), "%s", ",peeraccount,linkedid,sequence");
85  snprintf(new_values, sizeof(new_values), "%s", ",?,?,?");
86  }
87 
89  snprintf(sqlcmd,sizeof(sqlcmd),"INSERT INTO %s "
90  "(calldate,clid,src,dst,dcontext,channel,dstchannel,lastapp,"
91  "lastdata,duration,billsec,disposition,amaflags,accountcode,uniqueid,userfield%s) "
92  "VALUES ({ts '%s'},?,?,?,?,?,?,?,?,?,?,?,?,?,?,?%s)", table, new_columns, timestr, new_values);
93  } else {
94  snprintf(sqlcmd,sizeof(sqlcmd),"INSERT INTO %s "
95  "(calldate,clid,src,dst,dcontext,channel,dstchannel,lastapp,lastdata,"
96  "duration,billsec,disposition,amaflags,accountcode%s) "
97  "VALUES ({ts '%s'},?,?,?,?,?,?,?,?,?,?,?,?,?%s)", table, new_columns, timestr, new_values);
98  }
99 
100  ODBC_res = SQLAllocHandle(SQL_HANDLE_STMT, obj->con, &stmt);
101 
102  if ((ODBC_res != SQL_SUCCESS) && (ODBC_res != SQL_SUCCESS_WITH_INFO)) {
103  ast_log(LOG_WARNING, "cdr_odbc: Failure in AllocStatement %d\n", ODBC_res);
104  SQLFreeHandle(SQL_HANDLE_STMT, stmt);
105  return NULL;
106  }
107 
108  SQLBindParameter(stmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cdr->clid), 0, cdr->clid, 0, NULL);
109  SQLBindParameter(stmt, 2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cdr->src), 0, cdr->src, 0, NULL);
110  SQLBindParameter(stmt, 3, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cdr->dst), 0, cdr->dst, 0, NULL);
111  SQLBindParameter(stmt, 4, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cdr->dcontext), 0, cdr->dcontext, 0, NULL);
112  SQLBindParameter(stmt, 5, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cdr->channel), 0, cdr->channel, 0, NULL);
113  SQLBindParameter(stmt, 6, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cdr->dstchannel), 0, cdr->dstchannel, 0, NULL);
114  SQLBindParameter(stmt, 7, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cdr->lastapp), 0, cdr->lastapp, 0, NULL);
115  SQLBindParameter(stmt, 8, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cdr->lastdata), 0, cdr->lastdata, 0, NULL);
116 
118  double hrbillsec = 0.0;
119  double hrduration;
120 
121  if (!ast_tvzero(cdr->answer)) {
122  hrbillsec = (double) ast_tvdiff_us(cdr->end, cdr->answer) / 1000000.0;
123  }
124  hrduration = (double) ast_tvdiff_us(cdr->end, cdr->start) / 1000000.0;
125 
126  SQLBindParameter(stmt, 9, SQL_PARAM_INPUT, SQL_C_DOUBLE, SQL_FLOAT, 0, 0, &hrduration, 0, NULL);
127  SQLBindParameter(stmt, 10, SQL_PARAM_INPUT, SQL_C_DOUBLE, SQL_FLOAT, 0, 0, &hrbillsec, 0, NULL);
128  } else {
129  SQLBindParameter(stmt, 9, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &cdr->duration, 0, NULL);
130  SQLBindParameter(stmt, 10, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &cdr->billsec, 0, NULL);
131  }
132 
134  char *disposition;
135  disposition = ast_strdupa(ast_cdr_disp2str(cdr->disposition));
136  SQLBindParameter(stmt, 11, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(disposition) + 1, 0, disposition, 0, NULL);
137  } else {
138  SQLBindParameter(stmt, 11, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &cdr->disposition, 0, NULL);
139  }
140  SQLBindParameter(stmt, 12, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &cdr->amaflags, 0, NULL);
141  SQLBindParameter(stmt, 13, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cdr->accountcode), 0, cdr->accountcode, 0, NULL);
142 
143  i = 14;
145  SQLBindParameter(stmt, 14, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cdr->uniqueid), 0, cdr->uniqueid, 0, NULL);
146  SQLBindParameter(stmt, 15, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cdr->userfield), 0, cdr->userfield, 0, NULL);
147  i = 16;
148  }
149 
151  SQLBindParameter(stmt, i, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cdr->peeraccount), 0, cdr->peeraccount, 0, NULL);
152  SQLBindParameter(stmt, i + 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cdr->linkedid), 0, cdr->linkedid, 0, NULL);
153  SQLBindParameter(stmt, i + 2, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &cdr->sequence, 0, NULL);
154  }
155 
156  ODBC_res = ast_odbc_execute_sql(obj, stmt, sqlcmd);
157 
158  if ((ODBC_res != SQL_SUCCESS) && (ODBC_res != SQL_SUCCESS_WITH_INFO)) {
159  ast_log(LOG_WARNING, "cdr_odbc: Error in ExecDirect: %d, query is: %s\n", ODBC_res, sqlcmd);
160  SQLFreeHandle(SQL_HANDLE_STMT, stmt);
161  return NULL;
162  }
163 
164  return stmt;
165 }
SQLHDBC con
Definition: res_odbc.h:47
char accountcode[AST_MAX_ACCOUNT_CODE]
Definition: cdr.h:308
char dstchannel[AST_MAX_EXTENSION]
Definition: cdr.h:288
static struct ast_flags config
Definition: cdr_odbc.c:69
#define ast_test_flag(p, flag)
Definition: utils.h:63
long int billsec
Definition: cdr.h:302
#define LOG_WARNING
Definition: logger.h:274
char dcontext[AST_MAX_EXTENSION]
Definition: cdr.h:284
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
int ast_tvzero(const struct timeval t)
Returns true if the argument is 0,0.
Definition: time.h:108
int sequence
Definition: cdr.h:320
#define NULL
Definition: resample.c:96
static char * table
Definition: cdr_odbc.c:58
#define DATE_FORMAT
Definition: cdr_odbc.c:54
char lastdata[AST_MAX_EXTENSION]
Definition: cdr.h:292
long int amaflags
Definition: cdr.h:306
#define ast_log
Definition: astobj2.c:42
char linkedid[AST_MAX_UNIQUEID]
Definition: cdr.h:316
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
char uniqueid[AST_MAX_UNIQUEID]
Definition: cdr.h:314
char dst[AST_MAX_EXTENSION]
Definition: cdr.h:282
char channel[AST_MAX_EXTENSION]
Definition: cdr.h:286
struct timeval answer
Definition: cdr.h:296
Responsible for call detail data.
Definition: cdr.h:276
char lastapp[AST_MAX_EXTENSION]
Definition: cdr.h:290
const char * ast_cdr_disp2str(int disposition)
Disposition to a string.
Definition: cdr.c:3430
struct timeval start
Definition: cdr.h:294
long int duration
Definition: cdr.h:300
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
char src[AST_MAX_EXTENSION]
Definition: cdr.h:280
char peeraccount[AST_MAX_ACCOUNT_CODE]
Definition: cdr.h:310
SQLRETURN ast_odbc_execute_sql(struct odbc_obj *obj, SQLHSTMT *stmt, const char *sql)
Execute a nonprepared SQL query.
Definition: res_odbc.c:478
struct timeval end
Definition: cdr.h:298
int64_t ast_tvdiff_us(struct timeval end, struct timeval start)
Computes the difference (in microseconds) between two struct timeval instances.
Definition: time.h:78
long int disposition
Definition: cdr.h:304
char clid[AST_MAX_EXTENSION]
Definition: cdr.h:278
char userfield[AST_MAX_USER_FIELD]
Definition: cdr.h:318

◆ load_module()

static int load_module ( void  )
static

Definition at line 299 of file cdr_odbc.c.

References odbc_load_module().

Referenced by reload().

300 {
301  return odbc_load_module(0);
302 }
static int odbc_load_module(int reload)
Definition: cdr_odbc.c:193

◆ odbc_load_module()

static int odbc_load_module ( int  reload)
static

Definition at line 193 of file cdr_odbc.c.

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_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(), table, tmp(), and var.

Referenced by load_module(), and reload().

194 {
195  int res = 0;
196  struct ast_config *cfg;
197  struct ast_variable *var;
198  const char *tmp;
199  struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
200 
201  do {
202  cfg = ast_config_load(config_file, config_flags);
203  if (!cfg || cfg == CONFIG_STATUS_FILEINVALID) {
204  ast_log(LOG_WARNING, "cdr_odbc: Unable to load config for ODBC CDR's: %s\n", config_file);
206  break;
207  } else if (cfg == CONFIG_STATUS_FILEUNCHANGED)
208  break;
209 
210  var = ast_variable_browse(cfg, "global");
211  if (!var) {
212  /* nothing configured */
213  break;
214  }
215 
216  if ((tmp = ast_variable_retrieve(cfg, "global", "dsn")) == NULL) {
217  ast_log(LOG_WARNING, "cdr_odbc: dsn not specified. Assuming asteriskdb\n");
218  tmp = "asteriskdb";
219  }
220  if (dsn)
221  ast_free(dsn);
222  dsn = ast_strdup(tmp);
223  if (dsn == NULL) {
224  res = -1;
225  break;
226  }
227 
228  if (((tmp = ast_variable_retrieve(cfg, "global", "dispositionstring"))) && ast_true(tmp))
230  else
232 
233  if (((tmp = ast_variable_retrieve(cfg, "global", "loguniqueid"))) && ast_true(tmp)) {
235  ast_debug(1, "cdr_odbc: Logging uniqueid\n");
236  } else {
238  ast_debug(1, "cdr_odbc: Not logging uniqueid\n");
239  }
240 
241  if (((tmp = ast_variable_retrieve(cfg, "global", "usegmtime"))) && ast_true(tmp)) {
243  ast_debug(1, "cdr_odbc: Logging in GMT\n");
244  } else {
246  ast_debug(1, "cdr_odbc: Logging in local time\n");
247  }
248 
249  if (((tmp = ast_variable_retrieve(cfg, "global", "hrtime"))) && ast_true(tmp)) {
251  ast_debug(1, "cdr_odbc: Logging billsec and duration fields as floats\n");
252  } else {
254  ast_debug(1, "cdr_odbc: Logging billsec and duration fields as integers\n");
255  }
256 
257  if ((tmp = ast_variable_retrieve(cfg, "global", "table")) == NULL) {
258  ast_log(LOG_WARNING, "cdr_odbc: table not specified. Assuming cdr\n");
259  tmp = "cdr";
260  }
261  if (table)
262  ast_free(table);
263  table = ast_strdup(tmp);
264  if (table == NULL) {
265  res = -1;
266  break;
267  }
268 
271  if (res) {
272  ast_log(LOG_ERROR, "cdr_odbc: Unable to register ODBC CDR handling\n");
273  } else {
275  }
276  }
277  if (((tmp = ast_variable_retrieve(cfg, "global", "newcdrcolumns"))) && ast_true(tmp)) {
279  ast_debug(1, "cdr_odbc: Add new cdr columns\n");
280  } else {
282  ast_debug(1, "cdr_odbc: Not add new cdr columns\n");
283  }
284  } while (0);
285 
286  if (ast_test_flag(&config, CONFIG_REGISTERED) && (!cfg || dsn == NULL || table == NULL)) {
289  } else {
291  }
292 
293  if (cfg && cfg != CONFIG_STATUS_FILEUNCHANGED && cfg != CONFIG_STATUS_FILEINVALID) {
294  ast_config_destroy(cfg);
295  }
296  return res;
297 }
const char * description
Definition: module.h:352
int ast_cdr_backend_suspend(const char *name)
Suspend a CDR backend temporarily.
Definition: cdr.c:2866
static const char config_file[]
Definition: cdr_odbc.c:57
static struct ast_flags config
Definition: cdr_odbc.c:69
#define ast_test_flag(p, flag)
Definition: utils.h:63
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category_name)
Definition: extconf.c:1216
#define ast_set_flag(p, flag)
Definition: utils.h:70
#define LOG_WARNING
Definition: logger.h:274
int ast_cdr_backend_unsuspend(const char *name)
Unsuspend a CDR backend.
Definition: cdr.c:2884
#define CONFIG_STATUS_FILEINVALID
static const char name[]
Definition: cdr_odbc.c:56
static int tmp()
Definition: bt_open.c:389
Structure for variables, used for configurations and for channel variables.
#define var
Definition: ast_expr2f.c:614
Definition: func_odbc.c:150
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:243
#define NULL
Definition: resample.c:96
static int reload(void)
Definition: cdr_odbc.c:320
static char * table
Definition: cdr_odbc.c:58
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
#define ast_log
Definition: astobj2.c:42
#define ast_config_load(filename, flags)
Load a config file.
int ast_cdr_register(const char *name, const char *desc, ast_cdrbe be)
Register a CDR handling engine.
Definition: cdr.c:2943
void ast_config_destroy(struct ast_config *config)
Destroys a config.
Definition: extconf.c:1290
static int odbc_log(struct ast_cdr *cdr)
Definition: cdr_odbc.c:168
#define CONFIG_STATUS_FILEUNCHANGED
#define LOG_ERROR
Definition: logger.h:285
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true". This function checks to see whether a string passed to it is an indication of an "true" value. It checks to see if the string is "yes", "true", "y", "t", "on" or "1".
Definition: main/utils.c:1951
#define ast_free(a)
Definition: astmm.h:182
Module has failed to load, may be in an inconsistent state.
Definition: module.h:78
Structure used to handle boolean flags.
Definition: utils.h:199
#define ast_clear_flag(p, flag)
Definition: utils.h:77
const char * ast_variable_retrieve(struct ast_config *config, const char *category, const char *variable)
Definition: main/config.c:694

◆ odbc_log()

static int odbc_log ( struct ast_cdr cdr)
static

Definition at line 168 of file cdr_odbc.c.

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().

169 {
170  struct odbc_obj *obj = ast_odbc_request_obj(dsn, 0);
171  SQLHSTMT stmt;
172 
173  if (!obj) {
174  ast_log(LOG_ERROR, "Unable to retrieve database handle. CDR failed.\n");
175  return -1;
176  }
177 
178  stmt = ast_odbc_direct_execute(obj, execute_cb, cdr);
179  if (stmt) {
180  SQLLEN rows = 0;
181 
182  SQLRowCount(stmt, &rows);
183  SQLFreeHandle(SQL_HANDLE_STMT, stmt);
184 
185  if (rows == 0)
186  ast_log(LOG_WARNING, "CDR successfully ran, but inserted 0 rows?\n");
187  } else
188  ast_log(LOG_ERROR, "CDR direct execute failed\n");
190  return 0;
191 }
#define LOG_WARNING
Definition: logger.h:274
Definition: func_odbc.c:150
static SQLHSTMT execute_cb(struct odbc_obj *obj, void *data)
Definition: cdr_odbc.c:71
#define ast_log
Definition: astobj2.c:42
ODBC container.
Definition: res_odbc.h:46
#define LOG_ERROR
Definition: logger.h:285
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:369
#define ast_odbc_request_obj(a, b)
Definition: res_odbc.h:122
void ast_odbc_release_obj(struct odbc_obj *obj)
Releases an ODBC object previously allocated by ast_odbc_request_obj()
Definition: res_odbc.c:813

◆ reload()

static int reload ( void  )
static

Definition at line 320 of file cdr_odbc.c.

References AST_MODFLAG_LOAD_ORDER, AST_MODPRI_CDR_DRIVER, AST_MODULE_INFO(), AST_MODULE_SUPPORT_EXTENDED, ASTERISK_GPL_KEY, load_module(), odbc_load_module(), and unload_module().

321 {
322  return odbc_load_module(1);
323 }
static int odbc_load_module(int reload)
Definition: cdr_odbc.c:193

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 304 of file cdr_odbc.c.

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

Referenced by reload().

305 {
306  if (ast_cdr_unregister(name)) {
307  return -1;
308  }
309 
310  if (dsn) {
311  ast_free(dsn);
312  }
313  if (table) {
314  ast_free(table);
315  }
316 
317  return 0;
318 }
int ast_cdr_unregister(const char *name)
Unregister a CDR handling engine.
Definition: cdr.c:2988
static const char name[]
Definition: cdr_odbc.c:56
Definition: func_odbc.c:150
static char * table
Definition: cdr_odbc.c:58
#define ast_free(a)
Definition: astmm.h:182

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 = "30ef0c93b36035ec78c9cfd712d36d9b" , .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 332 of file cdr_odbc.c.

◆ ast_module_info

const struct ast_module_info* ast_module_info = &__mod_info
static

Definition at line 332 of file cdr_odbc.c.

◆ config

struct ast_flags config = { 0 }
static

Definition at line 69 of file cdr_odbc.c.

◆ config_file

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

◆ dsn

char* dsn = NULL
static

Definition at line 58 of file cdr_odbc.c.

Referenced by create_dsn(), and get_dsn().

◆ name

const char name[] = "ODBC"
static

Definition at line 56 of file cdr_odbc.c.

Referenced by odbc_load_module(), and unload_module().

◆ table

char * table = NULL
static