Asterisk - The Open Source Telephony Project GIT-master-80b953f
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
cdrel.h File Reference

Private header for res_cdrel_custom. More...

#include <sqlite3.h>
#include "asterisk.h"
#include "asterisk/cdr.h"
#include "asterisk/cel.h"
#include "asterisk/event.h"
#include "asterisk/lock.h"
#include "asterisk/strings.h"
#include "asterisk/vector.h"
#include "asterisk/res_cdrel_custom.h"
Include dependency graph for cdrel.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  cdrel_config
 
struct  cdrel_field
 
struct  cdrel_value
 
struct  cdrel_values
 

Macros

#define AST_EVENT_IE_CEL_EVENT_ENUM   (AST_EVENT_IE_TOTAL + 2)
 
#define AST_EVENT_IE_CEL_LITERAL   (AST_EVENT_IE_TOTAL + 1)
 
#define CDR_FIELD(__cdr, __offset)   (((void *)__cdr) + __offset - CDR_OFFSET_SHIFT)
 
#define CDR_OFFSET_SHIFT   (LAST_CEL_ID + 1)
 
#define CDR_OFFSETOF(_field)   (offsetof(struct ast_cdr, _field) + CDR_OFFSET_SHIFT)
 
#define CDREL_FIELD_FLAG_FORMAT_SPEC   (5)
 
#define CDREL_FIELD_FLAG_LAST   (6)
 
#define CDREL_FIELD_FLAG_LITERAL   (4)
 
#define CDREL_FIELD_FLAG_NOQUOTE   (1)
 
#define CDREL_FIELD_FLAG_QUOTE   (0)
 
#define CDREL_FIELD_FLAG_TYPE_FORCED   (2)
 
#define CDREL_FIELD_FLAG_USERVAR   (3)
 
#define DATA_TYPE_STR(_dt)   (_dt < cdrel_data_type_end ? cdrel_data_type_map[_dt] : NULL)
 
#define LAST_CEL_ID   AST_EVENT_IE_CEL_EVENT_ENUM
 
#define MODULE_TYPE_STR(_mt)   (cdrel_module_type_map[_mt])
 
#define RECORD_TYPE_STR(_rt)   (cdrel_record_type_map[_rt])
 

Typedefs

typedef int(* cdrel_backend_writer) (struct cdrel_config *config, struct cdrel_values *values)
 
typedef struct ast_channel *(* cdrel_dummy_channel_alloc) (struct cdrel_config *config, void *record)
 
typedef int(* cdrel_field_formatter) (struct cdrel_config *config, struct cdrel_field *field, struct cdrel_value *input_value, struct cdrel_value *output_value)
 
typedef int(* cdrel_field_getter) (void *record, struct cdrel_config *config, struct cdrel_field *field, struct cdrel_value *value)
 

Enumerations

enum  cdr_field_id {
  cdr_field_literal = -1 , cdr_field_clid = CDR_OFFSETOF(clid) , cdr_field_src = CDR_OFFSETOF(src) , cdr_field_dst = CDR_OFFSETOF(dst) ,
  cdr_field_dcontext = CDR_OFFSETOF(dcontext) , cdr_field_channel = CDR_OFFSETOF(channel) , cdr_field_dstchannel = CDR_OFFSETOF(dstchannel) , cdr_field_lastapp = CDR_OFFSETOF(lastapp) ,
  cdr_field_lastdata = CDR_OFFSETOF(lastdata) , cdr_field_start = CDR_OFFSETOF(start) , cdr_field_answer = CDR_OFFSETOF(answer) , cdr_field_end = CDR_OFFSETOF(end) ,
  cdr_field_duration = CDR_OFFSETOF(duration) , cdr_field_billsec = CDR_OFFSETOF(billsec) , cdr_field_disposition = CDR_OFFSETOF(disposition) , cdr_field_amaflags = CDR_OFFSETOF(amaflags) ,
  cdr_field_accountcode = CDR_OFFSETOF(accountcode) , cdr_field_peeraccount = CDR_OFFSETOF(peeraccount) , cdr_field_flags = CDR_OFFSETOF(flags) , cdr_field_uniqueid = CDR_OFFSETOF(uniqueid) ,
  cdr_field_linkedid = CDR_OFFSETOF(linkedid) , cdr_field_tenantid = CDR_OFFSETOF(tenantid) , cdr_field_peertenantid = CDR_OFFSETOF(peertenantid) , cdr_field_userfield = CDR_OFFSETOF(userfield) ,
  cdr_field_sequence = CDR_OFFSETOF(sequence) , cdr_field_varshead = CDR_OFFSETOF(varshead)
}
 
