39 #include "asterisk/paths.h"
47 #define CSV_LOG_DIR "/cdr-csv"
48 #define CSV_MASTER "/Master.csv"
50 #define DATE_FORMAT "%Y-%m-%d %T"
57 static const char config[] =
"cdr.conf";
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");
150 int pos = strlen(buf), spos = 0, error = -1;
152 if (pos >= bufsize - 4)
157 while(pos < bufsize - 3) {
164 buf[pos++] = s[spos];
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);
193 static int append_date(
char *buf,
struct timeval when,
size_t bufsize)
198 if (strlen(buf) > bufsize - 3)
202 strncat(buf,
",", bufsize - strlen(buf) - 1);
255 if (strlen(buf) < bufsize - 5) {
257 buf[strlen(buf) - 1] =
'\0';
258 strncat(buf,
"\n", bufsize - strlen(buf) - 1);
269 if (strchr(acc,
'/') || (acc[0] ==
'.')) {
277 if (!(f = fopen(tmp,
"a"))) {
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]
Asterisk locking-related definitions:
Asterisk main include file. File version handling, generic pbx functions.
const char * ast_variable_retrieve(const struct ast_config *config, const char *category, const char *variable)
Gets a variable.
static const char config[]
char dstchannel[AST_MAX_EXTENSION]
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category)
Goes through variables.
char dcontext[AST_MAX_EXTENSION]
static int load_config(int reload)
struct ast_tm * ast_localtime(const struct timeval *timep, struct ast_tm *p_tm, const char *zone)
Timezone-independent version of localtime_r(3).
Structure for variables, used for configurations and for channel variables.
int ast_tvzero(const struct timeval t)
Returns true if the argument is 0,0.
Configuration File Parser.
#define ast_mutex_lock(a)
static ast_mutex_t acf_lock
#define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...)
char * ast_cdr_flags2str(int flags)
void ast_config_destroy(struct ast_config *config)
Destroys a config.
char lastdata[AST_MAX_EXTENSION]
#define ast_debug(level,...)
Log a DEBUG message.
int ast_cdr_register(const char *name, const char *desc, ast_cdrbe be)
Register a CDR handling engine.
General Asterisk PBX channel definitions.
static ast_mutex_t mf_lock
static int load_module(void)
#define ast_config_load(filename, flags)
Load a config file.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
char dst[AST_MAX_EXTENSION]
char channel[AST_MAX_EXTENSION]
Responsible for call detail data.
char lastapp[AST_MAX_EXTENSION]
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".
static int build_csv_record(char *buf, size_t bufsize, struct ast_cdr *cdr)
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...
const char * ast_config_AST_LOG_DIR
static int writefile(char *s, char *acc)
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...
Structure used to handle boolean flags.
char src[AST_MAX_EXTENSION]
static int unload_module(void)
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]
#define CONFIG_STATUS_FILEINVALID
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
char * ast_cdr_disp2str(int disposition)
Disposition to a string.
#define AST_MUTEX_DEFINE_STATIC(mutex)
void ast_cdr_unregister(const char *name)
Unregister a CDR handling engine.
#define ASTERISK_FILE_VERSION(file, version)
Register/unregister a source code file with the core.
char userfield[AST_MAX_USER_FIELD]
#define CONFIG_STATUS_FILEUNCHANGED
#define ast_mutex_unlock(a)
static int append_date(char *buf, struct timeval when, size_t bufsize)