Comma Separated Value CDR records.
More...
Go to the source code of this file.
|
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 = "ac1f6a56484a8820659555499174e588" , .load = load_module, .unload = unload_module, .reload = reload, .load_pri = AST_MODPRI_CDR_DRIVER, } |
|
static int | accountlogs |
|
static ast_mutex_t | acf_lock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, 1 } |
|
static struct ast_module_info * | ast_module_info = &__mod_info |
|
static const char | config [] = "cdr.conf" |
|
static int | loaded = 0 |
|
static int | loguniqueid = 0 |
|
static int | loguserfield = 0 |
|
static ast_mutex_t | mf_lock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, 1 } |
|
static char * | name = "csv" |
|
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.
#define CSV_LOG_DIR "/cdr-csv" |
#define CSV_MASTER "/Master.csv" |
#define DATE_FORMAT "%Y-%m-%d %T" |
static void __reg_module |
( |
void |
| ) |
|
|
static |
static void __unreg_module |
( |
void |
| ) |
|
|
static |
static int append_date |
( |
char * |
buf, |
|
|
struct timeval |
when, |
|
|
size_t |
bufsize |
|
) |
| |
|
static |
Definition at line 193 of file cdr_csv.c.
References append_string(), ast_localtime(), ast_strftime(), ast_tvzero(), and DATE_FORMAT.
Referenced by build_csv_record().
198 if (strlen(buf) > bufsize - 3)
202 strncat(buf,
",", bufsize - strlen(buf) - 1);
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.
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...
static int append_string(char *buf, const char *s, size_t bufsize)
static int append_int |
( |
char * |
buf, |
|
|
int |
s, |
|
|
size_t |
bufsize |
|
) |
| |
|
static |
Definition at line 175 of file cdr_csv.c.
Referenced by build_csv_record().
178 int pos = strlen(buf);
180 snprintf(tmp,
sizeof(tmp),
"%d", s);
182 if (pos + strlen(tmp) > bufsize - 3)
185 strncat(buf, tmp, bufsize - strlen(buf) - 1);
static int append_string |
( |
char * |
buf, |
|
|
const char * |
s, |
|
|
size_t |
bufsize |
|
) |
| |
|
static |
Definition at line 148 of file cdr_csv.c.
Referenced by append_date(), and build_csv_record().
150 int pos = strlen(buf), spos = 0, error = -1;
152 if (pos >= bufsize - 4)
157 while(pos < bufsize - 3) {
164 buf[pos++] = s[spos];
static int build_csv_record |
( |
char * |
buf, |
|
|
size_t |
bufsize, |
|
|
struct ast_cdr * |
cdr |
|
) |
| |
|
static |
Definition at line 212 of file cdr_csv.c.
References ast_cdr::accountcode, ast_cdr::amaflags, ast_cdr::answer, append_date(), append_int(), append_string(), ast_cdr_disp2str(), ast_cdr_flags2str(), ast_cdr::billsec, 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::src, ast_cdr::start, ast_cdr::uniqueid, and ast_cdr::userfield.
Referenced by csv_log().
255 if (strlen(buf) < bufsize - 5) {
257 buf[strlen(buf) - 1] =
'\0';
258 strncat(buf,
"\n", bufsize - strlen(buf) - 1);
char accountcode[AST_MAX_ACCOUNT_CODE]
char dstchannel[AST_MAX_EXTENSION]
char dcontext[AST_MAX_EXTENSION]
char * ast_cdr_flags2str(int flags)
char lastdata[AST_MAX_EXTENSION]
char dst[AST_MAX_EXTENSION]
char channel[AST_MAX_EXTENSION]
char lastapp[AST_MAX_EXTENSION]
char src[AST_MAX_EXTENSION]
static int append_string(char *buf, const char *s, size_t bufsize)
static int append_int(char *buf, int s, size_t bufsize)
char clid[AST_MAX_EXTENSION]
char * ast_cdr_disp2str(int disposition)
Disposition to a string.
char userfield[AST_MAX_USER_FIELD]
static int append_date(char *buf, struct timeval when, size_t bufsize)
static int csv_log |
( |
struct ast_cdr * |
cdr | ) |
|
|
static |
Definition at line 291 of file cdr_csv.c.
References ast_cdr::accountcode, ast_cdr::amaflags, ast_cdr_disp2str(), ast_cdr_flags2str(), ast_config_AST_LOG_DIR, ast_log(), ast_mutex_lock, ast_mutex_unlock, ast_strlen_zero(), ast_cdr::billsec, build_csv_record(), ast_cdr::channel, CSV_LOG_DIR, CSV_MASTER, ast_cdr::disposition, ast_cdr::dst, ast_cdr::duration, errno, LOG_ERROR, LOG_WARNING, mf_lock, ast_cdr::src, and writefile().
Referenced by load_module().
296 char csvmaster[PATH_MAX];
302 ast_log(
LOG_WARNING,
"Unable to create CSV record in %d bytes. CDR not recorded!\n", (
int)
sizeof(buf));
310 if ((mf = fopen(csvmaster,
"a"))) {
char accountcode[AST_MAX_ACCOUNT_CODE]
#define ast_mutex_lock(a)
char * ast_cdr_flags2str(int flags)
static ast_mutex_t mf_lock
static force_inline int attribute_pure ast_strlen_zero(const char *s)
char dst[AST_MAX_EXTENSION]
char channel[AST_MAX_EXTENSION]
static int build_csv_record(char *buf, size_t bufsize, struct ast_cdr *cdr)
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
const char * ast_config_AST_LOG_DIR
static int writefile(char *s, char *acc)
char src[AST_MAX_EXTENSION]
char * ast_cdr_disp2str(int disposition)
Disposition to a string.
#define ast_mutex_unlock(a)
static int load_config |
( |
int |
reload | ) |
|
|
static |
Definition at line 95 of file cdr_csv.c.
References ast_config_destroy(), ast_config_load, ast_debug, ast_log(), ast_true(), ast_variable_browse(), ast_variable_retrieve(), CONFIG_FLAG_FILEUNCHANGED, CONFIG_STATUS_FILEINVALID, CONFIG_STATUS_FILEUNCHANGED, LOG_WARNING, and var.
Referenced by load_module(), and reload().
128 ast_debug(1,
"logging in separate files per accountcode\n");
135 ast_debug(1,
"logging CDR field UNIQUEID\n");
141 ast_debug(1,
"logging CDR user-defined field\n");
const char * ast_variable_retrieve(const struct ast_config *config, const char *category, const char *variable)
Gets a variable.
static const char config[]
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category)
Goes through variables.
Structure for variables, used for configurations and for channel variables.
void ast_config_destroy(struct ast_config *config)
Destroys a config.
#define ast_debug(level,...)
Log a DEBUG message.
#define ast_config_load(filename, flags)
Load a config file.
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".
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Structure used to handle boolean flags.
#define CONFIG_STATUS_FILEINVALID
#define CONFIG_STATUS_FILEUNCHANGED
static int load_module |
( |
void |
| ) |
|
|
static |
Definition at line 336 of file cdr_csv.c.
References ast_cdr_register(), ast_log(), AST_MODULE_LOAD_DECLINE, csv_log(), ast_module_info::description, load_config(), and LOG_ERROR.
static int load_config(int reload)
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)
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
static int reload |
( |
void |
| ) |
|
|
static |
Definition at line 351 of file cdr_csv.c.
References ast_cdr_unregister(), ast_log(), load_config(), and LOG_WARNING.
static int load_config(int reload)
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
void ast_cdr_unregister(const char *name)
Unregister a CDR handling engine.
static int unload_module |
( |
void |
| ) |
|
|
static |
static int writefile |
( |
char * |
s, |
|
|
char * |
acc |
|
) |
| |
|
static |
Definition at line 264 of file cdr_csv.c.
References acf_lock, ast_config_AST_LOG_DIR, ast_log(), ast_mutex_lock, ast_mutex_unlock, CSV_LOG_DIR, errno, f, LOG_ERROR, and LOG_WARNING.
Referenced by csv_log().
269 if (strchr(acc,
'/') || (acc[0] ==
'.')) {
277 if (!(f = fopen(tmp,
"a"))) {
#define ast_mutex_lock(a)
static ast_mutex_t acf_lock
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
const char * ast_config_AST_LOG_DIR
#define ast_mutex_unlock(a)
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 = "ac1f6a56484a8820659555499174e588" , .load = load_module, .unload = unload_module, .reload = reload, .load_pri = AST_MODPRI_CDR_DRIVER, } |
|
static |
ast_mutex_t acf_lock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, 1 } |
|
static |
const char config[] = "cdr.conf" |
|
static |
Definition at line 57 of file cdr_csv.c.
Referenced by ast_config_new(), ast_readconfig(), builtin_atxfer(), custom_log(), do_reload(), load_config(), load_module(), load_odbc_config(), load_pktccops_config(), misdn_cfg_init(), parse_config(), read_config_maps(), and reload_config().
ast_mutex_t mf_lock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, 1 } |
|
static |