XMLification (wave 1)

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@1401 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale
2006-05-10 03:23:05 +00:00
parent d9e8100737
commit 93666f6dd7
36 changed files with 1025 additions and 1093 deletions
@@ -139,8 +139,6 @@ static int show_callback(void *pArg, int argc, char **argv, char **columnNames){
char temp[1024];
size_t len;
printf("%s\n", argv[1]);
sprintf(temp, "%s\n", argv[1]);
len = strlen(temp);
@@ -152,6 +150,23 @@ static int show_callback(void *pArg, int argc, char **argv, char **columnNames){
return 0;
}
static switch_status_t status_function(char *cmd, char *out, size_t outlen)
{
switch_core_time_duration_t duration;
switch_core_measure_time(switch_core_uptime(), &duration);
snprintf(out, outlen, "<b>UP %u year(s), %u day(s), %u hour(s), %u minute(s), %u second(s), %u millisecond(s), %u microsecond(s)</b>\n",
duration.yr,
duration.day,
duration.hr,
duration.min,
duration.sec,
duration.ms,
duration.mms
);
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t show_function(char *cmd, char *out, size_t outlen)
{
char sql[1024];
@@ -176,12 +191,20 @@ static switch_status_t show_function(char *cmd, char *out, size_t outlen)
}
static switch_api_interface_t status_api_interface = {
/*.interface_name */ "status",
/*.desc */ "status",
/*.function */ status_function,
/*.next */ NULL
};
static switch_api_interface_t show_api_interface = {
/*.interface_name */ "show",
/*.desc */ "Show",
/*.function */ show_function,
/*.next */ NULL
/*.next */ &status_api_interface
};
static switch_api_interface_t pause_api_interface = {
/*.interface_name */ "pause",
/*.desc */ "Pause",
@@ -54,16 +54,19 @@ SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_base, globals.base)
static void load_config(void)
{
char *cf = "dialplan_directory.conf";
switch_config_t cfg;
char *var, *val;
switch_xml_t cfg, xml, settings, param;
if (!switch_config_open_file(&cfg, cf)) {
if (!(xml = switch_xml_open_cfg(cf, &cfg))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
return;
}
while (switch_config_next_pair(&cfg, &var, &val)) {
if (!strcasecmp(cfg.category, "settings")) {
if ((settings = switch_xml_child(cfg, "settings"))) {
for (param = switch_xml_child(settings, "param"); param; param = param->next) {
char *var = (char *) switch_xml_attr(param, "name");
char *val = (char *) switch_xml_attr(param, "value");
if (!strcmp(var, "directory_name") && val) {
set_global_directory_name(val);
} else if (!strcmp(var, "directory_name") && val) {
@@ -79,7 +82,7 @@ static void load_config(void)
}
}
}
switch_config_close_file(&cfg);
switch_xml_free(xml);
}
static switch_caller_extension_t *directory_dialplan_hunt(switch_core_session_t *session)
@@ -1,135 +0,0 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005/2006, Anthony Minessale II <anthmct@yahoo.com>
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
*
* The Initial Developer of the Original Code is
* Anthony Minessale II <anthmct@yahoo.com>
* Portions created by the Initial Developer are Copyright (C)
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Anthony Minessale II <anthmct@yahoo.com>
*
*
* mod_dialplan_flatfile.c -- Example Dialplan Module
*
*/
#include <switch.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
static const char modname[] = "mod_dialplan_flatfile";
static switch_caller_extension_t *flatfile_dialplan_hunt(switch_core_session_t *session)
{
switch_caller_profile_t *caller_profile = NULL;
switch_caller_extension_t *extension = NULL;
switch_channel_t *channel;
char *cf = "extensions.conf";
switch_config_t cfg;
char *var, *val;
char app[1024];
char *context = NULL;
channel = switch_core_session_get_channel(session);
if ((caller_profile = switch_channel_get_caller_profile(channel))) {
context = caller_profile->context ? caller_profile->context : "default";
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Obtaining Profile!\n");
return NULL;
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Hello %s You Dialed %s!\n", caller_profile->caller_id_name,
caller_profile->destination_number);
if (!switch_config_open_file(&cfg, cf)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
return NULL;
}
while (switch_config_next_pair(&cfg, &var, &val)) {
if (!strcasecmp(cfg.category, context)) {
if (!strcmp(var, caller_profile->destination_number) && val) {
char *data;
memset(app, 0, sizeof(app));
strncpy(app, val, sizeof(app));
if ((data = strchr(app, ' ')) != 0) {
*data = '\0';
data++;
} else {
data = "";
}
if (!extension) {
if ((extension =
switch_caller_extension_new(session, caller_profile->destination_number,
caller_profile->destination_number)) == 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "memory error!\n");
break;
}
}
switch_caller_extension_add_application(session, extension, app, data);
}
}
}
switch_config_close_file(&cfg);
if (extension) {
switch_channel_set_state(channel, CS_EXECUTE);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Cannot locate extension %s in context %s\n", caller_profile->destination_number, context);
switch_channel_hangup(channel, SWITCH_CAUSE_MESSAGE_TYPE_NONEXIST);
}
return extension;
}
static const switch_dialplan_interface_t flatfile_dialplan_interface = {
/*.interface_name = */ "flatfile",
/*.hunt_function = */ flatfile_dialplan_hunt
/*.next = NULL */
};
static const switch_loadable_module_interface_t flatfile_dialplan_module_interface = {
/*.module_name = */ modname,
/*.endpoint_interface = */ NULL,
/*.timer_interface = */ NULL,
/*.dialplan_interface = */ &flatfile_dialplan_interface,
/*.codec_interface = */ NULL,
/*.application_interface = */ NULL
};
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
{
/* connect my internal structure to the blank pointer passed to me */
*module_interface = &flatfile_dialplan_module_interface;
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
}
-17
View File
@@ -1,17 +0,0 @@
LDFLAGS += -lpcre -L/usr/local/lib
all: depends $(MODNAME).$(DYNAMIC_LIB_EXTEN)
depends:
MAKE=$(MAKE) $(BASE)/build/buildlib.sh $(BASE) install pcre-6.4.tar.gz --prefix=$(PREFIX)
$(MODNAME).$(DYNAMIC_LIB_EXTEN): $(MODNAME).c
$(CC) $(CFLAGS) -fPIC -c $(MODNAME).c -o $(MODNAME).o
$(CC) $(SOLINK) -o $(MODNAME).$(DYNAMIC_LIB_EXTEN) $(MODNAME).o $(LDFLAGS)
clean:
rm -fr *.$(DYNAMIC_LIB_EXTEN) *.o *~
install:
cp -f $(MODNAME).$(DYNAMIC_LIB_EXTEN) $(PREFIX)/mod
-224
View File
@@ -1,224 +0,0 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005/2006, Anthony Minessale II <anthmct@yahoo.com>
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
*
* The Initial Developer of the Original Code is
* Anthony Minessale II <anthmct@yahoo.com>
* Portions created by the Initial Developer are Copyright (C)
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Anthony Minessale II <anthmct@yahoo.com>
*
*
* mod_pcre.c -- Regex Dialplan Module
*
*/
#include <switch.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <pcre.h>
static const char modname[] = "mod_pcre";
#define cleanre() if (re) {\
pcre_free(re);\
re = NULL;\
}
static switch_caller_extension_t *dialplan_hunt(switch_core_session_t *session)
{
switch_caller_profile_t *caller_profile;
switch_caller_extension_t *extension = NULL;
switch_channel_t *channel;
char *cf = "regextensions.conf";
switch_config_t cfg;
char *var, *val;
char app[1024] = "";
int catno = -1;
char *exten_name = NULL;
pcre *re = NULL;
int match_count = 0;
int ovector[30];
int skip = 0;
channel = switch_core_session_get_channel(session);
caller_profile = switch_channel_get_caller_profile(channel);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Processing %s->%s!\n", caller_profile->caller_id_name,
caller_profile->destination_number);
if (!switch_config_open_file(&cfg, cf)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
return NULL;
}
while (switch_config_next_pair(&cfg, &var, &val)) {
if (cfg.catno != catno) { /* new category */
catno = cfg.catno;
exten_name = cfg.category;
cleanre();
match_count = 0;
skip = 0;
if (!strcasecmp(exten_name, "outbound") && !switch_channel_test_flag(channel, CF_OUTBOUND)) {
skip = 1;
} else if (!strcasecmp(exten_name, "inbound") && switch_channel_test_flag(channel, CF_OUTBOUND)) {
skip = 1;
} else if (*exten_name == 's' && *(exten_name+1) == ':') {
exten_name += 2;
if (strcasecmp(exten_name, caller_profile->source)) {
skip = 1;
}
} else if (*exten_name == 'c' && *(exten_name+1) == ':') {
exten_name += 2;
if (strcasecmp(exten_name, caller_profile->context)) {
skip = 1;
}
}
}
if (skip) {
continue;
}
if (!strcasecmp(var, "regex")) {
const char *error = NULL;
int erroffset = 0;
cleanre();
re = pcre_compile(val, /* the pattern */
0, /* default options */
&error, /* for error message */
&erroffset, /* for error offset */
NULL); /* use default character tables */
if (error) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "COMPILE ERROR: %d [%s]\n", erroffset, error);
cleanre();
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
return NULL;
}
match_count = pcre_exec(re, /* result of pcre_compile() */
NULL, /* we didn't study the pattern */
caller_profile->destination_number, /* the subject string */
(int) strlen(caller_profile->destination_number), /* the length of the subject string */
0, /* start at offset 0 in the subject */
0, /* default options */
ovector, /* vector of integers for substring information */
sizeof(ovector) / sizeof(ovector[0])); /* number of elements (NOT size in bytes) */
} else if (match_count > 0 && !strcasecmp(var, "match")) {
if (!re) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ERROR: match without regex in %s line %d\n", cfg.path,
cfg.lineno);
continue;
} else {
char newval[1024] = "";
char index[10] = "";
char replace[128] = "";
unsigned int x, y = 0, z = 0, num = 0;
char *data;
for (x = 0; x < sizeof(newval) && x < strlen(val);) {
if (val[x] == '$') {
x++;
while (val[x] > 47 && val[x] < 58) {
index[z++] = val[x];
x++;
}
index[z++] = '\0';
z = 0;
num = atoi(index);
if (pcre_copy_substring
(caller_profile->destination_number, ovector, match_count, num, replace,
sizeof(replace)) > 0) {
unsigned int r;
for (r = 0; r < strlen(replace); r++) {
newval[y++] = replace[r];
}
}
} else {
newval[y++] = val[x];
x++;
}
}
newval[y++] = '\0';
memset(app, 0, sizeof(app));
switch_copy_string(app, newval, sizeof(app));
if ((data = strchr(app, ' ')) != 0) {
*data = '\0';
data++;
}
if (!extension) {
if ((extension =
switch_caller_extension_new(session, exten_name, caller_profile->destination_number)) == 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "memory error!\n");
break;
}
}
switch_caller_extension_add_application(session, extension, app, data);
}
}
}
switch_config_close_file(&cfg);
if (extension) {
switch_channel_set_state(channel, CS_EXECUTE);
} else {
switch_channel_hangup(channel, SWITCH_CAUSE_MESSAGE_TYPE_NONEXIST);
}
cleanre();
return extension;
}
static const switch_dialplan_interface_t dialplan_interface = {
/*.interface_name = */ "pcre",
/*.hunt_function = */ dialplan_hunt
/*.next = NULL */
};
static const switch_loadable_module_interface_t dialplan_module_interface = {
/*.module_name = */ modname,
/*.endpoint_interface = */ NULL,
/*.timer_interface = */ NULL,
/*.dialplan_interface = */ &dialplan_interface,
/*.codec_interface = */ NULL,
/*.application_interface = */ NULL
};
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
{
/* connect my internal structure to the blank pointer passed to me */
*module_interface = &dialplan_module_interface;
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
}
-212
View File
@@ -1,212 +0,0 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="mod_pcre"
ProjectGUID="{07113B25-D3AF-4E04-BA77-4CD1171F022C}"
RootNamespace="mod_pcre"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
CommandLine="cscript /nologo $(InputDir)..\..\..\..\w32\vsnet\getlibs.vbs Mod_pcre Debug"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="&quot;$(InputDir)..\..\..\include&quot;;&quot;$(InputDir)include&quot;;&quot;$(InputDir)..\..\..\..\libs\include&quot;;&quot;$(InputDir)..\..\..\..\libs\pcre&quot;;&quot;$(InputDir)..\..\..\..\libs\pcre\win32&quot;"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;MOD_EXPORTS;PCRE_STATIC"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
WarningLevel="4"
WarnAsError="true"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="libpcre.lib"
OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_pcre.dll"
LinkIncremental="2"
AdditionalLibraryDirectories="$(InputDir)..\..\..\..\libs\pcre\win32\$(OutDir);..\..\..\..\w32\vsnet\$(OutDir)"
GenerateDebugInformation="true"
ProgramDatabaseFile="$(OutDir)/mod_pcre.pdb"
SubSystem="2"
ImportLibrary="$(OutDir)/mod_pcre.lib"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
CommandLine="cscript /nologo $(InputDir)..\..\..\..\w32\vsnet\getlibs.vbs Mod_pcre Release"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="&quot;$(InputDir)..\..\..\include&quot;;&quot;$(InputDir)include&quot;;&quot;$(InputDir)..\..\..\..\libs\include&quot;;&quot;$(InputDir)..\..\..\..\libs\pcre&quot;;&quot;$(InputDir)..\..\..\..\libs\pcre\win32&quot;"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;MOD_EXPORTS;PCRE_STATIC"
RuntimeLibrary="0"
UsePrecompiledHeader="0"
WarningLevel="4"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="libpcre.lib"
OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_pcre.dll"
LinkIncremental="1"
AdditionalLibraryDirectories="$(InputDir)..\..\..\..\libs\pcre\win32\$(OutDir);..\..\..\..\w32\vsnet\$(OutDir)"
GenerateDebugInformation="true"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
ImportLibrary="$(OutDir)/mod_pcre.lib"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\mod_pcre.c"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
+26 -18
View File
@@ -1173,7 +1173,9 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void)
break;
}
}
ldl_global_destroy();
if (globals.init) {
ldl_global_destroy();
}
}
return SWITCH_STATUS_SUCCESS;
}
@@ -1286,24 +1288,26 @@ static switch_status_t dl_login(char *arg, char *out, size_t outlen)
static switch_status_t load_config(void)
{
switch_config_t cfg;
char *var, *val;
char *cf = "dingaling.conf";
struct mdl_profile *profile = NULL;
int lastcat = -1;
switch_xml_t cfg, xml, settings, param, xmlint;
memset(&globals, 0, sizeof(globals));
globals.running = 1;
switch_core_hash_init(&globals.profile_hash, module_pool);
if (!switch_config_open_file(&cfg, cf)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "open of %s failed\n", cf);
if (!(xml = switch_xml_open_cfg(cf, &cfg))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
return SWITCH_STATUS_TERM;
}
while (switch_config_next_pair(&cfg, &var, &val)) {
if (!strcasecmp(cfg.category, "settings")) {
if ((settings = switch_xml_child(cfg, "settings"))) {
for (param = switch_xml_child(settings, "param"); param; param = param->next) {
char *var = (char *) switch_xml_attr(param, "name");
char *val = (char *) switch_xml_attr(param, "value");
if (!strcasecmp(var, "debug")) {
globals.debug = atoi(val);
} else if (!strcasecmp(var, "codec_prefs")) {
@@ -1315,27 +1319,30 @@ static switch_status_t load_config(void)
globals.codec_rates_last =
switch_separate_string(globals.codec_rates_string, ',', globals.codec_rates, SWITCH_MAX_CODECS);
}
} else if (!strcasecmp(cfg.category, "interface")) {
}
}
for (xmlint = switch_xml_child(cfg, "interface"); xmlint; xmlint = xmlint->next) {
for (param = switch_xml_child(xmlint, "param"); param; param = param->next) {
char *var = (char *) switch_xml_attr(param, "name");
char *val = (char *) switch_xml_attr(param, "value");
if (!globals.init) {
ldl_global_init(globals.debug);
ldl_global_set_logger(dl_logger);
globals.init = 1;
}
if (cfg.catno != lastcat) {
if (profile) {
init_profile(profile, switch_test_flag(profile, TFLAG_AUTO) ? 1 : 0);
profile = NULL;
}
lastcat = cfg.catno;
}
if(!profile) {
profile = switch_core_alloc(module_pool, sizeof(*profile));
}
set_profile_val(profile, var, val);
}
if (profile) {
init_profile(profile, switch_test_flag(profile, TFLAG_AUTO) ? 1 : 0);
profile = NULL;
}
}
if (profile) {
@@ -1354,7 +1361,8 @@ static switch_status_t load_config(void)
}
switch_config_close_file(&cfg);
switch_xml_free(xml);
return SWITCH_STATUS_SUCCESS;
}
+10 -9
View File
@@ -652,6 +652,7 @@ static switch_status_t exosip_read_frame(switch_core_session_t *session, switch_
}
switch_clear_flag(tech_pvt, TFLAG_READING);
if (switch_test_flag(tech_pvt, TFLAG_BYE)) {
@@ -1603,22 +1604,23 @@ static void log_event(eXosip_event_t * je)
static int config_exosip(int reload)
{
switch_config_t cfg;
char *var, *val;
char *cf = "exosip.conf";
switch_xml_t cfg, xml, settings, param;
globals.bytes_per_frame = DEFAULT_BYTES_PER_FRAME;
if (!switch_config_open_file(&cfg, cf)) {
if (!(xml = switch_xml_open_cfg(cf, &cfg))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
return SWITCH_STATUS_TERM;
}
globals.dtmf_duration = 100;
while (switch_config_next_pair(&cfg, &var, &val)) {
if (!strcasecmp(cfg.category, "settings")) {
if ((settings = switch_xml_child(cfg, "settings"))) {
for (param = switch_xml_child(settings, "param"); param; param = param->next) {
char *var = (char *) switch_xml_attr(param, "name");
char *val = (char *) switch_xml_attr(param, "value");
if (!strcmp(var, "debug")) {
globals.debug = atoi(val);
} else if (!strcmp(var, "port")) {
@@ -1663,6 +1665,7 @@ static int config_exosip(int reload)
}
}
}
if (!globals.rtpip) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Setting ip to 'guess'\n");
@@ -1677,9 +1680,7 @@ static int config_exosip(int reload)
globals.port = 5060;
}
switch_config_close_file(&cfg);
switch_xml_free(xml);
if (!globals.dialplan) {
set_global_dialplan("default");
+9 -6
View File
@@ -817,19 +817,21 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod
static switch_status_t load_config(void)
{
switch_config_t cfg;
char *var, *val;
char *cf = "iax.conf";
switch_xml_t cfg, xml, settings, param;
memset(&globals, 0, sizeof(globals));
if (!switch_config_open_file(&cfg, cf)) {
if (!(xml = switch_xml_open_cfg(cf, &cfg))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
return SWITCH_STATUS_TERM;
}
while (switch_config_next_pair(&cfg, &var, &val)) {
if (!strcasecmp(cfg.category, "settings")) {
if ((settings = switch_xml_child(cfg, "settings"))) {
for (param = switch_xml_child(settings, "param"); param; param = param->next) {
char *var = (char *) switch_xml_attr(param, "name");
char *val = (char *) switch_xml_attr(param, "value");
if (!strcmp(var, "debug")) {
globals.debug = atoi(val);
} else if (!strcmp(var, "port")) {
@@ -857,11 +859,12 @@ static switch_status_t load_config(void)
if (!globals.dialplan) {
set_global_dialplan("default");
}
if (!globals.port) {
globals.port = 4569;
}
switch_config_close_file(&cfg);
switch_xml_free(xml);
return SWITCH_STATUS_SUCCESS;
}
+6 -6
View File
@@ -348,20 +348,20 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void)
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface **interface, char *filename)
{
switch_config cfg;
char *var, *val;
char *cf = "opal.conf";
memset(&globals, 0, sizeof(globals));
if (!switch_config_open_file(&cfg, cf)) {
if (!(xml = switch_xml_open_cfg(cf, &cfg))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
return SWITCH_STATUS_TERM;
}
if ((settings = switch_xml_child(cfg, "settings"))) {
for (param = switch_xml_child(settings, "param"); param; param = param->next) {
char *var = (char *) switch_xml_attr(param, "name");
char *val = (char *) switch_xml_attr(param, "value");
while (switch_config_next_pair(&cfg, &var, &val)) {
if (!strcasecmp(cfg.category, "settings")) {
if (!strcmp(var, "debug")) {
globals.debug = atoi(val);
} else if (!strcmp(var, "port")) {
@@ -370,7 +370,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod
}
}
switch_config_close_file(&cfg);
switch_xml_free(xml);
if (switch_core_new_memory_pool(&module_pool) != SWITCH_STATUS_SUCCESS) {
@@ -566,19 +566,20 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod
static switch_status_t load_config(void)
{
switch_config_t cfg;
char *var, *val;
char *cf = "portaudio.conf";
memset(&globals, 0, sizeof(globals));
if (!switch_config_open_file(&cfg, cf)) {
if (!(xml = switch_xml_open_cfg(cf, &cfg))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
return SWITCH_STATUS_TERM;
}
while (switch_config_next_pair(&cfg, &var, &val)) {
if (!strcasecmp(cfg.category, "settings")) {
if ((settings = switch_xml_child(cfg, "settings"))) {
for (param = switch_xml_child(settings, "param"); param; param = param->next) {
char *var = (char *) switch_xml_attr(param, "name");
char *val = (char *) switch_xml_attr(param, "value");
if (!strcmp(var, "debug")) {
globals.debug = atoi(val);
} else if (!strcmp(var, "sample_rate")) {
@@ -613,7 +614,7 @@ static switch_status_t load_config(void)
globals.sample_rate = 8000;
}
switch_config_close_file(&cfg);
switch_xml_free(xml);
return SWITCH_STATUS_SUCCESS;
}
+18 -7
View File
@@ -1284,23 +1284,26 @@ static void pri_thread_launch(struct sangoma_pri *spri)
static switch_status_t config_wanpipe(int reload)
{
switch_config_t cfg;
char *var, *val;
char *cf = "wanpipe.conf";
int current_span = 0;
switch_xml_t cfg, xml, settings, param, span;
globals.mtu = DEFAULT_MTU;
globals.dtmf_on = 150;
globals.dtmf_off = 50;
if (!switch_config_open_file(&cfg, cf)) {
if (!(xml = switch_xml_open_cfg(cf, &cfg))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
return SWITCH_STATUS_TERM;
}
while (switch_config_next_pair(&cfg, &var, &val)) {
if (!strcasecmp(cfg.category, "settings")) {
if ((settings = switch_xml_child(cfg, "settings"))) {
for (param = switch_xml_child(settings, "param"); param; param = param->next) {
char *var = (char *) switch_xml_attr(param, "name");
char *val = (char *) switch_xml_attr(param, "value");
if (!strcmp(var, "debug")) {
globals.debug = atoi(val);
} else if (!strcmp(var, "mtu")) {
@@ -1312,7 +1315,15 @@ static switch_status_t config_wanpipe(int reload)
} else if (!strcmp(var, "supress_dtmf_tone")) {
globals.supress_dtmf_tone = switch_true(val);
}
} else if (!strcasecmp(cfg.category, "span")) {
}
}
for (span = switch_xml_child(cfg, "span"); span; span = span->next) {
for (param = switch_xml_child(span, "param"); param; param = param->next) {
char *var = (char *) switch_xml_attr(param, "name");
char *val = (char *) switch_xml_attr(param, "value");
if (!strcmp(var, "span")) {
current_span = atoi(val);
if (current_span <= 0 || current_span > MAX_SPANS) {
@@ -1382,7 +1393,7 @@ static switch_status_t config_wanpipe(int reload)
}
}
}
switch_config_close_file(&cfg);
switch_xml_free(xml);
if (!globals.dialplan) {
set_global_dialplan("default");
+15 -7
View File
@@ -1301,15 +1301,14 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void)
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
{
switch_config_t cfg;
char *var, *val;
struct woomera_profile *profile = &default_profile;
char *cf = "woomera.conf";
switch_xml_t cfg, xml, settings, param, xmlp;
memset(&globals, 0, sizeof(globals));
globals.next_woomera_port = WOOMERA_MIN_PORT;
if (!switch_config_open_file(&cfg, cf)) {
if (!(xml = switch_xml_open_cfg(cf, &cfg))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
return SWITCH_STATUS_TERM;
}
@@ -1318,15 +1317,24 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod
profile->name = "main";
strncpy(profile->dialplan, "default", sizeof(profile->dialplan) - 1);
while (switch_config_next_pair(&cfg, &var, &val)) {
if (!strcasecmp(cfg.category, "settings")) {
if ((settings = switch_xml_child(cfg, "settings"))) {
for (param = switch_xml_child(settings, "param"); param; param = param->next) {
char *var = (char *) switch_xml_attr(param, "name");
char *val = (char *) switch_xml_attr(param, "value");
if (!strcmp(var, "noload") && atoi(val)) {
return SWITCH_STATUS_TERM;
}
if (!strcmp(var, "debug")) {
globals.debug = atoi(val);
}
} else if (!strcasecmp(cfg.category, "profile")) {
}
}
for (xmlp = switch_xml_child(cfg, "interface"); xmlp; xmlp = xmlp->next) {
for (param = switch_xml_child(xmlp, "param"); param; param = param->next) {
char *var = (char *) switch_xml_attr(param, "name");
char *val = (char *) switch_xml_attr(param, "value");
if (!strcmp(var, "audio_ip")) {
strncpy(profile->audio_ip, val, sizeof(profile->audio_ip) - 1);
} else if (!strcmp(var, "host")) {
@@ -1351,7 +1359,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod
}
}
switch_config_close_file(&cfg);
switch_xml_free(xml);
if (switch_core_new_memory_pool(&module_pool) != SWITCH_STATUS_SUCCESS) {
@@ -50,12 +50,11 @@ SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_address, globals.address)
static switch_status_t load_config(void)
{
switch_config_t cfg;
switch_status_t status = SWITCH_STATUS_SUCCESS;
char *var, *val;
char *cf = "event_multicast.conf";
switch_xml_t cfg, xml, settings, param;
if (!switch_config_open_file(&cfg, cf)) {
if (!(xml = switch_xml_open_cfg(cf, &cfg))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
return SWITCH_STATUS_TERM;
}
@@ -64,9 +63,12 @@ static switch_status_t load_config(void)
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass!");
return SWITCH_STATUS_GENERR;
}
if ((settings = switch_xml_child(cfg, "settings"))) {
for (param = switch_xml_child(settings, "param"); param; param = param->next) {
char *var = (char *) switch_xml_attr(param, "name");
char *val = (char *) switch_xml_attr(param, "value");
while (switch_config_next_pair(&cfg, &var, &val)) {
if (!strcasecmp(cfg.category, "settings")) {
if (!strcasecmp(var, "address")) {
set_global_address(val);
} else if (!strcasecmp(var, "port")) {
@@ -75,7 +77,7 @@ static switch_status_t load_config(void)
}
}
switch_config_close_file(&cfg);
switch_xml_free(xml);
return status;
@@ -97,21 +97,23 @@ SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_jid, globals.jid)
static switch_status_t load_config(void)
{
switch_config_t cfg;
switch_status_t status = SWITCH_STATUS_FALSE;
char *var, *val;
char *cf = "xmpp_event.conf";
switch_xml_t cfg, xml, settings, param;
int count = 0;
memset(&globals, 0, sizeof(globals));
if (!switch_config_open_file(&cfg, cf)) {
if (!(xml = switch_xml_open_cfg(cf, &cfg))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
return SWITCH_STATUS_TERM;
}
while (switch_config_next_pair(&cfg, &var, &val)) {
if (!strcasecmp(cfg.category, "settings")) {
if ((settings = switch_xml_child(cfg, "settings"))) {
for (param = switch_xml_child(settings, "param"); param; param = param->next) {
char *var = (char *) switch_xml_attr(param, "name");
char *val = (char *) switch_xml_attr(param, "value");
if (!strcmp(var, "jid")) {
set_global_jid(val);
count++;
@@ -127,7 +129,7 @@ SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_jid, globals.jid)
}
}
switch_config_close_file(&cfg);
switch_xml_free(xml);
if (count == 3) {
/* TBD use config to pick what events to bind to */
@@ -193,20 +193,22 @@ static void event_handler(switch_event_t *event)
static switch_status_t load_config(void)
{
switch_config_t cfg;
switch_status_t status = SWITCH_STATUS_SUCCESS;
char *var, *val;
char *cf = "zeroconf.conf";
int count = 0;
sw_discovery_oid *oid;
switch_xml_t cfg, xml, settings, param;
if (!switch_config_open_file(&cfg, cf)) {
if (!(xml = switch_xml_open_cfg(cf, &cfg))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
return SWITCH_STATUS_TERM;
}
while (switch_config_next_pair(&cfg, &var, &val)) {
if (!strcasecmp(cfg.category, "settings")) {
if ((settings = switch_xml_child(cfg, "settings"))) {
for (param = switch_xml_child(settings, "param"); param; param = param->next) {
char *var = (char *) switch_xml_attr(param, "name");
char *val = (char *) switch_xml_attr(param, "value");
if (!strcmp(var, "browse")) {
if ((oid = switch_core_alloc(module_pool, sizeof(*oid))) != 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Bind browser to to %s\n", val);
@@ -233,7 +235,7 @@ static switch_status_t load_config(void)
}
}
switch_config_close_file(&cfg);
switch_xml_free(xml);
return status;
+11 -7
View File
@@ -80,24 +80,28 @@ static void add_mapping(char *var, char *val)
static switch_status_t config_logger(void)
{
switch_config_t cfg;
char *var, *val;
char *cf = "console.conf";
switch_xml_t cfg, xml, settings, param;
if (!switch_config_open_file(&cfg, cf)) {
if (!(xml = switch_xml_open_cfg(cf, &cfg))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
return SWITCH_STATUS_FALSE;
return SWITCH_STATUS_TERM;
}
switch_core_hash_init(&log_hash, module_pool);
switch_core_hash_init(&name_hash, module_pool);
if ((settings = switch_xml_child(cfg, "mappings"))) {
for (param = switch_xml_child(settings, "param"); param; param = param->next) {
char *var = (char *) switch_xml_attr(param, "name");
char *val = (char *) switch_xml_attr(param, "value");
while (switch_config_next_pair(&cfg, &var, &val)) {
if (!strcasecmp(cfg.category, "mappings")) {
add_mapping(var, val);
}
}
switch_xml_free(xml);
return SWITCH_STATUS_SUCCESS;
}
+19
View File
@@ -0,0 +1,19 @@
LDFLAGS += -lxmlrpc -lxmlrpc_abyss -lxmlrpc_server -lxmlrpc_server_abyss -lxmlrpc_xmlparse -lcurl
all: depends $(MODNAME).$(DYNAMIC_LIB_EXTEN)
depends:
MAKE=$(MAKE) $(BASE)/build/buildlib.sh $(BASE) install curl-7.15.2.tar.gz --prefix=$(PREFIX)
MAKE=$(MAKE) $(BASE)/build/buildlib.sh $(BASE) install xmlrpc-c-1.03.14.tgz --prefix=$(PREFIX) --disable-cplusplus --disable-wininet-client --disable-libwww-client
$(MODNAME).$(DYNAMIC_LIB_EXTEN): $(MODNAME).c
$(CC) $(CFLAGS) -fPIC -c $(MODNAME).c -o $(MODNAME).o
$(CC) $(SOLINK) -o $(MODNAME).$(DYNAMIC_LIB_EXTEN) $(MODNAME).o $(LDFLAGS)
clean:
rm -fr *.$(DYNAMIC_LIB_EXTEN) *.o *~
install:
cp -f $(MODNAME).$(DYNAMIC_LIB_EXTEN) $(PREFIX)/mod
@@ -2,9 +2,9 @@
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="mod_dialplan_flatfile"
ProjectGUID="{2988EB83-785F-45D4-8731-8E1E4345177E}"
RootNamespace="mod_dialplan_flatfile"
Name="mod_xml_rpc"
ProjectGUID="{E1794405-29D4-466D-9BE3-DD2344C2A663}"
RootNamespace="mod_xml_rpc""
Keyword="Win32Proj"
>
<Platforms>
@@ -63,13 +63,13 @@
/>
<Tool
Name="VCLinkerTool"
OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_dialplan_flatfile.dll"
OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_xml_rpc".dll"
LinkIncremental="2"
AdditionalLibraryDirectories="..\..\..\..\w32\vsnet\$(OutDir)"
GenerateDebugInformation="true"
ProgramDatabaseFile="$(OutDir)/mod_dialplan_flatfile.pdb"
ProgramDatabaseFile="$(OutDir)/mod_xml_rpc".pdb"
SubSystem="2"
ImportLibrary="$(OutDir)/mod_dialplan_flatfile.lib"
ImportLibrary="$(OutDir)/mod_xml_rpc".lib"
TargetMachine="1"
/>
<Tool
@@ -127,6 +127,7 @@
RuntimeLibrary="0"
UsePrecompiledHeader="0"
WarningLevel="4"
WarnAsError="true"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
@@ -141,14 +142,14 @@
/>
<Tool
Name="VCLinkerTool"
OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_dialplan_flatfile.dll"
OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_xml_rpc".dll"
LinkIncremental="1"
AdditionalLibraryDirectories="..\..\..\..\w32\vsnet\$(OutDir)"
GenerateDebugInformation="true"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
ImportLibrary="$(OutDir)/mod_dialplan_flatfile.lib"
ImportLibrary="$(OutDir)/mod_xml_rpc".lib"
TargetMachine="1"
/>
<Tool
@@ -186,7 +187,7 @@
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\mod_dialplan_flatfile.c"
RelativePath=".\mod_xml_rpc".c"
>
</File>
</Filter>