49#define CSV_LOG_DIR "/cdr-csv"
50#define CSV_MASTER "/Master.csv"
52#define DATE_FORMAT "%Y-%m-%d %T"
60static const char config[] =
"cdr.conf";
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")) {
149 int pos = strlen(
buf), spos = 0,
error = -1;
151 if (pos >= bufsize - 4)
156 while(pos < bufsize - 3) {
163 buf[pos++] = s[spos];
177 int pos = strlen(
buf);
179 snprintf(
tmp,
sizeof(
tmp),
"%d", s);
181 if (pos + strlen(
tmp) > bufsize - 3)
184 strncat(
buf,
tmp, bufsize - strlen(
buf) - 1);
197 if (strlen(
buf) > bufsize - 3)
201 strncat(
buf,
",", bufsize - strlen(
buf) - 1);
259 if (strlen(
buf) < bufsize - 5) {
261 buf[strlen(
buf) - 1] =
'\0';
262 strncat(
buf,
"\n", bufsize - strlen(
buf) - 1);
274 if (!(f = fopen(file_path,
"a"))) {
289 if (strchr(acc,
'/') || (acc[0] ==
'.')) {
302 ast_log(
LOG_WARNING,
"Unable to create CSV record in %d bytes. CDR not recorded!\n", (
int)
sizeof(
buf));
Asterisk main include file. File version handling, generic pbx functions.
int ast_cdr_unregister(const char *name)
Unregister a CDR handling engine.
const char * ast_cdr_disp2str(int disposition)
Disposition to a string.
int ast_cdr_register(const char *name, const char *desc, ast_cdrbe be)
Register a CDR handling engine.
static int append_date(char *buf, struct timeval when, size_t bufsize)
static int csv_log(struct ast_cdr *cdr)
static int writefile_account(char *s, char *acc)
static int writefile(char *s, char *file_path)
static ast_mutex_t f_lock
static int append_int(char *buf, int s, size_t bufsize)
static const char config[]
static int append_string(char *buf, const char *s, size_t bufsize)
static int load_module(void)
static char file_csv_master[PATH_MAX]
static int unload_module(void)
static int load_config(int reload)
static int build_csv_record(char *buf, size_t bufsize, struct ast_cdr *cdr)
General Asterisk PBX channel definitions.
const char * ast_channel_amaflags2string(enum ama_flags flags)
Convert the enum representation of an AMA flag to a string representation.
Configuration File Parser.
#define ast_config_load(filename, flags)
Load a config file.
#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)
@ CONFIG_FLAG_FILEUNCHANGED
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_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...
Asterisk locking-related definitions:
#define ast_mutex_unlock(a)
#define ast_mutex_lock(a)
#define AST_MUTEX_DEFINE_STATIC(mutex)
Asterisk module definitions.
#define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...)
@ AST_MODULE_SUPPORT_EXTENDED
#define ASTERISK_GPL_KEY
The text the key() function should return.
@ AST_MODULE_LOAD_DECLINE
Module has failed to load, may be in an inconsistent state.
Asterisk file paths, configured in asterisk.conf.
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"....
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Responsible for call detail data.
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]
Structure used to handle boolean flags.
Structure for variables, used for configurations and for channel variables.
struct ast_variable * next
int ast_tvzero(const struct timeval t)
Returns true if the argument is 0,0.
int error(const char *format,...)