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

View File

@ -44,6 +44,7 @@ AM_CFLAGS += -DSWITCH_CONF_DIR=\"$(PREFIX)/conf\"
AM_CFLAGS += -DSWITCH_DB_DIR=\"$(PREFIX)/db\"
AM_CFLAGS += -DSWITCH_LOG_DIR=\"$(PREFIX)/log\"
AM_CFLAGS += -DSWITCH_SCRIPT_DIR=\"$(PREFIX)/scripts\"
AM_CFLAGS += -DSWITCH_HTDOCS_DIR=\"$(PREFIX)/htdocs\"
libfreeswitch_la_SOURCES = \
@ -204,8 +205,8 @@ modwipe:
install_mod: modules
@echo Installing $(NAME)
@mkdir -p $(PREFIX) $(PREFIX)/conf $(PREFIX)/mod $(PREFIX)/db $(PREFIX)/log $(PREFIX)/bin $(PREFIX)/scripts
@if [ ! -f $(PREFIX)/conf/freeswitch.conf ] ; then /bin/cp -p conf/freeswitch.conf $(PREFIX)/conf/; fi
@mkdir -p $(PREFIX) $(PREFIX)/conf $(PREFIX)/mod $(PREFIX)/db $(PREFIX)/log $(PREFIX)/bin $(PREFIX)/scripts $(PREFIX)/htdocs
@if [ ! -f $(PREFIX)/conf/freeswitch.xml ] ; then /bin/cp -p conf/freeswitch.xml $(PREFIX)/conf/; fi
@if [ -f .libs/$(NAME) ] ; then /bin/cp -p .libs/$(NAME) $(PREFIX)/bin ; else /bin/cp -p ./$(NAME) $(PREFIX)/bin ; fi
@echo Installing Modules
@rm -f build/freeswitch.env

View File