enum  cdrel_config_type { cdrel_config_legacy = 0 , cdrel_config_advanced , cdrel_config_type_end }
 
enum  cdrel_data_type {
  cdrel_type_string = 0 , cdrel_type_timeval , cdrel_type_literal , cdrel_type_amaflags ,
  cdrel_type_disposition , cdrel_type_uservar , cdrel_type_event_type , cdrel_type_event_enum ,
  cdrel_type_cel_timefmt , cdrel_data_type_strings_end , cdrel_type_int32 , cdrel_type_uint32 ,
  cdrel_type_int64 , cdrel_type_uint64 , cdrel_type_double , cdrel_data_type_end
}
 
enum  cdrel_field_flags {
  cdrel_flag_quote = (1 << CDREL_FIELD_FLAG_QUOTE) , cdrel_flag_noquote = (1 << CDREL_FIELD_FLAG_NOQUOTE) , cdrel_flag_type_forced = (1 << CDREL_FIELD_FLAG_TYPE_FORCED) , cdrel_flag_uservar = (1 << CDREL_FIELD_FLAG_USERVAR) ,
  cdrel_flag_literal = (1 << CDREL_FIELD_FLAG_LITERAL) , cdrel_flag_format_spec = (1 << CDREL_FIELD_FLAG_FORMAT_SPEC) , cdrel_field_flags_end = (1 << CDREL_FIELD_FLAG_LAST)
}
 
enum  cdrel_quoting_method {
  cdrel_quoting_method_none = 0 , cdrel_quoting_method_all , cdrel_quoting_method_minimal , cdrel_quoting_method_non_numeric ,
  cdrel_quoting_method_end
}
 
enum  cdrel_text_format_type { cdrel_format_dsv = 0 , cdrel_format_json , cdrel_format_sql , cdrel_format_type_end }
 

Functions

const char * cdrel_basename (const char *path)
 
enum cdrel_data_type cdrel_data_type_from_str (const char *str)
 
const char * cdrel_get_field_flags (struct ast_flags *flags, struct ast_str **str)
 
const struct cdrel_fieldget_registered_field_by_name (enum cdrel_record_type record_type, const char *name)
 
int load_cdr (void)
 
int load_cel (void)
 
int load_formatters (void)
 
int load_writers (void)
 
int write_record_to_database (struct cdrel_config *config, struct cdrel_values *values)
 
int write_record_to_file (struct cdrel_config *config, struct ast_str *record)
 

Variables

cdrel_backend_writer cdrel_backend_writers [cdrel_format_type_end]
 
const char * cdrel_data_type_map []
 
cdrel_dummy_channel_alloc cdrel_dummy_channel_allocators [cdrel_format_type_end]
 
cdrel_field_formatter cdrel_field_formatters [cdrel_data_type_end]
 
cdrel_field_getter cdrel_field_getters [cdrel_record_type_end][cdrel_data_type_end]
 
const char * cdrel_module_type_map []
 
const char * cdrel_record_type_map []
 

Detailed Description

Private header for res_cdrel_custom.

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

Definition in file cdrel.h.

Macro Definition Documentation

◆ AST_EVENT_IE_CEL_EVENT_ENUM

#define AST_EVENT_IE_CEL_EVENT_ENUM   (AST_EVENT_IE_TOTAL + 2)

Definition at line 119 of file cdrel.h.

◆ AST_EVENT_IE_CEL_LITERAL

#define AST_EVENT_IE_CEL_LITERAL   (AST_EVENT_IE_TOTAL + 1)

Definition at line 118 of file cdrel.h.

◆ CDR_FIELD

