update
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@1476 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
31ee0d59fc
commit
21c2b5812e
|
@ -172,6 +172,12 @@ switch_xml_t switch_xml_idx(switch_xml_t xml, int idx);
|
|||
///\return the value
|
||||
SWITCH_DECLARE(const char *) switch_xml_attr(switch_xml_t xml, const char *attr);
|
||||
|
||||
///\brief returns the value of the requested tag attribute, or "" if not found
|
||||
///\param xml the xml node
|
||||
///\param attr the attribute
|
||||
///\return the value
|
||||
SWITCH_DECLARE(const char *) switch_xml_attr_soft(switch_xml_t xml, const char *attr);
|
||||
|
||||
///\brief 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
|
||||
///\ terminated by either an index of -1 or an empty string tag name. Example:
|
||||
|
|
|
@ -63,7 +63,7 @@ static void xml_function(switch_core_session_t *session, char *data)
|
|||
const char *teamname;
|
||||
|
||||
for (team = switch_xml_child(f1, "team"); team; team = team->next) {
|
||||
teamname = switch_xml_attr(team, "name");
|
||||
teamname = switch_xml_attr_soft(team, "name");
|
||||
for (driver = switch_xml_child(team, "driver"); driver; driver = driver->next) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
|
||||
"%s, %s: %s\n", switch_xml_child(driver, "name")->txt, teamname,
|
||||
|
|
|
@ -64,8 +64,8 @@ static void load_config(void)
|
|||
|
||||
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");
|
||||
char *var = (char *) switch_xml_attr_soft(param, "name");
|
||||
char *val = (char *) switch_xml_attr_soft(param, "value");
|
||||
|
||||
if (!strcmp(var, "directory-name") && val) {
|
||||
set_global_directory_name(val);
|
||||
|
|
|
@ -161,11 +161,11 @@ static switch_caller_extension_t *dialplan_hunt(switch_core_session_t *session)
|
|||
|
||||
for (xexten = switch_xml_child(xcontext, "extension"); xexten; xexten = xexten->next) {
|
||||
int proceed = 0;
|
||||
char *cont = (char *) switch_xml_attr(xexten, "continue");
|
||||
char *cont = (char *) switch_xml_attr_soft(xexten, "continue");
|
||||
|
||||
for (xcond = switch_xml_child(xexten, "condition"); xcond; xcond = xcond->next) {
|
||||
char *field = (char *) switch_xml_attr(xcond, "field");
|
||||
char *expression = (char *) switch_xml_attr(xcond, "expression");
|
||||
char *field = (char *) switch_xml_attr_soft(xcond, "field");
|
||||
char *expression = (char *) switch_xml_attr_soft(xcond, "expression");
|
||||
char *field_data = switch_caller_get_field_by_name(caller_profile, field);
|
||||
pcre *re = NULL;
|
||||
int ovector[30];
|
||||
|
@ -179,8 +179,8 @@ static switch_caller_extension_t *dialplan_hunt(switch_core_session_t *session)
|
|||
assert(re != NULL);
|
||||
|
||||
for (xaction = switch_xml_child(xcond, "action"); xaction; xaction = xaction->next) {
|
||||
char *application = (char*) switch_xml_attr(xaction, "application");
|
||||
char *data = (char *) switch_xml_attr(xaction, "data");
|
||||
char *application = (char*) switch_xml_attr_soft(xaction, "application");
|
||||
char *data = (char *) switch_xml_attr_soft(xaction, "data");
|
||||
char substituted[1024] = "";
|
||||
char *app_data = NULL;
|
||||
|
||||
|
|
|
@ -1305,8 +1305,8 @@ static switch_status_t load_config(void)
|
|||
|
||||
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");
|
||||
char *var = (char *) switch_xml_attr_soft(param, "name");
|
||||
char *val = (char *) switch_xml_attr_soft(param, "value");
|
||||
|
||||
if (!strcasecmp(var, "debug")) {
|
||||
globals.debug = atoi(val);
|
||||
|
@ -1324,8 +1324,8 @@ static switch_status_t load_config(void)
|
|||
|
||||
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");
|
||||
char *var = (char *) switch_xml_attr_soft(param, "name");
|
||||
char *val = (char *) switch_xml_attr_soft(param, "value");
|
||||
|
||||
if (!globals.init) {
|
||||
ldl_global_init(globals.debug);
|
||||
|
|
|
@ -1880,8 +1880,8 @@ static int config_exosip(int reload)
|
|||
|
||||
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");
|
||||
char *var = (char *) switch_xml_attr_soft(param, "name");
|
||||
char *val = (char *) switch_xml_attr_soft(param, "value");
|
||||
|
||||
if (!strcmp(var, "debug")) {
|
||||
globals.debug = atoi(val);
|
||||
|
|
|
@ -829,8 +829,8 @@ static switch_status_t load_config(void)
|
|||
|
||||
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");
|
||||
char *var = (char *) switch_xml_attr_soft(param, "name");
|
||||
char *val = (char *) switch_xml_attr_soft(param, "value");
|
||||
|
||||
if (!strcmp(var, "debug")) {
|
||||
globals.debug = atoi(val);
|
||||
|
|
|
@ -578,8 +578,8 @@ static switch_status_t load_config(void)
|
|||
|
||||
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");
|
||||
char *var = (char *) switch_xml_attr_soft(param, "name");
|
||||
char *val = (char *) switch_xml_attr_soft(param, "value");
|
||||
|
||||
if (!strcmp(var, "debug")) {
|
||||
globals.debug = atoi(val);
|
||||
|
|
|
@ -1302,8 +1302,8 @@ static switch_status_t config_wanpipe(int reload)
|
|||
|
||||
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");
|
||||
char *var = (char *) switch_xml_attr_soft(param, "name");
|
||||
char *val = (char *) switch_xml_attr_soft(param, "value");
|
||||
|
||||
if (!strcmp(var, "debug")) {
|
||||
globals.debug = atoi(val);
|
||||
|
@ -1322,8 +1322,8 @@ static switch_status_t config_wanpipe(int reload)
|
|||
|
||||
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");
|
||||
char *var = (char *) switch_xml_attr_soft(param, "name");
|
||||
char *val = (char *) switch_xml_attr_soft(param, "value");
|
||||
|
||||
if (!strcmp(var, "span")) {
|
||||
current_span = atoi(val);
|
||||
|
|
|
@ -1317,8 +1317,8 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod
|
|||
|
||||
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");
|
||||
char *var = (char *) switch_xml_attr_soft(param, "name");
|
||||
char *val = (char *) switch_xml_attr_soft(param, "value");
|
||||
|
||||
if (!strcmp(var, "noload") && atoi(val)) {
|
||||
return SWITCH_STATUS_TERM;
|
||||
|
@ -1331,8 +1331,8 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod
|
|||
|
||||
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");
|
||||
char *var = (char *) switch_xml_attr_soft(param, "name");
|
||||
char *val = (char *) switch_xml_attr_soft(param, "value");
|
||||
if (!strcmp(var, "audio_ip")) {
|
||||
strncpy(profile->audio_ip, val, sizeof(profile->audio_ip) - 1);
|
||||
} else if (!strcmp(var, "host")) {
|
||||
|
|
|
@ -66,8 +66,8 @@ static switch_status_t load_config(void)
|
|||
|
||||
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");
|
||||
char *var = (char *) switch_xml_attr_soft(param, "name");
|
||||
char *val = (char *) switch_xml_attr_soft(param, "value");
|
||||
|
||||
if (!strcasecmp(var, "address")) {
|
||||
set_global_address(val);
|
||||
|
|
|
@ -111,8 +111,8 @@ SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_jid, globals.jid)
|
|||
|
||||
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");
|
||||
char *var = (char *) switch_xml_attr_soft(param, "name");
|
||||
char *val = (char *) switch_xml_attr_soft(param, "value");
|
||||
|
||||
if (!strcmp(var, "jid")) {
|
||||
set_global_jid(val);
|
||||
|
|
|
@ -206,8 +206,8 @@ static switch_status_t load_config(void)
|
|||
|
||||
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");
|
||||
char *var = (char *) switch_xml_attr_soft(param, "name");
|
||||
char *val = (char *) switch_xml_attr_soft(param, "value");
|
||||
|
||||
if (!strcmp(var, "browse")) {
|
||||
if ((oid = switch_core_alloc(module_pool, sizeof(*oid))) != 0) {
|
||||
|
|
|
@ -93,8 +93,8 @@ static switch_status_t config_logger(void)
|
|||
|
||||
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");
|
||||
char *var = (char *) switch_xml_attr_soft(param, "name");
|
||||
char *val = (char *) switch_xml_attr_soft(param, "value");
|
||||
|
||||
add_mapping(var, val);
|
||||
}
|
||||
|
|
|
@ -146,11 +146,11 @@ static switch_status_t do_config(void)
|
|||
|
||||
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");
|
||||
char *var = (char *) switch_xml_attr_soft(param, "name");
|
||||
char *val = (char *) switch_xml_attr_soft(param, "value");
|
||||
|
||||
if (!strcasecmp(var, "gateway-url")) {
|
||||
char *bindings = (char *) switch_xml_attr(param, "bindings");
|
||||
char *bindings = (char *) switch_xml_attr_soft(param, "bindings");
|
||||
set_global_bindings(bindings);
|
||||
set_global_url(val);
|
||||
} else if (!strcasecmp(var, "http-port")) {
|
||||
|
|
|
@ -476,7 +476,7 @@ SWITCH_DECLARE(switch_status_t) switch_loadable_module_init()
|
|||
|
||||
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");
|
||||
const char *val = switch_xml_attr_soft(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;
|
||||
|
@ -496,7 +496,7 @@ SWITCH_DECLARE(switch_status_t) switch_loadable_module_init()
|
|||
|
||||
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");
|
||||
const char *val = switch_xml_attr_soft(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;
|
||||
|
|
|
@ -192,6 +192,14 @@ switch_xml_t switch_xml_idx(switch_xml_t xml, int idx)
|
|||
return xml;
|
||||
}
|
||||
|
||||
// returns the value of the requested tag attribute or "" if not found
|
||||
SWITCH_DECLARE(const char *) switch_xml_attr_soft(switch_xml_t xml, const char *attr)
|
||||
{
|
||||
const char *ret = switch_xml_attr(xml, attr);
|
||||
|
||||
return ret ? ret : "";
|
||||
}
|
||||
|
||||
// returns the value of the requested tag attribute or NULL if not found
|
||||
SWITCH_DECLARE(const char *) switch_xml_attr(switch_xml_t xml, const char *attr)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue