Asterisk - The Open Source Telephony Project GIT-master-80b953f
Loading...
Searching...
No Matches
Macros | Functions
getters_cdr.c File Reference

CDR Getters. More...

#include "cdrel.h"
#include "asterisk/cdr.h"
Include dependency graph for getters_cdr.c:

Go to the source code of this file.

Macros

#define DEFINE_CDR_GETTER(_sname, _ename, _type)
 

Functions

static int cdr_get_literal (void *record, struct cdrel_config *config, struct cdrel_field *field, struct cdrel_value *value)
 
static int cdr_get_string (void *record, struct cdrel_config *config, struct cdrel_field *field, struct cdrel_value *value)
 
static int cdr_get_uservar (void *record, struct cdrel_config *config, struct cdrel_field *field, struct cdrel_value *value)
 
static struct ast_channeldummy_chan_alloc_cdr (struct cdrel_config *config, void *data)
 
int load_cdr (void)
 

Detailed Description

CDR Getters.

Author
George Joseph gjose.nosp@m.ph@s.nosp@m.angom.nosp@m.a.co.nosp@m.m

Definition in file getters_cdr.c.

Macro Definition Documentation

◆ DEFINE_CDR_GETTER

#define DEFINE_CDR_GETTER (   _sname,
  _ename,
  _type 
)

Definition at line 40 of file getters_cdr.c.

43{ \
44 struct ast_cdr *cdr = record; \
45 value->data_type = field->input_data_type; \
46 value->field_name = field->name; \
47 value->values._sname = *(_type *)CDR_FIELD(cdr, field->field_id); \
48 return 0; \
49}\
50
#define CDR_FIELD(__cdr, __offset)
Definition cdrel.h:135
Responsible for call detail data.
Definition cdr.h:281
struct timeval start
Definition cdr.h:299
int value
Definition syslog.c:37

Function Documentation

◆ cdr_get_literal()

static int cdr_get_literal ( void *  record,
struct cdrel_config config,
struct cdrel_field field,
struct cdrel_value value 
)
static

Definition at line 58 of file getters_cdr.c.

60{
61 value->data_type = cdrel_type_string;
62 value->field_name = field->name;
63 value->values.string = field->data;
64 return 0;
65}
@ cdrel_type_string
Definition cdrel.h:73
char data[1]
Definition cdrel.h:277
char * name
Definition cdrel.h:273

References cdrel_type_string, and value.

Referenced by load_cdr().

◆ cdr_get_string()

static int cdr_get_string ( void *  record,
struct cdrel_config config,
struct cdrel_field field,
struct cdrel_value value 
)
static

Definition at line 30 of file getters_cdr.c.

32{
33 struct ast_cdr *cdr = record;
34 value->data_type = field->input_data_type;
35 value->field_name = field->name;
36 value->values.string = CDR_FIELD(cdr, field->field_id);
37 return 0;
38}
int field_id
Definition cdrel.h:272
enum cdrel_data_type input_data_type
Definition cdrel.h:274

References CDR_FIELD, cdrel_field::field_id, cdrel_field::input_data_type, cdrel_field::name, ast_cdr::start, and value.

Referenced by load_cdr().

◆ cdr_get_uservar()

static int cdr_get_uservar ( void *  record,
struct cdrel_config config,
struct cdrel_field field,
struct cdrel_value value 
)
static

Definition at line 67 of file getters_cdr.c.

69{
70 struct ast_cdr *cdr = record;
71 struct ast_var_t *variables;
72 const char *rtn = NULL;
73
74 value->data_type = cdrel_type_string;
75 value->field_name = field->name;
76 AST_LIST_TRAVERSE(&cdr->varshead, variables, entries) {
77 if (strcasecmp(field->data, ast_var_name(variables)) == 0) {
78 rtn = ast_var_value(variables);
79 }
80 }
81
82 value->values.string = (char *)S_OR(rtn, "");
83 return 0;
84}
const char * ast_var_name(const struct ast_var_t *var)
Definition chanvars.c:60
const char * ast_var_value(const struct ast_var_t *var)
Definition chanvars.c:80
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
#define NULL
Definition resample.c:96
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one.
Definition strings.h:80
struct varshead varshead
Definition cdr.h:332
struct ast_var_t::@220 entries