#define CDR_FIELD (   __cdr,
  __offset 
)    (((void *)__cdr) + __offset - CDR_OFFSET_SHIFT)

Definition at line 135 of file cdrel.h.

◆ CDR_OFFSET_SHIFT

#define CDR_OFFSET_SHIFT   (LAST_CEL_ID + 1)

While CEL event fields are published as a generic AST_EVENT with a field id assigned to each field, CDRs are published as a fixed ast_cdr structure. To make it easier to share lower level code, we assign pseudo-field-ids to each CDR field that are really the offset of the field in the structure. This allows us to generically get any field using its id just like we do for CEL.

To avoid conflicts with the existing CEL field ids, we'll start these after the last one.

Definition at line 133 of file cdrel.h.

◆ CDR_OFFSETOF

#define CDR_OFFSETOF (   _field)    (offsetof(struct ast_cdr, _field) + CDR_OFFSET_SHIFT)

Definition at line 134 of file cdrel.h.

◆ CDREL_FIELD_FLAG_FORMAT_SPEC

#define CDREL_FIELD_FLAG_FORMAT_SPEC   (5)

Definition at line 100 of file cdrel.h.

◆ CDREL_FIELD_FLAG_LAST

#define CDREL_FIELD_FLAG_LAST   (6)

Definition at line 101 of file cdrel.h.

◆ CDREL_FIELD_FLAG_LITERAL

#define CDREL_FIELD_FLAG_LITERAL   (4)

Definition at line 99 of file cdrel.h.

◆ CDREL_FIELD_FLAG_NOQUOTE

#define CDREL_FIELD_FLAG_NOQUOTE   (1)

Definition at line 96 of file cdrel.h.

◆ CDREL_FIELD_FLAG_QUOTE

#define CDREL_FIELD_FLAG_QUOTE   (0)

Definition at line 95 of file cdrel.h.

◆ CDREL_FIELD_FLAG_TYPE_FORCED

#define CDREL_FIELD_FLAG_TYPE_FORCED   (2)

Definition at line 97 of file cdrel.h.

◆ CDREL_FIELD_FLAG_USERVAR

#define CDREL_FIELD_FLAG_USERVAR   (3)

Definition at line 98 of file cdrel.h.

◆ DATA_TYPE_STR

#define DATA_TYPE_STR (   _dt)    (_dt < cdrel_data_type_end ? cdrel_data_type_map[_dt] : NULL)

Definition at line 92 of file cdrel.h.

◆ LAST_CEL_ID

#define LAST_CEL_ID   AST_EVENT_IE_CEL_EVENT_ENUM

Definition at line 120 of file cdrel.h.

◆ MODULE_TYPE_STR

#define MODULE_TYPE_STR (   _mt)    (cdrel_module_type_map[_mt])

Definition at line 45 of file cdrel.h.

◆ RECORD_TYPE_STR

#define RECORD_TYPE_STR (   _rt)    (cdrel_record_type_map[_rt])

Definition at line 42 of file cdrel.h.

Typedef Documentation

◆ cdrel_backend_writer

typedef int(* cdrel_backend_writer) (struct cdrel_config *config, struct cdrel_values *values)

Definition at line 245 of file cdrel.h.

◆ cdrel_dummy_channel_alloc

typedef struct ast_channel *(* cdrel_dummy_channel_alloc) (struct cdrel_config *config, void *record)

Definition at line 252 of file cdrel.h.

◆ cdrel_field_formatter

typedef int(* cdrel_field_formatter) (struct cdrel_config *config, struct cdrel_field *field, struct cdrel_value *input_value, struct cdrel_value *output_value)

Definition at line 226 of file cdrel.h.

◆ cdrel_field_getter

typedef int(* cdrel_field_getter) (void *record, struct cdrel_config *config, struct cdrel_field *field, struct cdrel_value *value)

Definition at line 205 of file cdrel.h.

Enumeration Type Documentation

◆ cdr_field_id

Enumerator
cdr_field_literal 
cdr_field_clid 
cdr_field_src 
cdr_field_dst 
cdr_field_dcontext 
cdr_field_channel 
cdr_field_dstchannel 
cdr_field_lastapp 
cdr_field_lastdata 
cdr_field_start 
cdr_field_answer 
cdr_field_end 
cdr_field_duration 
cdr_field_billsec 
cdr_field_disposition 
cdr_field_amaflags 
cdr_field_accountcode 
cdr_field_peeraccount 
cdr_field_flags 
cdr_field_uniqueid 
cdr_field_linkedid 
cdr_field_tenantid 
cdr_field_peertenantid 
cdr_field_userfield 
cdr_field_sequence 
cdr_field_varshead 

Definition at line 137 of file cdrel.h.

137 {
152 cdr_field_disposition = CDR_OFFSETOF(disposition),
155 cdr_field_peeraccount = CDR_OFFSETOF(peeraccount),
160 cdr_field_peertenantid = CDR_OFFSETOF(peertenantid),
164};
@ cdr_field_peeraccount
Definition cdrel.h:155
@ cdr_field_amaflags
Definition cdrel.h:153
@ cdr_field_dcontext
Definition cdrel.h:142
@ cdr_field_flags
Definition cdrel.h:156
@ cdr_field_end
Definition cdrel.h:149
@ cdr_field_duration
Definition cdrel.h:150
@ cdr_field_billsec
Definition cdrel.h:151
@ cdr_field_dstchannel
Definition cdrel.h:144
@ cdr_field_literal
Definition cdrel.h:138
@ cdr_field_sequence
Definition cdrel.h:162
@ cdr_field_lastdata
Definition cdrel.h:146
@ cdr_field_uniqueid
Definition cdrel.h:157
@ cdr_field_answer
Definition cdrel.h:148
@ cdr_field_tenantid
Definition cdrel.h:159
@ cdr_field_linkedid
Definition cdrel.h:158
@ cdr_field_channel
Definition cdrel.h:143
@ cdr_field_peertenantid
Definition cdrel.h:160
@ cdr_field_clid
Definition cdrel.h:139
@ cdr_field_dst
Definition cdrel.h:141
@ cdr_field_varshead
Definition cdrel.h:163
@ cdr_field_start
Definition cdrel.h:147
@ cdr_field_disposition
Definition cdrel.h:152
@ cdr_field_lastapp
Definition cdrel.h:145
@ cdr_field_userfield
Definition cdrel.h:161
@ cdr_field_accountcode
Definition cdrel.h:154
@ cdr_field_src
Definition cdrel.h:140
#define CDR_OFFSETOF(_field)
Definition cdrel.h:134
static int amaflags
Definition chan_iax2.c:500
static char accountcode[AST_MAX_ACCOUNT_CODE]
Definition chan_iax2.c:497
static int answer(void *data)
Definition chan_pjsip.c:687
char * end
Definition eagi_proxy.c:73

◆ cdrel_config_type

Enumerator
cdrel_config_legacy 
cdrel_config_advanced 
cdrel_config_type_end 

Definition at line 54 of file cdrel.h.

54 {
58};
@ cdrel_config_type_end
Definition cdrel.h:57
@ cdrel_config_legacy
Definition cdrel.h:55
@ cdrel_config_advanced
Definition cdrel.h:56

◆ cdrel_data_type

Enumerator
cdrel_type_string 
cdrel_type_timeval 
cdrel_type_literal 
cdrel_type_amaflags 
cdrel_type_disposition 
cdrel_type_uservar 
cdrel_type_event_type 
cdrel_type_event_enum 
cdrel_type_cel_timefmt 
cdrel_data_type_strings_end 
cdrel_type_int32 
cdrel_type_uint32 
cdrel_type_int64 
cdrel_type_uint64 
cdrel_type_double 
cdrel_data_type_end 

Definition at line 72 of file cdrel.h.

72 {
89};
@ cdrel_type_event_type
Definition cdrel.h:79
@ cdrel_data_type_strings_end
Definition cdrel.h:82
@ cdrel_type_cel_timefmt
Definition cdrel.h:81
@ cdrel_type_amaflags
Definition cdrel.h:76
@ cdrel_type_event_enum
Definition cdrel.h:80
@ cdrel_type_disposition
Definition cdrel.h:77
@ 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_string
Definition cdrel.h:73
@ cdrel_data_type_end
Definition cdrel.h:88
@ cdrel_type_timeval
Definition cdrel.h:74
@ cdrel_type_uint32
Definition cdrel.h:84

