]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
XMLification (wave 1)
authorAnthony Minessale <anthony.minessale@gmail.com>
Wed, 10 May 2006 03:23:05 +0000 (03:23 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Wed, 10 May 2006 03:23:05 +0000 (03:23 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@1401 d0543943-73ff-0310-b7d9-9358b9ac24b2

36 files changed:
Makefile.am
Makefile.in
conf/freeswitch.conf [deleted file]
conf/freeswitch.xml [new file with mode: 0644]
modules.conf.in
src/include/switch_caller.h
src/include/switch_core.h
src/include/switch_types.h
src/include/switch_xml.h
src/mod/applications/mod_commands/mod_commands.c
src/mod/dialplans/mod_dialplan_directory/mod_dialplan_directory.c
src/mod/dialplans/mod_dialplan_flatfile/mod_dialplan_flatfile.c [deleted file]
src/mod/dialplans/mod_pcre/Makefile [deleted file]
src/mod/dialplans/mod_pcre/mod_pcre.c [deleted file]
src/mod/dialplans/mod_pcre/mod_pcre.vcproj [deleted file]
src/mod/endpoints/mod_dingaling/mod_dingaling.c
src/mod/endpoints/mod_exosip/mod_exosip.c
src/mod/endpoints/mod_iax/mod_iax.c
src/mod/endpoints/mod_opal/mod_opal.c
src/mod/endpoints/mod_portaudio/mod_portaudio.c
src/mod/endpoints/mod_wanpipe/mod_wanpipe.c
src/mod/endpoints/mod_woomera/mod_woomera.c
src/mod/event_handlers/mod_event_multicast/mod_event_multicast.c
src/mod/event_handlers/mod_xmpp_event/mod_xmpp_event.c
src/mod/event_handlers/mod_zeroconf/mod_zeroconf.c
src/mod/loggers/mod_console/mod_console.c
src/mod/xml_int/mod_xml_rpc/Makefile [new file with mode: 0644]
src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.vcproj [moved from src/mod/dialplans/mod_dialplan_flatfile/mod_dialplan_flatfile.vcproj with 85% similarity]
src/switch_caller.c
src/switch_channel.c
src/switch_core.c
src/switch_loadable_module.c
src/switch_log.c
src/switch_rtp.c
src/switch_xml.c
w32/vsnet/Freeswitch.sln

index 437aeac799b29a9897c8f80063b307dbcd503c73..d36a0677b596908c4d7fc3c0c79db94d5a885173 100644 (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
index b387c8e17a3bbee6a751ebfe4ef052640e653eca..f2cfcfb3d264f66df6a1f2efdf2f1df580a64c9a 100644 (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
diff --git a/conf/freeswitch.conf b/conf/freeswitch.conf
deleted file mode 100644 (file)
index d34551a..0000000
+++ /dev/null
@@ -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
diff --git a/conf/freeswitch.xml b/conf/freeswitch.xml
new file mode 100644 (file)
index 0000000..f00e071
--- /dev/null
@@ -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>
+        
+  
index 04c592b4dba2fa73d7f7ab60f546464478b68130..2975cbd936a81ea11f036bc37f1c2a7c71b1fcb3 100644 (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
index 11e4435dc021047d5567bd71dedadbd79d6cc762..fc0c1a50d3db3db7691a7e2b3f339e950d7e8737 100644 (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
index 2da608994c0fa1a14e7c6819fe561c6bf80b06c6..c404c7163d0af7457e141872cc04c8f4d6a4da8d 100644 (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
index 2bf554493f998d9a4c551deeff7d565f7d3c7ae8..51877d84a10b20477b9a18e0441fea34b5dbe52f 100644 (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 */
 
index a56ed5d768b69bb1feb3a01a3703a71a946d7c53..d9672012b8f2bc457247bc2b01fa8da01c62e861 100644 (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
 
index b4f9ff6fa2291e5527779d03bd248c5615aa529d..83e9525de554e1f54cf186042905f04d1c6f0657 100644 (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",
index 798dadcff9a09ffcc27add0d740882ed5ba54dda..abcafa2998243b155546e4bb8b647cb860666b0b 100644 (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)
diff --git a/src/mod/dialplans/mod_dialplan_flatfile/mod_dialplan_flatfile.c b/src/mod/dialplans/mod_dialplan_flatfile/mod_dialplan_flatfile.c
deleted file mode 100644 (file)
index 99b14d2..0000000
+++ /dev/null
@@ -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;
-}
diff --git a/src/mod/dialplans/mod_pcre/Makefile b/src/mod/dialplans/mod_pcre/Makefile
deleted file mode 100644 (file)
index 8a769aa..0000000
+++ /dev/null
@@ -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
diff --git a/src/mod/dialplans/mod_pcre/mod_pcre.c b/src/mod/dialplans/mod_pcre/mod_pcre.c
deleted file mode 100644 (file)
index a2b3494..0000000
+++ /dev/null
@@ -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;
-}
diff --git a/src/mod/dialplans/mod_pcre/mod_pcre.vcproj b/src/mod/dialplans/mod_pcre/mod_pcre.vcproj
deleted file mode 100644 (file)
index 999861e..0000000
+++ /dev/null
@@ -1,212 +0,0 @@
-<?xml version="1.0" encoding="Windows-1252"?>\r
-<VisualStudioProject\r
-       ProjectType="Visual C++"\r
-       Version="8.00"\r
-       Name="mod_pcre"\r
-       ProjectGUID="{07113B25-D3AF-4E04-BA77-4CD1171F022C}"\r
-       RootNamespace="mod_pcre"\r
-       Keyword="Win32Proj"\r
-       >\r
-       <Platforms>\r
-               <Platform\r
-                       Name="Win32"\r
-               />\r
-       </Platforms>\r
-       <ToolFiles>\r
-       </ToolFiles>\r
-       <Configurations>\r
-               <Configuration\r
-                       Name="Debug|Win32"\r
-                       OutputDirectory="Debug"\r
-                       IntermediateDirectory="Debug"\r
-                       ConfigurationType="2"\r
-                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"\r
-                       CharacterSet="2"\r
-                       >\r
-                       <Tool\r
-                               Name="VCPreBuildEventTool"\r
-                               CommandLine="cscript /nologo $(InputDir)..\..\..\..\w32\vsnet\getlibs.vbs Mod_pcre Debug"\r
-                       />\r
-                       <Tool\r
-                               Name="VCCustomBuildTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCXMLDataGeneratorTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCWebServiceProxyGeneratorTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCMIDLTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCCLCompilerTool"\r
-                               Optimization="0"\r
-                               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;"\r
-                               PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;MOD_EXPORTS;PCRE_STATIC"\r
-                               MinimalRebuild="true"\r
-                               BasicRuntimeChecks="3"\r
-                               RuntimeLibrary="1"\r
-                               UsePrecompiledHeader="0"\r
-                               WarningLevel="4"\r
-                               WarnAsError="true"\r
-                               Detect64BitPortabilityProblems="true"\r
-                               DebugInformationFormat="4"\r
-                       />\r
-                       <Tool\r
-                               Name="VCManagedResourceCompilerTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCResourceCompilerTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCPreLinkEventTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCLinkerTool"\r
-                               AdditionalDependencies="libpcre.lib"\r
-                               OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_pcre.dll"\r
-                               LinkIncremental="2"\r
-                               AdditionalLibraryDirectories="$(InputDir)..\..\..\..\libs\pcre\win32\$(OutDir);..\..\..\..\w32\vsnet\$(OutDir)"\r
-                               GenerateDebugInformation="true"\r
-                               ProgramDatabaseFile="$(OutDir)/mod_pcre.pdb"\r
-                               SubSystem="2"\r
-                               ImportLibrary="$(OutDir)/mod_pcre.lib"\r
-                               TargetMachine="1"\r
-                       />\r
-                       <Tool\r
-                               Name="VCALinkTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCManifestTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCXDCMakeTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCBscMakeTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCFxCopTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCAppVerifierTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCWebDeploymentTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCPostBuildEventTool"\r
-                       />\r
-               </Configuration>\r
-               <Configuration\r
-                       Name="Release|Win32"\r
-                       OutputDirectory="Release"\r
-                       IntermediateDirectory="Release"\r
-                       ConfigurationType="2"\r
-                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"\r
-                       CharacterSet="2"\r
-                       >\r
-                       <Tool\r
-                               Name="VCPreBuildEventTool"\r
-                               CommandLine="cscript /nologo $(InputDir)..\..\..\..\w32\vsnet\getlibs.vbs Mod_pcre Release"\r
-                       />\r
-                       <Tool\r
-                               Name="VCCustomBuildTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCXMLDataGeneratorTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCWebServiceProxyGeneratorTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCMIDLTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCCLCompilerTool"\r
-                               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;"\r
-                               PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;MOD_EXPORTS;PCRE_STATIC"\r
-                               RuntimeLibrary="0"\r
-                               UsePrecompiledHeader="0"\r
-                               WarningLevel="4"\r
-                               Detect64BitPortabilityProblems="true"\r
-                               DebugInformationFormat="3"\r
-                       />\r
-                       <Tool\r
-                               Name="VCManagedResourceCompilerTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCResourceCompilerTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCPreLinkEventTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCLinkerTool"\r
-                               AdditionalDependencies="libpcre.lib"\r
-                               OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_pcre.dll"\r
-                               LinkIncremental="1"\r
-                               AdditionalLibraryDirectories="$(InputDir)..\..\..\..\libs\pcre\win32\$(OutDir);..\..\..\..\w32\vsnet\$(OutDir)"\r
-                               GenerateDebugInformation="true"\r
-                               SubSystem="2"\r
-                               OptimizeReferences="2"\r
-                               EnableCOMDATFolding="2"\r
-                               ImportLibrary="$(OutDir)/mod_pcre.lib"\r
-                               TargetMachine="1"\r
-                       />\r
-                       <Tool\r
-                               Name="VCALinkTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCManifestTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCXDCMakeTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCBscMakeTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCFxCopTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCAppVerifierTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCWebDeploymentTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCPostBuildEventTool"\r
-                       />\r
-               </Configuration>\r
-       </Configurations>\r
-       <References>\r
-       </References>\r
-       <Files>\r
-               <Filter\r
-                       Name="Source Files"\r
-                       Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"\r
-                       UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"\r
-                       >\r
-                       <File\r
-                               RelativePath=".\mod_pcre.c"\r
-                               >\r
-                       </File>\r
-               </Filter>\r
-               <Filter\r
-                       Name="Header Files"\r
-                       Filter="h;hpp;hxx;hm;inl;inc;xsd"\r
-                       UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"\r
-                       >\r
-               </Filter>\r
-               <Filter\r
-                       Name="Resource Files"\r
-                       Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"\r
-                       UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"\r
-                       >\r
-               </Filter>\r
-       </Files>\r
-       <Globals>\r
-       </Globals>\r
-</VisualStudioProject>\r
index 8978d3c343ba33bc15cf68557f89d4b45e47e1c0..fcaa880f99bbcc696a642d23d20437ebeb5f623a 100644 (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;
 }
 
index 48820ff915eb458d93e7b270c766b50b41e9c271..29d4b19282ee573ff4c5d1df605537c41062b96e 100644 (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");
index c3c78233e571b4566a8bf35c9e2a8d27cc179cec..6182ea5a42a46b15b2b3676ad4b882b60ba9c644 100644 (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;
 }
index 32ca15818d8683eb6898f92f53c9664ade217d64..3a5b126892cb92b1a4d4a2f92c0515d940f31c66 100644 (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) {
index 478da7ecdfaf2c10a1e20282518ab226333240d5..aa5857c5329fa9a299d781285cf71ce70e5e8631 100644 (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;
 }
index 0f9b472e277b7e2b8476aa3aed03082be390df40..331548f2311caf7a0e6f3becf6f6b39a6caff48c 100644 (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");
index 974b3fd4b5884b855f4d8a67a4ac7bf96eaea114..0d20b3b4cd01dd946a9f5ffdb9e050f0762d43bc 100644 (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) {
index 9f8abdd22d798954fae3108c63e44389824fa9d6..dae1addd22c14fe7cf21c072833d3232a5eaf5fe 100644 (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;
 
index 84098ffb583b0816cd3c2a5d19e62541d6dd3bde..098affa4555afb3f66a29dd7959679697d539660 100644 (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 */
index 43120151f4026b7f3cfc2435720d720e6afa44c4..a0b1c88a3a84b9f0533b698599b21e901c0ce7ca 100644 (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;
 
index 7b14e4a5a122eb29157106d1436efb3d79d0f1de..0fe866d3a09f04a10139a4552358f4afe2461077 100644 (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;
 }
 
diff --git a/src/mod/xml_int/mod_xml_rpc/Makefile b/src/mod/xml_int/mod_xml_rpc/Makefile
new file mode 100644 (file)
index 0000000..3fffa85
--- /dev/null
@@ -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
similarity index 85%
rename from src/mod/dialplans/mod_dialplan_flatfile/mod_dialplan_flatfile.vcproj
rename to src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.vcproj
index f4d932b71c4188d034d0c21c4d31bb96242f8a19..e184008dd1e2e66b259f3451e8d10306aad89ed0 100644 (file)
@@ -2,9 +2,9 @@
 <VisualStudioProject\r
        ProjectType="Visual C++"\r
        Version="8.00"\r
-       Name="mod_dialplan_flatfile"\r
-       ProjectGUID="{2988EB83-785F-45D4-8731-8E1E4345177E}"\r
-       RootNamespace="mod_dialplan_flatfile"\r
+       Name="mod_xml_rpc"\r
+       ProjectGUID="{E1794405-29D4-466D-9BE3-DD2344C2A663}"\r
+       RootNamespace="mod_xml_rpc""\r
        Keyword="Win32Proj"\r
        >\r
        <Platforms>\r
                        />\r
                        <Tool\r
                                Name="VCLinkerTool"\r
-                               OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_dialplan_flatfile.dll"\r
+                               OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_xml_rpc".dll"\r
                                LinkIncremental="2"\r
                                AdditionalLibraryDirectories="..\..\..\..\w32\vsnet\$(OutDir)"\r
                                GenerateDebugInformation="true"\r
-                               ProgramDatabaseFile="$(OutDir)/mod_dialplan_flatfile.pdb"\r
+                               ProgramDatabaseFile="$(OutDir)/mod_xml_rpc".pdb"\r
                                SubSystem="2"\r
-                               ImportLibrary="$(OutDir)/mod_dialplan_flatfile.lib"\r
+                               ImportLibrary="$(OutDir)/mod_xml_rpc".lib"\r
                                TargetMachine="1"\r
                        />\r
                        <Tool\r
                                RuntimeLibrary="0"\r
                                UsePrecompiledHeader="0"\r
                                WarningLevel="4"\r
+                               WarnAsError="true"\r
                                Detect64BitPortabilityProblems="true"\r
                                DebugInformationFormat="3"\r
                        />\r
                        />\r
                        <Tool\r
                                Name="VCLinkerTool"\r
-                               OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_dialplan_flatfile.dll"\r
+                               OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_xml_rpc".dll"\r
                                LinkIncremental="1"\r
                                AdditionalLibraryDirectories="..\..\..\..\w32\vsnet\$(OutDir)"\r
                                GenerateDebugInformation="true"\r
                                SubSystem="2"\r
                                OptimizeReferences="2"\r
                                EnableCOMDATFolding="2"\r
-                               ImportLibrary="$(OutDir)/mod_dialplan_flatfile.lib"\r
+                               ImportLibrary="$(OutDir)/mod_xml_rpc".lib"\r
                                TargetMachine="1"\r
                        />\r
                        <Tool\r
                        UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"\r
                        >\r
                        <File\r
-                               RelativePath=".\mod_dialplan_flatfile.c"\r
+                               RelativePath=".\mod_xml_rpc".c"\r
                                >\r
                        </File>\r
                </Filter>\r
index 041cc874fceeed1f163fc4882e938275f5e11f20..141693a01a3e76cc7c9af5497dc0fe3581d23914 100644 (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)
 {
index e6fd9a76d81daa957975a45a3b981d1413e9a743..c0c4207d306c694739109d8fc46b5fe7c156dc1e 100644 (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();
        }
 
index ab0418649f0f950e05a99a42607277e324ef1cdb..96c0cc1ad6157498ff172335b6df2c191a3e75fb 100644 (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");
index 586e1e86c2caa741d319b651491c153034f3c799..2630babf4cdb6af2144eefd4bc7655b3a06ab4c7 100644 (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;
 }
 
index 811bfa83e6824c3e5c9728a310d1c55a32d7d3e8..9276b2cd89cafee50bd2dd974103fe047822c6f0 100644 (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;
index 123de33f43a10567771c08193d3645bf1949bfb1..60d08508050aceb76fde6c736d957d69a2ab02bb 100644 (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;
                        }
                }               
                
index 4cd8aff314af44ceb37169bac31d1f8a95ff434a..2125f2f3b5983d67ae6363b17e86caa0f34162aa 100644 (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
index 8528fc07d1becba0c7a3208ace8ccfedb010bb86..b105c6a460ad547693279b5b73036afe37d488ec 100644 (file)
@@ -36,11 +36,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_bridgecall", "..\..\src
                {202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}\r
        EndProjectSection\r
 EndProject\r
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_dialplan_flatfile", "..\..\src\mod\dialplans\mod_dialplan_flatfile\mod_dialplan_flatfile.vcproj", "{2988EB83-785F-45D4-8731-8E1E4345177E}"\r
-       ProjectSection(ProjectDependencies) = postProject\r
-               {202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}\r
-       EndProjectSection\r
-EndProject\r
 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}"\r
        ProjectSection(ProjectDependencies) = postProject\r
                {202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}\r
@@ -111,7 +106,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "docs", "..\..\docs\docs.vcp
 EndProject\r
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FreeSwitchVersion", "FreeSwitchVersion.vcproj", "{FE191916-DEDD-43B3-B28C-D09C9088C586}"\r
 EndProject\r
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_pcre", "..\..\src\mod\dialplans\mod_pcre\mod_pcre.vcproj", "{07113B25-D3AF-4E04-BA77-4CD1171F022C}"\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_dialplan_xml", "..\..\src\mod\dialplans\mod_dialplan_xml\mod_dialplan_xml.vcproj", "{07113B25-D3AF-4E04-BA77-4CD1171F022C}"\r
        ProjectSection(ProjectDependencies) = postProject\r
                {202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}\r
        EndProjectSection\r
@@ -231,10 +226,6 @@ Global
                {E1794405-29D4-466D-9BE3-DD2344C2A663}.Debug|Win32.Build.0 = Debug|Win32\r
                {E1794405-29D4-466D-9BE3-DD2344C2A663}.Release|Win32.ActiveCfg = Release|Win32\r
                {E1794405-29D4-466D-9BE3-DD2344C2A663}.Release|Win32.Build.0 = Release|Win32\r
-               {2988EB83-785F-45D4-8731-8E1E4345177E}.Debug|Win32.ActiveCfg = Debug|Win32\r
-               {2988EB83-785F-45D4-8731-8E1E4345177E}.Debug|Win32.Build.0 = Debug|Win32\r
-               {2988EB83-785F-45D4-8731-8E1E4345177E}.Release|Win32.ActiveCfg = Release|Win32\r
-               {2988EB83-785F-45D4-8731-8E1E4345177E}.Release|Win32.Build.0 = Release|Win32\r
                {3A2A7795-C216-4FFF-B8EF-4D17A84BACCC}.Debug|Win32.ActiveCfg = Debug|Win32\r
                {3A2A7795-C216-4FFF-B8EF-4D17A84BACCC}.Debug|Win32.Build.0 = Debug|Win32\r
                {3A2A7795-C216-4FFF-B8EF-4D17A84BACCC}.Release|Win32.ActiveCfg = Release|Win32\r
@@ -362,7 +353,6 @@ Global
                {419AA391-5F3F-4BFE-A869-9D154D62A792} = {E72B5BCB-6462-4D23-B419-3AF1A4AC3D78}\r
                {0E2C6395-13B9-46E5-9264-8859D346018D} = {E72B5BCB-6462-4D23-B419-3AF1A4AC3D78}\r
                {30A5B29C-983E-4580-9FD0-D647CCDCC7EB} = {E72B5BCB-6462-4D23-B419-3AF1A4AC3D78}\r
-               {2988EB83-785F-45D4-8731-8E1E4345177E} = {C5F182F9-754A-4EC5-B50F-76ED02BE13F4}\r
                {07113B25-D3AF-4E04-BA77-4CD1171F022C} = {C5F182F9-754A-4EC5-B50F-76ED02BE13F4}\r
                {A27CCA23-1541-4337-81A4-F0A6413078A0} = {C5F182F9-754A-4EC5-B50F-76ED02BE13F4}\r
                {3A5B9131-F20C-4A85-9447-6C1610941CEE} = {9460B5F1-0A95-41C4-BEB7-9C2C96459A7C}\r