提交 8bf63d3d authored 作者: Anthony Minessale's avatar Anthony Minessale

add mod_cdr_csv

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@6542 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 773894bc
......@@ -40,6 +40,7 @@ endpoints/mod_sofia
#../../libs/openzap/mod_openzap
#event_handlers/mod_event_multicast
event_handlers/mod_event_socket
event_handlers/mod_cdr_csv
#event_handlers/mod_radius_cdr
formats/mod_native_file
formats/mod_sndfile
......
<configuration name="cdr_csv.conf" description="CDR CSV Format">
<settings>
<!-- 'cdr-csv' will always be appended to log-base -->
<!--<param name="log-base" value="/var/log"/>-->
<param name="default-template" value="example"/>
<param name="rotate-on-hup" value="true"/>
</settings>
<templates>
<template name="example">"${caller_id_name}","${caller_id_number}","${destination_number}","${context}","${start_stamp}","${answer_stamp}","${end_stamp}","${duration}","${billsec}","${hangup_cause}","${uuid}","${bleg_uuid}", "${accountcode}"</template>
<template name="asterisk">"${accountcode}","${caller_id_number}","${destination_number}","${context}","${caller_id}","${channel_name}","${bridge_channel}","${last_app}","${last_arg}","${start_stamp}","${answer_stamp}","${end_stamp}","${duration}","${billsec}","${hangup_cause}","${amaflags}","${uuid}","${userfield}"</template>
</templates>
</configuration>
......@@ -15,7 +15,7 @@
<!-- <load module="mod_xml_cdr"/> -->
<!-- Event Handlers -->
<!-- <load module="mod_cdr"/> -->
<load module="mod_cdr_csv"/>
<!-- <load module="mod_event_multicast"/> -->
<!-- <load module="mod_event_socket"/> -->
<!-- <load module="mod_xmpp_event"/> -->
......
......@@ -91,6 +91,10 @@ SWITCH_BEGIN_EXTERN_C
#define SWITCH_SEQ_CLEARLINE SWITCH_SEQ_ESC SWITCH_SEQ_CLEARLINE_CHAR_STR
#define SWITCH_SEQ_CLEARLINEEND SWITCH_SEQ_ESC SWITCH_SEQ_CLEARLINEEND_CHAR
#define SWITCH_SEQ_CLEARSCR SWITCH_SEQ_ESC SWITCH_SEQ_CLEARSCR_CHAR SWITCH_SEQ_HOME
#define SWITCH_DEFAULT_DIR_PERMS SWITCH_FPROT_UREAD | SWITCH_FPROT_UWRITE | SWITCH_FPROT_UEXECUTE | SWITCH_FPROT_GREAD | SWITCH_FPROT_GEXECUTE
#ifdef WIN32
#define SWITCH_PATH_SEPARATOR "\\"
#else
......@@ -98,6 +102,7 @@ SWITCH_BEGIN_EXTERN_C
#endif
#define SWITCH_URL_SEPARATOR "://"
#define SWITCH_BRIDGE_CHANNEL_VARIABLE "bridge_channel"
#define SWITCH_CHANNEL_NAME_VARIABLE "channel_name"
#define SWITCH_BRIDGE_UUID_VARIABLE "bridge_uuid"
#define SWITCH_PLAYBACK_TERMINATORS_VARIABLE "playback_terminators"
#define SWITCH_CACHE_SPEECH_HANDLES_VARIABLE "cache_speech_handles"
......
......@@ -875,8 +875,6 @@ typedef enum {
MSG_SAVED
} msg_type_t;
static uint32_t DEFAULT_DIR_PERMS = SWITCH_FPROT_UREAD | SWITCH_FPROT_UWRITE | SWITCH_FPROT_UEXECUTE | SWITCH_FPROT_GREAD | SWITCH_FPROT_GEXECUTE;
static switch_status_t create_file(switch_core_session_t *session, vm_profile_t *profile, char *macro_name, char *file_path, switch_size_t *message_len)
{
......@@ -1640,7 +1638,7 @@ static void voicemail_check_main(switch_core_session_t *session, const char *pro
}
if (switch_dir_make_recursive(dir_path, DEFAULT_DIR_PERMS, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
if (switch_dir_make_recursive(dir_path, SWITCH_DEFAULT_DIR_PERMS, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error creating %s\n", dir_path);
return;
}
......@@ -1739,7 +1737,7 @@ static switch_status_t voicemail_leave_main(switch_core_session_t *session, cons
id);
}
if (switch_dir_make_recursive(dir_path, DEFAULT_DIR_PERMS, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
if (switch_dir_make_recursive(dir_path, SWITCH_DEFAULT_DIR_PERMS, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error creating %s\n", dir_path);
goto end;
}
......@@ -2069,7 +2067,7 @@ SWITCH_STANDARD_APP(voicemail_function)
channel = switch_core_session_get_channel(session);
assert(channel != NULL);
if (switch_dir_make_recursive(SWITCH_GLOBAL_dirs.storage_dir, DEFAULT_DIR_PERMS, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
if (switch_dir_make_recursive(SWITCH_GLOBAL_dirs.storage_dir, SWITCH_DEFAULT_DIR_PERMS, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error creating %s\n", SWITCH_GLOBAL_dirs.storage_dir);
return;
}
......
include ../../../../build/modmake.rules
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="mod_cdr_csv"
ProjectGUID="{08DAD348-9E0A-4A2E-97F1-F1E7E24A7836}"
RootNamespace="mod_cdr_csv"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
ConfigurationType="2"
InheritedPropertySheets="..\..\..\..\w32\module_debug.vsprops;..\..\..\..\w32\curl.vsprops"
CharacterSet="2"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
UsePrecompiledHeader="0"
/>
<Tool
Name="VCLinkerTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
ConfigurationType="2"
InheritedPropertySheets="..\..\..\..\w32\module_release.vsprops;..\..\..\..\w32\curl.vsprops"
CharacterSet="2"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
UsePrecompiledHeader="0"
/>
<Tool
Name="VCLinkerTool"
AdditionalLibraryDirectories=""
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath=".\mod_cdr_csv.c"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
......@@ -356,7 +356,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_logfile_load)
for (param = switch_xml_child(settings, "param"); param; param = param->next) {
char *var = (char *) switch_xml_attr_soft(param, "name");
char *val = (char *) switch_xml_attr_soft(param, "value");
if (!strcmp(var, "rotate")) {
if (!strcmp(var, "rotate-on-hup")) {
globals.rotate = switch_true(val);
}
}
......
......@@ -21,7 +21,7 @@
* Portions created by the Initial Developer are Copyright (C)
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Anthony Minessale II <anthmct@yahoo.com>
*
......
......@@ -327,13 +327,21 @@ SWITCH_DECLARE(const char *) switch_channel_get_variable(switch_channel_t *chann
switch_mutex_lock(channel->profile_mutex);
if (!(v = switch_event_get_header(channel->variables, (char*)varname))) {
if (!channel->caller_profile || !(v = switch_caller_get_field_by_name(channel->caller_profile, varname))) {
if (!strcmp(varname, "base_dir")) {
v = SWITCH_GLOBAL_dirs.base_dir;
} else {
v = switch_core_get_variable(varname);
switch_caller_profile_t *cp = channel->caller_profile;
if (cp) {
if (!strncmp(varname, "aleg_", 5)) {
cp = cp->originator_caller_profile;
varname += 5;
} else if (!strncmp(varname, "bleg_", 5)) {
cp = cp->originatee_caller_profile;
varname += 5;
}
}
if (!cp || !(v = switch_caller_get_field_by_name(cp, varname))) {
v = switch_core_get_variable(varname);
}
}
switch_mutex_unlock(channel->profile_mutex);
......@@ -389,6 +397,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_set_name(switch_channel_t *channe
if (name) {
char *uuid = switch_core_session_get_uuid(channel->session);
channel->name = switch_core_session_strdup(channel->session, name);
switch_channel_set_variable(channel, SWITCH_CHANNEL_NAME_VARIABLE, name);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "New Chan %s [%s]\n", name, uuid);
}
return SWITCH_STATUS_SUCCESS;
......
......@@ -678,6 +678,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_init(switch_core_flag_t flags, switc
switch_core_set_variable("local_ip_v4", guess_ip);
switch_find_local_ip(guess_ip, sizeof(guess_ip), AF_INET6);
switch_core_set_variable("local_ip_v6", guess_ip);
switch_core_set_variable("base_dir", SWITCH_GLOBAL_dirs.base_dir);
if (switch_xml_init(runtime.memory_pool, err) != SWITCH_STATUS_SUCCESS) {
......@@ -810,6 +811,20 @@ static void handle_SIGINT(int sig)
if (sig);
return;
}
static void handle_SIGHUP(int sig)
{
if (sig) {
switch_event_t *event;
if (switch_event_create(&event, SWITCH_EVENT_TRAP) == SWITCH_STATUS_SUCCESS) {
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Trapped-Signal", "HUP");
switch_event_fire(&event);
}
}
return;
}
SWITCH_DECLARE(switch_status_t) switch_core_init_and_modload(switch_core_flag_t flags, switch_bool_t console, const char **err)
{
switch_event_t *event;
......@@ -832,6 +847,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_init_and_modload(switch_core_flag_t
signal(SIGBUS, handle_SIGBUS);
#endif
signal(SIGHUP, handle_SIGHUP);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Bringing up environment.\n");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Loading Modules.\n");
if (switch_loadable_module_init() != SWITCH_STATUS_SUCCESS) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论