◆ cdrel_field_flags

Enumerator
cdrel_flag_quote 
cdrel_flag_noquote 
cdrel_flag_type_forced 
cdrel_flag_uservar 
cdrel_flag_literal 
cdrel_flag_format_spec 
cdrel_field_flags_end 

Definition at line 103 of file cdrel.h.

103 {
111};
#define CDREL_FIELD_FLAG_USERVAR
Definition cdrel.h:98
#define CDREL_FIELD_FLAG_LITERAL
Definition cdrel.h:99
#define CDREL_FIELD_FLAG_LAST
Definition cdrel.h:101
#define CDREL_FIELD_FLAG_TYPE_FORCED
Definition cdrel.h:97
#define CDREL_FIELD_FLAG_FORMAT_SPEC
Definition cdrel.h:100
@ cdrel_flag_literal
Definition cdrel.h:108
@ cdrel_flag_quote
Definition cdrel.h:104
@ cdrel_flag_format_spec
Definition cdrel.h:109
@ cdrel_flag_noquote
Definition cdrel.h:105
@ cdrel_flag_uservar
Definition cdrel.h:107
@ cdrel_field_flags_end
Definition cdrel.h:110
@ cdrel_flag_type_forced
Definition cdrel.h:106
#define CDREL_FIELD_FLAG_QUOTE
Definition cdrel.h:95
#define CDREL_FIELD_FLAG_NOQUOTE
Definition cdrel.h:96

◆ cdrel_quoting_method

Enumerator
cdrel_quoting_method_none 
cdrel_quoting_method_all 
cdrel_quoting_method_minimal 
cdrel_quoting_method_non_numeric 
cdrel_quoting_method_end 

Definition at line 60 of file cdrel.h.

60 {
66};
@ cdrel_quoting_method_all
Definition cdrel.h:62
@ cdrel_quoting_method_none
Definition cdrel.h:61
@ cdrel_quoting_method_non_numeric
Definition cdrel.h:64
@ cdrel_quoting_method_end
Definition cdrel.h:65
@ cdrel_quoting_method_minimal
Definition cdrel.h:63

◆ cdrel_text_format_type

Enumerator
cdrel_format_dsv 
cdrel_format_json 
cdrel_format_sql 
cdrel_format_type_end 

Definition at line 47 of file cdrel.h.

47 {
52};
@ cdrel_format_json
Definition cdrel.h:49
@ cdrel_format_type_end
Definition cdrel.h:51
@ cdrel_format_dsv
Definition cdrel.h:48
@ cdrel_format_sql
Definition cdrel.h:50

Function Documentation

◆ cdrel_basename()

const char * cdrel_basename ( const char *  path)

Definition at line 219 of file res_cdrel_custom.c.

220{
221 int i = 0;
222 const char *basename = path;
223
224 if (ast_strlen_zero(path)) {
225 return path;
226 }
227 i = strlen(path) - 1;
228 while(i >= 0) {
229 if (path[i] == '/') {
230 basename = &path[i + 1];
231 break;
232 }
233 i--;
234 }
235 return basename;
236}
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition strings.h:65

References ast_strlen_zero().

Referenced by config_alloc(), field_alloc(), format_string(), load_database_columns(), load_database_config(), load_fields(), load_text_file_advanced_config(), load_text_file_legacy_config(), load_text_file_legacy_mappings(), open_database(), and parse_legacy_template().

◆ cdrel_data_type_from_str()

enum cdrel_data_type cdrel_data_type_from_str ( const char *  str)

Definition at line 179 of file res_cdrel_custom.c.

180{
181 enum cdrel_data_type data_type = 0;
182 for (data_type = 0; data_type < cdrel_data_type_end; data_type++) {
183 if (strcasecmp(cdrel_data_type_map[data_type], str) == 0) {
184 return data_type;
185 }
186
187 }
188 return cdrel_data_type_end;
189}
const char * str
Definition app_jack.c:150
cdrel_data_type
Definition cdrel.h:72
const char * cdrel_data_type_map[]

