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 = \
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
-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)
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
+++ /dev/null
-; 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
--- /dev/null
+<?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>
+
+
#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
languages/mod_perl
#languages/mod_spidermonkey
timers/mod_softtimer
-
-
+#xml_int/mod_xml_rpc
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
#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)*/
*/
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
char *db_dir;
char *script_dir;
char *temp_dir;
+ char *htdocs_dir;
};
typedef struct switch_directories switch_directories;
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
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 */
-/* 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>
*
#ifndef _SWITCH_XML_H
#define _SWITCH_XML_H
-
+#include <switch_types.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#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 }
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
#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
// 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)
// 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
char temp[1024];
size_t len;
- printf("%s\n", argv[1]);
-
sprintf(temp, "%s\n", argv[1]);
len = strlen(temp);
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];
}
+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",
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) {
}
}
}
- switch_config_close_file(&cfg);
+ switch_xml_free(xml);
}
static switch_caller_extension_t *directory_dialplan_hunt(switch_core_session_t *session)
+++ /dev/null
-/*
- * 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;
-}
+++ /dev/null
-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
+++ /dev/null
-/*
- * 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;
-}
+++ /dev/null
-<?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=""$(InputDir)..\..\..\include";"$(InputDir)include";"$(InputDir)..\..\..\..\libs\include";"$(InputDir)..\..\..\..\libs\pcre";"$(InputDir)..\..\..\..\libs\pcre\win32""\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=""$(InputDir)..\..\..\include";"$(InputDir)include";"$(InputDir)..\..\..\..\libs\include";"$(InputDir)..\..\..\..\libs\pcre";"$(InputDir)..\..\..\..\libs\pcre\win32""\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
break;
}
}
- ldl_global_destroy();
+ if (globals.init) {
+ ldl_global_destroy();
+ }
}
return SWITCH_STATUS_SUCCESS;
}
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")) {
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) {
}
- switch_config_close_file(&cfg);
+ switch_xml_free(xml);
+
return SWITCH_STATUS_SUCCESS;
}
}
+
switch_clear_flag(tech_pvt, TFLAG_READING);
if (switch_test_flag(tech_pvt, TFLAG_BYE)) {
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")) {
}
}
}
+
if (!globals.rtpip) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Setting ip to 'guess'\n");
globals.port = 5060;
}
-
-
- switch_config_close_file(&cfg);
+ switch_xml_free(xml);
if (!globals.dialplan) {
set_global_dialplan("default");
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")) {
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;
}
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")) {
}
}
- switch_config_close_file(&cfg);
+ switch_xml_free(xml);
if (switch_core_new_memory_pool(&module_pool) != SWITCH_STATUS_SUCCESS) {
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")) {
globals.sample_rate = 8000;
}
- switch_config_close_file(&cfg);
+ switch_xml_free(xml);
return SWITCH_STATUS_SUCCESS;
}
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")) {
} 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) {
}
}
}
- switch_config_close_file(&cfg);
+ switch_xml_free(xml);
if (!globals.dialplan) {
set_global_dialplan("default");
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;
}
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")) {
}
}
- switch_config_close_file(&cfg);
+ switch_xml_free(xml);
if (switch_core_new_memory_pool(&module_pool) != SWITCH_STATUS_SUCCESS) {
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;
}
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")) {
}
}
- switch_config_close_file(&cfg);
+ switch_xml_free(xml);
return status;
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++;
}
}
- switch_config_close_file(&cfg);
+ switch_xml_free(xml);
if (count == 3) {
/* TBD use config to pick what events to bind to */
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);
}
}
- switch_config_close_file(&cfg);
+ switch_xml_free(xml);
return status;
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;
}
--- /dev/null
+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
<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
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)
{
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;
{
assert(channel != NULL);
- if (!channel->times->hungup) {
+ if (channel->times && !channel->times->hungup) {
channel->times->hungup = switch_time_now();
}
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;
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) {
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
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];
#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)
{
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");
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;
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;
apr_dir_close(module_dir_handle);
}
+
return SWITCH_STATUS_SUCCESS;
}
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;
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)))) {
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;
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;
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;
}
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;
}
}
-/* 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>
*
#include <sys/mman.h>
#endif
-
#define SWITCH_XML_WS "\t\r\n " // whitespace
#define SWITCH_XML_ERRL 128 // maximum error string length
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;
}
// 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;
// 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;
// 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;
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);
}
// 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
// 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;
// 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;
}
// 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);
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)
// 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;
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);
}
// 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;", "<", "gt;", ">", "quot;", """,
"apos;", "'", "amp;", "&", NULL };
// 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;
}
// 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;
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
{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
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
{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
{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