References AST_LIST_TRAVERSE, ast_var_name(), ast_var_value(), cdrel_type_string, cdrel_field::data, ast_var_t::entries, cdrel_field::name, NULL, S_OR, ast_cdr::start, value, and ast_cdr::varshead.

Referenced by load_cdr().

◆ dummy_chan_alloc_cdr()

static struct ast_channel * dummy_chan_alloc_cdr ( struct cdrel_config config,
void *  data 
)
static

Definition at line 86 of file getters_cdr.c.

87{
88 struct ast_cdr *cdr = data;
89 struct ast_channel *dummy = NULL;
90
92 if (!dummy) {
93 ast_log(LOG_ERROR, "Unable to fabricate channel from CDR for '%s'\n",
94 config->output_filename);
95 return NULL;
96 }
98 return dummy;
99}
#define ast_log
Definition astobj2.c:42
struct ast_cdr * ast_cdr_dup(struct ast_cdr *cdr)
Duplicate a public CDR.
Definition cdr.c:3131
static const char config[]
static void dummy(char *unused,...)
void ast_channel_cdr_set(struct ast_channel *chan, struct ast_cdr *value)
#define ast_dummy_channel_alloc()
Create a fake channel structure.
Definition channel.h:1328
#define LOG_ERROR
Main Channel structure associated with a channel.
struct ast_cdr * cdr

References ast_cdr_dup(), ast_channel_cdr_set(), ast_dummy_channel_alloc, ast_log, ast_channel::cdr, config, dummy(), LOG_ERROR, and NULL.

Referenced by load_cdr().

◆ load_cdr()

int load_cdr ( void  )

Definition at line 101 of file getters_cdr.c.

102{
103 ast_debug(1, "Loading CDR getters\n");
114
115 return 0;
116}
@ cdrel_type_uint64
Definition cdrel.h:86
@ cdrel_type_uservar
Definition cdrel.h:78
@ cdrel_type_double
Definition cdrel.h:87
@ cdrel_type_int64
Definition cdrel.h:85
@ cdrel_type_literal
Definition cdrel.h:75
@ cdrel_type_int32
Definition cdrel.h:83
@ cdrel_type_timeval
Definition cdrel.h:74
@ cdrel_type_uint32
Definition cdrel.h:84
cdrel_dummy_channel_alloc cdrel_dummy_channel_allocators[cdrel_format_type_end]
cdrel_field_getter cdrel_field_getters[cdrel_record_type_end][cdrel_data_type_end]
static struct ast_channel * dummy_chan_alloc_cdr(struct cdrel_config *config, void *data)
Definition getters_cdr.c:86
static int cdr_get_string(void *record, struct cdrel_config *config, struct cdrel_field *field, struct cdrel_value *value)
Definition getters_cdr.c:30
static int cdr_get_literal(void *record, struct cdrel_config *config, struct cdrel_field *field, struct cdrel_value *value)
Definition getters_cdr.c:58
static int cdr_get_uservar(void *record, struct cdrel_config *config, struct cdrel_field *field, struct cdrel_value *value)
Definition getters_cdr.c:67
#define ast_debug(level,...)
Log a DEBUG message.
@ cdrel_record_cdr

References ast_debug, cdr_get_literal(), cdr_get_string(), cdr_get_uservar(), cdrel_dummy_channel_allocators, cdrel_field_getters, cdrel_record_cdr, cdrel_type_double, cdrel_type_int32, cdrel_type_int64, cdrel_type_literal, cdrel_type_string, cdrel_type_timeval, cdrel_type_uint32, cdrel_type_uint64, cdrel_type_uservar, and dummy_chan_alloc_cdr().

Referenced by load_module().