References cdrel_data_type_end, cdrel_data_type_map, and str.

Referenced by field_alloc().

◆ cdrel_get_field_flags()

const char * cdrel_get_field_flags ( struct ast_flags flags,
struct ast_str **  str 
)

Definition at line 201 of file res_cdrel_custom.c.

202{
203 int ix = 0;
204 int res = 0;
205 int trues = 0;
206
207 for (ix = 0; ix < CDREL_FIELD_FLAG_LAST; ix++) {
208 if (ast_test_flag(flags, (1 << ix))) {
209 res = ast_str_append(str, -1, "%s%s", trues++ ? "," : "", cdrel_field_flags_map[ix]);
210 if (res < 0) {
211 return "";
212 }
213 }
214 }
215 return ast_str_buffer(*str);
216}
static const char * cdrel_field_flags_map[]
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
Definition strings.h:1139
char *attribute_pure ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
Definition strings.h:761
#define ast_test_flag(p, flag)
Definition utils.h:64

References ast_str_append(), ast_str_buffer(), ast_test_flag, CDREL_FIELD_FLAG_LAST, cdrel_field_flags_map, and str.

Referenced by field_alloc(), and format_string().

◆ get_registered_field_by_name()

const struct cdrel_field * get_registered_field_by_name ( enum cdrel_record_type  record_type,
const char *  name 
)

Definition at line 113 of file registry.c.

114{
115 int ix = 0;
116
117 for (ix = 0; ix < ARRAY_LEN(cdrel_field_registry); ix++) {
118 if (cdrel_field_registry[ix].record_type == type && strcasecmp(cdrel_field_registry[ix].name, name) == 0) {
119 return &cdrel_field_registry[ix];
120 }
121 }
122 return NULL;
123}
static const char type[]
static const char name[]
Definition format_mp3.c:68
static const struct cdrel_field cdrel_field_registry[]
Definition registry.c:47
#define NULL
Definition resample.c:96
#define ARRAY_LEN(a)
Definition utils.h:706

References ARRAY_LEN, cdrel_field_registry, name, NULL, cdrel_field::record_type, and type.

Referenced by field_alloc(), and parse_legacy_template().

◆ 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_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().

◆ load_cel()

int load_cel ( void  )

Definition at line 104 of file getters_cel.c.

105{
106 ast_debug(1, "Loading CEL getters\n");
114
115 return 0;
116}
static int cel_get_event_type(void *record, struct cdrel_config *config, struct cdrel_field *field, struct cdrel_value *value)
Definition getters_cel.c:70
static int cel_get_event_enum(void *record, struct cdrel_config *config, struct cdrel_field *field, struct cdrel_value *value)
Definition getters_cel.c:87
static struct ast_channel * dummy_chan_alloc_cel(struct cdrel_config *config, void *data)
Definition getters_cel.c:97
static int cel_get_literal(void *record, struct cdrel_config *config, struct cdrel_field *field, struct cdrel_value *value)
Definition getters_cel.c:40
static int cel_get_uint32(void *record, struct cdrel_config *config, struct cdrel_field *field, struct cdrel_value *value)
Definition getters_cel.c:60
static int cel_get_string(void *record, struct cdrel_config *config, struct cdrel_field *field, struct cdrel_value *value)
Definition getters_cel.c:30
static int cel_get_timeval(void *record, struct cdrel_config *config, struct cdrel_field *field, struct cdrel_value *value)
Definition getters_cel.c:49
@ cdrel_record_cel

References ast_debug, cdrel_dummy_channel_allocators, cdrel_field_getters, cdrel_record_cel, cdrel_type_event_enum, cdrel_type_event_type, cdrel_type_literal, cdrel_type_string, cdrel_type_timeval, cdrel_type_uint32, cel_get_event_enum(), cel_get_event_type(), cel_get_literal(), cel_get_string(), cel_get_timeval(), cel_get_uint32(), and dummy_chan_alloc_cel().

Referenced by load_module().

◆ load_formatters()

int load_formatters ( void  )

Definition at line 189 of file formatters.c.

190{
191 ast_debug(1, "Loading Formatters\n");
201
202 return 0;
203}
cdrel_field_formatter cdrel_field_formatters[cdrel_data_type_end]
static int format_string(struct cdrel_config *config, struct cdrel_field *field, struct cdrel_value *input_value, struct cdrel_value *output_value)
Definition formatters.c:51
static int format_amaflags(struct cdrel_config *config, struct cdrel_field *field, struct cdrel_value *input_value, struct cdrel_value *output_value)
Definition formatters.c:165
static int format_disposition(struct cdrel_config *config, struct cdrel_field *field, struct cdrel_value *input_value, struct cdrel_value *output_value)
Definition formatters.c:177
static int format_timeval(struct cdrel_config *config, struct cdrel_field *field, struct cdrel_value *input_value, struct cdrel_value *output_value)
Definition formatters.c:123

References ast_debug, cdrel_field_formatters, cdrel_type_amaflags, cdrel_type_disposition, cdrel_type_double, cdrel_type_int32, cdrel_type_int64, cdrel_type_string, cdrel_type_timeval, cdrel_type_uint32, cdrel_type_uint64, format_amaflags(), format_disposition(), format_string(), and format_timeval().

Referenced by load_module().

◆ load_writers()

int load_writers ( void  )

Definition at line 221 of file writers.c.

222{
223 ast_debug(1, "Loading Writers\n");
227
228 return 0;
229}
cdrel_backend_writer cdrel_backend_writers[cdrel_format_type_end]
static int dsv_writer(struct cdrel_config *config, struct cdrel_values *values)
Definition writers.c:108
static int json_writer(struct cdrel_config *config, struct cdrel_values *values)
Definition writers.c:135
static int database_writer(struct cdrel_config *config, struct cdrel_values *values)
Definition writers.c:216

References ast_debug, cdrel_backend_writers, cdrel_format_dsv, cdrel_format_json, cdrel_format_sql, database_writer(), dsv_writer(), and json_writer().

Referenced by load_module().

◆ write_record_to_database()

int write_record_to_database ( struct cdrel_config config,
struct cdrel_values values 
)

Definition at line 169 of file writers.c.

170{
171 int res = 0;
172 int ix;
173
174 ast_mutex_lock(&config->lock);
175 for (ix = 0; ix < AST_VECTOR_SIZE(values); ix++) {
176 struct cdrel_value *value = AST_VECTOR_GET(values, ix);
177 ast_assert(value->data_type == cdrel_type_string);
178 ast_debug(6, "%s '%s'\n", value->field_name, value->values.string);
179 res = sqlite3_bind_text(config->insert, ix + 1, value->values.string, -1, SQLITE_STATIC);
180 if (res != SQLITE_OK) {
181 ast_log(LOG_ERROR, "Unable to write %s to database %s. SQL bind for field %s:'%s'. Error: %s\n",
182 RECORD_TYPE_STR(config->record_type), config->output_filename,
183 value->field_name, value->values.string,
184 sqlite3_errmsg(config->db));
185 sqlite3_reset(config->insert);
186 ast_mutex_unlock(&config->lock);
187 return -1;
188 }
189 }
190
191 res = sqlite3_step(config->insert);
192 if (res != SQLITE_DONE) {
193 ast_log(LOG_ERROR, "Unable to write %s to database %s. Error: %s\n",
194 RECORD_TYPE_STR(config->record_type), config->output_filename,
195 sqlite3_errmsg(config->db));
196 sqlite3_reset(config->insert);
197 ast_mutex_unlock(&config->lock);
198 return -1;
199 }
200
201 sqlite3_reset(config->insert);
202 ast_mutex_unlock(&config->lock);
203
204 return res;
205}
#define ast_log
Definition astobj2.c:42
#define RECORD_TYPE_STR(_rt)
Definition cdrel.h:42
static const char config[]
#define LOG_ERROR
#define ast_mutex_unlock(a)
Definition lock.h:197
#define ast_mutex_lock(a)
Definition lock.h:196
union cdrel_value::@454 values
int value
Definition syslog.c:37
#define ast_assert(a)
Definition utils.h:779
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition vector.h:620
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.
Definition vector.h:691

References ast_assert, ast_debug, ast_log, ast_mutex_lock, ast_mutex_unlock, AST_VECTOR_GET, AST_VECTOR_SIZE, cdrel_type_string, config, LOG_ERROR, RECORD_TYPE_STR, value, and cdrel_value::values.

Referenced by database_writer(), and log_legacy_database_record().

◆ write_record_to_file()

int write_record_to_file ( struct cdrel_config config,
struct ast_str record 
)

Definition at line 50 of file writers.c.

51{
52 FILE *out;
53 int res = 0;
54
55 ast_mutex_lock(&config->lock);
56 if ((out = fopen(config->output_filename, "a"))) {
57 res = fputs(ast_str_buffer(record), out);
58 fputs("\n", out);
59 fclose(out);
60 }
62
63 if (!out || res < 0) {
64 ast_log(LOG_ERROR, "Unable to write %s to file %s : %s\n",
65 RECORD_TYPE_STR(config->record_type), config->output_filename, strerror(errno));
66 return -1;
67 }
68 return 0;
69}
int errno
FILE * out
Definition utils/frame.c:33

References ast_log, ast_mutex_lock, ast_mutex_unlock, ast_str_buffer(), config, errno, LOG_ERROR, out, and RECORD_TYPE_STR.

Referenced by dsv_writer(), json_writer(), and log_legacy_dsv_record().

Variable Documentation

◆ cdrel_backend_writers

cdrel_backend_writer cdrel_backend_writers[cdrel_format_type_end]
extern

Definition at line 137 of file res_cdrel_custom.c.

Referenced by load_writers(), and log_advanced_record().

◆ cdrel_data_type_map

const char* cdrel_data_type_map[]
extern

Definition at line 160 of file res_cdrel_custom.c.

160 {
161 [cdrel_type_string] = "string",
162 [cdrel_type_timeval] = "timeval",
163 [cdrel_type_literal] = "literal",
164 [cdrel_type_amaflags] = "amaflags",
165 [cdrel_type_disposition] = "disposition",
166 [cdrel_type_uservar] = "uservar",
167 [cdrel_type_event_type] = "event_type",
168 [cdrel_type_event_enum] = "event_enum",
169 [cdrel_type_cel_timefmt] = "cel_timefmt",
170 [cdrel_data_type_strings_end] = "!!STRINGS END!!",
171 [cdrel_type_int32] = "int32",
172 [cdrel_type_uint32] = "uint32",
173 [cdrel_type_int64] = "int64",
174 [cdrel_type_uint64] = "uint64",
175 [cdrel_type_double] = "double",
176 [cdrel_data_type_end] = "!!END!!",
177};

Referenced by cdrel_data_type_from_str().

◆ cdrel_dummy_channel_allocators

cdrel_dummy_channel_alloc cdrel_dummy_channel_allocators[cdrel_format_type_end]
extern

Definition at line 142 of file res_cdrel_custom.c.

Referenced by config_alloc(), load_cdr(), and load_cel().

◆ cdrel_field_formatters

cdrel_field_formatter cdrel_field_formatters[cdrel_data_type_end]
extern

Definition at line 132 of file res_cdrel_custom.c.

Referenced by load_formatters(), and log_advanced_record().

◆ cdrel_field_getters

Definition at line 127 of file res_cdrel_custom.c.

Referenced by load_cdr(), load_cel(), and log_advanced_record().

◆ cdrel_module_type_map

const char* cdrel_module_type_map[]
extern

Definition at line 154 of file res_cdrel_custom.c.

154 {
155 [cdrel_backend_text] = "Custom ",
156 [cdrel_backend_db] = "SQLITE3 Custom",
157 [cdrel_backend_type_end] = "!!END!!",
158};
@ cdrel_backend_db
@ cdrel_backend_text
@ cdrel_backend_type_end

◆ cdrel_record_type_map

const char* cdrel_record_type_map[]
extern

Definition at line 148 of file res_cdrel_custom.c.

148 {
149 [cdrel_record_cdr] = "CDR",
150 [cdrel_record_cel] = "CEL",
151 [cdrel_record_type_end] = "!!END!!",
152};
@ cdrel_record_type_end