@ -253,7 +253,8 @@ AM_CFLAGS = -I$(PREFIX)/include $(shell $(APR_CONFIG) --cflags \
-DSWITCH_CONF_DIR=\"$(PREFIX)/conf\" \
-DSWITCH_DB_DIR=\"$(PREFIX)/db\" \
-DSWITCH_LOG_DIR=\"$(PREFIX)/log\" \
-DSWITCH_SCRIPT_DIR=\"$(PREFIX)/scripts\"
-DSWITCH_SCRIPT_DIR=\"$(PREFIX)/scripts\" \
-DSWITCH_HTDOCS_DIR=\"$(PREFIX)/htdocs\"
AM_LDFLAGS = -L$(PREFIX)/lib $(shell $(APR_CONFIG) --link-ld --libs ) \
$(shell $(APU_CONFIG) --link-ld --libs ) -lm \
-L/usr/local/lib/db42 -L/usr/local/lib $(am__append_1)
@ -1111,8 +1112,8 @@ modwipe:
install_mod: modules
@echo Installing $(NAME)
@mkdir -p $(PREFIX) $(PREFIX)/conf $(PREFIX)/mod $(PREFIX)/db $(PREFIX)/log $(PREFIX)/bin $(PREFIX)/scripts
@if [ ! -f $(PREFIX)/conf/freeswitch.conf ] ; then /bin/cp -p conf/freeswitch.conf $(PREFIX)/conf/; fi
@mkdir -p $(PREFIX) $(PREFIX)/conf $(PREFIX)/mod $(PREFIX)/db $(PREFIX)/log $(PREFIX)/bin $(PREFIX)/scripts $(PREFIX)/htdocs
@if [ ! -f $(PREFIX)/conf/freeswitch.xml ] ; then /bin/cp -p conf/freeswitch.xml $(PREFIX)/conf/; fi
@if [ -f .libs/$(NAME) ] ; then /bin/cp -p .libs/$(NAME) $(PREFIX)/bin ; else /bin/cp -p ./$(NAME) $(PREFIX)/bin ; fi
@echo Installing Modules
@rm -f build/freeswitch.env

View File

@ -1,275 +0,0 @@
; Unified Config file
; each section denoted with a + could also be in it's own file
;---- CONSOLE LOGGER
;--------------------------------------------------------------------------------
[+console.conf]
[mappings]
; pick a file name, a function name or 'all'
; map as many as you need for specific debugging
;mod_exosip.c => DEBUG
;log_event => DEBUG
;all => DEBUG
;---- MODULES
;--------------------------------------------------------------------------------
[+modules.conf]
[modules]
; Loggers (I'd load these first)
load => mod_console
;load => mod_syslog
; Event Handlers
;load => mod_event_multicast
;load => mod_event_test
;load => mod_zeroconf
;load => mod_xmpp_event
; Directory Interfaces
;load => mod_ldap
; Endpoints
load => mod_exosip
load => mod_iax
;load => mod_portaudio
;load => mod_woomera
;load => mod_wanpipe
;load => mod_dingaling
; Applications
load => mod_bridgecall
load => mod_echo
;load => mod_ivrtest
load => mod_playback
load => mod_commands
;load => mod_commands
; Dialplan Interfaces
load => mod_dialplan_flatfile
;load => mod_dialplan_directory
load => mod_pcre
; Codec Interfaces
load => mod_g711
load => mod_gsm
load => mod_l16
;load => mod_speex
;load => mod_ilbc
; File Format Interfaces
load => mod_sndfile
; Timers
load => mod_softtimer
; Languages
;load => mod_spidermonkey
;load => mod_perl
; ASR /TTS
;load => mod_cepstral
;---- SYSLOG
;--------------------------------------------------------------------------------
; emerg - system is unusable
; alert - action must be taken immediately
; crit - critical conditions
; err - error conditions
; warning - warning conditions
; notice - normal, but significant, condition
; info - informational message
; debug - debug-level message
;
[+syslog.conf]
[settings]
ident => freeswitch
facility => user
format => ${time} - ${message}
level => debug,info,warning-alert
;---- IAX PROTOCOL
;--------------------------------------------------------------------------------
[+iax.conf]
[settings]
debug => 0
;ip => 1.2.3.4
port => 4569
dialplan => flatfile
codec_prefs => PCMU,PCMA,speex,L16
codec_master => us
codec_rates=8
;---- SIP PROTOCOL
;--------------------------------------------------------------------------------
[+exosip.conf]
[settings]
port => 5060
dialplan => pcre
dtmf_duration => 100
; pick one (default if not specified is 'guess');
rtp-ip => guess
;rtp-ip => 10.0.0.1
; leave commented or 0.0.0.0 for all ip
;sip-ip => 127.0.0.1
; optional ;
;ext-rtp-ip => stun:stun.server.com
;ext-rtp-ip => 100.101.102.103
; specify 'myrealm' with certian key
; use !myrealm! at beginning of url to activate
; exosip/!myrealm!1000@dest
;srtp:myrealm => ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
; VAD choose one (out is a good choice);
; vad => in
; vad => out
; vad => both
;---- WOOMERA PROTOCOL
;--------------------------------------------------------------------------------
[+woomera.conf]
[settings]
debug=0
;---- WANPIPE PRI
;--------------------------------------------------------------------------------
[+wanpipe.conf]
[settings]
debug => 1
dialplan => pcre
mtu => 160
dtmf_on => 800
dtmf_off => 100
supress_dtmf_tone => yes
[span]
span => 1
node => cpe
;switch => ni2
switch => dms100
;switch => lucent5e
;switch => att4ess
;switch => euroisdn
;switch => gr303eoc
;switch => gr303tmc
dp => national
;dp => international
;dp => local
;dp => private
;dp => unknown
l1 => ulaw
;l1 => alaw
bchan => 1-23
dchan => 24
dialplan => pcre
;---- SOUND CARD CHANNEL
;--------------------------------------------------------------------------------
[+portaudio.conf]
[settings]
debug => 2
dialplan => flatfile
; partial string match on something in the name or the device #
indev => USB
outdev => USB
cid_name => FreeSwitch
cid_num => 5555551212
;--- ZEROCONF
;--------------------------------------------------------------------------------
[+zeroconf.conf]
[settings]
publish => yes
browse => _sip._udp
;---- XMPP EVENT
;--------------------------------------------------------------------------------
[+xmpp_event.conf]
[settings]
#debug => 1
jid => freeswitch@my.jabber.com/me
passwd => mypass
target_jid => freeswitch@reader.org/him
;---- LDAP DIALPLAN
;--------------------------------------------------------------------------------
[+dialplan_directory.conf]
[settings]
directory_name => ldap
host => ldap.freeswitch.org
dn => cn=Manager,dc=freeswitch,dc=org
pass => test
base => dc=freeswitch,dc=org
;----REGULAR EXPRESSION DIALPLAN
;--------------------------------------------------------------------------------
[+regextensions.conf]
; any extension starting with a '4'
; strip the '4' and consider the rest a numeric filename
[playfile]
regex => ^4(\d+)
match => playback /var/sounds/$1.raw
; send everything to wanpipe isdn
[gateway]
regex => (.*)
match => bridge wanpipe/a/a/$1
; ordniary extension
[plain_old_extension]
regex => 9999
match => playback /var/sounds/beep.gsm
;---- BASIC EXTENSIONS
;--------------------------------------------------------------------------------
[+extensions.conf]
[default]
1000 => playback /var/sounds/beep.raw
; to time from a timer instead of from the input stream use
; 1000 => playback /var/sounds/beep.raw soft
; call the freeswitch conference
888 => bridge iax/guest@66.250.68.194/888
[+dingaling.conf]
[settings]
debug => 0
codec_prefs => PCMU
; *NOTE* your resource (after the /) MUST contain the string "talk" (upper or lower case is ok)
; *NOTE* as of May 2 2006 you must set auto-login => true if you want to be able to auto-login on startup
[interface]
name => google
login => myjabberid@myjabberserver.com/talk
password => mypass
dialplan => flatfile
message => Jingle all the way
rtp-ip => 0.0.0.0
auto-login => true
; or ;
;rtp-ip => my_lan_ip
;ext-rtp-ip => stun:stun.server.com
exten => 1000
; VAD choose one
; vad => in
; vad => out
; vad => both

312
conf/freeswitch.xml Normal file
View File

@ -0,0 +1,312 @@
<?xml version="1.0"?>
<document type="freeswitch/xml">
<section name="configuration">
<configuration name="modules.conf" description="Modules">
<modules>
<!-- Loggers (I'd load these first) -->
<load module="mod_console"/>
<!-- <load module="mod_syslog"/> -->
<!-- XML Interfaces -->
<!-- <load module="mod_xml_rpc"/> -->
<!-- Event Handlers -->
<!-- <load module="mod_event_multicast"/> -->
<!-- <load module="mod_event_test"/> -->
<!-- <load module="mod_zeroconf"/> -->
<!-- <load module="mod_xmpp_event"/> -->
<!-- Directory Interfaces -->
<!-- <load module="mod_ldap"/> -->
<!-- Endpoints -->
<load module="mod_exosip"/>
<!--<load module="mod_iax"/>-->
<!-- <load module="mod_portaudio"/> -->
<!-- <load module="mod_woomera"/> -->
<!-- <load module="mod_wanpipe"/> -->
<!-- <load module="mod_dingaling"/> -->
<!-- Applications -->
<load module="mod_bridgecall"/>
<load module="mod_echo"/>
<!-- <load module="mod_ivrtest"/> -->
<load module="mod_playback"/>
<load module="mod_commands"/>
<!-- <load module="mod_commands"/> -->
<!-- Dialplan Interfaces -->
<load module="mod_dialplan_xml"/>
<!-- <load module="mod_dialplan_directory"/> -->
<!-- Codec Interfaces -->
<load module="mod_g711"/>
<load module="mod_gsm"/>
<load module="mod_l16"/>
<!-- <load module="mod_speex"/> -->
<!-- <load module="mod_ilbc"/> -->
<!-- File Format Interfaces -->
<load module="mod_sndfile"/>
<!-- Timers -->
<load module="mod_softtimer"/>
<!-- Languages -->
<!-- <load module="mod_spidermonkey"/> -->
<!-- <load module="mod_perl"/> -->
<!-- ASR /TTS -->
<!-- <load module="mod_cepstral"/> -->
</modules>
</configuration>
<configuration name="iax.conf" description="IAX Configuration">
<settings>
<param name="debug" value="0"/>
<!-- <param name="ip" value="1.2.3.4"> -->
<param name="port" value="4569"/>
<param name="dialplan" value="flatfile"/>
<param name="codec_prefs" value="PCMU,PCMA,speex,L16"/>
<param name="codec_master" value="us"/>
<param name="codec_rates" value="8"/>
</settings>
</configuration>
<configuration name="console.conf" description="Console Logger">
<!-- pick a file name, a function name or 'all' -->
<!-- map as many as you need for specific debugging -->
<mappings>
<!-- <param name="log_event" value="DEBUG"/> -->
<param name="all" value="DEBUG"/>
</mappings>
</configuration>
<configuration name="syslog.conf" description="Syslog Logger">
<!-- SYSLOG -->
<!-- emerg - system is unusable -->
<!-- alert - action must be taken immediately -->
<!-- crit - critical conditions -->
<!-- err - error conditions -->
<!-- warning - warning conditions -->
<!-- notice - normal, but significant, condition -->
<!-- info - informational message -->
<!-- debug - debug-level message -->
<settings>
<param name="ident" value="freeswitch"/>
<param name="facility" value="user"/>
<param name="format" value="${time} - ${message}"/>
<param name="level" value="debug,info,warning-alert"/>
</settings>
</configuration>
<configuration name="exosip.conf" description="Exosip Endpoint">
<settings>
<param name="port" value="5060"/>
<param name="dialplan" value="XML"/>
<param name="dtmf_duration" value="100"/>
<!-- pick one (default if not specified is 'guess'); -->
<param name="rtp-ip" value="guess"/>
<!-- <param name-"rtp-ip" value="10.0.0.1"/> -->
<!-- leave commented or 0.0.0.0 for all ip -->
<!-- <param name="sip-ip" value="127.0.0.1"/> -->
<!-- optional ; -->
<!-- <param name="ext-rtp-ip" value="stun:stun.server.com"/> -->
<!-- <param name="ext-rtp-ip" value="100.101.102.103"/> -->
<!-- specify 'myrealm' with certian key -->
<!-- use !myrealm! at beginning of url to activate -->
<!-- exosip/!myrealm!1000@dest -->
<!-- srtp:<param name="myrealm" value="ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"/> -->
<!-- VAD choose one (out is a good choice); -->
<!-- <param name="vad" value="in"/> -->
<!-- <param name="vad" value="out"/> -->
<!-- <param name="vad" value="both"/> -->
</settings>
</configuration>
<configuration name="woomera.conf" description="Woomera Endpoint">
<settings>
<param name="debug" value="0"/>
</settings>
</configuration>
<configuration name="wanpipe.conf" description="Sangoma Wanpipe Endpoint">
<settings>
<param name="debug" value="1"/>
<param name="dialplan" value="XML"/>
<param name="mtu" value="160"/>
<param name="dtmf_on" value="800"/>
<param name="dtmf_off" value="100"/>
<param name="supress_dtmf_tone" value="yes"/>
</settings>
<span>
<param name="span" value="1"/>
<param name="node" value="cpe"/>
<!-- <param name="switch" value="ni2"/> -->
<param name="switch" value="dms100"/>
<!-- <param name="switch" value="lucent5e"/> -->
<!-- <param name="switch" value="att4ess"/> -->
<!-- <param name="switch" value="euroisdn"/> -->
<!-- <param name="switch" value="gr303eoc"/> -->
<!-- <param name="switch" value="gr303tmc"/> -->
<param name="dp" value="national"/>
<!-- <param name="dp" value="international"/> -->
<!-- <param name="dp" value="local"/> -->
<!-- <param name="dp" value="private"/> -->
<!-- <param name="dp" value="unknown"/> -->
<param name="l1" value="ulaw"/>
<!-- <param name="l1" value="alaw"/> -->
<param name="bchan" value="1-23"/>
<param name="dchan" value="24"/>
<param name="dialplan" value="XML"/>
</span>
</configuration>
<configuration name="portaudio.conf" description="Soundcard Endpoint">
<settings>
<param name="debug" value="2"/>
<param name="dialplan" value="flatfile"/>
<!-- partial string match on something in the name or the device # -->
<param name="indev" value="USB"/>
<param name="outdev" value="USB"/>
<param name="cid_name" value="FreeSwitch"/>
<param name="cid_num" value="5555551212"/>
</settings>
</configuration>
<configuration name="zeroconf.conf" description="Zeroconf Event Handler">
<settings>
<param name="publish" value="yes"/>
<param name="browse" value="_sip._udp"/>
</settings>
</configuration>
<configuration name="xmpp_event.conf" description="XMPP Event Handler">
<settings>
<param name="#debug" value="1"/>
<param name="jid" value="freeswitch@my.jabber.com/me"/>
<param name="passwd" value="mypass"/>
<param name="target_jid" value="freeswitch@reader.org/him"/>
</settings>
</configuration>
<configuration name="dialplan_directory.conf" description="Dialplan Directory">
<settings>
<param name="directory_name" value="ldap"/>
<param name="host" value="ldap.freeswitch.org"/>
<param name="dn" value="cn=Manager,dc=freeswitch,dc=org"/>
<param name="pass" value="test"/>
<param name="base" value="dc=freeswitch,dc=org"/>
</settings>
</configuration>
<configuration name="extensions.conf" description="Regex/XML Dialplan">
<!-- any extension starting with a '4' -->
<!-- strip the '4' and consider the rest a numeric filename -->
<!-- Valid fields in conditions:
"dialplan, caller_id_name, ani, ani2, caller_id_number,
network_addr, rdnis, destination_number, uuid, source,
context, chan_name" -->
<context name="default">
<extension name="devconf">
<condition field="destination_number" expression="888">
<action application="bridge" data="exosip/888@66.250.68.194"/>
</condition>
</extension>
<!-- extensions starting with 4, all the numbers after 4 form a numeric filename
continue=true means keep looking for more extensions to match
*NOTE* The entire dialplan is parsed ONCE when the call starts
so any call info acquired after the various actions cannot
be taken into consideration.
The first match will play a beep and the second one plays
the desired file. This is for demo purposes both actions
could have been under the same <extension> tag as well.
-->
<extension name="playsound1" continue="true">
<condition field="source" expression="mod_exosip"/>
<condition field="destination_number" expression="^4(\d+)">
<action application="playback" data="/var/sounds/beep.gsm"/>
</condition>
</extension>
<extension name="playsound2">
<condition field="source" expression="mod_exosip"/>
<condition field="destination_number" expression="^4(\d+)">
<action application="playback" data="/root/$1.raw"/>
</condition>
</extension>
<!-- send everything with a certian RDNIS to Wanpipe ISDN -->
<extension name="To PRI">
<condition field="rdnis" expression="8881231234"/>
<condition field="destination_number" expression="(.*)">
<action application="bridge" data="wanpipe/a/a/$1"/>
</condition>
</extension>
<!-- Call *MUST* originate from mod_iax and also be dialing ext 9999-->
<extension name="9999">
<condition field="source" expresion="mod_iax"/>
<condition field="destination_number" expression="9999">
<action application="playback" data="/var/sounds/beep.gsm"/>
</condition>
</extension>
<!-- Call the FreeSWITCH conference via SIP -->
<extension name="FreeSWITCH Conference SIP">
<condition field="destination_number" expression="888">
<action application="bridge" data="exosip/888@66.250.68.194"/>
</condition>
</extension>
<!-- Call the FreeSWITCH conference via IAX -->
<extension name="FreeSWITCH Conference IAX">
<condition field="destination_number" expression="8888">
<action application="bridge" data="iax/guest@66.250.68.194/888"/>
</condition>
</extension>
</context>
</configuration>
<configuration name="dingaling.conf" description="XMPP Jingle Endpoint">
<settings>
<param name="debug" value="0"/>
<param name="codec_prefs" value="PCMU"/>
</settings>
<!-- *NOTE* your resource (after the /) MUST contain the string "talk" (upper or lower case is ok) -->
<!-- *NOTE* as of May 2 2006 you must set"auto-login" to"true" if you want to be able to auto-login on startup"/> -->
<interface>
<param name="name" value="jingle"/>
<param name="login" value="myjid@myserver.com/talk"/>
<param name="password" value="mypass"/>
<param name="dialplan" value="XML"/>
<param name="message" value="Jingle all the way"/>
<param name="rtp-ip" value="10.0.0.1"/>
<param name="auto-login" value="true"/>
<!-- or -->
<!-- rtp-<param name="ip" value="my_lan_ip"/> -->
<!-- ext-rtp-<param name="ip" value="stun:stun.server.com"/> -->
<!-- default extension (if one cannot be determined) -->
<param name="exten" value="888"/>
<!-- VAD choose one -->
<!-- <param name="vad" value="in"/> -->
<!-- <param name="vad" value="out"/> -->
<param name="vad" value="both"/>
</interface>
</configuration>
<configuration name="xml_rpc.conf" description="XML RPC">
<settings>
<!-- The port where you want to run the http service (default 8080) -->
<param name="http_port" value="8080">
<!-- The url to a gateway cgi that can generate xml similar to
what's in this file only on-the-fly (leave it commented if you dont
need it) -->
<!-- <param name="gateway_url" value="http://www.server.com/gateway.cgi"/> -->
</configuration>
</section>
</document>

View File

@ -14,9 +14,8 @@ codecs/mod_gsm
#codecs/mod_ilbc
codecs/mod_l16
#codecs/mod_speex
dialplans/mod_dialplan_flatfile
#dialplans/mod_dialplan_directory
dialplans/mod_pcre
dialplans/mod_dialplan_xml
#directories/mod_ldap
endpoints/mod_exosip
endpoints/mod_iax
@ -33,5 +32,4 @@ formats/mod_sndfile
languages/mod_perl
#languages/mod_spidermonkey
timers/mod_softtimer
#xml_int/mod_xml_rpc

View File

@ -137,6 +137,14 @@ SWITCH_DECLARE(void) switch_caller_extension_add_application(switch_core_session
char *extra_data);
/*!
\brief Get the value of a field in a caller profile based on it's name
\param caller_profile The caller profile
\param name the name
\note this function is meant for situations where the name paramater is the contents of the variable
*/
SWITCH_DECLARE(char *) switch_caller_get_field_by_name(switch_caller_profile_t *caller_profile, char *name);
/*!
\brief Create a new caller profile object
\param pool memory pool to use

View File

@ -45,6 +45,16 @@ BEGIN_EXTERN_C
#define SWITCH_MAX_CORE_THREAD_SESSION_OBJS 128
#define SWITCH_MAX_STREAMS 128
struct switch_core_time_duration {
uint32_t mms;
uint32_t ms;
uint32_t sec;
uint32_t min;
uint32_t hr;
uint32_t day;
uint32_t yr;
};
/*! \brief A message object designed to allow unlike technologies to exchange data */
struct switch_core_session_message {
/*! uuid of the sender (for replies)*/
@ -954,6 +964,19 @@ SWITCH_DECLARE(FILE *) switch_core_data_channel(switch_text_channel_t channel);
*/
SWITCH_DECLARE(switch_status_t) switch_core_set_console(char *console);
/*!
\brief Breakdown a number of milliseconds into various time spec
\param total_ms a number of milliseconds
\param duration an object to store the results
*/
SWITCH_DECLARE(void) switch_core_measure_time(switch_time_t total_ms, switch_core_time_duration_t *duration);
/*!
\brief Number of microseconds the system has been up
\return a number of microseconds
*/
SWITCH_DECLARE(switch_time_t) switch_core_uptime(void);
/*!
\brief Get the output console
\return the FILE stream

View File

@ -76,6 +76,7 @@ struct switch_directories {
char *db_dir;
char *script_dir;
char *temp_dir;
char *htdocs_dir;
};
typedef struct switch_directories switch_directories;
@ -166,7 +167,7 @@ typedef enum {
SWITCH_IVR_OPTION_ASYNC = (1 << 0),
SWITCH_IVR_OPTION_FILE = (1 << 1)
} switch_ivr_option_t;
/*!
\enum switch_core_session_message_types_t
\brief Possible types of messages for inter-session communication
@ -676,7 +677,12 @@ typedef switch_status_t (*switch_module_resume_t) (void);
typedef switch_status_t (*switch_module_status_t) (void);
typedef switch_status_t (*switch_module_runtime_t) (void);
typedef switch_status_t (*switch_module_shutdown_t) (void);
typedef struct switch_xml *switch_xml_t;
typedef struct switch_core_time_duration switch_core_time_duration_t;
typedef switch_xml_t (*switch_xml_search_function_t)(char *section,
char *tag_name,
char *key_name,
char *key_value);
/* things we don't deserve to know about */

View File

@ -1,4 +1,35 @@
/* switch_xml.h
/*
* 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>
*
*
* switch_xml.h -- XML PARSER
*
* Derived from EZXML http://ezxml.sourceforge.net
* Original Copyright
*
* Copyright 2004, 2005 Aaron Voisine <aaron@voisine.org>
*
@ -24,7 +55,7 @@
#ifndef _SWITCH_XML_H
#define _SWITCH_XML_H
#include <switch_types.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
@ -34,11 +65,14 @@ BEGIN_EXTERN_C
#define SWITCH_XML_BUFSIZE 1024 // size of internal memory buffers
#define SWITCH_XML_NAMEM 0x80 // name is malloced
#define SWITCH_XML_TXTM 0x40 // txt is malloced
#define SWITCH_XML_DUP 0x20 // attribute name and value are strduped
typedef enum {
SWITCH_XML_ROOT = (1 << 0), // root
SWITCH_XML_NAMEM = (1 << 1), // name is malloced
SWITCH_XML_TXTM = (1 << 2), // txt is malloced
SWITCH_XML_DUP = (1 << 3) // attribute name and value are strduped
} switch_xml_flag_t;
typedef struct switch_xml *switch_xml_t;
struct switch_xml {
char *name; // tag name
char **attr; // tag attributes { name, value, name, value, ... NULL }
@ -49,31 +83,33 @@ struct switch_xml {
switch_xml_t ordered; // next tag, same section and depth, in original order
switch_xml_t child; // head of sub tag list, NULL if none
switch_xml_t parent; // parent tag, NULL if current tag is root tag
short flags; // additional information
uint32_t flags; // additional information
};
// Given a string of xml data and its length, parses it and creates an switch_xml
// structure. For efficiency, modifies the data by adding null terminators
// and decoding ampersand sequences. If you don't want this, copy the data and
// pass in the copy. Returns NULL on failure.
switch_xml_t switch_xml_parse_str(char *s, switch_size_t len);
SWITCH_DECLARE(switch_xml_t) switch_xml_parse_str(char *s, switch_size_t len);
// A wrapper for switch_xml_parse_str() that accepts a file descriptor. First
// attempts to mem map the file. Failing that, reads the file into memory.
// Returns NULL on failure.
switch_xml_t switch_xml_parse_fd(int fd);
SWITCH_DECLARE(switch_xml_t) switch_xml_parse_fd(int fd);
// a wrapper for switch_xml_parse_fd() that accepts a file name
switch_xml_t switch_xml_parse_file(const char *file);
SWITCH_DECLARE(switch_xml_t) switch_xml_parse_file(const char *file);
// Wrapper for switch_xml_parse_str() that accepts a file stream. Reads the entire
// stream into memory and then parses it. For xml files, use switch_xml_parse_file()
// or switch_xml_parse_fd()
switch_xml_t switch_xml_parse_fp(FILE *fp);
SWITCH_DECLARE(switch_xml_t) switch_xml_parse_fp(FILE *fp);
// returns the first child tag (one level deeper) with the given name or NULL
// if not found
switch_xml_t switch_xml_child(switch_xml_t xml, const char *name);
SWITCH_DECLARE(switch_xml_t) switch_xml_child(switch_xml_t xml, const char *name);
SWITCH_DECLARE(switch_xml_t) switch_xml_find_child(switch_xml_t node, char *childname, char *attrname, char *value);
// returns the next tag of the same name in the same section and depth or NULL
// if not found
@ -90,7 +126,7 @@ switch_xml_t switch_xml_idx(switch_xml_t xml, int idx);
#define switch_xml_txt(xml) ((xml) ? xml->txt : "")
// returns the value of the requested tag attribute, or NULL if not found
const char *switch_xml_attr(switch_xml_t xml, const char *attr);
SWITCH_DECLARE(const char *) switch_xml_attr(switch_xml_t xml, const char *attr);
// Traverses the switch_xml sturcture to retrieve a specific subtag. Takes a
// variable length list of tag names and indexes. The argument list must be
@ -98,24 +134,24 @@ const char *switch_xml_attr(switch_xml_t xml, const char *attr);
// title = switch_xml_get(library, "shelf", 0, "book", 2, "title", -1);
// This retrieves the title of the 3rd book on the 1st shelf of library.
// Returns NULL if not found.
switch_xml_t switch_xml_get(switch_xml_t xml, ...);
SWITCH_DECLARE(switch_xml_t) switch_xml_get(switch_xml_t xml, ...);
// Converts an switch_xml structure back to xml. Returns a string of xml data that
// must be freed.
char *switch_xml_toxml(switch_xml_t xml);
SWITCH_DECLARE(char *) switch_xml_toxml(switch_xml_t xml);
// returns a NULL terminated array of processing instructions for the given
// target
const char **switch_xml_pi(switch_xml_t xml, const char *target);
SWITCH_DECLARE(const char **) switch_xml_pi(switch_xml_t xml, const char *target);
// frees the memory allocated for an switch_xml structure
void switch_xml_free(switch_xml_t xml);
// returns parser error message or empty string if none
const char *switch_xml_error(switch_xml_t xml);
SWITCH_DECLARE(const char *) switch_xml_error(switch_xml_t xml);
// returns a new empty switch_xml structure with the given root tag name
switch_xml_t switch_xml_new(const char *name);
SWITCH_DECLARE(switch_xml_t) switch_xml_new(const char *name);
// wrapper for switch_xml_new() that strdup()s name
#define switch_xml_new_d(name) switch_xml_set_flag(switch_xml_new(strdup(name)), SWITCH_XML_NAMEM)
@ -137,17 +173,33 @@ switch_xml_t switch_xml_set_txt(switch_xml_t xml, const char *txt);
// Sets the given tag attribute or adds a new attribute if not found. A value
// of NULL will remove the specified attribute.
void switch_xml_set_attr(switch_xml_t xml, const char *name, const char *value);
SWITCH_DECLARE(void) switch_xml_set_attr(switch_xml_t xml, const char *name, const char *value);
// Wrapper for switch_xml_set_attr() that strdup()s name/value. Value cannot be NULL
#define switch_xml_set_attr_d(xml, name, value) \
switch_xml_set_attr(switch_xml_set_flag(xml, SWITCH_XML_DUP), strdup(name), strdup(value))
// sets a flag for the given tag and returns the tag
switch_xml_t switch_xml_set_flag(switch_xml_t xml, short flag);
SWITCH_DECLARE(switch_xml_t) switch_xml_set_flag(switch_xml_t xml, switch_xml_flag_t flag);
// removes a tag along with all its subtags
void switch_xml_remove(switch_xml_t xml);
SWITCH_DECLARE(void) switch_xml_remove(switch_xml_t xml);
SWITCH_DECLARE(switch_xml_t) switch_xml_open_root(uint8_t reload);
SWITCH_DECLARE(switch_status_t) switch_xml_init(switch_memory_pool_t *pool);
SWITCH_DECLARE(switch_status_t) switch_xml_destroy(void);
SWITCH_DECLARE(switch_xml_t) switch_xml_root(void);
SWITCH_DECLARE(switch_status_t) switch_xml_locate(char *section,
char *tag_name,
char *key_name,
char *key_value,
switch_xml_t *root,
switch_xml_t *node);
SWITCH_DECLARE(switch_xml_t) switch_xml_open_cfg(char *file_path, switch_xml_t *node);
SWITCH_DECLARE(switch_status_t) switch_xml_bind_search_function(switch_xml_search_function_t function);
END_EXTERN_C

View File

@ -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",

View File

@ -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)

View File

@ -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;
}

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

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;
}

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>

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;
}

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");

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;
}

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) {

View File

@ -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;
}

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");

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) {

View File

@ -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;

View File

@ -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 */

View File

@ -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;

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;
}

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

View File

@ -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>

View File

@ -90,6 +90,47 @@ SWITCH_DECLARE(switch_caller_profile_t *) switch_caller_profile_clone(switch_cor
return profile;
}
SWITCH_DECLARE(char *) switch_caller_get_field_by_name(switch_caller_profile_t *caller_profile, char *name)
{
if (!strcasecmp(name, "dialplan")) {
return caller_profile->dialplan;
}
if (!strcasecmp(name, "caller_id_name")) {
return caller_profile->caller_id_name;
}
if (!strcasecmp(name, "ani")) {
return caller_profile->ani;
}
if (!strcasecmp(name, "ani2")) {
return caller_profile->ani2;
}
if (!strcasecmp(name, "caller_id_number")) {
return caller_profile->caller_id_number;
}
if (!strcasecmp(name, "network_addr")) {
return caller_profile->network_addr;
}
if (!strcasecmp(name, "rdnis")) {
return caller_profile->rdnis;
}
if (!strcasecmp(name, "destination_number")) {
return caller_profile->destination_number;
}
if (!strcasecmp(name, "uuid")) {
return caller_profile->uuid;
}
if (!strcasecmp(name, "source")) {
return caller_profile->source;
}
if (!strcasecmp(name, "context")) {
return caller_profile->context;
}
if (!strcasecmp(name, "chan_name")) {
return caller_profile->chan_name;
}
return NULL;
}
SWITCH_DECLARE(void) switch_caller_profile_event_set_data(switch_caller_profile_t *caller_profile, char *prefix,
switch_event_t *event)
{

View File

@ -616,6 +616,10 @@ SWITCH_DECLARE(void) switch_channel_set_caller_profile(switch_channel_t *channel
caller_profile->chan_name = switch_core_session_strdup(channel->session, channel->name);
}
if (!caller_profile->context) {
caller_profile->chan_name = switch_core_session_strdup(channel->session, "default");
}
if (!channel->caller_profile) {
switch_event_t *event;
@ -773,7 +777,7 @@ SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_hangup(switch_chan
{
assert(channel != NULL);
if (!channel->times->hungup) {
if (channel->times && !channel->times->hungup) {
channel->times->hungup = switch_time_now();
}

View File

@ -81,7 +81,7 @@ struct switch_core_session {
SWITCH_DECLARE_DATA switch_directories SWITCH_GLOBAL_dirs;
struct switch_core_runtime {
time_t initiated;
switch_time_t initiated;
uint32_t session_id;
apr_pool_t *memory_pool;
switch_hash_t *session_table;
@ -1764,9 +1764,12 @@ static void switch_core_standard_on_ring(switch_core_session_t *session)
if (!dialplan_interface) {
if (switch_channel_test_flag(session->channel, CF_OUTBOUND)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "No Dialplan, changing state to TRANSMIT\n");
switch_channel_set_state(session->channel, CS_TRANSMIT);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "No Dialplan, changing state to HOLD\n");
switch_channel_set_state(session->channel, CS_HOLD);
return;
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "No Dialplan, Aborting\n");
switch_channel_hangup(session->channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
}
} else {
if ((extension = dialplan_interface->hunt_function(session)) != 0) {
@ -2721,6 +2724,7 @@ SWITCH_DECLARE(void) switch_core_set_globals(void)
SWITCH_GLOBAL_dirs.log_dir = SWITCH_LOG_DIR;
SWITCH_GLOBAL_dirs.db_dir = SWITCH_DB_DIR;
SWITCH_GLOBAL_dirs.script_dir = SWITCH_SCRIPT_DIR;
SWITCH_GLOBAL_dirs.htdocs_dir = SWITCH_HTDOCS_DIR;
#ifdef SWITCH_TEMP_DIR
SWITCH_GLOBAL_dirs.temp_dir = SWITCH_TEMP_DIR;
#else
@ -2753,6 +2757,12 @@ SWITCH_DECLARE(switch_status_t) switch_core_init(char *console)
return SWITCH_STATUS_MEMERR;
}
if (switch_xml_init(runtime.memory_pool) != SWITCH_STATUS_SUCCESS) {
fprintf(stderr, "FATAL ERROR! Could not open XML Registry\n");
switch_core_destroy();
return SWITCH_STATUS_MEMERR;
}
if(console) {
if (*console != '/') {
char path[265];
@ -2829,11 +2839,34 @@ SWITCH_DECLARE(switch_status_t) switch_core_init(char *console)
#ifdef CRASH_PROT
switch_core_hash_init(&runtime.stack_table, runtime.memory_pool);
#endif
time(&runtime.initiated);
runtime.initiated = switch_time_now();
return SWITCH_STATUS_SUCCESS;
}
SWITCH_DECLARE(void) switch_core_measure_time(switch_time_t total_ms, switch_core_time_duration_t *duration)
{
memset(duration, 0, sizeof(*duration));
duration->mms = total_ms;
duration->ms = total_ms / 1000;
duration->mms = duration->mms % 1000;
duration->sec = duration->ms / 1000;
duration->ms = duration->ms % 1000;
duration->min = duration->sec / 60;
duration->sec = duration->sec % 60;
duration->hr = duration->min / 60;
duration->min = duration->min % 60;
duration->day = duration->hr / 24;
duration->hr = duration->hr % 24;
duration->yr = duration->day / 365;
duration->day = duration->day % 365;
}
SWITCH_DECLARE(switch_time_t) switch_core_uptime(void)
{
return switch_time_now() - runtime.initiated;
}
SWITCH_DECLARE(switch_status_t) switch_core_destroy(void)
{
@ -2847,6 +2880,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_destroy(void)
switch_yield(1000);
}
switch_core_db_close(runtime.db);
switch_xml_destroy();
if (runtime.memory_pool) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Unallocating memory pool.\n");

View File

@ -436,8 +436,8 @@ SWITCH_DECLARE(switch_status_t) switch_loadable_module_init()
apr_dir_t *module_dir_handle = NULL;
apr_int32_t finfo_flags = APR_FINFO_DIRENT | APR_FINFO_TYPE | APR_FINFO_NAME;
char *cf = "modules.conf";
char *var, *val;
switch_config_t cfg;
char *pcf = "post_load_modules.conf";
switch_xml_t cfg, xml;
unsigned char all = 0;
unsigned int count = 0;
@ -471,49 +471,57 @@ SWITCH_DECLARE(switch_status_t) switch_loadable_module_init()
switch_core_hash_init(&loadable_modules.directory_hash, loadable_modules.pool);
switch_core_hash_init(&loadable_modules.dialplan_hash, loadable_modules.pool);
if ((xml = switch_xml_open_cfg(cf, &cfg))) {
switch_xml_t mods, ld;
if (switch_config_open_file(&cfg, cf)) {
while (switch_config_next_pair(&cfg, &var, &val)) {
count++;
if (!strcasecmp(cfg.category, "modules")) {
if (!strcasecmp(var, "load")) {
if (!strcasecmp(val, "all")) {
if (count == 1) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Loading all modules.\n");
all = 1;
break;
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "This option must be the first one to work.\n");
}
} else {
if (strchr(val, '.') && !strstr(val, ext) && !strstr(val, EXT)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Invalid extension for %s\n", val);
continue;
}
switch_loadable_module_load_module((char *) SWITCH_GLOBAL_dirs.mod_dir, (char *) val);
}
if ((mods = switch_xml_child(cfg, "modules"))) {
for (ld = switch_xml_child(mods, "load"); ld; ld = ld->next) {
const char *val = switch_xml_attr(ld, "module");
if (strchr(val, '.') && !strstr(val, ext) && !strstr(val, EXT)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Invalid extension for %s\n", val);
continue;
}
switch_loadable_module_load_module((char *) SWITCH_GLOBAL_dirs.mod_dir, (char *) val);
count++;
}
}
switch_config_close_file(&cfg);
switch_xml_free(xml);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "open of %s failed\n", cf);
all = 1;
}
if (!count && !all) {
all = 1;
if ((xml = switch_xml_open_cfg(pcf, &cfg))) {
switch_xml_t mods, ld;
if ((mods = switch_xml_child(cfg, "modules"))) {
for (ld = switch_xml_child(mods, "load"); ld; ld = ld->next) {
const char *val = switch_xml_attr(ld, "module");
if (strchr(val, '.') && !strstr(val, ext) && !strstr(val, EXT)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Invalid extension for %s\n", val);
continue;
}
switch_loadable_module_load_module((char *) SWITCH_GLOBAL_dirs.mod_dir, (char *) val);
count++;
}
}
switch_xml_free(xml);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "open of %s failed\n", pcf);
}
if (!count) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "No modules loaded assuming 'load all'\n");
all = 1;
}
if (all) {
if (apr_dir_open(&module_dir_handle, SWITCH_GLOBAL_dirs.mod_dir, loadable_modules.pool) != APR_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Can't open directory: %s\n", SWITCH_GLOBAL_dirs.mod_dir);
return SWITCH_STATUS_GENERR;
}
}
if (all) {
while (apr_dir_read(&finfo, finfo_flags, module_dir_handle) == APR_SUCCESS) {
const char *fname = finfo.fname;
@ -538,6 +546,7 @@ SWITCH_DECLARE(switch_status_t) switch_loadable_module_init()
apr_dir_close(module_dir_handle);
}
return SWITCH_STATUS_SUCCESS;
}

View File

@ -51,10 +51,10 @@ struct switch_log_binding {
struct switch_log_binding *next;
};
typedef struct switch_log_binding switch_log_binding;
typedef struct switch_log_binding switch_log_binding_t;
static switch_memory_pool_t *LOG_POOL = NULL;
static switch_log_binding *BINDINGS = NULL;
static switch_log_binding_t *BINDINGS = NULL;
static switch_mutex_t *BINDLOCK = NULL;
static switch_queue_t *LOG_QUEUE = NULL;
static int8_t THREAD_RUNNING = 0;
@ -84,7 +84,7 @@ SWITCH_DECLARE(switch_log_level_t) switch_log_str2level(const char *str)
SWITCH_DECLARE(switch_status_t) switch_log_bind_logger(switch_log_function_t function, switch_log_level_t level)
{
switch_log_binding *binding = NULL, *ptr = NULL;
switch_log_binding_t *binding = NULL, *ptr = NULL;
assert(function != NULL);
if (!(binding = switch_core_alloc(LOG_POOL, sizeof(*binding)))) {
@ -121,7 +121,7 @@ static void *SWITCH_THREAD_FUNC log_thread(switch_thread_t *thread, void *obj)
for(;;) {
void *pop = NULL;
switch_log_node_t *node = NULL;
switch_log_binding *binding;
switch_log_binding_t *binding;
if (switch_queue_pop(LOG_QUEUE, &pop) != SWITCH_STATUS_SUCCESS) {
break;

View File

@ -703,9 +703,9 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_
stat = srtp_unprotect(rtp_session->recv_ctx, &rtp_session->recv_msg.header, &sbytes);
if (stat) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
"error: srtp unprotection failed with code %d%s\n", stat,
stat == err_status_replay_fail ? " (replay check failed)" :
stat == err_status_auth_fail ? " (auth check failed)" : "");
"error: srtp unprotection failed with code %d%s\n", stat,
stat == err_status_replay_fail ? " (replay check failed)" :
stat == err_status_auth_fail ? " (auth check failed)" : "");
return -1;
}
bytes = sbytes;
@ -747,16 +747,6 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_
if ((switch_time_now() - rtp_session->next_read) > 1000) {
do_2833(rtp_session);
if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_USE_TIMER)) {
/* We're late! We're Late!*/
memset(&rtp_session->recv_msg, 0, SWITCH_RTP_CNG_PAYLOAD);
rtp_session->recv_msg.header.pt = SWITCH_RTP_CNG_PAYLOAD;
*flags |= SFF_CNG;
/* Return a CNG frame */
*payload_type = SWITCH_RTP_CNG_PAYLOAD;
return SWITCH_RTP_CNG_PAYLOAD;
}
/* Set the next waypoint */
if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_TIMER_RECLOCK)) {
rtp_session->next_read = switch_time_now() + rtp_session->ms_per_packet;
@ -765,10 +755,17 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_
}
if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_USE_TIMER)) {
/* We're late! We're Late!*/
if (!switch_test_flag(rtp_session, SWITCH_RTP_FLAG_NOBLOCK) && status == SWITCH_STATUS_BREAK) {
switch_yield(1000);
continue;
}
memset(&rtp_session->recv_msg, 0, SWITCH_RTP_CNG_PAYLOAD);
rtp_session->recv_msg.header.pt = SWITCH_RTP_CNG_PAYLOAD;
*flags |= SFF_CNG;
/* Return a CNG frame */
*payload_type = SWITCH_RTP_CNG_PAYLOAD;
return SWITCH_RTP_CNG_PAYLOAD;
}
}

View File

@ -1,4 +1,35 @@
/* switch_xml.c
/*
* 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>
*
*
* switch_xml.c -- XML PARSER
*
* Derived from EZXML http://ezxml.sourceforge.net
* Original Copyright
*
* Copyright 2004, 2005 Aaron Voisine <aaron@voisine.org>
*
@ -29,7 +60,6 @@
#include <sys/mman.h>
#endif
#define SWITCH_XML_WS "\t\r\n " // whitespace
#define SWITCH_XML_ERRL 128 // maximum error string length
@ -52,8 +82,59 @@ struct switch_xml_root { // additional data for the root tag
char *SWITCH_XML_NIL[] = { NULL }; // empty, null terminated array of strings
struct switch_xml_binding {
switch_xml_search_function_t function;
struct switch_xml_binding *next;
};
typedef struct switch_xml_binding switch_xml_binding_t;
static switch_xml_binding_t *BINDINGS = NULL;
static switch_xml_t MAIN_XML_ROOT = NULL;
static switch_memory_pool_t *XML_MEMORY_POOL;
static switch_mutex_t *XML_LOCK;
static switch_thread_rwlock_t *RWLOCK;
SWITCH_DECLARE(switch_status_t) switch_xml_bind_search_function(switch_xml_search_function_t function)
{
switch_xml_binding_t *binding = NULL, *ptr = NULL;
assert(function != NULL);
if (!(binding = switch_core_alloc(XML_MEMORY_POOL, sizeof(*binding)))) {
return SWITCH_STATUS_MEMERR;
}
binding->function = function;
switch_mutex_lock(XML_LOCK);
for (ptr = BINDINGS; ptr && ptr->next; ptr = ptr->next);
if (ptr) {
ptr->next = binding;
} else {
BINDINGS = binding;
}
switch_mutex_unlock(XML_LOCK);
return SWITCH_STATUS_SUCCESS;
}
SWITCH_DECLARE(switch_xml_t) switch_xml_find_child(switch_xml_t node, char *childname, char *attrname, char *value)
{
switch_xml_t p = NULL;
for (p = switch_xml_child(node, childname); p; p = p->next) {
const char *aname = switch_xml_attr(p, attrname);
if (!strcasecmp(aname, value)) {
break;
}
}
return p;
}
// returns the first child tag with the given name or NULL if not found
switch_xml_t switch_xml_child(switch_xml_t xml, const char *name)
SWITCH_DECLARE(switch_xml_t) switch_xml_child(switch_xml_t xml, const char *name)
{
xml = (xml) ? xml->child : NULL;
while (xml && strcmp(name, xml->name)) xml = xml->sibling;
@ -69,7 +150,7 @@ switch_xml_t switch_xml_idx(switch_xml_t xml, int idx)
}
// returns the value of the requested tag attribute or NULL if not found
const char *switch_xml_attr(switch_xml_t xml, const char *attr)
SWITCH_DECLARE(const char *) switch_xml_attr(switch_xml_t xml, const char *attr)
{
int i = 0, j = 1;
switch_xml_root_t root = (switch_xml_root_t)xml;
@ -104,7 +185,7 @@ static switch_xml_t switch_xml_vget(switch_xml_t xml, va_list ap)
// title = switch_xml_get(library, "shelf", 0, "book", 2, "title", -1);
// This retrieves the title of the 3rd book on the 1st shelf of library.
// Returns NULL if not found.
switch_xml_t switch_xml_get(switch_xml_t xml, ...)
SWITCH_DECLARE(switch_xml_t) switch_xml_get(switch_xml_t xml, ...)
{
va_list ap;
switch_xml_t r;
@ -117,7 +198,7 @@ switch_xml_t switch_xml_get(switch_xml_t xml, ...)
// returns a null terminated array of processing instructions for the given
// target
const char **switch_xml_pi(switch_xml_t xml, const char *target)
SWITCH_DECLARE(const char **) switch_xml_pi(switch_xml_t xml, const char *target)
{
switch_xml_root_t root = (switch_xml_root_t)xml;
int i = 0;
@ -135,7 +216,7 @@ static switch_xml_t switch_xml_err(switch_xml_root_t root, char *s, const char *
int line = 1;
char *t, fmt[SWITCH_XML_ERRL];
for (t = root->s; t < s; t++) if (*t == '\n') line++;
for (t = root->s; t && t < s; t++) if (*t == '\n') line++;
snprintf(fmt, SWITCH_XML_ERRL, "[error near line %d]: %s", line, err);
va_start(ap, err);
@ -463,7 +544,7 @@ static void switch_xml_free_attr(char **attr) {
}
// parse the given xml string and return an switch_xml structure
switch_xml_t switch_xml_parse_str(char *s, switch_size_t len)
SWITCH_DECLARE(switch_xml_t) switch_xml_parse_str(char *s, switch_size_t len)
{
switch_xml_root_t root = (switch_xml_root_t)switch_xml_new(NULL);
char q, e, *d, **attr, **a = NULL; // initialize a to avoid compile warning
@ -598,7 +679,7 @@ switch_xml_t switch_xml_parse_str(char *s, switch_size_t len)
// Wrapper for switch_xml_parse_str() that accepts a file stream. Reads the entire
// stream into memory and then parses it. For xml files, use switch_xml_parse_file()
// or switch_xml_parse_fd()
switch_xml_t switch_xml_parse_fp(FILE *fp)
SWITCH_DECLARE(switch_xml_t) switch_xml_parse_fp(FILE *fp)
{
switch_xml_root_t root;
switch_size_t l, len = 0;
@ -619,7 +700,7 @@ switch_xml_t switch_xml_parse_fp(FILE *fp)
// A wrapper for switch_xml_parse_str() that accepts a file descriptor. First
// attempts to mem map the file. Failing that, reads the file into memory.
// Returns NULL on failure.
switch_xml_t switch_xml_parse_fd(int fd)
SWITCH_DECLARE(switch_xml_t) switch_xml_parse_fd(int fd)
{
switch_xml_root_t root;
struct stat st;
@ -649,7 +730,7 @@ switch_xml_t switch_xml_parse_fd(int fd)
}
// a wrapper for switch_xml_parse_fd that accepts a file name
switch_xml_t switch_xml_parse_file(const char *file)
SWITCH_DECLARE(switch_xml_t) switch_xml_parse_file(const char *file)
{
int fd = open(file, O_RDONLY, 0);
switch_xml_t xml = switch_xml_parse_fd(fd);
@ -658,6 +739,162 @@ switch_xml_t switch_xml_parse_file(const char *file)
return xml;
}
SWITCH_DECLARE(switch_status_t) switch_xml_locate(char *section,
char *tag_name,
char *key_name,
char *key_value,
switch_xml_t *root,
switch_xml_t *node)
{
switch_xml_t conf = NULL;
switch_xml_t tag = NULL;
switch_xml_t xml = NULL;
switch_xml_binding_t *binding;
switch_mutex_lock(XML_LOCK);
for(binding = BINDINGS; binding; binding = binding->next) {
if ((xml = binding->function(section, tag_name, key_name, key_value))) {
const char *err = NULL;
err = switch_xml_error(xml);
if (switch_strlen_zero(err)) {
if ((conf = switch_xml_find_child(xml, "section", "name", "result"))) {
switch_xml_t p;
const char *aname;
if ((p = switch_xml_child(conf, "result"))) {
aname = switch_xml_attr(p, "status");
if (aname && !strcasecmp(aname, "not found")) {
switch_xml_free(xml);
xml = NULL;
continue;
}
}
}
break;
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error[%s]\n", err);
switch_xml_free(xml);
xml = NULL;
}
}
}
switch_mutex_unlock(XML_LOCK);
for(;;) {
if (!xml) {
if (!(xml = MAIN_XML_ROOT)) {
*node = NULL;
*root = NULL;
return SWITCH_STATUS_FALSE;
}
}
if ((conf = switch_xml_find_child(xml, "section", "name", section)) &&
(tag = switch_xml_find_child(conf, tag_name, key_name, key_value))) {
*node = tag;
*root = xml;
return SWITCH_STATUS_SUCCESS;
} else {
switch_xml_free(xml);
xml = NULL;
*node = NULL;
*root = NULL;
}
}
return SWITCH_STATUS_FALSE;
}
SWITCH_DECLARE(switch_xml_t) switch_xml_root(void)
{
switch_thread_rwlock_rdlock(RWLOCK);
return MAIN_XML_ROOT;
}
SWITCH_DECLARE(switch_xml_t) switch_xml_open_root(uint8_t reload)
{
char path_buf[1024];
uint8_t hasmain = 0;
switch_mutex_lock(XML_LOCK);
if (MAIN_XML_ROOT) {
switch_xml_t xml;
hasmain++;
if (!reload) {
switch_mutex_unlock(XML_LOCK);
return switch_xml_root();
}
xml = MAIN_XML_ROOT;
MAIN_XML_ROOT = NULL;
switch_thread_rwlock_wrlock(RWLOCK);
switch_xml_free(xml);
}
snprintf(path_buf, sizeof(path_buf), "%s/%s", SWITCH_GLOBAL_dirs.conf_dir, "freeswitch.xml");
if ((MAIN_XML_ROOT = switch_xml_parse_file(path_buf))) {
switch_set_flag(MAIN_XML_ROOT, SWITCH_XML_ROOT);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Cannot Open XML Root!\n");
}
if (hasmain) {
switch_thread_rwlock_unlock(RWLOCK);
}
switch_mutex_unlock(XML_LOCK);
return switch_xml_root();
}
SWITCH_DECLARE(switch_status_t) switch_xml_init(switch_memory_pool_t *pool)
{
switch_xml_t xml;
XML_MEMORY_POOL = pool;
switch_mutex_init(&XML_LOCK, SWITCH_MUTEX_NESTED, XML_MEMORY_POOL);
switch_thread_rwlock_create(&RWLOCK, XML_MEMORY_POOL);
assert(pool != NULL);
if((xml=switch_xml_open_root(FALSE))) {
switch_xml_free(xml);
return SWITCH_STATUS_SUCCESS;
} else {
return SWITCH_STATUS_FALSE;
}
}
SWITCH_DECLARE(switch_status_t) switch_xml_destroy(void)
{
if (MAIN_XML_ROOT) {
switch_xml_t xml = MAIN_XML_ROOT;
MAIN_XML_ROOT = NULL;
switch_xml_free(xml);
return SWITCH_STATUS_SUCCESS;
}
return SWITCH_STATUS_FALSE;
}
SWITCH_DECLARE(switch_xml_t) switch_xml_open_cfg(char *file_path, switch_xml_t *node)
{
switch_xml_t xml = NULL, cfg = NULL;
*node = NULL;
assert(MAIN_XML_ROOT != NULL);
if (switch_xml_locate("configuration", "configuration", "name", file_path, &xml, &cfg) == SWITCH_STATUS_SUCCESS) {
*node = cfg;
}
return xml;
}
// Encodes ampersand sequences appending the results to *dst, reallocating *dst
// if length excedes max. a is non-zero for attribute encoding. Returns *dst
static char *switch_xml_ampencode(const char *s, switch_size_t len, char **dst, switch_size_t *dlen, switch_size_t *max, short a)
@ -690,7 +927,7 @@ static char *switch_xml_ampencode(const char *s, switch_size_t len, char **dst,
// Recursively converts each tag to xml appending it to *s. Reallocates *s if
// its length excedes max. start is the location of the previous tag in the
// parent tag's character content. Returns *s.
static char *switch_xml_toxml_r(switch_xml_t xml, char **s, switch_size_t *len, switch_size_t *max,
SWITCH_DECLARE(static char *) switch_xml_toxml_r(switch_xml_t xml, char **s, switch_size_t *len, switch_size_t *max,
switch_size_t start, char ***attr)
{
int i, j;
@ -787,7 +1024,17 @@ void switch_xml_free(switch_xml_t xml)
int i, j;
char **a, *s;
if (! xml) return;
if (! xml ) return;
if (switch_test_flag(xml, SWITCH_XML_ROOT)) {
switch_thread_rwlock_unlock(RWLOCK);
}
if (xml == MAIN_XML_ROOT) {
return;
}
switch_xml_free(xml->child);
switch_xml_free(xml->ordered);
@ -824,14 +1071,14 @@ void switch_xml_free(switch_xml_t xml)
}
// return parser error message or empty string if none
const char *switch_xml_error(switch_xml_t xml)
SWITCH_DECLARE(const char *) switch_xml_error(switch_xml_t xml)
{
while (xml && xml->parent) xml = xml->parent; // find root tag
return (xml) ? ((switch_xml_root_t)xml)->err : "";
}
// returns a new empty switch_xml structure with the given root tag name
switch_xml_t switch_xml_new(const char *name)
SWITCH_DECLARE(switch_xml_t) switch_xml_new(const char *name)
{
static char *ent[] = { "lt;", "&#60;", "gt;", "&#62;", "quot;", "&#34;",
"apos;", "&#39;", "amp;", "&#38;", NULL };
@ -904,7 +1151,7 @@ switch_xml_t switch_xml_set_txt(switch_xml_t xml, const char *txt)
// Sets the given tag attribute or adds a new attribute if not found. A value
// of NULL will remove the specified attribute.
void switch_xml_set_attr(switch_xml_t xml, const char *name, const char *value)
SWITCH_DECLARE(void) switch_xml_set_attr(switch_xml_t xml, const char *name, const char *value)
{
int l = 0, c;
@ -944,14 +1191,14 @@ void switch_xml_set_attr(switch_xml_t xml, const char *name, const char *value)
}
// sets a flag for the given tag and returns the tag
switch_xml_t switch_xml_set_flag(switch_xml_t xml, short flag)
SWITCH_DECLARE(switch_xml_t) switch_xml_set_flag(switch_xml_t xml, switch_xml_flag_t flag)
{
if (xml) xml->flags |= flag;
return xml;
}
// removes a tag along with all its subtags
void switch_xml_remove(switch_xml_t xml)
SWITCH_DECLARE(void) switch_xml_remove(switch_xml_t xml)
{
switch_xml_t cur;
@ -984,20 +1231,4 @@ void switch_xml_remove(switch_xml_t xml)
switch_xml_free(xml);
}
#ifdef SWITCH_XML_TEST // test harness
int main(int argc, char **argv)
{
switch_xml_t xml;
char *s;
int i;
if (argc != 2) return fprintf(stderr, "usage: %s xmlfile\n", argv[0]);
xml = switch_xml_parse_file(argv[1]);
printf("%s\n", (s = switch_xml_toxml(xml)));
free(s);
i = fprintf(stderr, "%s", switch_xml_error(xml));
switch_xml_free(xml);
return (i) ? 1 : 0;
}
#endif // SWITCH_XML_TEST

View File

@ -36,11 +36,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_bridgecall", "..\..\src
{202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_dialplan_flatfile", "..\..\src\mod\dialplans\mod_dialplan_flatfile\mod_dialplan_flatfile.vcproj", "{2988EB83-785F-45D4-8731-8E1E4345177E}"
ProjectSection(ProjectDependencies) = postProject
{202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_event_test", "..\..\src\mod\event_handlers\mod_event_test\mod_event_test.vcproj", "{3A2A7795-C216-4FFF-B8EF-4D17A84BACCC}"
ProjectSection(ProjectDependencies) = postProject
{202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
@ -111,7 +106,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "docs", "..\..\docs\docs.vcp
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FreeSwitchVersion", "FreeSwitchVersion.vcproj", "{FE191916-DEDD-43B3-B28C-D09C9088C586}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_pcre", "..\..\src\mod\dialplans\mod_pcre\mod_pcre.vcproj", "{07113B25-D3AF-4E04-BA77-4CD1171F022C}"
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_dialplan_xml", "..\..\src\mod\dialplans\mod_dialplan_xml\mod_dialplan_xml.vcproj", "{07113B25-D3AF-4E04-BA77-4CD1171F022C}"
ProjectSection(ProjectDependencies) = postProject
{202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
EndProjectSection
@ -231,10 +226,6 @@ Global
{E1794405-29D4-466D-9BE3-DD2344C2A663}.Debug|Win32.Build.0 = Debug|Win32
{E1794405-29D4-466D-9BE3-DD2344C2A663}.Release|Win32.ActiveCfg = Release|Win32
{E1794405-29D4-466D-9BE3-DD2344C2A663}.Release|Win32.Build.0 = Release|Win32
{2988EB83-785F-45D4-8731-8E1E4345177E}.Debug|Win32.ActiveCfg = Debug|Win32
{2988EB83-785F-45D4-8731-8E1E4345177E}.Debug|Win32.Build.0 = Debug|Win32
{2988EB83-785F-45D4-8731-8E1E4345177E}.Release|Win32.ActiveCfg = Release|Win32
{2988EB83-785F-45D4-8731-8E1E4345177E}.Release|Win32.Build.0 = Release|Win32
{3A2A7795-C216-4FFF-B8EF-4D17A84BACCC}.Debug|Win32.ActiveCfg = Debug|Win32
{3A2A7795-C216-4FFF-B8EF-4D17A84BACCC}.Debug|Win32.Build.0 = Debug|Win32
{3A2A7795-C216-4FFF-B8EF-4D17A84BACCC}.Release|Win32.ActiveCfg = Release|Win32
@ -362,7 +353,6 @@ Global
{419AA391-5F3F-4BFE-A869-9D154D62A792} = {E72B5BCB-6462-4D23-B419-3AF1A4AC3D78}
{0E2C6395-13B9-46E5-9264-8859D346018D} = {E72B5BCB-6462-4D23-B419-3AF1A4AC3D78}
{30A5B29C-983E-4580-9FD0-D647CCDCC7EB} = {E72B5BCB-6462-4D23-B419-3AF1A4AC3D78}
{2988EB83-785F-45D4-8731-8E1E4345177E} = {C5F182F9-754A-4EC5-B50F-76ED02BE13F4}
{07113B25-D3AF-4E04-BA77-4CD1171F022C} = {C5F182F9-754A-4EC5-B50F-76ED02BE13F4}
{A27CCA23-1541-4337-81A4-F0A6413078A0} = {C5F182F9-754A-4EC5-B50F-76ED02BE13F4}
{3A5B9131-F20C-4A85-9447-6C1610941CEE} = {9460B5F1-0A95-41C4-BEB7-9C2C96459A7C}