From 93666f6dd726e7944a74c85333dc5a2d043b73d4 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Wed, 10 May 2006 03:23:05 +0000 Subject: [PATCH] XMLification (wave 1) git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@1401 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- Makefile.am | 5 +- Makefile.in | 7 +- conf/freeswitch.conf | 275 --------------- conf/freeswitch.xml | 312 ++++++++++++++++++ modules.conf.in | 6 +- src/include/switch_caller.h | 8 + src/include/switch_core.h | 23 ++ src/include/switch_types.h | 10 +- src/include/switch_xml.h | 94 ++++-- .../applications/mod_commands/mod_commands.c | 29 +- .../mod_dialplan_directory.c | 15 +- .../mod_dialplan_flatfile.c | 135 -------- src/mod/dialplans/mod_pcre/Makefile | 17 - src/mod/dialplans/mod_pcre/mod_pcre.c | 224 ------------- src/mod/dialplans/mod_pcre/mod_pcre.vcproj | 212 ------------ .../endpoints/mod_dingaling/mod_dingaling.c | 44 ++- src/mod/endpoints/mod_exosip/mod_exosip.c | 19 +- src/mod/endpoints/mod_iax/mod_iax.c | 15 +- src/mod/endpoints/mod_opal/mod_opal.c | 12 +- .../endpoints/mod_portaudio/mod_portaudio.c | 13 +- src/mod/endpoints/mod_wanpipe/mod_wanpipe.c | 25 +- src/mod/endpoints/mod_woomera/mod_woomera.c | 22 +- .../mod_event_multicast/mod_event_multicast.c | 14 +- .../mod_xmpp_event/mod_xmpp_event.c | 14 +- .../mod_zeroconf/mod_zeroconf.c | 14 +- src/mod/loggers/mod_console/mod_console.c | 18 +- src/mod/xml_int/mod_xml_rpc/Makefile | 19 ++ .../mod_xml_rpc/mod_xml_rpc.vcproj} | 19 +- src/switch_caller.c | 41 +++ src/switch_channel.c | 6 +- src/switch_core.c | 42 ++- src/switch_loadable_module.c | 67 ++-- src/switch_log.c | 8 +- src/switch_rtp.c | 23 +- src/switch_xml.c | 299 +++++++++++++++-- w32/vsnet/Freeswitch.sln | 12 +- 36 files changed, 1025 insertions(+), 1093 deletions(-) delete mode 100644 conf/freeswitch.conf create mode 100644 conf/freeswitch.xml delete mode 100644 src/mod/dialplans/mod_dialplan_flatfile/mod_dialplan_flatfile.c delete mode 100644 src/mod/dialplans/mod_pcre/Makefile delete mode 100644 src/mod/dialplans/mod_pcre/mod_pcre.c delete mode 100644 src/mod/dialplans/mod_pcre/mod_pcre.vcproj create mode 100644 src/mod/xml_int/mod_xml_rpc/Makefile rename src/mod/{dialplans/mod_dialplan_flatfile/mod_dialplan_flatfile.vcproj => xml_int/mod_xml_rpc/mod_xml_rpc.vcproj} (85%) diff --git a/Makefile.am b/Makefile.am index 437aeac799..d36a0677b5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 diff --git a/Makefile.in b/Makefile.in index b387c8e17a..f2cfcfb3d2 100644 --- a/Makefile.in +++ b/Makefile.in @@ -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 index d34551a0f3..0000000000 --- a/conf/freeswitch.conf +++ /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 index 0000000000..f00e0711f4 --- /dev/null +++ b/conf/freeswitch.xml @@ -0,0 +1,312 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + diff --git a/modules.conf.in b/modules.conf.in index 04c592b4db..2975cbd936 100644 --- a/modules.conf.in +++ b/modules.conf.in @@ -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 diff --git a/src/include/switch_caller.h b/src/include/switch_caller.h index 11e4435dc0..fc0c1a50d3 100644 --- a/src/include/switch_caller.h +++ b/src/include/switch_caller.h @@ -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 diff --git a/src/include/switch_core.h b/src/include/switch_core.h index 2da608994c..c404c7163d 100644 --- a/src/include/switch_core.h +++ b/src/include/switch_core.h @@ -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 diff --git a/src/include/switch_types.h b/src/include/switch_types.h index 2bf554493f..51877d84a1 100644 --- a/src/include/switch_types.h +++ b/src/include/switch_types.h @@ -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 */ diff --git a/src/include/switch_xml.h b/src/include/switch_xml.h index a56ed5d768..d9672012b8 100644 --- a/src/include/switch_xml.h +++ b/src/include/switch_xml.h @@ -1,4 +1,35 @@ -/* switch_xml.h +/* + * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * Copyright (C) 2005/2006, Anthony Minessale II + * + * 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 + * Portions created by the Initial Developer are Copyright (C) + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Anthony Minessale II + * + * + * switch_xml.h -- XML PARSER + * + * Derived from EZXML http://ezxml.sourceforge.net + * Original Copyright * * Copyright 2004, 2005 Aaron Voisine * @@ -24,7 +55,7 @@ #ifndef _SWITCH_XML_H #define _SWITCH_XML_H - +#include #include #include #include @@ -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 diff --git a/src/mod/applications/mod_commands/mod_commands.c b/src/mod/applications/mod_commands/mod_commands.c index b4f9ff6fa2..83e9525de5 100644 --- a/src/mod/applications/mod_commands/mod_commands.c +++ b/src/mod/applications/mod_commands/mod_commands.c @@ -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, "UP %u year(s), %u day(s), %u hour(s), %u minute(s), %u second(s), %u millisecond(s), %u microsecond(s)\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", diff --git a/src/mod/dialplans/mod_dialplan_directory/mod_dialplan_directory.c b/src/mod/dialplans/mod_dialplan_directory/mod_dialplan_directory.c index 798dadcff9..abcafa2998 100644 --- a/src/mod/dialplans/mod_dialplan_directory/mod_dialplan_directory.c +++ b/src/mod/dialplans/mod_dialplan_directory/mod_dialplan_directory.c @@ -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 index 99b14d29ce..0000000000 --- a/src/mod/dialplans/mod_dialplan_flatfile/mod_dialplan_flatfile.c +++ /dev/null @@ -1,135 +0,0 @@ -/* - * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005/2006, Anthony Minessale II - * - * 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 - * Portions created by the Initial Developer are Copyright (C) - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Anthony Minessale II - * - * - * mod_dialplan_flatfile.c -- Example Dialplan Module - * - */ -#include -#include -#include -#include - - -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 index 8a769aa0ad..0000000000 --- a/src/mod/dialplans/mod_pcre/Makefile +++ /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 index a2b349469a..0000000000 --- a/src/mod/dialplans/mod_pcre/mod_pcre.c +++ /dev/null @@ -1,224 +0,0 @@ -/* - * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005/2006, Anthony Minessale II - * - * 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 - * Portions created by the Initial Developer are Copyright (C) - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Anthony Minessale II - * - * - * mod_pcre.c -- Regex Dialplan Module - * - */ -#include -#include -#include -#include -#include - -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 index 999861e058..0000000000 --- a/src/mod/dialplans/mod_pcre/mod_pcre.vcproj +++ /dev/null @@ -1,212 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/mod/endpoints/mod_dingaling/mod_dingaling.c b/src/mod/endpoints/mod_dingaling/mod_dingaling.c index 8978d3c343..fcaa880f99 100644 --- a/src/mod/endpoints/mod_dingaling/mod_dingaling.c +++ b/src/mod/endpoints/mod_dingaling/mod_dingaling.c @@ -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; } diff --git a/src/mod/endpoints/mod_exosip/mod_exosip.c b/src/mod/endpoints/mod_exosip/mod_exosip.c index 48820ff915..29d4b19282 100644 --- a/src/mod/endpoints/mod_exosip/mod_exosip.c +++ b/src/mod/endpoints/mod_exosip/mod_exosip.c @@ -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"); diff --git a/src/mod/endpoints/mod_iax/mod_iax.c b/src/mod/endpoints/mod_iax/mod_iax.c index c3c78233e5..6182ea5a42 100644 --- a/src/mod/endpoints/mod_iax/mod_iax.c +++ b/src/mod/endpoints/mod_iax/mod_iax.c @@ -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; } diff --git a/src/mod/endpoints/mod_opal/mod_opal.c b/src/mod/endpoints/mod_opal/mod_opal.c index 32ca15818d..3a5b126892 100644 --- a/src/mod/endpoints/mod_opal/mod_opal.c +++ b/src/mod/endpoints/mod_opal/mod_opal.c @@ -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) { diff --git a/src/mod/endpoints/mod_portaudio/mod_portaudio.c b/src/mod/endpoints/mod_portaudio/mod_portaudio.c index 478da7ecdf..aa5857c532 100644 --- a/src/mod/endpoints/mod_portaudio/mod_portaudio.c +++ b/src/mod/endpoints/mod_portaudio/mod_portaudio.c @@ -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; } diff --git a/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c b/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c index 0f9b472e27..331548f231 100644 --- a/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c +++ b/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c @@ -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"); diff --git a/src/mod/endpoints/mod_woomera/mod_woomera.c b/src/mod/endpoints/mod_woomera/mod_woomera.c index 974b3fd4b5..0d20b3b4cd 100644 --- a/src/mod/endpoints/mod_woomera/mod_woomera.c +++ b/src/mod/endpoints/mod_woomera/mod_woomera.c @@ -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) { diff --git a/src/mod/event_handlers/mod_event_multicast/mod_event_multicast.c b/src/mod/event_handlers/mod_event_multicast/mod_event_multicast.c index 9f8abdd22d..dae1addd22 100644 --- a/src/mod/event_handlers/mod_event_multicast/mod_event_multicast.c +++ b/src/mod/event_handlers/mod_event_multicast/mod_event_multicast.c @@ -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; diff --git a/src/mod/event_handlers/mod_xmpp_event/mod_xmpp_event.c b/src/mod/event_handlers/mod_xmpp_event/mod_xmpp_event.c index 84098ffb58..098affa455 100644 --- a/src/mod/event_handlers/mod_xmpp_event/mod_xmpp_event.c +++ b/src/mod/event_handlers/mod_xmpp_event/mod_xmpp_event.c @@ -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 */ diff --git a/src/mod/event_handlers/mod_zeroconf/mod_zeroconf.c b/src/mod/event_handlers/mod_zeroconf/mod_zeroconf.c index 43120151f4..a0b1c88a3a 100644 --- a/src/mod/event_handlers/mod_zeroconf/mod_zeroconf.c +++ b/src/mod/event_handlers/mod_zeroconf/mod_zeroconf.c @@ -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; diff --git a/src/mod/loggers/mod_console/mod_console.c b/src/mod/loggers/mod_console/mod_console.c index 7b14e4a5a1..0fe866d3a0 100644 --- a/src/mod/loggers/mod_console/mod_console.c +++ b/src/mod/loggers/mod_console/mod_console.c @@ -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 index 0000000000..3fffa85095 --- /dev/null +++ b/src/mod/xml_int/mod_xml_rpc/Makefile @@ -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 diff --git a/src/mod/dialplans/mod_dialplan_flatfile/mod_dialplan_flatfile.vcproj b/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.vcproj 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 f4d932b71c..e184008dd1 100644 --- a/src/mod/dialplans/mod_dialplan_flatfile/mod_dialplan_flatfile.vcproj +++ b/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.vcproj @@ -2,9 +2,9 @@ @@ -63,13 +63,13 @@ /> @@ -141,14 +142,14 @@ /> diff --git a/src/switch_caller.c b/src/switch_caller.c index 041cc874fc..141693a01a 100644 --- a/src/switch_caller.c +++ b/src/switch_caller.c @@ -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) { diff --git a/src/switch_channel.c b/src/switch_channel.c index e6fd9a76d8..c0c4207d30 100644 --- a/src/switch_channel.c +++ b/src/switch_channel.c @@ -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(); } diff --git a/src/switch_core.c b/src/switch_core.c index ab0418649f..96c0cc1ad6 100644 --- a/src/switch_core.c +++ b/src/switch_core.c @@ -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"); diff --git a/src/switch_loadable_module.c b/src/switch_loadable_module.c index 586e1e86c2..2630babf4c 100644 --- a/src/switch_loadable_module.c +++ b/src/switch_loadable_module.c @@ -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; } diff --git a/src/switch_log.c b/src/switch_log.c index 811bfa83e6..9276b2cd89 100644 --- a/src/switch_log.c +++ b/src/switch_log.c @@ -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; diff --git a/src/switch_rtp.c b/src/switch_rtp.c index 123de33f43..60d0850805 100644 --- a/src/switch_rtp.c +++ b/src/switch_rtp.c @@ -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; } } diff --git a/src/switch_xml.c b/src/switch_xml.c index 4cd8aff314..2125f2f3b5 100644 --- a/src/switch_xml.c +++ b/src/switch_xml.c @@ -1,4 +1,35 @@ -/* switch_xml.c +/* + * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * Copyright (C) 2005/2006, Anthony Minessale II + * + * 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 + * Portions created by the Initial Developer are Copyright (C) + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Anthony Minessale II + * + * + * switch_xml.c -- XML PARSER + * + * Derived from EZXML http://ezxml.sourceforge.net + * Original Copyright * * Copyright 2004, 2005 Aaron Voisine * @@ -29,7 +60,6 @@ #include #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;", "<", "gt;", ">", "quot;", """, "apos;", "'", "amp;", "&", 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 diff --git a/w32/vsnet/Freeswitch.sln b/w32/vsnet/Freeswitch.sln index 8528fc07d1..b105c6a460 100644 --- a/w32/vsnet/Freeswitch.sln +++ b/w32/vsnet/Freeswitch.sln @@ -36,11 +36,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_bridgecall", "..\..\src {202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF} EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_dialplan_flatfile", "..\..\src\mod\dialplans\mod_dialplan_flatfile\mod_dialplan_flatfile.vcproj", "{2988EB83-785F-45D4-8731-8E1E4345177E}" - ProjectSection(ProjectDependencies) = postProject - {202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF} - EndProjectSection -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_event_test", "..\..\src\mod\event_handlers\mod_event_test\mod_event_test.vcproj", "{3A2A7795-C216-4FFF-B8EF-4D17A84BACCC}" ProjectSection(ProjectDependencies) = postProject {202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF} @@ -111,7 +106,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "docs", "..\..\docs\docs.vcp EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FreeSwitchVersion", "FreeSwitchVersion.vcproj", "{FE191916-DEDD-43B3-B28C-D09C9088C586}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_pcre", "..\..\src\mod\dialplans\mod_pcre\mod_pcre.vcproj", "{07113B25-D3AF-4E04-BA77-4CD1171F022C}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_dialplan_xml", "..\..\src\mod\dialplans\mod_dialplan_xml\mod_dialplan_xml.vcproj", "{07113B25-D3AF-4E04-BA77-4CD1171F022C}" ProjectSection(ProjectDependencies) = postProject {202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF} EndProjectSection @@ -231,10 +226,6 @@ Global {E1794405-29D4-466D-9BE3-DD2344C2A663}.Debug|Win32.Build.0 = Debug|Win32 {E1794405-29D4-466D-9BE3-DD2344C2A663}.Release|Win32.ActiveCfg = Release|Win32 {E1794405-29D4-466D-9BE3-DD2344C2A663}.Release|Win32.Build.0 = Release|Win32 - {2988EB83-785F-45D4-8731-8E1E4345177E}.Debug|Win32.ActiveCfg = Debug|Win32 - {2988EB83-785F-45D4-8731-8E1E4345177E}.Debug|Win32.Build.0 = Debug|Win32 - {2988EB83-785F-45D4-8731-8E1E4345177E}.Release|Win32.ActiveCfg = Release|Win32 - {2988EB83-785F-45D4-8731-8E1E4345177E}.Release|Win32.Build.0 = Release|Win32 {3A2A7795-C216-4FFF-B8EF-4D17A84BACCC}.Debug|Win32.ActiveCfg = Debug|Win32 {3A2A7795-C216-4FFF-B8EF-4D17A84BACCC}.Debug|Win32.Build.0 = Debug|Win32 {3A2A7795-C216-4FFF-B8EF-4D17A84BACCC}.Release|Win32.ActiveCfg = Release|Win32 @@ -362,7 +353,6 @@ Global {419AA391-5F3F-4BFE-A869-9D154D62A792} = {E72B5BCB-6462-4D23-B419-3AF1A4AC3D78} {0E2C6395-13B9-46E5-9264-8859D346018D} = {E72B5BCB-6462-4D23-B419-3AF1A4AC3D78} {30A5B29C-983E-4580-9FD0-D647CCDCC7EB} = {E72B5BCB-6462-4D23-B419-3AF1A4AC3D78} - {2988EB83-785F-45D4-8731-8E1E4345177E} = {C5F182F9-754A-4EC5-B50F-76ED02BE13F4} {07113B25-D3AF-4E04-BA77-4CD1171F022C} = {C5F182F9-754A-4EC5-B50F-76ED02BE13F4} {A27CCA23-1541-4337-81A4-F0A6413078A0} = {C5F182F9-754A-4EC5-B50F-76ED02BE13F4} {3A5B9131-F20C-4A85-9447-6C1610941CEE} = {9460B5F1-0A95-41C4-BEB7-9C2C96459A7C}