///\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:
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,
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);
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];
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;
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);
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);
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);
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);
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);
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);
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);
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;
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")) {
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);
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);
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) {
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);
}
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")) {
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;
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;
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)
{