Comma Separated Value CDR records.
More...
Go to the source code of this file.
|
static void | __reg_module (void) |
|
static void | __unreg_module (void) |
|
static int | append_date (char *buf, struct timeval when, size_t bufsize) |
|
static int | append_int (char *buf, int s, size_t bufsize) |
|
static int | append_string (char *buf, const char *s, size_t bufsize) |
|
struct ast_module * | AST_MODULE_SELF_SYM (void) |
|
static int | build_csv_record (char *buf, size_t bufsize, struct ast_cdr *cdr) |
|
static int | csv_log (struct ast_cdr *cdr) |
|
static int | load_config (int reload) |
|
static int | load_module (void) |
|
static int | reload (void) |
|
static int | unload_module (void) |
|
static int | writefile (char *s, char *file_path) |
|
static int | writefile_account (char *s, char *acc) |
|
|
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Comma Separated Values 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", } |
|
static int | accountlogs = 1 |
|
static const struct ast_module_info * | ast_module_info = &__mod_info |
|
static const char | config [] = "cdr.conf" |
|
static ast_mutex_t | f_lock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} } |
|
static char | file_csv_master [PATH_MAX] |
|
static int | loaded = 0 |
|
static int | loguniqueid = 0 |
|
static int | loguserfield = 0 |
|
static char * | name = "csv" |
|
static int | newcdrcolumns = 0 |
|
static int | usegmtime = 0 |
|
Comma Separated Value CDR records.
- Author
- Mark Spencer marks.nosp@m.ter@.nosp@m.digiu.nosp@m.m.co.nosp@m.m
Definition in file cdr_csv.c.
◆ CSV_LOG_DIR
#define CSV_LOG_DIR "/cdr-csv" |
◆ CSV_MASTER
#define CSV_MASTER "/Master.csv" |
◆ DATE_FORMAT
#define DATE_FORMAT "%Y-%m-%d %T" |
◆ __reg_module()
static void __reg_module |
( |
void |
| ) |
|
|
static |
◆ __unreg_module()
static void __unreg_module |
( |
void |
| ) |
|
|
static |
◆ append_date()
static int append_date |
( |
char * |
buf, |
|
|
struct timeval |
when, |
|
|
size_t |
bufsize |
|
) |
| |
|
static |
Definition at line 192 of file cdr_csv.c.
197 if (strlen(
buf) > bufsize - 3)
201 strncat(
buf,
",", bufsize - strlen(
buf) - 1);
static int append_string(char *buf, const char *s, size_t bufsize)
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...
struct ast_tm * ast_localtime(const struct timeval *timep, struct ast_tm *p_tm, const char *zone)
Timezone-independent version of localtime_r(3).
int ast_tvzero(const struct timeval t)
Returns true if the argument is 0,0.
References append_string(), ast_localtime(), ast_strftime(), ast_tvzero(), buf, DATE_FORMAT, NULL, tmp(), and usegmtime.
Referenced by build_csv_record().
◆ append_int()
static int append_int |
( |
char * |
buf, |
|
|
int |
s, |
|
|
size_t |
bufsize |
|
) |
| |
|
static |
◆ append_string()
static int append_string |
( |
char * |
buf, |
|
|
const char * |
s, |
|
|
size_t |
bufsize |
|
) |
| |
|
static |
◆ AST_MODULE_SELF_SYM()
◆ build_csv_record()
static int build_csv_record |
( |
char * |
buf, |
|
|
size_t |
bufsize, |
|
|
struct ast_cdr * |
cdr |
|
) |
| |
|
static |
Definition at line 211 of file cdr_csv.c.
259 if (strlen(
buf) < bufsize - 5) {
261 buf[strlen(
buf) - 1] =
'\0';
262 strncat(
buf,
"\n", bufsize - strlen(
buf) - 1);
const char * ast_cdr_disp2str(int disposition)
Disposition to a string.
static int append_date(char *buf, struct timeval when, size_t bufsize)
static int append_int(char *buf, int s, size_t bufsize)
const char * ast_channel_amaflags2string(enum ama_flags flags)
Convert the enum representation of an AMA flag to a string representation.
char dstchannel[AST_MAX_EXTENSION]
char lastdata[AST_MAX_EXTENSION]
char linkedid[AST_MAX_UNIQUEID]
char userfield[AST_MAX_USER_FIELD]
char channel[AST_MAX_EXTENSION]
char peeraccount[AST_MAX_ACCOUNT_CODE]
char src[AST_MAX_EXTENSION]
char dst[AST_MAX_EXTENSION]
char clid[AST_MAX_EXTENSION]
char uniqueid[AST_MAX_UNIQUEID]
char accountcode[AST_MAX_ACCOUNT_CODE]
char lastapp[AST_MAX_EXTENSION]
char dcontext[AST_MAX_EXTENSION]
References ast_cdr::accountcode, ast_cdr::amaflags, ast_cdr::answer, append_date(), append_int(), append_string(), ast_cdr_disp2str(), ast_channel_amaflags2string(), ast_cdr::billsec, buf, ast_cdr::channel, ast_cdr::clid, 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, loguniqueid, loguserfield, newcdrcolumns, ast_cdr::peeraccount, ast_cdr::sequence, ast_cdr::src, ast_cdr::start, ast_cdr::uniqueid, and ast_cdr::userfield.
Referenced by csv_log().
◆ csv_log()
static int csv_log |
( |
struct ast_cdr * |
cdr | ) |
|
|
static |
Definition at line 297 of file cdr_csv.c.
302 ast_log(
LOG_WARNING,
"Unable to create CSV record in %d bytes. CDR not recorded!\n", (
int)
sizeof(
buf));
static int writefile_account(char *s, char *acc)
static int writefile(char *s, char *file_path)
static ast_mutex_t f_lock
static char file_csv_master[PATH_MAX]
static int build_csv_record(char *buf, size_t bufsize, struct ast_cdr *cdr)
#define ast_mutex_unlock(a)
#define ast_mutex_lock(a)
static force_inline int attribute_pure ast_strlen_zero(const char *s)
References ast_cdr::accountcode, accountlogs, ast_log, ast_mutex_lock, ast_mutex_unlock, ast_strlen_zero(), buf, build_csv_record(), errno, f_lock, file_csv_master, LOG_WARNING, writefile(), and writefile_account().
Referenced by load_module().
◆ load_config()
static int load_config |
( |
int |
reload | ) |
|
|
static |
Definition at line 98 of file cdr_csv.c.
128 for (; v; v = v->
next) {
129 if (!strcasecmp(v->
name,
"usegmtime")) {
131 }
else if (!strcasecmp(v->
name,
"accountlogs")) {
134 }
else if (!strcasecmp(v->
name,
"loguniqueid")) {
136 }
else if (!strcasecmp(v->
name,
"loguserfield")) {
138 }
else if (!strcasecmp(v->
name,
"newcdrcolumns")) {
static const char config[]
#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.
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category_name)
const char * ast_config_AST_LOG_DIR
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true"....
Structure used to handle boolean flags.
Structure for variables, used for configurations and for channel variables.
struct ast_variable * next
References accountlogs, ast_config_AST_LOG_DIR, ast_config_destroy(), ast_config_load, ast_log, ast_mutex_lock, ast_mutex_unlock, ast_true(), ast_variable_browse(), config, CONFIG_FLAG_FILEUNCHANGED, CONFIG_STATUS_FILEINVALID, CONFIG_STATUS_FILEUNCHANGED, CSV_LOG_DIR, CSV_MASTER, f_lock, file_csv_master, LOG_WARNING, loguniqueid, loguserfield, ast_variable::name, newcdrcolumns, ast_variable::next, reload(), usegmtime, and ast_variable::value.
Referenced by load_module().
◆ load_module()
static int load_module |
( |
void |
| ) |
|
|
static |
Definition at line 328 of file cdr_csv.c.
int ast_cdr_register(const char *name, const char *desc, ast_cdrbe be)
Register a CDR handling engine.
static int csv_log(struct ast_cdr *cdr)
static int load_config(int reload)
@ AST_MODULE_LOAD_DECLINE
Module has failed to load, may be in an inconsistent state.
References ast_cdr_register(), ast_log, AST_MODULE_LOAD_DECLINE, csv_log(), ast_module_info::description, load_config(), loaded, LOG_ERROR, and name.
◆ reload()
static int reload |
( |
void |
| ) |
|
|
static |
Definition at line 344 of file cdr_csv.c.
int ast_cdr_unregister(const char *name)
Unregister a CDR handling engine.
Referenced by load_config().
◆ unload_module()
static int unload_module |
( |
void |
| ) |
|
|
static |
◆ writefile()
static int writefile |
( |
char * |
s, |
|
|
char * |
file_path |
|
) |
| |
|
static |
◆ writefile_account()
static int writefile_account |
( |
char * |
s, |
|
|
char * |
acc |
|
) |
| |
|
static |
◆ __mod_info
struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Comma Separated Values 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", } |
|
static |
◆ accountlogs
◆ ast_module_info
◆ config
const char config[] = "cdr.conf" |
|
static |
◆ f_lock
ast_mutex_t f_lock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} } |
|
static |
◆ file_csv_master
◆ loaded
◆ loguniqueid
◆ loguserfield
◆ name
◆ newcdrcolumns
◆ usegmtime