xml_config: Fix issue where default NULL strings were ignored on reload
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@13052 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
de0696d414
commit
98a7172281
|
@ -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(_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_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_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 }
|
#define SWITCH_CONFIG_ITEM_END() { NULL, SWITCH_CONFIG_LAST, 0, NULL, NULL, NULL, NULL, NULL, NULL }
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Gets the int representation of an enum
|
* \brief Gets the int representation of an enum
|
||||||
|
|
|
@ -89,7 +89,7 @@ static switch_xml_config_item_t instructions[] = {
|
||||||
"greedy|generous|evil", "Specifies the codec negotiation scheme to be used."),
|
"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 ,
|
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."),
|
"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),
|
NULL, NULL),
|
||||||
SWITCH_CONFIG_ITEM_END()
|
SWITCH_CONFIG_ITEM_END()
|
||||||
};
|
};
|
||||||
|
@ -108,8 +108,8 @@ static switch_status_t do_config(switch_bool_t reload)
|
||||||
|
|
||||||
SWITCH_STANDARD_API(skel_function)
|
SWITCH_STANDARD_API(skel_function)
|
||||||
{
|
{
|
||||||
stream->write_function(stream, "+OK Reloading\n");
|
|
||||||
do_config(SWITCH_TRUE);
|
do_config(SWITCH_TRUE);
|
||||||
|
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -232,26 +232,48 @@ SWITCH_DECLARE(switch_status_t) switch_xml_config_parse_event(switch_event_t *ev
|
||||||
newstring = (char*)item->defaultvalue;
|
newstring = (char*)item->defaultvalue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (string_options->length > 0) {
|
||||||
|
/* We have a preallocated buffer */
|
||||||
|
char *dest = (char*)item->ptr;
|
||||||
|
|
||||||
if (newstring) {
|
if (newstring) {
|
||||||
if (string_options->length > 0) {
|
|
||||||
/* We have a preallocated buffer */
|
|
||||||
char *dest = (char*)item->ptr;
|
|
||||||
|
|
||||||
if (strncasecmp(dest, newstring, string_options->length)) {
|
if (strncasecmp(dest, newstring, string_options->length)) {
|
||||||
switch_copy_string(dest, newstring, string_options->length);
|
switch_copy_string(dest, newstring, string_options->length);
|
||||||
changed = SWITCH_TRUE;
|
changed = SWITCH_TRUE;
|
||||||
}
|
}
|
||||||
} else {
|
} 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 (newstring) {
|
||||||
if (string_options->pool) {
|
if (!*dest || strcmp(*dest, newstring)) {
|
||||||
*dest = switch_core_strdup(string_options->pool, newstring);
|
*dest = switch_core_strdup(string_options->pool, newstring);
|
||||||
} else {
|
}
|
||||||
switch_safe_free(*dest);
|
} else {
|
||||||
*dest = strdup(newstring);
|
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;
|
changed = SWITCH_TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue