diff --git a/src/include/switch_xml_config.h b/src/include/switch_xml_config.h index 92cb7b4e34..35bb0d7e75 100644 --- a/src/include/switch_xml_config.h +++ b/src/include/switch_xml_config.h @@ -100,8 +100,8 @@ struct switch_xml_config_item { #define SWITCH_CONFIG_ITEM(_key, _type, _flags, _ptr, _defaultvalue, _data, _syntax, _helptext) { _key, _type, _flags, _ptr, _defaultvalue, _data, NULL, _syntax, _helptext } #define SWITCH_CONFIG_ITEM_STRING_STRDUP(_key, _flags, _ptr, _defaultvalue, _syntax, _helptext) { _key, SWITCH_CONFIG_STRING, _flags, _ptr, _defaultvalue, &switch_config_string_strdup, NULL, _helptext} -#define SWITCH_CONFIG_ITEM_CALLBACK(_key, _type, _flags, _ptr, _defaultvalue, _data, _functiondata, _syntax, _helptext) { _key, _type, _flags, _ptr, _defaultvalue, _functiondata, _data, _helptext} -#define SWITCH_CONFIG_ITEM_END() { NULL, SWITCH_CONFIG_LAST, 0, NULL ,NULL, NULL, NULL, NULL, NULL } +#define SWITCH_CONFIG_ITEM_CALLBACK(_key, _type, _flags, _ptr, _defaultvalue, _data, _functiondata, _syntax, _helptext) { _key, _type, _flags, _ptr, _defaultvalue, _functiondata, _data, _syntax, _helptext } +#define SWITCH_CONFIG_ITEM_END() { NULL, SWITCH_CONFIG_LAST, 0, NULL, NULL, NULL, NULL, NULL, NULL } /*! * \brief Gets the int representation of an enum diff --git a/src/mod/applications/mod_skel/mod_skel.c b/src/mod/applications/mod_skel/mod_skel.c index a96204e7a2..a904140705 100644 --- a/src/mod/applications/mod_skel/mod_skel.c +++ b/src/mod/applications/mod_skel/mod_skel.c @@ -89,7 +89,7 @@ static switch_xml_config_item_t instructions[] = { "greedy|generous|evil", "Specifies the codec negotiation scheme to be used."), SWITCH_CONFIG_ITEM_CALLBACK("sip-trace", SWITCH_CONFIG_BOOL, CONFIG_RELOADABLE, &globals.sip_trace, (void*)SWITCH_FALSE, config_callback_siptrace, NULL , "yes|no", "If enabled, print out sip messages on the console."), - SWITCH_CONFIG_ITEM("integer", SWITCH_CONFIG_INT, CONFIG_RELOADABLE | CONFIG_REQUIRED, &globals.integer, (void*)100, &config_opt_integer, + SWITCH_CONFIG_ITEM("integer", SWITCH_CONFIG_INT, CONFIG_RELOADABLE, &globals.integer, (void*)100, &config_opt_integer, NULL, NULL), SWITCH_CONFIG_ITEM_END() }; @@ -108,8 +108,8 @@ static switch_status_t do_config(switch_bool_t reload) SWITCH_STANDARD_API(skel_function) { - stream->write_function(stream, "+OK Reloading\n"); do_config(SWITCH_TRUE); + return SWITCH_STATUS_SUCCESS; } diff --git a/src/switch_xml_config.c b/src/switch_xml_config.c index 44266707b0..79ea008279 100644 --- a/src/switch_xml_config.c +++ b/src/switch_xml_config.c @@ -232,27 +232,49 @@ SWITCH_DECLARE(switch_status_t) switch_xml_config_parse_event(switch_event_t *ev newstring = (char*)item->defaultvalue; } - - if (newstring) { - if (string_options->length > 0) { - /* We have a preallocated buffer */ - char *dest = (char*)item->ptr; + if (string_options->length > 0) { + /* We have a preallocated buffer */ + char *dest = (char*)item->ptr; + if (newstring) { if (strncasecmp(dest, newstring, string_options->length)) { switch_copy_string(dest, newstring, string_options->length); changed = SWITCH_TRUE; } } else { - char **dest = (char**)item->ptr; + if (*dest != '\0') { + *dest = '\0'; + changed = SWITCH_TRUE; + } + } + } else if (string_options->pool) { + /* Pool-allocated buffer */ + char **dest = (char**)item->ptr; - if (!*dest || strcasecmp(*dest, newstring)) { - if (string_options->pool) { - *dest = switch_core_strdup(string_options->pool, newstring); - } else { - switch_safe_free(*dest); - *dest = strdup(newstring); - } - changed = SWITCH_TRUE; + if (newstring) { + if (!*dest || strcmp(*dest, newstring)) { + *dest = switch_core_strdup(string_options->pool, newstring); + } + } else { + if (*dest) { + changed = SWITCH_TRUE; + *dest = NULL; + } + } + } else { + /* Dynamically allocated buffer */ + char **dest = (char**)item->ptr; + + if (newstring) { + if (!*dest || strcmp(*dest, newstring)) { + switch_safe_free(*dest); + *dest = strdup(newstring); + changed = SWITCH_TRUE; + } + } else { + if (*dest) { + switch_safe_free(*dest); + changed = SWITCH_TRUE; } } }